コード例 #1
0
  private void initAccelerator(Class<? extends Action> actionClass, JMenuItem mnuItem) {
    Action action = _session.getApplication().getActionCollection().get(actionClass);

    String accel = (String) action.getValue(Resources.ACCELERATOR_STRING);
    if (null != accel && 0 != accel.trim().length()) {
      mnuItem.setAccelerator(KeyStroke.getKeyStroke(accel));
    }
  }
コード例 #2
0
  /**
   * 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);
          }
        });
  }