sclass tablePopupMenu_Maker {
new L menuMakers;
}
static Map<JTable, tablePopupMenu_Maker> tablePopupMenu_map = newWeakHashMap();
static new ThreadLocal<MouseEvent> tablePopupMenu_mouseEvent;
static new ThreadLocal<Bool> tablePopupMenu_first;
// menuMaker = voidfunc(JPopupMenu, int row)
static void tablePopupMenu(final JTable table, fO menuMaker) {
final bool first = isTrue(getAndClearThreadLocal(tablePopupMenu_first));
swing {
tablePopupMenu_Maker maker = tablePopupMenu_map.get(table);
if (maker == null) {
tablePopupMenu_map.put(table, maker = new tablePopupMenu_Maker);
final tablePopupMenu_Maker _maker = maker;
table.addMouseListener(new MouseAdapter {
public void mousePressed(MouseEvent e) { displayMenu(e); }
public void mouseReleased(MouseEvent e) { displayMenu(e); }
void displayMenu(MouseEvent e) {
if (!e.isPopupTrigger()) ret;
new JPopupMenu menu;
int row = table.rowAtPoint(e.getPoint());
if (table.getSelectedRowCount() < 2)
table.setRowSelectionInterval(row, row);
int modelRow = convertTableRowToModel(table, row);
int emptyCount = menu.getComponentCount();
tablePopupMenu_mouseEvent.set(e);
for (O menuMaker : _maker.menuMakers)
pcallF(menuMaker, menu, modelRow);
vmBus_send('showingPopupMenu, table, menu);
// show menu if any items in it
if (menu.getComponentCount() != emptyCount)
menu.show(e.getComponent(), e.getX(), e.getY());
}
});
}
if (first)
maker.menuMakers.add(0, menuMaker);
else
maker.menuMakers.add(menuMaker);
}
}download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1004446 |
| Snippet name: | tablePopupMenu - adds to the menu if it already exists |
| Eternal ID of this version: | #1004446/6 |
| Text MD5: | 5bbf0eb8153f47ef6151233f24c3da90 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-01-02 16:44:42 |
| Source code size: | 1786 bytes / 48 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1098 / 1115 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |