Example usage for javax.swing JPopupMenu add

List of usage examples for javax.swing JPopupMenu add

Introduction

In this page you can find the example usage for javax.swing JPopupMenu add.

Prototype

public JMenuItem add(Action a) 

Source Link

Document

Appends a new menu item to the end of the menu which dispatches the specified Action object.

Usage

From source file:gdt.jgui.entity.webset.JWebsetFacetOpenItem.java

/**
 * Get the popup menu for the child node of the facet node 
 * in the digest view.//from  w  w  w  .  ja  va 2s  .c o  m
 * @return the popup menu.   
 */
@Override
public JPopupMenu getPopupMenu(final String digestLocator$) {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem openItem = new JMenuItem("Open");
    popup.add(openItem);
    openItem.setHorizontalTextPosition(JMenuItem.RIGHT);
    openItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                //     System.out.println("JWebsetFacetOpenItem:open:digest locator="+digestLocator$); 
                Properties locator = Locator.toProperties(digestLocator$);
                String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION);
                byte[] ba = Base64.decodeBase64(encodedSelection$);
                String selection$ = new String(ba, "UTF-8");
                //      System.out.println("JWebsetFacetOpenItem:open:selection="+selection$);
                locator = Locator.toProperties(selection$);
                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                String type$ = locator.getProperty(Locator.LOCATOR_TYPE);
                if (LOCATOR_TYPE_WEB_ADDRESS.equals(type$)) {
                    try {
                        String url$ = locator.getProperty(JWeblinksPanel.WEB_LINK_URL);
                        //                        System.out.println("weblinkEditor:browseUrl:url="+url$);
                        Desktop.getDesktop().browse(new URI(url$));
                    } catch (Exception ee) {
                        Logger.getLogger(JFileOpenItem.class.getName()).info(ee.toString());
                    }
                    return;
                }
                if (JEntityDigestDisplay.LOCATOR_FACET_COMPONENT.equals(type$)) {
                    // String entityKey$=locator.getProperty(EntityHandler.ENTITY_KEY);
                    JWeblinkEditor we = new JWeblinkEditor();
                    String weLocator$ = we.getLocator();
                    weLocator$ = Locator.append(weLocator$, Entigrator.ENTIHOME, entihome$);
                    weLocator$ = Locator.append(weLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    //JConsoleHandler.execute(console,beLocator$);
                    return;
                }
                String weblinkKey$ = locator.getProperty(JWeblinksPanel.WEB_LINK_KEY);
                JWeblinkEditor we = new JWeblinkEditor();
                String weLocator$ = we.getLocator();
                weLocator$ = Locator.append(weLocator$, Entigrator.ENTIHOME, entihome$);
                weLocator$ = Locator.append(weLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                weLocator$ = Locator.append(weLocator$, JWeblinksPanel.WEB_LINK_KEY, weblinkKey$);
                /*
                Entigrator entigrator=console.getEntigrator(entihome$);
                String componentKey$=locator.getProperty(JEntityDigestDisplay.COMPONENT_KEY);
                Sack entity=entigrator.getEntityAtKey(componentKey$);
                Core weblink=entity.getElementItem("web", weblinkKey$);
                */
                //                  System.out.println("JBookmarkFacetOpenItem:open:selection="+selection$);
                JConsoleHandler.execute(console, weLocator$);
            } catch (Exception ee) {
                Logger.getLogger(JWebsetFacetOpenItem.class.getName()).info(ee.toString());
            }
        }
    });
    return popup;
}

From source file:coolmap.application.widget.impl.console.WidgetConsole.java

