Example usage for javax.swing JMenuItem addActionListener

List of usage examples for javax.swing JMenuItem addActionListener

Introduction

In this page you can find the example usage for javax.swing JMenuItem addActionListener.

Prototype

public void addActionListener(ActionListener l) 

Source Link

Document

Adds an ActionListener to the button.

Usage

From source file:gdt.jgui.entity.JEntityStructurePanel.java

/**
 * Get the context menu.//from  ww w.  jav  a  2s  . co m
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    JMenu menu = new JMenu("Context");
    menu.setName("Context");
    JMenuItem facetItem = new JMenuItem("Facets");
    facetItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Properties locator = Locator.toProperties(locator$);
            String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
            String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
            JEntityFacetPanel efp = new JEntityFacetPanel();
            String efpLocator$ = efp.getLocator();
            efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$);
            efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$);
            JConsoleHandler.execute(console, efpLocator$);
        }
    });
    menu.add(facetItem);

    JMenuItem digestItem = new JMenuItem("Digest");
    digestItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Properties locator = Locator.toProperties(locator$);
            String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
            String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
            JEntityDigestDisplay edp = new JEntityDigestDisplay();
            String edpLocator$ = edp.getLocator();
            edpLocator$ = Locator.append(edpLocator$, Entigrator.ENTIHOME, entihome$);
            edpLocator$ = Locator.append(edpLocator$, EntityHandler.ENTITY_KEY, entityKey$);
            JConsoleHandler.execute(console, edpLocator$);
        }
    });
    menu.add(digestItem);
    return menu;
}

From source file:edu.clemson.cs.nestbed.client.gui.NetworkMonitorFrame.java

private final JMenu buildNetworkMenu() {
    final JMenu menu = new JMenu("Network");
    final JMenuItem install = new JMenuItem("Install Programs");
    final JMenuItem vizMenu = new JMenuItem("Visualizations");

    install.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Thread() {
                public void run() {
                    try {
                        install.setEnabled(false);
                        progDeployMgr.deployConfiguration(config.getID());
                    } catch (Exception ex) {
                        log.error("Exception occured while installing " + "programs.", ex);
                        ClientUtils.displayErrorMessage(NetworkMonitorFrame.this, ex);
                    } finally {
                        install.setEnabled(true);
                    }/*from   w  w w.j  av  a2  s  . c om*/
                }
            }.start();
        }
    });
    menu.add(install);
    menu.add(new JSeparator());

    vizMenu.addActionListener(new VisualizationMenuListener());
    menu.add(vizMenu);

    return menu;
}

From source file:ca.uviccscu.lp.server.main.MainFrame.java

public static void setupTablePopup() {
    JMenuItem menuItem = new JMenuItem("Edit");
    menuItem.addActionListener(new ActionListener() {

        @Override/*w w  w.  j  a va 2 s .c  o m*/
        public void actionPerformed(final ActionEvent e) {
            int row = jTable1.rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY));
            DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
            jTable1.setRowSelectionInterval(row, row);
            jButton2.doClick();
        }
    });
    popupMenu.add(menuItem);
    JMenuItem menuItem2 = new JMenuItem("Hash");
    menuItem2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            int row = jTable1.rowAtPoint(new Point(Shared.guiLastTablePopupX, Shared.guiLastTablePopupY));
            DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
            jTable1.setRowSelectionInterval(row, row);
            jButton5.doClick();
        }
    });
    //menuItem.addActionListener(new ActionAdapter(this));
    popupMenu.add(menuItem2);
    MouseListener popupListener = new PopupListener();
    jTable1.addMouseListener(popupListener);
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopPopupButton.java

protected void showPopup() {
    popup.removeAll();/*from  w w  w  .  j  av a  2 s.co m*/

    for (final Action action : actionList) {
        if (action.isVisible()) {
            final JMenuItem menuItem = new JMenuItem(action.getCaption());
            menuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    action.actionPerform((Component) action.getOwner());
                }
            });
            menuItem.setEnabled(action.isEnabled());
            menuItem.setName(action.getId());

            initAction(action, menuItem);

            popup.add(menuItem);
        }
    }

    int popupHeight = popup.getComponentCount() * 25;

    Point pt = new Point();
    SwingUtilities.convertPointToScreen(pt, impl);

    int y;
    if (pt.getY() + impl.getHeight() + popupHeight < Toolkit.getDefaultToolkit().getScreenSize().getHeight()) {
        y = impl.getHeight();
    } else {
        y = -popupHeight;
    }

    // do not show ugly empty popup
    if (popup.getComponentCount() > 0) {
        popup.show(impl, 0, y);
    }
}

