Example usage for javax.swing JPopupMenu addSeparator

List of usage examples for javax.swing JPopupMenu addSeparator

Introduction

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

Prototype

public void addSeparator() 

Source Link

Document

Appends a new separator at the end of the menu.

Usage

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

private JPopupMenu createPopupMenu(boolean over_peak) {

    JPopupMenu menu = new JPopupMenu();

    if (over_peak) {
        updatePeakActions();//  w  w w  . ja  va 2  s.  co m

        menu.add(theActionManager.get("addpeaks"));

        ButtonGroup group = new ButtonGroup();
        if (shown_mslevel.equals("ms")) {
            for (GlycanAction a : theApplication.getPluginManager().getMsPeakActions()) {
                JRadioButtonMenuItem last = new JRadioButtonMenuItem(
                        new GlycanAction(a, "annotatepeaks", -1, "", this));

                menu.add(last);
                last.setSelected(a == ms_action);
                group.add(last);
            }
        } else {
            for (GlycanAction a : theApplication.getPluginManager().getMsMsPeakActions()) {
                JRadioButtonMenuItem last = new JRadioButtonMenuItem(
                        new GlycanAction(a, "annotatepeaks", -1, "", this));

                menu.add(last);
                last.setSelected(a == msms_action);
                group.add(last);
            }
        }
        menu.addSeparator();
    }

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

    return menu;
}

From source file:com.mirth.connect.client.ui.components.MirthTreeTable.java

private JPopupMenu getColumnMenu() {
    SortableTreeTableModel model = (SortableTreeTableModel) getTreeTableModel();
    JPopupMenu columnMenu = new JPopupMenu();

    for (int i = 0; i < model.getColumnCount(); i++) {
        final String columnName = model.getColumnName(i);
        // Get the column object by name. Using an index may not return the column object if the column is hidden
        TableColumnExt column = getColumnExt(columnName);

        // Create the menu item
        final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(columnName);
        // Show or hide the checkbox
        menuItem.setSelected(column.isVisible());

        menuItem.addActionListener(new ActionListener() {
            @Override//from w  ww.  ja va2 s . c  om
            public void actionPerformed(ActionEvent arg0) {
                TableColumnExt column = getColumnExt(menuItem.getText());
                // Determine whether to show or hide the selected column
                boolean enable = !column.isVisible();
                // Do not hide a column if it is the last remaining visible column              
                if (enable || getColumnCount() > 1) {
                    column.setVisible(enable);

                    Set<String> customHiddenColumns = customHiddenColumnMap.get(channelId);

                    if (customHiddenColumns != null) {
                        if (enable) {
                            customHiddenColumns.remove(columnName);
                        } else {
                            customHiddenColumns.add(columnName);
                        }
                    }
                }
                saveColumnOrder();
            }
        });

        columnMenu.add(menuItem);
    }

    columnMenu.addSeparator();

    JMenuItem menuItem = new JMenuItem("Collapse All");
    menuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            collapseAll();
        }

    });
    columnMenu.add(menuItem);

    menuItem = new JMenuItem("Expand All");
    menuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            expandAll();
        }

    });
    columnMenu.add(menuItem);

    columnMenu.addSeparator();

    menuItem = new JMenuItem("Restore Default");
    menuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (metaDataColumns != null) {
                defaultVisibleColumns.addAll(metaDataColumns);
            }
            restoreDefaultColumnPreferences();
        }

    });
    columnMenu.add(menuItem);

    return columnMenu;
}

From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java

protected ChartPanelEx createChartPanel(JFreeChart chart, final ChartDefinition cd) {
    ChartPanelEx cp = new ChartPanelEx(chart, cd.isScrollWheelZoomingAllowed()) {
        @Override/*  w ww.ja va 2s .c  om*/
        protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print,
                boolean zoom) {
            JPopupMenu menu;
            aChartViewer cv = cd.getChartViewer();

            menu = super.createPopupMenu(false, cd.getChartViewer().canCopy(), cv.canSave(), cv.canPrint(),
                    cd.isAllowZooming());

            UIPopupMenu sm = cv.getPopupMenu();

            if (sm != null) {
                menu.addSeparator();
                sm.copyTo(menu);
            }

            return menu;
        }
    };

    cp.maxZoom = cd.getMaxZoomFactor();

    if (cd.wantsMouseEvents()) {
        cp.addChartMouseListener(new ChartMouseHandler(cd));
    }

    return cp;
}