public WidgetConsole() {
    super("Console", W_DATA, L_DATAPORT, UI.getImageIcon("console"), "Displays console information");
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(_container, BorderLayout.CENTER);
    _container.setLayout(new BorderLayout());
    _container.add(new JScrollPane(consolePane), BorderLayout.CENTER);

    ////from   w  w  w  . ja v a  2  s  . c o m
    consolePane.setFont(UI.fontMono.deriveFont(12f));
    consolePane.setBackground(new Color(255, 255, 204));

    //        for (int i = 0; i < 100; i++) {
    //            logError("abcdefgh\n");
    //            logInfo("ABCDEFGH\n");
    //            log("DEFGHIJKL\n");
    //        }
    JPopupMenu popupMenu = new JPopupMenu();
    consolePane.setComponentPopupMenu(popupMenu);
    JMenuItem item = new JMenuItem("Clear", UI.getImageIcon("trashBin"));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            consolePane.setText("");
        }
    });
    popupMenu.add(item);
}

From source file:fi.elfcloud.client.tree.DataItemNode.java

private void populatePopupMenu(JPopupMenu menu, BeaverGUI gui) {
    JMenuItem item;//  w  w w  .j a  v a 2s  .  c om
    item = new JMenuItem(Messages.getString("DataItemNode.popup_download")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_SAVE_ITEM));
    item.addActionListener(gui);
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/download16.png"))); //$NON-NLS-1$
    menu.add(item);

    item = new JMenuItem(Messages.getString("DataItemNode.popup_modify")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_MODIFY));
    item.addActionListener(gui);
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/modify_rename16.png"))); //$NON-NLS-1$
    menu.add(item);

    item = new JMenuItem(Messages.getString("DataItemNode.popup_move")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_MOVE));
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/move_file16.png"))); //$NON-NLS-1$
    item.addActionListener(gui);
    menu.add(item);

    item = new JMenuItem(Messages.getString("DataItemNode.popup_information")); //$NON-NLS-1$
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/info_file16.png"))); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_INFORMATION));
    item.addActionListener(gui);
    menu.add(item);

    menu.addSeparator();
    item = new JMenuItem(Messages.getString("DataItemNode.popup_delete")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_DELETE));
    item.addActionListener(gui);
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/delete16.png"))); //$NON-NLS-1$
    menu.add(item);
}

From source file:com.eviware.soapui.support.log.JLogList.java

public JLogList(String title) {
    super(new BorderLayout());
    this.title = title;

    model = new LogListModel();
    logList = new JList(model);
    logList.setToolTipText(title);//from   ww  w .j  a  va2s .  c  o  m
    logList.setCellRenderer(new LogAreaCellRenderer());
    logList.setPrototypeCellValue("Testing 123");
    logList.setFixedCellWidth(-1);

    JPopupMenu listPopup = new JPopupMenu();
    listPopup.add(new ClearAction());
    enableAction = new EnableAction();
    enableMenuItem = new JCheckBoxMenuItem(enableAction);
    enableMenuItem.setSelected(true);
    listPopup.add(enableMenuItem);
    listPopup.addSeparator();
    listPopup.add(new CopyAction());
    listPopup.add(new SetMaxRowsAction());
    listPopup.addSeparator();
    listPopup.add(new ExportToFileAction());

    logList.setComponentPopupMenu(listPopup);

    setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    JScrollPane scrollPane = new JScrollPane(logList);
    UISupport.addPreviewCorner(scrollPane, true);
    add(scrollPane, BorderLayout.CENTER);

    requestAttributes = new SimpleAttributeSet();
    StyleConstants.setForeground(requestAttributes, Color.BLUE);

    responseAttributes = new SimpleAttributeSet();
    StyleConstants.setForeground(responseAttributes, Color.GREEN);

    try {
        maxRows = Long.parseLong(SoapUI.getSettings().getString("JLogList#" + title, "1000"));
    } catch (NumberFormatException e) {
    }
}

From source file:fi.elfcloud.client.tree.ClusterNode.java

