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.broad.igv.track.TrackMenuUtils.java

public static void addStandardItems(JPopupMenu menu, Collection<Track> tracks, TrackClickEvent te) {

    boolean hasDataTracks = false;
    boolean hasFeatureTracks = false;
    boolean hasOtherTracks = false;
    for (Track track : tracks) {

        //  TODO -- this is ugly, refactor to remove instanceof
        if (track instanceof DataTrack) {
            hasDataTracks = true;/*w  w w .ja v a 2 s  . co  m*/
        } else if (track instanceof FeatureTrack) {
            hasFeatureTracks = true;
        } else {
            hasOtherTracks = true;
        }
        if (hasDataTracks && hasFeatureTracks && hasOtherTracks) {
            break;
        }
    }

    boolean featureTracksOnly = hasFeatureTracks && !hasDataTracks && !hasOtherTracks;
    boolean dataTracksOnly = !hasFeatureTracks && hasDataTracks && !hasOtherTracks;

    addSharedItems(menu, tracks, hasFeatureTracks);
    menu.addSeparator();
    if (dataTracksOnly) {
        addDataItems(menu, tracks);
    } else if (featureTracksOnly) {
        addFeatureItems(menu, tracks, te);
    }

    menu.addSeparator();
    menu.add(getRemoveMenuItem(tracks));

}

From source file:org.broad.igv.track.TrackMenuUtils.java

/**
 * Return popup menu with items applicable to data tracks
 *
 * @return//from  ww  w .  j  a va 2  s  .c  o m
 */
public static void addDataItems(JPopupMenu menu, final Collection<Track> tracks) {

    if (log.isDebugEnabled()) {
        log.debug("enter getDataPopupMenu");
    }

    final String[] labels = { "Heatmap", "Bar Chart", "Scatterplot", "Line Plot" };
    final Class[] renderers = { HeatmapRenderer.class, BarChartRenderer.class, PointsRenderer.class,
            LineplotRenderer.class };

    //JLabel popupTitle = new JLabel(LEADING_HEADING_SPACER + title, JLabel.CENTER);

    JLabel rendererHeading = new JLabel(LEADING_HEADING_SPACER + "Type of Graph", JLabel.LEFT);
    rendererHeading.setFont(UIConstants.boldFont);

    menu.add(rendererHeading);

    // Get existing selections
    Set<Class> currentRenderers = new HashSet<Class>();
    for (Track track : tracks) {
        if (track.getRenderer() != null) {
            currentRenderers.add(track.getRenderer().getClass());
        }
    }

    // Create and renderer menu items
    for (int i = 0; i < labels.length; i++) {
        JCheckBoxMenuItem item = new JCheckBoxMenuItem(labels[i]);
        final Class rendererClass = renderers[i];
        if (currentRenderers.contains(rendererClass)) {
            item.setSelected(true);
        }
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                changeRenderer(tracks, rendererClass);
            }
        });
        menu.add(item);
    }
    menu.addSeparator();

    // Get union of all valid window functions for selected tracks
    Set<WindowFunction> avaibleWindowFunctions = new HashSet();
    for (Track track : tracks) {
        avaibleWindowFunctions.addAll(track.getAvailableWindowFunctions());
    }
    avaibleWindowFunctions.add(WindowFunction.none);

    // dataPopupMenu.addSeparator();
    // Collection all window functions for selected tracks
    Set<WindowFunction> currentWindowFunctions = new HashSet<WindowFunction>();
    for (Track track : tracks) {
        if (track.getWindowFunction() != null) {
            currentWindowFunctions.add(track.getWindowFunction());
        }
    }

    if (avaibleWindowFunctions.size() > 1 || currentWindowFunctions.size() > 1) {
        JLabel statisticsHeading = new JLabel(LEADING_HEADING_SPACER + "Windowing Function", JLabel.LEFT);
        statisticsHeading.setFont(UIConstants.boldFont);

        menu.add(statisticsHeading);

        for (final WindowFunction wf : ORDERED_WINDOW_FUNCTIONS) {
            JCheckBoxMenuItem item = new JCheckBoxMenuItem(wf.getDisplayName());
            if (avaibleWindowFunctions.contains(wf) || currentWindowFunctions.contains(wf)) {
                if (currentWindowFunctions.contains(wf)) {
                    item.setSelected(true);
                }
                item.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        changeStatType(wf.toString(), tracks);
                    }
                });
                menu.add(item);
            }
        }
        menu.addSeparator();
    }

    menu.add(getDataRangeItem(tracks));
    menu.add(getHeatmapScaleItem(tracks));

    if (tracks.size() > 0) {
        menu.add(getLogScaleItem(tracks));
    }

    menu.add(getAutoscaleItem(tracks));

    menu.add(getShowDataRangeItem(tracks));

    menu.addSeparator();
    menu.add(getChangeKMPlotItem(tracks));

}