From source file:biz.wolschon.finance.jgnucash.panels.WritableTransactionsPanel.java

/**
 * @return the context-menu for the transactionTable.
 * @see #getTransactionTable()//from  w w  w  .  ja v a2s . c om
 */
private Component getTransactionTableContextMenu() {
    if (myContextMenu == null) {
        myContextMenu = new JPopupMenu();

        PluginManager manager = getPluginManager();
        // if we are configured for the plugin-api
        if (manager != null) {
            ExtensionPoint toolExtPoint = manager.getRegistry().getExtensionPoint(getPluginDescriptor().getId(),
                    "TransactionMenuAction");
            for (Iterator<Extension> it = toolExtPoint.getConnectedExtensions().iterator(); it.hasNext();) {
                Extension ext = it.next();
                String pluginName = "unknown";

                try {
                    pluginName = ext.getParameter("name").valueAsString();
                    JMenuItem newMenuItem = new JMenuItem();
                    newMenuItem.putClientProperty("extension", ext);
                    newMenuItem.setText(pluginName);
                    newMenuItem.addActionListener(new TransactionMenuActionMenuAction(ext, pluginName));
                    myContextMenu.add(newMenuItem);
                } catch (Exception e) {
                    LOG.log(Level.SEVERE, "cannot load TransactionMenuAction-Plugin '" + pluginName + "'", e);
                    JOptionPane.showMessageDialog(this, "Error",
                            "Cannot load TransactionMenuAction-Plugin '" + pluginName + "'",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }

    }
    return myContextMenu;
}

From source file:erigo.filepump.FilePump.java

public JMenuBar createMenu() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menuBar.add(menu);//from w  w  w  . j  a v  a  2s  .c o  m
    JMenuItem menuItem = new JMenuItem("Settings...");
    menu.add(menuItem);
    menuItem.addActionListener(this);
    menuItem = new JMenuItem("Exit");
    menu.add(menuItem);
    menuItem.addActionListener(this);
    return menuBar;
}

From source file:gdt.jgui.entity.contact.JContactEditor.java

@Override
public JMenu getContextMenu() {
    final JMenu menu = new JMenu("Context");
    menu.addMenuListener(new MenuListener() {
        @Override// w  w w. j  av a  2  s. c o  m
        public void menuSelected(MenuEvent e) {
            //         System.out.println("EntityEditor:getConextMenu:menu selected");
            menu.removeAll();
            JMenuItem facetsItem = new JMenuItem("Facets");
            facetsItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    save();
                    JEntityFacetPanel erm = new JEntityFacetPanel();
                    String locator$ = erm.getLocator();
                    locator$ = Locator.append(locator$, Entigrator.ENTIHOME, entihome$);
                    locator$ = Locator.append(locator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, locator$);
                }
            });
            menu.add(facetsItem);

            JMenuItem digestItem = new JMenuItem("Digest");
            digestItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    save();
                    String locator$ = getLocator();
                    JEntityDigestDisplay edd = new JEntityDigestDisplay();
                    edd.instantiate(console, locator$);
                    String eddLocator$ = edd.getLocator();
                    eddLocator$ = Locator.append(eddLocator$, Entigrator.ENTIHOME, entihome$);
                    eddLocator$ = Locator.append(eddLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, eddLocator$);

                }
            });
            menu.add(digestItem);

            JMenuItem structureItem = new JMenuItem("Structure");
            structureItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    save();
                    String locator$ = getLocator();
                    JEntityStructurePanel esp = new JEntityStructurePanel();
                    esp.instantiate(console, locator$);
                    String espLocator$ = esp.getLocator();
                    espLocator$ = Locator.append(espLocator$, Entigrator.ENTIHOME, entihome$);
                    espLocator$ = Locator.append(espLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, espLocator$);

                }
            });
            menu.add(structureItem);
            menu.addSeparator();
            JMenuItem doneItem = new JMenuItem("Done");
            doneItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {

                    try {
                        Entigrator entigrator = console.getEntigrator(entihome$);
                        Sack contact = entigrator.getEntityAtKey(entityKey$);
                        String entityLabel$ = contact.getProperty("label");
                        String title$ = title.getText();
                        if (!entityLabel$.equals(title$)) {
                            contact = entigrator.ent_assignLabel(contact, title$);
                            contact = entigrator.ent_assignProperty(contact, "contact",
                                    contact.getProperty("label"));
                        }
                        contact = entigrator.ent_assignProperty(contact, "phone", phone.getText());
                        contact = entigrator.ent_assignProperty(contact, "email", email.getText());
                        if (requesterResponseLocator$ != null) {
                            byte[] ba = Base64.decodeBase64(requesterResponseLocator$);
                            String responseLocator$ = new String(ba, "UTF-8");
                            //                     System.out.println("TextEditor:done:response locator="+responseLocator$);
                            JConsoleHandler.execute(console, responseLocator$);
                        } else
                            console.back();
                    } catch (Exception ee) {
                        Logger.getLogger(JContactEditor.class.getName()).severe(ee.toString());
                    }

                }
            });
            menu.add(doneItem);

            JMenuItem cancelItem = new JMenuItem("Cancel");
            cancelItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    console.back();
                }
            });
            menu.add(cancelItem);
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void menuCanceled(MenuEvent e) {
            // TODO Auto-generated method stub

        }

    });
    return menu;
}

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

