protected void initColumnSelectorItems() {
    cornerPopup.removeAll();

    JCheckBoxMenuItem menuItem;

    for (int i = 0; i < realFieldsListTableModel.getColumnCount(); i++) {
      menuItem = new JCheckBoxMenuItem(realFieldsListTableModel.getColumnName(i));
      menuItem.setActionCommand(Integer.valueOf(i).toString());
      addMenuItemListener(menuItem);

      if (fieldsListTable != null) {
        menuItem.setState(fieldsListTableModel.isRealColumnVisible(i));

        if (i == 0) {
          menuItem.setEnabled(false);
        }
      } else {
        menuItem.setState(true);
      }

      cornerPopup.add(menuItem);
    }

    cornerPopup.pack();
  }
  /** Display the forwards window history in a menu. */
  private void onShowForwardHistory() {

    UIScrollableMenu hist =
        new UIScrollableMenu(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forwardHistory"),
            0); //$NON-NLS-1$

    Vector views = history.getForwardHistory();
    int currentIndex = history.getCurrentPosition();

    int count = views.size();
    if (count == 0) return;

    JMenuItem item = null;
    for (int i = 0; i < count; i++) {
      View view = (View) views.elementAt(i);
      item = new JMenuItem(view.getLabel());

      final View fview = view;
      final int fi = (currentIndex + 1) + i;
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (history.goToHistoryItem(fi)) oParent.addViewToDesktop(fview, fview.getLabel());
            }
          });

      hist.add(item);
    }

    JPopupMenu pop = hist.getPopupMenu();
    pop.pack();

    Point loc = pbShowForwardHistory.getLocation();
    Dimension size = pbShowForwardHistory.getSize();
    Dimension popsize = hist.getPreferredSize();
    Point finalP = SwingUtilities.convertPoint(tbrToolBar.getParent(), loc, oParent.getDesktop());

    int x = 0;
    int y = 0;
    if (oManager.getLeftToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x + size.width;
      y = finalP.y;
    } else if (oManager.getRightToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x - popsize.width;
      y = finalP.y;
    } else if (oManager.getTopToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y + size.width;
    } else if (oManager.getBottomToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y - popsize.height;
    }

    hist.setPopupMenuVisible(true);
    pop.show(oParent.getDesktop(), x, y);
  }
예제 #3
0
 private void displayPopUp(MouseEvent e, JPopupMenu popup) {
   log.warn("Shouldn't be here");
   if (popup != null) {
     popup.pack();
     popup.show(tree, e.getX(), e.getY());
     popup.setVisible(true);
     popup.requestFocusInWindow();
   }
 }
  public void createPopupMenu() {
    menu = new JPopupMenu();
    for (int i = filenames.size() - 2, j = 0; i >= 0; i--, j++) {
      menu.add((String) filenames.elementAt(i));
      JMenuItem mi = (JMenuItem) menu.getComponent(j);
      mi.setFont(new Font("Arial", Font.PLAIN, 11));
      mi.addActionListener(this);
    }

    menu.pack();
    // setPopupLocation(200, 200);
  }
예제 #5
0
 @Override
 public void invokePopup(Component comp, int x, int y) {
   // Single right click
   ActionManager actionManager = ActionManager.getInstance();
   ActionGroup actionGroup =
       (ActionGroup) actionManager.getAction(ImageEditorActions.GROUP_POPUP);
   ActionPopupMenu menu =
       actionManager.createActionPopupMenu(ImageEditorActions.ACTION_PLACE, actionGroup);
   JPopupMenu popupMenu = menu.getComponent();
   popupMenu.pack();
   popupMenu.show(comp, x, y);
 }
예제 #6
0
  /** DOCUMENT ME! */
  private void doPopup() {
    if (findPopup != null) {
      JTextComponent c = getComponent();

      findPopup.pack();
      // The "-1" just snugs us up a bit under the text field.
      findPopup.show(c, 0, c.getHeight() - 1);

      // Set focus back to the text field.
      // TODO Fix caret positioning, selection, etc.
      c.requestFocusInWindow();
    }
  }
예제 #7
0
 /** opens pop-up menu or displays context node content */
 public void mouseReleased(MouseEvent e) {
   // on Solaris, the right mouse button somehow seems not be a popup trigger, so we
   // accept mouse 3 explicitly
   if (e.isPopupTrigger() || e.getModifiers() == java.awt.event.InputEvent.BUTTON3_MASK) {
     popup.pack();
     popup.show(tree, e.getX(), e.getY());
   } else {
     TreePath path = tree.getPathForLocation(e.getX(), e.getY());
     if (path != null) {
       DefaultMutableTreeNode node =
           (DefaultMutableTreeNode) path.getPathComponent(path.getPathCount() - 1);
       ((ContextNode) node.getUserObject()).display();
     }
   }
 }
예제 #8
0
  /**
   * Show the popup under the button
   *
   * @param prev if true, the popup is show under the previous button
   */
  private void showPopup(boolean prev) {
    popup.removeAll();
    if (prev) {
      for (int i = position - 1; i >= 0; i--) {
        JMenuItem item = new JMenuItem(history.get(i));
        final int j = i;
        item.addActionListener(
            new CommonCallBack(null) {
              @Override
              public void callBack() {
                ScilabFileBrowserHistory.this.stt.setBaseDir(history.get(j), false);
                chDir(history.get(j));
                setPositionInHistory(j);
              }
            });
        popup.add(item);
      }
    } else {
      for (int i = position + 1; i < history.size(); i++) {
        JMenuItem item = new JMenuItem(history.get(i));
        final int j = i;
        item.addActionListener(
            new CommonCallBack(null) {
              @Override
              public void callBack() {
                ScilabFileBrowserHistory.this.stt.setBaseDir(history.get(j), false);
                chDir(history.get(j));
                setPositionInHistory(j);
              }
            });
        popup.add(item);
      }
    }
    popup.pack();

    JButton button;
    if (prev) {
      button = previous;
    } else {
      button = next;
    }

    popup.show(button, 0, button.getBounds(null).height);
  }