private void populatePopupMenu(JPopupMenu menu, BeaverGUI gui) {
    JMenuItem item;/* w ww .j  av  a  2s .  c o  m*/
    item = new JMenuItem(Messages.getString("ClusterNode.popup_modify")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_MODIFY));
    item.addActionListener(gui);
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/modify_rename16.png"))); //$NON-NLS-1$
    menu.add(item);

    item = new JMenuItem(Messages.getString("ClusterNode.popup_information")); //$NON-NLS-1$
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/info_file16.png"))); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_INFORMATION));
    item.addActionListener(gui);
    menu.add(item);
    menu.addSeparator();

    item = new JMenuItem(Messages.getString("ClusterNode.popup_delete")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_DELETE));
    item.addActionListener(gui);
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/delete16.png"))); //$NON-NLS-1$
    menu.add(item);
}

From source file:com.frostwire.gui.library.LibraryDeviceTableMediator.java

protected JPopupMenu createPopupMenu() {
    if (TABLE.getSelectionModel().isSelectionEmpty())
        return null;

    JPopupMenu menu = new SkinPopupMenu();

    menu.add(new SkinMenuItem(LAUNCH_ACTION));
    menu.add(new SkinMenuItem(saveToAction));

    int[] rows = TABLE.getSelectedRows();

    menu.addSeparator();/*from w w w  .ja  va2 s.  c  o  m*/
    LibraryDeviceTableDataLine line = DATA_MODEL.get(rows[0]);
    menu.add(createSearchSubMenu(line));

    return menu;
}

From source file:be.nbb.demetra.dfm.output.ConfidenceGraph.java

public void addPopupMenuItem(JMenuItem item) {
    JPopupMenu menu = chartPanel.getPopupMenu();

    menu.addSeparator();
    menu.add(item);
}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java

/**
 * Not yet fully implemented//  w  ww . j  ava2s .c o m
 * @param e
 */
void handleFileLocationPopup(MouseEvent e) {

    if (!GUIUtil.isRightMouseButton(e))
        return;

    JPopupMenu fileLocationPopup = new JPopupMenu();
    JMenuItem fileLocationItem = new JMenuItem("Open content folder");
    fileLocationPopup.add(fileLocationItem);

    fileLocationPopup.show(fileLocation, e.getX(), e.getY());
}

From source file:gdt.jgui.entity.fields.JFieldsFacetOpenItem.java

/**
 * Get the popup menu for the child node of the facet node 
 * in the digest view./*from  ww w .j av a2  s  .c om*/
 * @return the popup menu.   
 */
