コード例 #1
0
  /**
   * Inserts the given <code>command</command> at the end of the <code>popupMenu</code>.
   *
   * @param popupMenu The popup menu to add the given <code>command</code> to.
   * @param command The command to insert.
   * @param manager The command manager.
   */
  public static void insertCommandMenuItem(
      final JPopupMenu popupMenu, final Command command, final CommandManager manager) {
    Command[] commands = getCommands(popupMenu, manager, command);
    commands = sort(commands);

    final Map<String, Component> popupMenues = new HashMap<String, Component>();
    int count = popupMenu.getComponentCount();
    for (int i = 0; i < count; i++) {
      final Component component = popupMenu.getComponent(i);
      if (component instanceof JMenu) {
        popupMenues.put(component.getName(), component);
      }
    }

    popupMenu.removeAll();
    for (Command command1 : commands) {
      insertCommandMenuItem(popupMenu, command1, popupMenu.getComponentCount());
    }
    count = popupMenu.getComponentCount();
    for (int i = 0; i < count; i++) {
      final Component component = popupMenu.getComponent(i);
      if (component instanceof JMenu) {
        final String name = component.getName();
        final Object o = popupMenues.get(name);
        if (o != null) {
          popupMenu.remove(i);
          popupMenu.insert((Component) o, i);
        }
      }
    }
  }
コード例 #2
0
  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();
  }
コード例 #3
0
ファイル: DPopLabel.java プロジェクト: robertcannon/PSICS
  public void clear() {
    // popB.remove(mymenu);
    // mymenu = new JPopupMenu();
    // popB.add(mymenu);

    mymenu.removeAll();
  }
コード例 #4
0
ファイル: MenuScroller.java プロジェクト: rapla/rapla
  private void refreshMenu() {
    if (menuItems != null && menuItems.length > 0) {
      firstIndex = Math.max(topFixedCount, firstIndex);
      firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);

      upItem.setEnabled(firstIndex > topFixedCount);
      downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);

      menu.removeAll();
      for (int i = 0; i < topFixedCount; i++) {
        menu.add(menuItems[i]);
      }
      if (topFixedCount > 0) {
        menu.addSeparator();
      }

      menu.add(upItem);
      for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
        menu.add(menuItems[i]);
      }
      menu.add(downItem);

      if (bottomFixedCount > 0) {
        menu.addSeparator();
      }
      for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
        menu.add(menuItems[i]);
      }

      JComponent parent = (JComponent) upItem.getParent();
      parent.revalidate();
      parent.repaint();
    }
  }
コード例 #5
0
ファイル: WorkspaceTree.java プロジェクト: wstarcev/RText
  private void configurePopupMenu(Object node) {

    if (node != null) {

      if (popup == null) {
        popup = new JPopupMenu();
      } else {
        popup.removeAll();
      }

      AbstractWorkspaceTreeNode treeNode = (AbstractWorkspaceTreeNode) node;
      List<PopupContent> actions = treeNode.getPopupActions();
      for (PopupContent obj : actions) {
        if (obj instanceof PopupSubMenu) {
          popup.add((PopupSubMenu) obj);
        } else {
          Action action = (Action) obj;
          if (action == null) {
            popup.addSeparator();
          } else {
            popup.add(new JMenuItem(action));
          }
        }
      }

      ComponentOrientation o = ComponentOrientation.getOrientation(Locale.getDefault());
      popup.applyComponentOrientation(o);
    }
  }
コード例 #6
0
ファイル: Scene.java プロジェクト: kbarros/scikit
 private void maybeShowPopup(MouseEvent e) {
   List<JMenuItem> items = getAllPopupMenuItems();
   if (e.isPopupTrigger() && items.size() > 0) {
     _popup.removeAll();
     for (JMenuItem item : items) _popup.add(item);
     _popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }
コード例 #7
0
ファイル: Test.java プロジェクト: milekicnikola/JSD
 public SuggestionPanel(JTextArea textarea, int position, String subWord, Point location) {
   this.insertionPosition = position;
   this.subWord = subWord;
   popupMenu = new JPopupMenu();
   popupMenu.removeAll();
   popupMenu.setOpaque(false);
   popupMenu.setBorder(null);
   popupMenu.add(list = createSuggestionList(position, subWord), BorderLayout.CENTER);
   popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y);
 }