From source file:com.pironet.tda.TDA.java

/**
 * create a instance of this menu for a category
 *///from  w ww. j a v  a 2  s. c  om
private PopupListener getMonitorsPopupMenu() {
    if (monitorsPopupListener == null) {
        final JPopupMenu popup = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem("Search...");
        menuItem.addActionListener(this);
        popup.add(menuItem);
        popup.addSeparator();
        menuItem = new JMenuItem("Expand all nodes");
        menuItem.addActionListener(this);
        popup.add(menuItem);
        menuItem = new JMenuItem("Collapse all nodes");
        menuItem.addActionListener(this);
        popup.add(menuItem);
        popup.addSeparator();
        menuItem = new JMenuItem("Sort by thread count");
        menuItem.addActionListener(this);
        popup.add(menuItem);

        //Add listener to the text area so the popup menu can come up.
        monitorsPopupListener = new PopupListener(popup);
    }

    return (monitorsPopupListener);
}

From source file:net.sf.jabref.openoffice.OpenOfficePanel.java

private void showSettingsPopup() {
    JPopupMenu menu = new JPopupMenu();
    final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem(
            Localization.lang("Automatically sync bibliography when inserting citations"),
            Globals.prefs.getBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING));
    final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem(
            Localization.lang("Look up BibTeX entries in the active tab only"));
    final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem(
            Localization.lang("Look up BibTeX entries in all open databases"));
    final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings"));
    ButtonGroup bg = new ButtonGroup();
    bg.add(useActiveBase);// www  .ja v a2 s  . co m
    bg.add(useAllBases);
    if (Globals.prefs.getBoolean(JabRefPreferences.USE_ALL_OPEN_BASES)) {
        useAllBases.setSelected(true);
    } else {
        useActiveBase.setSelected(true);
    }

    autoSync.addActionListener(
            e -> Globals.prefs.putBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING, autoSync.isSelected()));

    useAllBases.addActionListener(
            e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, useAllBases.isSelected()));

    useActiveBase.addActionListener(
            e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, !useActiveBase.isSelected()));

    clearConnectionSettings.addActionListener(e -> {

        Globals.prefs.clear(JabRefPreferences.OO_PATH);
        Globals.prefs.clear(JabRefPreferences.OO_EXECUTABLE_PATH);
        Globals.prefs.clear(JabRefPreferences.OO_JARS_PATH);
        frame.output(Localization.lang("Cleared connection settings."));

    });

    menu.add(autoSync);
    menu.addSeparator();
    menu.add(useActiveBase);
    menu.add(useAllBases);
    menu.addSeparator();
    menu.add(clearConnectionSettings);
    menu.show(settingsB, 0, settingsB.getHeight());
}

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();//from  w w w  .ja  va  2s .c  om

    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:net.sf.jabref.gui.JabRefFrame.java

