Example usage for javax.swing JMenuItem setEnabled

List of usage examples for javax.swing JMenuItem setEnabled

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The enabled state of the component.")
public void setEnabled(boolean b) 

Source Link

Document

Enables or disables the menu item.

Usage

From source file:org.apache.pdfbox.debugger.PDFDebugger.java

private JMenu createEditMenu() {
    JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic('E');

    JMenuItem cutMenuItem = new JMenuItem("Cut");
    cutMenuItem.setEnabled(false);
    editMenu.add(cutMenuItem);//from   ww  w  .  ja v a  2  s.  com

    JMenuItem copyMenuItem = new JMenuItem("Copy");
    copyMenuItem.setEnabled(false);
    editMenu.add(copyMenuItem);

    JMenuItem pasteMenuItem = new JMenuItem("Paste");
    pasteMenuItem.setEnabled(false);
    editMenu.add(pasteMenuItem);

    JMenuItem deleteMenuItem = new JMenuItem("Delete");
    deleteMenuItem.setEnabled(false);
    editMenu.add(deleteMenuItem);
    editMenu.addSeparator();
    editMenu.add(createFindMenu());

    return editMenu;
}

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

/**
 * Return popup menu with items applicable to feature tracks
 *
 * @return/*from w  w w.java 2  s  .c om*/
 */
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.broad.igv.track.TrackMenuUtils.java

public static JMenuItem getTrackRenameItem(final Collection<Track> selectedTracks) {
    // Change track height by attribute
    JMenuItem item = new JMenuItem("Rename Track...");
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            UIUtilities.invokeOnEventThread(new Runnable() {

                public void run() {
                    renameTrack(selectedTracks);
                }/* ww  w . j  av  a  2  s .  co  m*/
            });
        }
    });
    if (selectedTracks.size() > 1) {
        item.setEnabled(false);
    }
    return item;
}

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

public static JMenuItem getChangeKMPlotItem(final Collection<Track> selectedTracks) {
    // Change track height by attribute
    JMenuItem item = new JMenuItem("Kaplan-Meier Plot...");
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {

            // If one or fewer tracks are selected assume the intent is to use all tracks.  A right-click
            // will always result in one selected track.
            Collection<Track> tracks = selectedTracks.size() > 1 ? selectedTracks
                    : IGV.getInstance().getAllTracks();
            KMPlotFrame frame = new KMPlotFrame(tracks);
            frame.setVisible(true);//from  w  ww  . j av  a2s. c o  m
        }
    });

    // The Kaplan-Meier plot requires sample information, specifically survival, sample, and censure.  We
    // can't know if these columns exist, but we can at least know if sample-info has been loaded.
    // 3-4 columns always exist by default, more indicate at least some sample attributes are defined.
    boolean sampleInfoLoaded = AttributeManager.getInstance().getAttributeNames().size() > 4;
    item.setEnabled(sampleInfoLoaded);
    return item;
}

From source file:org.docx4all.ui.menu.FileMenu.java

protected JMenuItem createMenuItem(String actionName) {
    JMenuItem theItem = super.createMenuItem(actionName);

    WordMLEditor editor = WordMLEditor.getInstance(WordMLEditor.class);
    ToolBarStates toolbarStates = editor.getToolbarStates();

    if (SAVE_FILE_ACTION_NAME.equals(actionName) || SAVE_AS_DOCX_ACTION_NAME.equals(actionName)) {
        theItem.setEnabled(false);
        toolbarStates.addPropertyChangeListener(ToolBarStates.DOC_DIRTY_PROPERTY_NAME,
                new EnableOnEqual(theItem, Boolean.TRUE));

    } else if (SAVE_ALL_FILES_ACTION_NAME.equals(actionName)) {
        theItem.setEnabled(false);/*from ww w  .  ja  va  2 s .c  o m*/
        toolbarStates.addPropertyChangeListener(ToolBarStates.ANY_DOC_DIRTY_PROPERTY_NAME,
                new EnableOnEqual(theItem, Boolean.TRUE));

    } else if (EXPORT_AS_SHARED_DOC_ACTION_NAME.equals(actionName)) {
        theItem.setEnabled(false);
        toolbarStates.addPropertyChangeListener(ToolBarStates.DOC_SHARED_PROPERTY_NAME,
                new DisableOnEqual(theItem, Boolean.TRUE));

    } else if (EXPORT_AS_NON_SHARED_DOC_ACTION_NAME.equals(actionName)) {
        theItem.setEnabled(false);
        toolbarStates.addPropertyChangeListener(ToolBarStates.DOC_SHARED_PROPERTY_NAME,
                new EnableOnEqual(theItem, Boolean.TRUE));

    } else if (PRINT_PREVIEW_ACTION_NAME.equals(actionName) || EXPORT_AS_HTML_ACTION_NAME.equals(actionName)
            || CLOSE_FILE_ACTION_NAME.equals(actionName) || CLOSE_ALL_FILES_ACTION_NAME.equals(actionName)) {
        theItem.setEnabled(false);
        toolbarStates.addPropertyChangeListener(ToolBarStates.IFRAME_NUMBERS_PROPERTY_NAME,
                new EnableOnPositive(theItem));
    }

    return theItem;
}