From source file:org.broad.igv.track.TrackMenuUtils.java

/**
 * Return popup menu with items applicable to feature tracks
 *
 * @return//from  w w  w  . ja va 2s .  c o  m
 */
private static void addFeatureItems(JPopupMenu featurePopupMenu, final Collection<Track> tracks,
        TrackClickEvent te) {

    addDisplayModeItems(tracks, featurePopupMenu);

    if (tracks.size() == 1) {
        Track t = tracks.iterator().next();
        Feature f = t.getFeatureAtMousePosition(te);
        if (f != null) {
            featurePopupMenu.addSeparator();

            // If we are over an exon, copy its sequence instead of the entire feature.
            if (f instanceof IGVFeature) {
                double position = te.getChromosomePosition();
                Collection<Exon> exons = ((IGVFeature) f).getExons();
                if (exons != null) {
                    for (Exon exon : exons) {
                        if (position > exon.getStart() && position < exon.getEnd()) {
                            f = exon;
                            break;
                        }
                    }
                }
            }

            featurePopupMenu.add(getCopyDetailsItem(f, te));
            featurePopupMenu.add(getCopySequenceItem(f));
        }
    }

    featurePopupMenu.addSeparator();
    featurePopupMenu.add(getChangeFeatureWindow(tracks));

    //---------------------//
    //Track analysis
    if (Globals.toolsMenuEnabled && tracks.size() >= 2) {

        JMenuItem item = new JMenuItem("Create Overlap Track");
        item.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String newName = JOptionPane.showInputDialog(IGV.getMainFrame(), "Enter overlap track name: ",
                        "Overlaps");

                if (newName == null || newName.trim() == "") {
                    return;
                }
                CombinedFeatureSource source = new CombinedFeatureSource(tracks,
                        CombinedFeatureSource.Operation.MULTIINTER);
                Track newTrack = new FeatureTrack("", newName, source);

                IGV.getInstance().getTrackPanel(IGV.FEATURE_PANEL_NAME).addTrack(newTrack);
                IGV.getInstance().repaint();
            }
        });
        item.setEnabled(CombinedFeatureSource.checkBEDToolsPathValid());
        featurePopupMenu.add(item);
    }

    //--------------------//
}

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private JComponent getWindowPanelContent() {
    if (_datastore != null) {
        setDatastore(_datastore);/*from   w ww.  j  ava 2  s . c  om*/
    }

    final SaveAnalysisJobActionListener saveAnalysisJobActionListener = _saveAnalysisJobActionListenerProvider
            .get();
    _saveButton.addActionListener(saveAnalysisJobActionListener);
    _saveAsButton.addActionListener(saveAnalysisJobActionListener);
    _saveAsButton.setActionCommand(SaveAnalysisJobActionListener.ACTION_COMMAND_SAVE_AS);

    // Run analysis
    _executeButton.addActionListener(execute(_analysisJobBuilder));

    _executionAlternativesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final JMenuItem executeNormallyMenutItem = WidgetFactory.createMenuItem("Run normally",
                    IconUtils.ACTION_EXECUTE);
            executeNormallyMenutItem.addActionListener(execute(_analysisJobBuilder));

            final JMenuItem executePreviewMenuItem = WidgetFactory.createMenuItem("Run first N records",
                    IconUtils.ACTION_PREVIEW);
            executePreviewMenuItem.addActionListener(executePreview());

            final JMenuItem executeSingleThreadedMenuItem = WidgetFactory.createMenuItem("Run single-threaded",
                    IconUtils.MODEL_ROW);
            executeSingleThreadedMenuItem.addActionListener(executeSingleThreaded());

            final JPopupMenu menu = new JPopupMenu();
            menu.add(executeNormallyMenutItem);
            menu.addSeparator();
            menu.add(executePreviewMenuItem);
            menu.add(executeSingleThreadedMenuItem);

            final int horizontalPosition = -1 * menu.getPreferredSize().width
                    + _executionAlternativesButton.getWidth();
            menu.show(_executionAlternativesButton, horizontalPosition,
                    _executionAlternativesButton.getHeight());
        }
    });

    final JButton newJobButton = createToolbarButton("New", IconUtils.MENU_NEW);
    newJobButton.addActionListener(_newAnalysisJobActionListenerProvider.get());

    final JButton openJobButton = createToolbarButton("Open", IconUtils.MENU_OPEN);
    openJobButton.addActionListener(_openAnalysisJobActionListenerProvider.get());

    final JToggleButton moreButton = createMoreMenuButton();

    final JButton logoButton = new JButton(imageManager.getImageIcon("images/menu/dc-logo-30.png"));
    logoButton.setToolTipText("About DataCleaner");
    logoButton.setBorder(new EmptyBorder(0, 4, 0, 10));
    logoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutDialog(getWindowContext()).open();
        }
    });

    final JToolBar toolBar = WidgetFactory.createToolBar();
    toolBar.add(logoButton);
    toolBar.add(newJobButton);
    toolBar.add(openJobButton);
    toolBar.add(_saveButton);
    toolBar.add(_saveAsButton);
    toolBar.add(DCLabel.bright(" | "));
    toolBar.add(moreButton);

    toolBar.add(WidgetFactory.createToolBarSeparator());
    toolBar.add(_executeButton);
    toolBar.add(DCLabel.bright("|"));
    toolBar.add(_executionAlternativesButton);

    final JXStatusBar statusBar = WidgetFactory.createStatusBar(_statusLabel);
    statusBar.add(_classicViewButton);
    statusBar.add(_graphViewButton);
    statusBar.add(Box.createHorizontalStrut(10));

    final LicenceAndEditionStatusLabel statusLabel = new LicenceAndEditionStatusLabel(_glassPane);
    statusBar.add(statusLabel);

    final DCPanel toolBarPanel = new DCPanel(WidgetUtils.BG_COLOR_DARK);
    toolBarPanel.setLayout(new BorderLayout());
    toolBarPanel.add(toolBar, BorderLayout.CENTER);

    final DCPanel panel = new DCPersistentSizedPanel(_windowSizePreference);
    panel.setLayout(new BorderLayout());
    panel.add(toolBarPanel, BorderLayout.NORTH);
    panel.add(_leftPanel, BorderLayout.WEST);

    // newPanel.add(_tabbedPane, BorderLayout.NORTH);
    panel.add(_contentContainerPanel, BorderLayout.CENTER);

    panel.add(statusBar, BorderLayout.SOUTH);

    // invoke to trigger enablement/disablement of buttons.
    onSourceColumnsChanged();
    updateStatusLabel();

    WidgetUtils.centerOnScreen(this);
    return panel;
}