private JPopupMenu tabPopupMenu() {
    JPopupMenu popupMenu = new JPopupMenu();

    // Close actions
    JMenuItem close = new JMenuItem(Localization.lang("Close"));
    JMenuItem closeOthers = new JMenuItem(Localization.lang("Close Others"));
    JMenuItem closeAll = new JMenuItem(Localization.lang("Close All"));
    close.addActionListener(closeDatabaseAction);
    closeOthers.addActionListener(closeOtherDatabasesAction);
    closeAll.addActionListener(closeAllDatabasesAction);
    popupMenu.add(close);/*from w  ww.java2 s . c o m*/
    popupMenu.add(closeOthers);
    popupMenu.add(closeAll);

    popupMenu.addSeparator();

    JMenuItem databaseProperties = new JMenuItem(Localization.lang("Database properties"));
    databaseProperties.addActionListener(this.databaseProperties);
    popupMenu.add(databaseProperties);

    JMenuItem bibtexKeyPatternBtn = new JMenuItem(Localization.lang("BibTeX key patterns"));
    bibtexKeyPatternBtn.addActionListener(bibtexKeyPattern);
    popupMenu.add(bibtexKeyPatternBtn);

    JMenuItem manageSelectorsBtn = new JMenuItem(Localization.lang("Manage content selectors"));
    manageSelectorsBtn.addActionListener(manageSelectors);
    popupMenu.add(manageSelectorsBtn);

    return popupMenu;
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Creates a popup menu for the panel./* w  w  w.j a v a2s  . c  o  m*/
 * 
 * @param properties
 *            include a menu item for the chart property editor.
 * @param save
 *            include a menu item for saving the chart.
 * @param print
 *            include a menu item for printing the chart.
 * @param zoom
 *            include menu items for zooming.
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {

    JPopupMenu result = new JPopupMenu("Chart:");
    boolean separator = false;

    if (properties) {
        JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties..."));
        propertiesItem.setActionCommand(PROPERTIES_COMMAND);
        propertiesItem.addActionListener(this);
        result.add(propertiesItem);
        separator = true;
    }

    if (save) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as..."));
        saveItem.setActionCommand(SAVE_COMMAND);
        saveItem.addActionListener(this);
        result.add(saveItem);
        separator = true;
    }

    if (print) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem printItem = new JMenuItem(localizationResources.getString("Print..."));
        printItem.setActionCommand(PRINT_COMMAND);
        printItem.addActionListener(this);
        result.add(printItem);
        separator = true;
    }

    if (zoom) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }

        JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In"));

        this.zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND);
        this.zoomInBothMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInBothMenuItem);

        zoomInMenu.addSeparator();

        this.zoomInDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND);
        this.zoomInDomainMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInDomainMenuItem);

        this.zoomInRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND);
        this.zoomInRangeMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInRangeMenuItem);

        result.add(zoomInMenu);

        JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out"));

        this.zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND);
        this.zoomOutBothMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutBothMenuItem);

        zoomOutMenu.addSeparator();

        this.zoomOutDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomOutDomainMenuItem.setActionCommand(ZOOM_OUT_DOMAIN_COMMAND);
        this.zoomOutDomainMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutDomainMenuItem);

        this.zoomOutRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND);
        this.zoomOutRangeMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutRangeMenuItem);

        result.add(zoomOutMenu);

        JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range"));

        this.zoomResetBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomResetBothMenuItem.setActionCommand(ZOOM_RESET_BOTH_COMMAND);
        this.zoomResetBothMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetBothMenuItem);

        autoRangeMenu.addSeparator();
        this.zoomResetDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomResetDomainMenuItem.setActionCommand(ZOOM_RESET_DOMAIN_COMMAND);
        this.zoomResetDomainMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetDomainMenuItem);

        this.zoomResetRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomResetRangeMenuItem.setActionCommand(ZOOM_RESET_RANGE_COMMAND);
        this.zoomResetRangeMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetRangeMenuItem);

        result.addSeparator();
        result.add(autoRangeMenu);
    }

    return result;
}

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