コード例 #8
0
ファイル: InviteLabel.java プロジェクト: wudigithub1/client
  /** Popuplates the menu. */
  private void popuplateMenu() {
    menu.removeAll();

    final List<Invite> invites = activeServer.getInvites();
    for (Invite invite : invites) {
      menu.add(new JMenuItem(new InviteAction(invite)));
    }
    menu.add(new JSeparator());
    menu.add(accept);
    menu.add(dismiss);
  }
 /**
  * Fill the specified menu bar with the menu elements that have the given URI as their parent.
  *
  * <p>Existing elements on the menu bar will be removed.
  *
  * @param popupMenu The {@link JPopupMenu} to update
  * @param id The {@link URI} of the menu bar
  * @param contextualSelection The current selection for the context menu
  */
 protected void populateContextMenu(
     JPopupMenu popupMenu, URI id, ContextualSelection contextualSelection) {
   popupMenu.removeAll();
   MenuComponent menuDef = uriToMenuElement.get(id);
   if (menuDef == null) throw new IllegalArgumentException("Unknown menuBar " + id);
   if (!menuDef.getType().equals(MenuType.menu))
     throw new IllegalArgumentException(
         "Element " + id + " is not a menu, but a " + menuDef.getType());
   MenuOptions menuOptions = new MenuOptions();
   menuOptions.setContextualSelection(contextualSelection);
   for (Component component : makeComponents(id, menuOptions))
     if (component == null) popupMenu.addSeparator();
     else popupMenu.add(component);
 }
コード例 #10
0
 private void updateMenu() {
   if (myNativeSearchPopup != null) {
     myNativeSearchPopup.removeAll();
     final int itemsCount = myModel.getSize();
     if (itemsCount == 0) {
       myNativeSearchPopup.add(myNoItems);
     } else {
       for (int i = 0; i < itemsCount; i++) {
         String item = (String) myModel.getElementAt(i);
         addMenuItem(item);
       }
     }
   }
 }
コード例 #11
0
  /**
   * Reassigns the set of canvases that this explorer controls. Though the collection of canvas mnay
   * be empty, it may not be null.
   *
   * @param items
   * @requires items != null && for each element in item, element!= null
   */
  public void setDrawersCard(List<? extends Canvas> items) {
    drawerCards.clear();
    menu.removeAll();
    List<JComponent> buttons = new ArrayList<JComponent>();
    for (int i = 0; i < items.size(); i++) {
      TabCard card = new TabCard(i, items.get(i), this, scrollable);
      drawerCards.add(card);
      buttons.add(card.getButton());
      card.getButton().setPreferredSize(new Dimension(125, BUTTON_HEIGHT));

      menu.add(card.getMenuItem());
    }
    wheeler.setElements(buttons);
    this.selectCanvas(0);
  }
コード例 #12
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);
  }
コード例 #13
0
  public void refreshPopupItems() {
    if (!showPopUp) {
      return;
    }
    macrosPopup.removeAll();
    TextArea ta = OJ.editor.getTextArea();
    String macros_text = ta.getText();
    int caretPos = ta.getCaretPosition();
    String menuStrings = UtilsOJ.extractFunctions(macros_text, caretPos);
    String[] lines = menuStrings.split("\n");
    Font theFont = new java.awt.Font("MS Sans Serif", 0, 12); // NOI18N

    for (int jj = 0; jj < lines.length; jj++) {
      String line = lines[jj];
      if (line.length() > 5) {
        int lineNo = Integer.parseInt(line.substring(0, 5).trim());
        char kind = line.charAt(6);
        char caret = line.charAt(7);
        String title = line.substring(8, line.length());
        Color color = new Color(0, 0, 255);

        if (kind == 'f') {
          color = new Color(0, 100, 0);
          title = "    " + title;
        }
        if (kind == 'b') {
          color = new Color(200, 0, 80);
          title = "    " + title;
        }

        JMenuItem thisItem = new javax.swing.JMenuItem(title);
        thisItem.setAlignmentX((float) lineNo / 1000000);
        thisItem.setForeground(color);
        if (caret == '*') {
          thisItem.setBackground(new Color(255, 255, 188));
        }
        thisItem.setFont(theFont);
        macrosPopup.add(thisItem);
        thisItem.addActionListener(itemAction);
      }
    }
  }