@Override
public JPopupMenu getPopupMenu(final String digestLocator$) {
    System.out.println("JFieldsFacetOpenItem:getPopupMenu:digest locator="
            + Locator.remove(digestLocator$, Locator.LOCATOR_ICON));
    JPopupMenu popup = new JPopupMenu();
    JMenuItem editItem = new JMenuItem("Edit");
    popup.add(editItem);
    editItem.setHorizontalTextPosition(JMenuItem.RIGHT);
    editItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Properties locator = Locator.toProperties(digestLocator$);
                String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION);
                byte[] ba = Base64.decodeBase64(encodedSelection$);
                String selection$ = new String(ba, "UTF-8");
                locator = Locator.toProperties(selection$);
                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                String nodeType$ = locator.getProperty(JEntityDigestDisplay.NODE_TYPE);
                System.out.println("JFieldsFacetOpenItem:getPopupMenu:node type:" + nodeType$);
                Entigrator entigrator = console.getEntigrator(entihome$);
                //      Sack entity=entigrator.getEntityAtKey(entityKey$);
                if (NODE_TYPE_FIELD_NAME.equals(nodeType$)) {
                    String fieldName$ = locator.getProperty(Locator.LOCATOR_TITLE);
                    JTextEditor te = new JTextEditor();
                    String teLocator$ = te.getLocator();
                    teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, fieldName$);
                    if (entihome$ != null)
                        teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$);
                    if (entityKey$ != null)
                        teLocator$ = Locator.append(teLocator$, EntityHandler.ENTITY_KEY, entityKey$);

                    String foiLocator$ = getLocator();
                    foiLocator$ = Locator.append(foiLocator$, BaseHandler.HANDLER_METHOD, METHOD_RESPONSE);
                    foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_ACTION, ACTION_DIGEST_CALL);
                    foiLocator$ = Locator.append(foiLocator$, FIELD_NAME, fieldName$);
                    foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            Locator.compressText(digestLocator$));
                    if (entihome$ != null)
                        foiLocator$ = Locator.append(foiLocator$, Entigrator.ENTIHOME, entihome$);
                    if (entityKey$ != null)
                        foiLocator$ = Locator.append(foiLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    System.out.println("JFieldsFacetOpenItem:getPopupMenu:name:locator=" + foiLocator$);
                    teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            Locator.compressText(foiLocator$));
                    JConsoleHandler.execute(console, teLocator$);
                    System.out.println("JFieldsFacetOpenItem:getPopupMenu:teLocator=" + teLocator$);
                    return;
                }
                if (NODE_TYPE_FIELD_VALUE.equals(nodeType$)) {
                    String fieldName$ = locator.getProperty(Locator.LOCATOR_TITLE);
                    JTextEditor te = new JTextEditor();
                    String teLocator$ = te.getLocator();
                    teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, fieldName$);
                    if (entihome$ != null)
                        teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$);
                    if (entityKey$ != null)
                        teLocator$ = Locator.append(teLocator$, EntityHandler.ENTITY_KEY, entityKey$);

                    String foiLocator$ = getLocator();
                    foiLocator$ = Locator.append(foiLocator$, BaseHandler.HANDLER_METHOD, METHOD_RESPONSE);
                    foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_ACTION, ACTION_DIGEST_CALL);
                    foiLocator$ = Locator.append(foiLocator$, FIELD_NAME, fieldName$);
                    foiLocator$ = Locator.append(foiLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            Locator.compressText(digestLocator$));
                    if (entihome$ != null)
                        foiLocator$ = Locator.append(foiLocator$, Entigrator.ENTIHOME, entihome$);
                    if (entityKey$ != null)
                        foiLocator$ = Locator.append(foiLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    System.out.println("JFieldsFacetOpenItem:getPopupMenu:value:locator=" + foiLocator$);

                    teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            Locator.compressText(foiLocator$));
                    JConsoleHandler.execute(console, teLocator$);
                    return;
                }
                if (JEntityDigestDisplay.NODE_TYPE_FACET_OWNER.equals(nodeType$)) {
                    JEntityDigestDisplay edd = new JEntityDigestDisplay();
                    String eddLocator$ = edd.getLocator();
                    eddLocator$ = Locator.append(eddLocator$, Entigrator.ENTIHOME, entihome$);
                    eddLocator$ = Locator.append(eddLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    eddLocator$ = Locator.append(eddLocator$, JEntityDigestDisplay.SELECTION,
                            encodedSelection$);
                    String requesterResponseLocator$ = Locator.compressText(eddLocator$);
                    JFieldsEditor fieldsEditor = new JFieldsEditor();
                    String feLocator$ = fieldsEditor.getLocator();
                    feLocator$ = Locator.append(feLocator$, Entigrator.ENTIHOME, entihome$);
                    feLocator$ = Locator.append(feLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    feLocator$ = Locator.append(feLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            requesterResponseLocator$);
                    feLocator$ = Locator.append(feLocator$, BaseHandler.HANDLER_METHOD, "instantiate");
                    JConsoleHandler.execute(console, feLocator$);
                }
            } catch (Exception ee) {
                Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString());
            }
        }
    });
    return popup;
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationCalibrationPanel.java

protected JPopupMenu createPopupMenu() {

    JPopupMenu menu = new JPopupMenu();

    menu.add(theActionManager.get("zoomnone"));
    menu.add(theActionManager.get("zoomin"));
    menu.add(theActionManager.get("zoomout"));

    return menu;/*from   www .  j  a va2 s .c  o m*/
}