From source file:org.domainmath.gui.FileTreePanel.java

/**
 * Add popup menu.//from   w ww. jav a  2s.c o  m
 */
private void addPopupMenuToFileTree() {
    refreshItem = new JMenuItem(bundle.getString("fileTreeRefreshItem.text"));
    fileTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            addGlobalAction(e);

            if (SwingUtilities.isRightMouseButton(e)) {
                TreePath path = fileTree.getPathForLocation(e.getX(), e.getY());
                Rectangle pathBounds = fileTree.getUI().getPathBounds(fileTree, path);

                if (pathBounds != null && pathBounds.contains(e.getX(), e.getY())) {
                    JPopupMenu menu = new JPopupMenu();
                    File file = (File) fileTree.getLastSelectedPathComponent();
                    openItem = new JMenuItem(bundle.getString("fileTreeOpenItem.text"));
                    runScriptItem = new JMenuItem(bundle.getString("fileTreeRunItem.text"));
                    openOutsideItem = new JMenuItem(bundle.getString("fileTreeOpenOutsideItem.text"));
                    renameItem = new JMenuItem(bundle.getString("fileTreeRenameItem.text"));
                    deleteItem = new JMenuItem(bundle.getString("fileTreeDeleteItem.text"));

                    openItem.setAccelerator(keyOpenItem);
                    renameItem.setAccelerator(keyRenameItem);
                    deleteItem.setAccelerator(keyDeleteItem);
                    refreshItem.setAccelerator(keyRefreshItem);
                    menu.add(openItem);
                    menu.add(runScriptItem);
                    menu.add(openOutsideItem);
                    menu.addSeparator();
                    menu.add(renameItem);
                    menu.add(deleteItem);
                    menu.addSeparator();
                    menu.add(refreshItem);

                    fileTreeOpenItemActionPerformed(file);
                    fileTreeRunItemActionPerformed(file);
                    fileTreeOpenOutsideItemActionPerformed(file);
                    fileTreeRenameItemActionPerformed(fileTree.getSelectionPath());
                    fileTreeDeleteItemActionPerformed(fileTree.getSelectionModel().getSelectionPaths());
                    fileTreeRefreshItemActionPerformed((File) fileTree.getModel().getRoot());

                    if (file.isDirectory()) {
                        runScriptItem.setEnabled(false);
                    } else {
                        String name = file.getName();
                        if (!name.endsWith(".m")) {
                            runScriptItem.setEnabled(false);
                        }
                    }
                    menu.show(fileTree, e.getX(), e.getY());
                }
                if (pathBounds == null) {
                    JPopupMenu menu = new JPopupMenu();
                    newFolderItem = new JMenuItem(bundle.getString("fileTreeNewFolderItem.text"));
                    File file = (File) fileTree.getModel().getRoot();
                    menu.add(newFolderItem);
                    menu.add(refreshItem);

                    fileTreeNewFolderItemActionPerformed(file);
                    fileTreeRefreshItemActionPerformed(file);
                    menu.show(fileTree, e.getX(), e.getY());
                }
            }
        }
    });
}