コード例 #14
0
 /** Populate DJs */
 private void populateDJs() {
   try {
     ddbDDJ.setToolTipText(
         "<html>"
             + Messages.getString("CommandJPanel.18")
             + "<p><b>"
             + DigitalDJManager.getCurrentDJ()
             + "</b></html>");
     popupDDJ.removeAll();
     JMenuItem jmiNew = new JMenuItem(ActionManager.getAction(CONFIGURE_DJS));
     popupDDJ.add(jmiNew);
     Iterator<DigitalDJ> it = DigitalDJManager.getInstance().getDJs().iterator();
     while (it.hasNext()) {
       final DigitalDJ dj = it.next();
       JCheckBoxMenuItem jmi =
           new JCheckBoxMenuItem(dj.getName(), IconLoader.ICON_DIGITAL_DJ_16x16);
       jmi.addActionListener(
           new ActionListener() {
             public void actionPerformed(ActionEvent arg0) {
               ConfigurationManager.setProperty(CONF_DEFAULT_DJ, dj.getID());
               DigitalDJManager.setCurrentDJ(dj);
               // force to reselect the item
               populateDJs();
               // update action tooltip on main button with right item
               ActionBase action = ActionManager.getAction(JajukAction.DJ);
               action.setShortDescription(
                   "<html>"
                       + Messages.getString("CommandJPanel.18")
                       + "<p><b>"
                       + dj.getName()
                       + "</b></p></html>");
             }
           });
       popupDDJ.add(jmi);
       jmi.setSelected(ConfigurationManager.getProperty(CONF_DEFAULT_DJ).equals(dj.getID()));
     }
   } catch (Exception e) {
     Log.error(e);
   }
 }
コード例 #15
0
ファイル: StatusButton.java プロジェクト: Easygor/experiment
  /** Populate the popup menu */
  private static void populateStatusMenu() {
    statusMenu.removeAll();
    JMenuItem menuItem = null;
    statusMenu.add(new JMenuItem(I18N.gettext("main.main.statusmenu.Status_message:")));

    txtStatus.setEditable(false);
    txtStatus.setBorder(
        BorderFactory.createBevelBorder(
            BevelBorder.LOWERED,
            Color.white,
            Color.white,
            new Color(134, 134, 134),
            new Color(93, 93, 93)));
    txtStatus.setOpaque(false);
    txtStatus.setLineWrap(true);
    txtStatus.setWrapStyleWord(true);
    statusMenu.add(txtStatus);

    menuItem = new JMenuItem();
    I18N.setTextAndMnemonic("main.main.statusmenu.Change_message", menuItem, true);
    menuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            currentParent.message =
                JOptionPane.showInputDialog(
                    currentParent,
                    I18N.gettext("main.main.statusmenu.Status_message:"),
                    currentParent.message);
            if (currentParent.message == null) return;
            changeStatus(currentParent.status, currentParent.message);
          }
        });
    statusMenu.add(menuItem);

    menuItem = new JMenuItem();
    I18N.setTextAndMnemonic("main.main.statusmenu.Manage_messages", menuItem, true);
    menuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new StatusMessagesWindow().show();
          }
        });
    statusMenu.add(menuItem);

    statusMenu.add(createSubMenu(Presence.FREE_FOR_CHAT));
    statusMenu.add(createSubMenu(Presence.AVAILABLE));
    statusMenu.add(createSubMenu(Presence.DND));
    statusMenu.add(createSubMenu(Presence.AWAY));
    statusMenu.add(createSubMenu(Presence.XA));

    menuItem = new JMenuItem(StatusIcons.getStatusIcon(Presence.INVISIBLE));
    I18N.setTextAndMnemonic("main.main.presencebutton.Invisible", menuItem);
    menuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            changeStatus(Presence.INVISIBLE, null);
          }
        });
    statusMenu.add(menuItem);

    menuItem = new JMenuItem(StatusIcons.getOfflineIcon());
    I18N.setTextAndMnemonic("main.main.presencebutton.Offline", menuItem);
    menuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            changeStatus(Presence.UNAVAILABLE, null);
          }
        });
    statusMenu.add(menuItem);

    heightInvalid = true;
  }
