private void maybeShowPopup(MouseEvent e, JPopupMenu popup) { if (e.isPopupTrigger()) { int tab = _tabbedExecutionsPanel .getUI() .tabForCoordinate(_tabbedExecutionsPanel, e.getX(), e.getY()); if (-1 != tab) { popup.show(e.getComponent(), e.getX(), e.getY()); } } }
/** * Due to JDK 1.4 Bug 4465870 this doesn't work with JDK 1.4. when scrollable tabbed pane is used. */ private void createTabPopup() { final JPopupMenu popup = new JPopupMenu(); // i18n[SQLResultExecuterPanel.close=Close] String closeLabel = s_stringMgr.getString("SQLResultExecuterPanel.close"); JMenuItem mnuClose = new JMenuItem(closeLabel); initAccelerator(CloseCurrentSQLResultTabAction.class, mnuClose); mnuClose.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeCurrentResultTab(); } }); popup.add(mnuClose); // i18n[SQLResultExecuterPanel.closeAllButThis=Close all but this] String cabtLabel = s_stringMgr.getString("SQLResultExecuterPanel.closeAllButThis"); JMenuItem mnuCloseAllButThis = new JMenuItem(cabtLabel); initAccelerator(CloseAllSQLResultTabsButCurrentAction.class, mnuCloseAllButThis); mnuCloseAllButThis.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeAllButCurrentResultTabs(); } }); popup.add(mnuCloseAllButThis); // i18n[SQLResultExecuterPanel.closeAll=Close all] String caLabel = s_stringMgr.getString("SQLResultExecuterPanel.closeAll"); JMenuItem mnuCloseAll = new JMenuItem(caLabel); initAccelerator(CloseAllSQLResultTabsAction.class, mnuCloseAll); mnuCloseAll.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeAllSQLResultTabs(); } }); popup.add(mnuCloseAll); // i18n[SQLResultExecuterPanel.toggleSticky=Toggle sticky] String tsLabel = s_stringMgr.getString("SQLResultExecuterPanel.toggleSticky"); JMenuItem mnuToggleSticky = new JMenuItem(tsLabel); initAccelerator(ToggleCurrentSQLResultTabStickyAction.class, mnuToggleSticky); mnuToggleSticky.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { toggleCurrentSQLResultTabSticky(); } }); popup.add(mnuToggleSticky); _tabbedExecutionsPanel.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { maybeShowPopup(e, popup); } public void mouseReleased(MouseEvent e) { maybeShowPopup(e, popup); } }); }