/**
 * Get the context menu./*from  w  w w .ja  va 2 s  .c o  m*/
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    menu = super.getContextMenu();
    int cnt = menu.getItemCount();
    mia = new JMenuItem[cnt];
    for (int i = 0; i < cnt; i++)
        mia[i] = menu.getItem(i);
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            //System.out.println("WeblinkPanel:getConextMenu:menu selected");
            menu.removeAll();
            if (mia != null) {
                for (JMenuItem mi : mia)
                    menu.add(mi);
                menu.addSeparator();
            }
            if (hasSelectedItems()) {
                JMenuItem deleteItem = new JMenuItem("Delete");
                deleteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {

                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?",
                                "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION) {
                            String[] sa = JWeblinksPanel.this.listSelectedItems();
                            if (sa == null)
                                return;
                            String webLinkKey$;
                            Entigrator entigrator = console.getEntigrator(entihome$);
                            Sack entity = entigrator.getEntityAtKey(entityKey$);
                            for (String aSa : sa) {
                                webLinkKey$ = Locator.getProperty(aSa, WEB_LINK_KEY);
                                if (webLinkKey$ == null)
                                    continue;
                                entity.removeElementItem("web", webLinkKey$);
                                entity.removeElementItem("web.login", webLinkKey$);
                                entity.removeElementItem("web.icon", webLinkKey$);
                            }
                            entigrator.save(entity);

                            JConsoleHandler.execute(console, locator$);
                        }
                    }
                });
                menu.add(deleteItem);
                JMenuItem copyItem = new JMenuItem("Copy");
                copyItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        JItemPanel[] ipa = JWeblinksPanel.this.getItems();
                        ArrayList<String> sl = new ArrayList<String>();
                        for (JItemPanel ip : ipa)
                            if (ip.isChecked())
                                sl.add(ip.getLocator());
                        String[] sa = sl.toArray(new String[0]);
                        console.clipboard.clear();
                        for (String aSa : sa)
                            console.clipboard.putString(aSa);
                    }
                });
                menu.add(copyItem);
            }
            JMenuItem newItem = new JMenuItem("New");
            newItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    System.out.println("WeblinksPanel:new:" + locator$);
                    Entigrator entigrator = console.getEntigrator(entihome$);
                    Sack entity = entigrator.getEntityAtKey(entityKey$);
                    if (!entity.existsElement("web"))
                        entity.createElement("web");
                    String webLinkKey$ = Identity.key();
                    entity.putElementItem("web", new Core("Google", webLinkKey$, "http://www.google.com"));
                    if (!entity.existsElement("web.icon"))
                        entity.createElement("web.icon");
                    String icon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "globe.png");
                    entity.putElementItem("web.icon", new Core(null, webLinkKey$, icon$));
                    entigrator.save(entity);
                    JWeblinkEditor wle = new JWeblinkEditor();
                    String wleLocator$ = wle.getLocator();
                    wleLocator$ = Locator.append(wleLocator$, Entigrator.ENTIHOME, entihome$);
                    wleLocator$ = Locator.append(wleLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    wleLocator$ = Locator.append(wleLocator$, WEB_LINK_KEY, webLinkKey$);
                    String requesterResponseLocator$ = Locator.compressText(getLocator());
                    wleLocator$ = Locator.append(wleLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            requesterResponseLocator$);
                    JConsoleHandler.execute(console, wleLocator$);

                }
            });
            menu.add(newItem);
            if (hasItemsToPaste()) {
                JMenuItem pasteItem = new JMenuItem("Paste");
                pasteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String[] sa = getItemsToPaste();
                        Entigrator entigrator = console.getEntigrator(entihome$);
                        Sack entity = entigrator.getEntityAtKey(entityKey$);
                        if (!entity.existsElement("web"))
                            entity.createElement("web");
                        if (!entity.existsElement("web.icon"))
                            entity.createElement("web.icon");
                        if (!entity.existsElement("web.login"))
                            entity.createElement("web.login");
                        Properties itemLocator;
                        String webLinkKey$;
                        String webLinkUrl$;
                        String webLinkName$;
                        String webLinkIcon$;
                        String webLinkLogin$;
                        String webLinkPassword$;
                        for (String aSa : sa) {
                            itemLocator = Locator.toProperties(aSa);
                            webLinkKey$ = itemLocator.getProperty(WEB_LINK_KEY);
                            webLinkUrl$ = itemLocator.getProperty(WEB_LINK_URL);
                            webLinkName$ = itemLocator.getProperty(WEB_LINK_NAME);
                            webLinkIcon$ = itemLocator.getProperty(Locator.LOCATOR_ICON);
                            webLinkLogin$ = itemLocator.getProperty(WEB_LINK_LOGIN);
                            webLinkPassword$ = itemLocator.getProperty(WEB_LINK_PASSWORD);
                            if (webLinkKey$ == null || webLinkUrl$ == null)
                                continue;
                            entity.putElementItem("web", new Core(webLinkName$, webLinkKey$, webLinkUrl$));
                            if (webLinkLogin$ != null || webLinkPassword$ != null)
                                entity.putElementItem("web.login",
                                        new Core(webLinkLogin$, webLinkKey$, webLinkPassword$));
                            if (webLinkIcon$ != null)
                                entity.putElementItem("web.icon", new Core(null, webLinkKey$, webLinkIcon$));
                        }
                        entigrator.save(entity);
                        JConsoleHandler.execute(console, getLocator());
                    }
                });
                menu.add(pasteItem);
            }
            menu.addSeparator();
            JMenuItem doneItem = new JMenuItem("Done");
            doneItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (requesterResponseLocator$ != null) {
                        try {
                            byte[] ba = Base64.decodeBase64(requesterResponseLocator$);
                            String responseLocator$ = new String(ba, "UTF-8");
                            JConsoleHandler.execute(console, responseLocator$);
                        } catch (Exception ee) {
                            Logger.getLogger(JWeblinksPanel.class.getName()).severe(ee.toString());
                        }
                    } else
                        console.back();
                }
            });
            menu.add(doneItem);
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    return menu;
}