コード例 #16
0
ファイル: RobotViewModule.java プロジェクト: hchapman/tool
 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
   robotMenu.removeAll();
 }
コード例 #17
0
ファイル: MessageInputPanel.java プロジェクト: huxi/whistler
 private void populateRecipients(Message.Element element) {
   popup.removeAll();
   popup.add(new PopupAction(element, "@Foo"));
   popup.add(new PopupAction(element, "@Bar"));
   popup.add(new PopupAction(element, "@Foobar"));
 }
コード例 #18
0
 @Override
 public void removeAll() {
   if (popupMenu != null) {
     popupMenu.removeAll();
   }
 }
コード例 #19
0
ファイル: MessageInputPanel.java プロジェクト: huxi/whistler
 private void populateHashTags(Message.Element element) {
   popup.removeAll();
   popup.add(new PopupAction(element, "#Foo"));
   popup.add(new PopupAction(element, "#Bar"));
   popup.add(new PopupAction(element, "#Foobar"));
 }
コード例 #20
0
 private void setPopupMenu() {
   actionPopupMenu.removeAll();
   if (isMaxButtonEnabled) actionPopupMenu.add(maxItem);
   if (isMaxButtonEnabled && isCloseButtonEnabled) actionPopupMenu.addSeparator();
   if (isCloseButtonEnabled) actionPopupMenu.add(closeItem);
 }