From source file:org.executequery.gui.ExportResultSetPanel.java

private void init() throws Exception {

    fileNameField = WidgetFactory.createTextField();
    connectionsCombo = WidgetFactory.createComboBox();

    String[] delims = { "|", ",", ";", "#" };
    delimiterCombo = WidgetFactory.createComboBox(delims);
    delimiterCombo.setEditable(true);//  w  w w.ja  va2s  .co m

    combosGroup = new TableSelectionCombosGroup(connectionsCombo);

    includeColumNamesCheck = new JCheckBox("Include column names as first row");

    sqlText = new SimpleSqlTextPanel();
    //        sqlText.getTextPane().setBackground(Color.WHITE);
    sqlText.setBorder(null);
    sqlText.setScrollPaneBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, UIUtils.getDefaultBorderColour()));

    statusBar = new SqlTextPaneStatusBar();
    JPanel sqlPanel = new JPanel(new BorderLayout());
    sqlPanel.add(sqlText, BorderLayout.CENTER);
    sqlPanel.add(statusBar, BorderLayout.SOUTH);
    statusBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));

    outputPanel = new LoggingOutputPanel();
    FlatSplitPane splitPane = new FlatSplitPane(JSplitPane.VERTICAL_SPLIT, sqlPanel, outputPanel);
    splitPane.setResizeWeight(0.5);
    splitPane.setDividerLocation(0.8);
    splitPane.setDividerSize(5);

    JButton button = WidgetFactory.createInlineFieldButton("Browse");
    button.setActionCommand("browse");
    button.addActionListener(this);
    button.setMnemonic('r');

    JPanel mainPanel = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridheight = 1;
    gbc.insets.top = 5;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    gbc.insets.left = 5;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    mainPanel.add(new JLabel("Connection:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(connectionsCombo, gbc);
    gbc.insets.left = 5;
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    mainPanel.add(new JLabel("Data Delimiter:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(delimiterCombo, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 2;
    mainPanel.add(new JLabel("Output File:"), gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(fileNameField, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.left = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(button, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets.top = 2;
    gbc.insets.left = 5;
    mainPanel.add(includeColumNamesCheck, gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    mainPanel.add(new JLabel(instructionNote()), gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.insets.top = 0;
    gbc.insets.left = 5;
    gbc.insets.bottom = 5;
    gbc.fill = GridBagConstraints.BOTH;
    mainPanel.add(splitPane, gbc);

    mainPanel.setBorder(BorderFactory.createEtchedBorder());

    int minimumButtonWidth = 85;
    executeButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Execute", "executeAndExport");
    stopButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Stop", "stop");
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5));
    buttonPanel.add(executeButton);
    buttonPanel.add(stopButton);

    stopButton.setEnabled(false);

    add(mainPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    // register as a keyword and connection listener
    EventMediator.registerListener(this);

    JTextPane textPane = sqlText.getTextPane();
    ActionMap actionMap = textPane.getActionMap();

    String actionKey = "executeQueryAction";
    actionMap.put(actionKey, executeQueryAction);

    InputMap inputMap = textPane.getInputMap();
    inputMap.put(EXECUTE_KEYSTROKE, actionKey);

    JPopupMenu popupMenu = sqlText.getPopup();
    popupMenu.addSeparator();
    popupMenu.add(executeQueryAction);
}

From source file:org.gofleet.module.routing.RoutingMap.java

@Override
protected JPopupMenu getContextMenu() {
    JPopupMenu menu = new JPopupMenu();

    menu.setBackground(Color.decode("#E8EDF6"));

    String mapMenuTituloPlanning = i18n.getString("map.menu.titulo.planning");
    String mapMenuNewPlanning = i18n.getString("map.menu.new.planning");
    // Ttulo/*from ww  w  . j a  va2s. c o  m*/
    final JMenuItem titulo = new JMenuItem(mapMenuTituloPlanning);
    titulo.setFont(LogicConstants.deriveBoldFont(10.0f));
    titulo.setBackground(Color.decode("#A4A4A4"));
    titulo.setFocusable(false);

    menu.add(titulo);

    // New Planning
    final JMenuItem to = new JMenuItem(mapMenuNewPlanning, KeyEvent.VK_F6);
    to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta"));
    to.addActionListener(this);
    menu.add(to);

    menu.addSeparator();

    return menu;
}

From source file:org.javaswift.cloudie.CloudiePanel.java

private JPopupMenu createContainerPopupMenu() {
    JPopupMenu pop = new JPopupMenu("Container");
    pop.add(new JMenuItem(containerRefreshAction));
    pop.add(new JMenuItem(containerViewMetaData));
    pop.addSeparator();
    pop.add(new JMenuItem(containerCreateAction));
    pop.add(new JMenuItem(containerDeleteAction));
    pop.addSeparator();//from  w  w  w  .  j  a  va2s.  co m
    pop.add(new JMenuItem(containerEmptyAction));
    pop.addSeparator();
    pop.add(new JMenuItem(containerPurgeAction));
    return pop;
}

From source file:org.javaswift.cloudie.CloudiePanel.java

/**
 * @return/*from www .ja  va  2s  .  c o  m*/
 */
private JPopupMenu createStoredObjectPopupMenu() {
    JPopupMenu pop = new JPopupMenu("StoredObject");
    pop.add(new JMenuItem(storedObjectPreviewAction));
    pop.add(new JMenuItem(storedObjectOpenAction));
    pop.add(new JMenuItem(storedObjectViewMetaData));
    pop.addSeparator();
    pop.add(new JMenuItem(storedObjectCreateAction));
    pop.add(new JMenuItem(storedObjectDownloadAction));
    pop.addSeparator();
    pop.add(new JMenuItem(storedObjectDeleteAction));
    return pop;
}

From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java

private JPopupMenu createFilterTablePopUp() {
    final JPopupMenu result = new JPopupMenu();
    JMenuItem excludeSelectedHosts = new JMenuItem("Exclude selected hosts", KeyEvent.VK_U);
    result.add(excludeSelectedHosts);// ww  w  . j  a  v  a 2s .c om
    excludeSelectedHosts.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int[] selectedRows = createFilterTables.getSelectedRows();
            ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, false);
        }
    });

    JMenuItem includeSelectedHost = new JMenuItem("Include selected hosts", KeyEvent.VK_I);
    result.add(includeSelectedHost);
    includeSelectedHost.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int[] selectedRows = createFilterTables.getSelectedRows();
            ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, true);
        }
    });
    result.addSeparator();

    JMenuItem deleteSelectedHost = new JMenuItem("Deleted selected hosts", KeyEvent.VK_D);
    result.add(deleteSelectedHost);
    deleteSelectedHost.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int[] selectedRows = createFilterTables.getSelectedRows();
            ((FilterTableModel) createFilterTables.getModel()).removeRows(selectedRows);
        }
    });
    return result;
}