From source file:org.cds06.speleograph.graph.SeriesMenu.java

private JPopupMenu createPopupMenuForSeries(final Series series) {

    if (series == null)
        return new JPopupMenu();

    final JPopupMenu menu = new JPopupMenu(series.getName());

    menu.removeAll();/*ww  w  .j  a  v  a  2  s  .c o  m*/

    menu.add(new AbstractAction() {
        {
            putValue(NAME, "Renommer la srie");
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            menu.setVisible(false);
            String newName = "";
            while (newName == null || newName.equals("")) {
                newName = (String) JOptionPane.showInputDialog(application,
                        "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null,
                        series.getName());
            }
            series.setName(newName);
        }
    });

    if (series.hasOwnAxis()) {
        menu.add(new AbstractAction() {

            {
                putValue(NAME, "Supprimer l'axe spcifique");
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?",
                        "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
                    series.setAxis(null);
                }
            }
        });
    } else {
        menu.add(new JMenuItem(new AbstractAction() {

            {
                putValue(NAME, "Crer un axe spcifique pour la srie");
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?",
                        series.getAxis().getLabel());
                if (name == null || "".equals(name))
                    return; // User has canceled
                series.setAxis(new NumberAxis(name));
            }
        }));
    }

    menu.add(new SetTypeMenu(series));

    if (series.isWater()) {
        menu.addSeparator();
        menu.add(new SumOnPeriodAction(series));
        menu.add(new CreateCumulAction(series));
    }
    if (series.isWaterCumul()) {
        menu.addSeparator();
        menu.add(new SamplingAction(series));
    }

    if (series.isPressure()) {
        menu.addSeparator();
        menu.add(new CorrelateAction(series));
        menu.add(new WaterHeightAction(series));
    }

    menu.addSeparator();

    menu.add(new AbstractAction() {
        {
            String name;
            if (series.canUndo())
                name = "Annuler " + series.getItemsName();
            else
                name = series.getLastUndoName();

            putValue(NAME, name);

            if (series.canUndo())
                setEnabled(true);
            else {
                setEnabled(false);
            }

        }

        @Override
        public void actionPerformed(ActionEvent e) {
            series.undo();
        }
    });

    menu.add(new AbstractAction() {
        {
            String name;
            if (series.canRedo()) {
                name = "Refaire " + series.getNextRedoName();
                setEnabled(true);
            } else {
                name = series.getNextRedoName();
                setEnabled(false);
            }

            putValue(NAME, name);
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            series.redo();
        }
    });

    menu.add(new AbstractAction() {
        {
            putValue(NAME, I18nSupport.translate("menus.serie.resetSerie"));
            if (series.canUndo())
                setEnabled(true);
            else
                setEnabled(false);
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            series.reset();
        }
    });

    menu.add(new LimitDateRangeAction(series));

    menu.add(new HourSettingAction(series));

    menu.addSeparator();

    {
        JMenuItem deleteItem = new JMenuItem("Supprimer la srie");
        deleteItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (JOptionPane.showConfirmDialog(application,
                        "tes-vous sur de vouloir supprimer cette srie ?\n"
                                + "Cette action est dfinitive.",
                        "Confirmation", JOptionPane.OK_CANCEL_OPTION,
                        JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
                    series.delete();
                }
            }
        });
        menu.add(deleteItem);
    }

    menu.addSeparator();

    {
        final JMenuItem up = new JMenuItem("Remonter dans la liste"),
                down = new JMenuItem("Descendre dans la liste");
        ActionListener listener = new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (e.getSource().equals(up)) {
                    series.upSeriesInList();
                } else {
                    series.downSeriesInList();
                }
            }
        };
        up.addActionListener(listener);
        down.addActionListener(listener);
        if (series.isFirst()) {
            menu.add(down);
        } else if (series.isLast()) {
            menu.add(up);
        } else {
            menu.add(up);
            menu.add(down);
        }
    }

    menu.addSeparator();

    {
        menu.add(new SeriesInfoAction(series));
    }

    {
        JMenuItem colorItem = new JMenuItem("Couleur de la srie");
        colorItem.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                series.setColor(JColorChooser.showDialog(application,
                        I18nSupport.translate("actions.selectColorForSeries"), series.getColor()));
            }
        });
        menu.add(colorItem);
    }

    {
        JMenu plotRenderer = new JMenu("Affichage de la srie");
        final ButtonGroup modes = new ButtonGroup();
        java.util.List<DrawStyle> availableStyles;
        if (series.isMinMax()) {
            availableStyles = DrawStyles.getDrawableStylesForHighLow();
        } else {
            availableStyles = DrawStyles.getDrawableStyles();
        }
        for (final DrawStyle s : availableStyles) {
            final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s));
            item.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    if (item.isSelected())
                        series.setStyle(s);
                }
            });
            modes.add(item);
            if (s.equals(series.getStyle())) {
                modes.setSelected(item.getModel(), true);
            }
            plotRenderer.add(item);
        }
        menu.add(plotRenderer);
    }
    menu.addSeparator();

    menu.add(new AbstractAction() {
        {
            putValue(Action.NAME, "Fermer le fichier");
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(application,
                    "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
                final File f = series.getOrigin();
                for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) {
                    if (s.getOrigin().equals(f))
                        s.delete();
                }
            }
        }
    });

    return menu;
}

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./* w w w  .  j a va 2 s . co  m*/
 * @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;
}