コード例 #21
0
  /**
   * Add support for right clicking verticies to expand them.
   *
   * @param e
   */
  @Override
  public void mousePressed(MouseEvent e) {
    super.mousePressed(e);
    GUI2.getInstance().getGraphPanel().highlightedNodes.clear();
    if (e.getButton() != MouseEvent.BUTTON3) {
      popup.setVisible(false);
    }
    if (e.getButton() == MouseEvent.BUTTON3) {
      final VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
      GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
      Layout<V, E> layout = vv.getGraphLayout();
      Point2D loc = e.getPoint();
      V vertex = pickSupport.getVertex(layout, loc.getX(), loc.getY());
      final TermNode node = (TermNode) vertex;
      if (vertex == null) {
        popup.setVisible(false);
        return;
      } else {
        popup.setVisible(false);
        popup.removeAll();

        int dncsvis = node.getDownCablesetVisibleCount();
        int upcsvis = node.getUpCablesetVisibleCount();
        System.out.println("UpCSVis: " + upcsvis + " DnCSVis " + dncsvis);

        if (upcsvis < node.getInEdges().size()) {
          popup.add(
              new AbstractAction(
                  "Show All In Edges (" + (node.getInEdges().size() - upcsvis) + " edges)") {

                public void actionPerformed(ActionEvent e) {
                  GUI2.getInstance().getGraph().showInEdges(node);
                  vv.repaint();
                  // JungGraphPanel.instance.showUpCableset(node);
                }
              });

          popup.add(
              new AbstractAction("Show In Edges By Relation") {

                public void actionPerformed(ActionEvent e) {
                  CaseframeBasedShowHideDialog cd =
                      new CaseframeBasedShowHideDialog(
                          GUI2.getInstance(),
                          new ArrayList<String>(
                              GUI2.getInstance().getGraph().getInHiddenFSymbols(node)));

                  cd.setHelpText("   Select the relations you        wish to show in the graph.");
                  cd.setVisible(true);

                  for (String fsym : cd.getResult()) {
                    GUI2.getInstance().getGraph().showInEdges(node, fsym);
                  }

                  vv.repaint();
                }
              });

          /*JMenu submenu = new JMenu("Show In Relations");
          final HashMap<Caseframe, ArrayList<Edge>> hm = JungGraphPanel.instance.getHiddenUpCablesetCfs(node);
          for(final Caseframe cf : hm.keySet()){
          submenu.add(new AbstractAction(cf.toString()) {
          public void actionPerformed(ActionEvent e) {
          for(Edge je : hm.get(cf))
          JungGraphPanel.instance.showNode(je.from);
          }
          });
          }
          popup.add(submenu);*/
        }
        if (dncsvis < node.getOutEdges().size()) {
          popup.add(
              new AbstractAction(
                  "Show All Out Edges (" + (node.getOutEdges().size() - dncsvis) + " edges)") {

                public void actionPerformed(ActionEvent e) {
                  GUI2.getInstance().getGraph().showOutEdges(node);
                  vv.repaint();
                }
              });
        }

        if (upcsvis > 0) {
          popup.add(
              new AbstractAction("Hide All In Edges (" + upcsvis + " edges)") {

                public void actionPerformed(ActionEvent e) {
                  GUI2.getInstance().getGraph().hideInEdges(node);
                  vv.repaint();
                }
              });

          popup.add(
              new AbstractAction("Hide In Edges By Relation") {

                public void actionPerformed(ActionEvent e) {
                  CaseframeBasedShowHideDialog cd =
                      new CaseframeBasedShowHideDialog(
                          GUI2.getInstance(),
                          new ArrayList<String>(
                              GUI2.getInstance().getGraph().getInShownFSymbols(node)));

                  cd.setHelpText("   Select the relations you       wish to hide from the graph.");
                  cd.setVisible(true);

                  for (String fsym : cd.getResult()) {
                    GUI2.getInstance().getGraph().hideInEdges(node, fsym);
                  }

                  vv.repaint();
                }
              });
        }
        if (dncsvis > 0 && !node.getTerm().isMolecular()) {
          popup.add(
              new AbstractAction("Hide All Out Edges (" + dncsvis + " edges)") {

                public void actionPerformed(ActionEvent e) {
                  GUI2.getInstance().getGraph().hideOutEdges(node);
                  // JungGraphPanel.instance.hideDownCableset(node);
                  vv.repaint();
                }
              });
        }

        popup.add(
            new AbstractAction("Hide Node") {

              public void actionPerformed(ActionEvent e) {
                GUI2.getInstance().getGraph().hideVertex(node);
                vv.repaint();
                // JungGraphPanel.instance.hideNode(node);
              }
            });
        if (!node.getTerm().isAsserted()) {
          popup.add(
              new AbstractAction("Assert") {

                public void actionPerformed(ActionEvent e) {
                  FnInterop.addToContext(node.getTerm(), Context.getCurrentContext());
                  GUI2.getInstance().getGraphPanel().getVV().repaint();
                }
              });
        }
        if (node.getTerm().isAsserted()) {
          popup.add(
              new AbstractAction("Unassert") {

                public void actionPerformed(ActionEvent e) {
                  FnInterop.unassertTerm(node.getTerm());
                  GUI2.getInstance().getGraphPanel().getVV().repaint();
                }
              });
        }

        popup.show(vv, e.getX(), e.getY());
      }
    }
  }
コード例 #22
0
ファイル: DPopLabel.java プロジェクト: robertcannon/PSICS
 public void removeAll() {
   options = null;
   mymenu.removeAll();
 }
コード例 #23
0
ファイル: PopupMenuButton.java プロジェクト: tomasp8/geogebra
 public void removeAllMenuItems() {
   myPopup.removeAll();
 }