protected JPopupMenu createPopupMenu() {
    if (TABLE.getSelectionModel().isSelectionEmpty()) {
        return null;
    }/*from w  w w.j a v  a 2s .co  m*/

    JPopupMenu menu = new SkinPopupMenu();

    menu.add(new SkinMenuItem(LAUNCH_ACTION));
    if (getMediaType().equals(MediaType.getAudioMediaType())) {
        menu.add(new SkinMenuItem(LAUNCH_OS_ACTION));
    }
    if (hasExploreAction()) {
        menu.add(new SkinMenuItem(OPEN_IN_FOLDER_ACTION));
    }

    if (areAllSelectedFilesMP4s()) {
        menu.add(DEMUX_MP4_AUDIO_ACTION);
        DEMUX_MP4_AUDIO_ACTION.setEnabled(!((DemuxMP4AudioAction) DEMUX_MP4_AUDIO_ACTION).isDemuxing());
    }

    menu.add(new SkinMenuItem(CREATE_TORRENT_ACTION));

    if (areAllSelectedFilesPlayable()) {
        menu.add(createAddToPlaylistSubMenu());
    }

    //sharing takes a while...
    //there's an in between state while the file is changing from
    //unshare to shared, this is "being shared"
    boolean noneSharing = !isAnyBeingShared();
    boolean allShared = areAllSelectedFilesShared();

    WIFI_SHARE_ACTION.setEnabled(noneSharing && !allShared);

    //unsharing is immediate.
    WIFI_UNSHARE_ACTION.setEnabled(noneSharing && allShared);

    //menu.add(new SkinMenuItem(areAllSelectedFilesShared() ? WIFI_UNSHARE_ACTION : WIFI_SHARE_ACTION));
    if (WIFI_SHARE_ACTION.isEnabled()) {
        menu.add(WIFI_SHARE_ACTION);
    }

    if (WIFI_UNSHARE_ACTION.isEnabled()) {
        menu.add(WIFI_UNSHARE_ACTION);
    }

    menu.add(new SkinMenuItem(SEND_TO_FRIEND_ACTION));
    menu.add(new SkinMenuItem(SEND_TO_ITUNES_ACTION));

    menu.addSeparator();
    menu.add(new SkinMenuItem(DELETE_ACTION));
    menu.add(new SkinMenuItem(RENAME_ACTION));
    menu.addSeparator();

    int[] rows = TABLE.getSelectedRows();
    boolean dirSelected = false;
    boolean fileSelected = false;

    for (int i = 0; i < rows.length; i++) {
        File f = DATA_MODEL.get(rows[i]).getFile();
        if (f.isDirectory()) {
            dirSelected = true;
            //            if (IncompleteFileManager.isTorrentFolder(f))
            //               torrentSelected = true;
        } else
            fileSelected = true;

        if (dirSelected && fileSelected)
            break;
    }
    if (dirSelected) {
        DELETE_ACTION.setEnabled(true);
        RENAME_ACTION.setEnabled(false);
    } else {
        DELETE_ACTION.setEnabled(true);
    }

    LibraryFilesTableDataLine line = DATA_MODEL.get(rows[0]);
    menu.add(createSearchSubMenu(line));

    return menu;
}

From source file:com.pironet.tda.TDA.java

public void createPopupMenu() {

    //Create the popup menu.
    JPopupMenu popup = new JPopupMenu();

    JMenuItem menuItem = new JMenuItem("Diff Selection");
    menuItem.addActionListener(this);
    popup.add(menuItem);//from www .j ava 2 s . c o  m
    menuItem = new JMenuItem("Find long running threads...");
    menuItem.addActionListener(this);
    popup.add(menuItem);

    showDumpMenuItem = new JMenuItem("Show selected Dump in logfile");
    showDumpMenuItem.addActionListener(this);
    showDumpMenuItem.setEnabled(false);
    if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) {
        popup.addSeparator();
        menuItem = new JMenuItem("Parse loggc-logfile...");
        menuItem.addActionListener(this);
        if (!PrefManager.get().getForceLoggcLoading()) {
            menuItem.setEnabled(!isFoundClassHistogram);
        }
        popup.add(menuItem);

        menuItem = new JMenuItem("Close logfile...");
        menuItem.addActionListener(this);
        popup.add(menuItem);
        popup.addSeparator();
        popup.add(showDumpMenuItem);
    } else {
        popup.addSeparator();
        if (!runningAsVisualVMPlugin) {
            menuItem = new JMenuItem("Request Thread Dump...");
            menuItem.addActionListener(this);
            popup.add(menuItem);
            popup.addSeparator();
            menuItem = new JMenuItem("Preferences");
            menuItem.addActionListener(this);
            popup.add(menuItem);
            menuItem = new JMenuItem("Filters");
            menuItem.addActionListener(this);
            popup.add(menuItem);
            popup.addSeparator();
            menuItem = new JMenuItem("Save Logfile...");
            menuItem.addActionListener(this);
            popup.add(menuItem);
            popup.addSeparator();
            menuItem = new JCheckBoxMenuItem("Show Toolbar", PrefManager.get().getShowToolbar());
            menuItem.addActionListener(this);
            popup.add(menuItem);
            popup.addSeparator();
            menuItem = new JMenuItem("Help");
            menuItem.addActionListener(this);
            popup.add(menuItem);
            popup.addSeparator();
        }
        menuItem = new JMenuItem("About TDA");
        menuItem.addActionListener(this);
        popup.add(menuItem);
    }

    //Add listener to the text area so the popup menu can come up.
    MouseListener popupListener = new PopupListener(popup);
    tree.addMouseListener(popupListener);
}