From source file:org.docx4all.ui.menu.HyperlinkMenu.java

protected JMenuItem createMenuItem(String actionName) {
    JMenuItem theItem = super.createMenuItem(actionName);
    theItem.setEnabled(false);

    WordMLEditor editor = WordMLEditor.getInstance(WordMLEditor.class);
    ToolBarStates toolbarStates = editor.getToolbarStates();

    if (INSERT_EXTERNAL_LINK_ACTION_NAME.equals(actionName)) {
        toolbarStates.addPropertyChangeListener(ToolBarStates.CARET_UPDATE_PROPERTY_NAME,
                new InsertHyperlinkEnabler(theItem));

    } else if (EDIT_EXTERNAL_LINK_ACTION_NAME.equals(actionName)) {
        toolbarStates.addPropertyChangeListener(ToolBarStates.CARET_UPDATE_PROPERTY_NAME,
                new EditHyperlinkEnabler(theItem));
    }/*from  www  .j  a v  a2 s.  co m*/
    return theItem;
}

From source file:org.esa.nest.dat.views.polarview.PolarView.java

@Override
public JPopupMenu createPopupMenu(MouseEvent event) {
    final JPopupMenu popup = new JPopupMenu();

    final JMenuItem itemNext = createMenuItem("Next");
    popup.add(itemNext);/*from  w w w  .  j  av  a 2 s .  c o  m*/
    itemNext.setEnabled(currentRecord < numRecords);

    final JMenuItem itemPrev = createMenuItem("Previous");
    popup.add(itemPrev);
    itemPrev.setEnabled(currentRecord > 0);

    final JMenuItem itemColourScale = createMenuItem("Colour Scale");
    popup.add(itemColourScale);

    final JMenu unitMenu = new JMenu("Unit");
    popup.add(unitMenu);

    if (waveProductType == WaveProductType.WAVE_SPECTRA) {
        createCheckedMenuItem(unitTypes[Unit.AMPLITUDE.ordinal()], unitMenu, graphUnit == Unit.AMPLITUDE);
        createCheckedMenuItem(unitTypes[Unit.INTENSITY.ordinal()], unitMenu, graphUnit == Unit.INTENSITY);
    } else {
        createCheckedMenuItem(unitTypes[Unit.REAL.ordinal()], unitMenu, graphUnit == Unit.REAL);
        createCheckedMenuItem(unitTypes[Unit.IMAGINARY.ordinal()], unitMenu, graphUnit == Unit.IMAGINARY);
        createCheckedMenuItem(unitTypes[Unit.AMPLITUDE.ordinal()], unitMenu, graphUnit == Unit.AMPLITUDE);
        createCheckedMenuItem(unitTypes[Unit.INTENSITY.ordinal()], unitMenu, graphUnit == Unit.INTENSITY);
    }

    final JMenuItem itemExportReadout = createMenuItem("Export Readouts");
    popup.add(itemExportReadout);

    popup.setLabel("Justification");
    popup.setBorder(new BevelBorder(BevelBorder.RAISED));
    popup.addPopupMenuListener(this);
    popup.show(this, event.getX(), event.getY());

    return popup;
}

From source file:org.esa.snap.core.gpf.ui.OperatorMenu.java

private JMenuItem createHelpMenuItem() {
    JMenuItem menuItem = new JMenuItem("Help");
    if (helpId != null && !helpId.isEmpty()) {
        menuItem.addActionListener(e -> new HelpCtx(helpId).display());
    } else {//from w  w w  . ja v  a 2s  .  c o m
        menuItem.setEnabled(false);
    }
    return menuItem;
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createStopMenuItem() {
    JMenuItem menuItem = MenuItemFactory.createMenuItem(action());
    menuItem.setText("Cancel Query");
    menuItem.setActionCommand("cancelQuery");
    menuItem.setEnabled(false);
    executingButtons().add(menuItem);// ww  w  .ja  va2 s.co  m
    return menuItem;
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private void setTransactionButtonsEnabled(boolean enable) {

    for (JMenuItem menuItem : transactionButtons()) {

        menuItem.setEnabled(enable);
    }// ww  w .  ja  va2s .  com

}