Example usage for javax.swing JMenu addSeparator

List of usage examples for javax.swing JMenu addSeparator

Introduction

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

Prototype

public void addSeparator() 

Source Link

Document

Appends a new separator to the end of the menu.

Usage

From source file:org.languagetool.gui.Main.java

private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(getLabel("guiMenuFile"));
    fileMenu.setMnemonic(getMnemonic("guiMenuFile"));
    JMenu editMenu = new JMenu(getLabel("guiMenuEdit"));
    editMenu.setMnemonic(getMnemonic("guiMenuEdit"));
    JMenu grammarMenu = new JMenu(getLabel("guiMenuGrammar"));
    grammarMenu.setMnemonic(getMnemonic("guiMenuGrammar"));
    JMenu helpMenu = new JMenu(getLabel("guiMenuHelp"));
    helpMenu.setMnemonic(getMnemonic("guiMenuHelp"));

    fileMenu.add(openAction);//from w  ww.  j  a va2  s.c o m
    fileMenu.add(saveAction);
    fileMenu.add(saveAsAction);
    recentFilesMenu = new JMenu(getLabel("guiMenuRecentFiles"));
    recentFilesMenu.setMnemonic(getMnemonic("guiMenuRecentFiles"));
    fileMenu.add(recentFilesMenu);
    updateRecentFilesMenu();
    fileMenu.addSeparator();
    fileMenu.add(new HideAction());
    fileMenu.addSeparator();
    fileMenu.add(new QuitAction());

    grammarMenu.add(checkAction);
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(autoCheckAction);
    grammarMenu.add(item);
    JCheckBoxMenuItem showResult = new JCheckBoxMenuItem(showResultAction);
    grammarMenu.add(showResult);
    grammarMenu.add(new CheckClipboardAction());
    grammarMenu.add(new TagTextAction());
    grammarMenu.add(new AddRulesAction());
    grammarMenu.add(new OptionsAction());
    grammarMenu.add(new SelectFontAction());
    JMenu lafMenu = new JMenu(messages.getString("guiLookAndFeelMenu"));
    UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
    ButtonGroup buttonGroup = new ButtonGroup();
    for (UIManager.LookAndFeelInfo laf : lafInfo) {
        if (!"Nimbus".equals(laf.getName())) {
            continue;
        }
        addLookAndFeelMenuItem(lafMenu, laf, buttonGroup);
    }
    for (UIManager.LookAndFeelInfo laf : lafInfo) {
        if ("Nimbus".equals(laf.getName())) {
            continue;
        }
        addLookAndFeelMenuItem(lafMenu, laf, buttonGroup);
    }
    grammarMenu.add(lafMenu);

    helpMenu.add(new AboutAction());

    undoRedo.undoAction.putValue(Action.NAME, getLabel("guiMenuUndo"));
    undoRedo.undoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuUndo"));
    undoRedo.redoAction.putValue(Action.NAME, getLabel("guiMenuRedo"));
    undoRedo.redoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuRedo"));

    editMenu.add(undoRedo.undoAction);
    editMenu.add(undoRedo.redoAction);
    editMenu.addSeparator();

    Action cutAction = new DefaultEditorKit.CutAction();
    cutAction.putValue(Action.SMALL_ICON, getImageIcon("sc_cut.png"));
    cutAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_cut.png"));
    cutAction.putValue(Action.NAME, getLabel("guiMenuCut"));
    cutAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_T);
    editMenu.add(cutAction);

    Action copyAction = new DefaultEditorKit.CopyAction();
    copyAction.putValue(Action.SMALL_ICON, getImageIcon("sc_copy.png"));
    copyAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_copy.png"));
    copyAction.putValue(Action.NAME, getLabel("guiMenuCopy"));
    copyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
    editMenu.add(copyAction);

    Action pasteAction = new DefaultEditorKit.PasteAction();
    pasteAction.putValue(Action.SMALL_ICON, getImageIcon("sc_paste.png"));
    pasteAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_paste.png"));
    pasteAction.putValue(Action.NAME, getLabel("guiMenuPaste"));
    pasteAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_P);
    editMenu.add(pasteAction);

    editMenu.addSeparator();

    editMenu.add(new SelectAllAction());

    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(grammarMenu);
    menuBar.add(helpMenu);
    return menuBar;
}

From source file:org.lnicholls.galleon.gui.MainFrame.java

public MainFrame(String version) {

    super("Galleon " + version);

    setDefaultCloseOperation(0);//from   w ww  .  jav a 2s  .  c  o  m

    JMenuBar menuBar = new JMenuBar();

    menuBar.putClientProperty("jgoodies.headerStyle", HeaderStyle.BOTH);

    menuBar.putClientProperty("jgoodies.windows.borderStyle", BorderStyle.SEPARATOR);

    menuBar.putClientProperty("Plastic.borderStyle", BorderStyle.SEPARATOR);

    JMenu fileMenu = new JMenu("File");

    fileMenu.setMnemonic('F');

    fileMenu.add(new MenuAction("New App...", null, "", new Integer(KeyEvent.VK_N)) {

        public void actionPerformed(ActionEvent event) {

            new AddAppDialog(Galleon.getMainFrame()).setVisible(true);

        }

    });

    fileMenu.addSeparator();

    fileMenu.add(new MenuAction("Properties...", null, "", new Integer(KeyEvent.VK_P)) {

        public void actionPerformed(ActionEvent event) {

            new ServerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    /*
            
    fileMenu.add(new MenuAction("Galleon.tv Account...", null, "", new Integer(KeyEvent.VK_A)) {
            
            
            
       public void actionPerformed(ActionEvent event) {
            
    new DataDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);
            
       }
            
            
            
    });
            
    */

    fileMenu.add(new MenuAction("Download Manager...", null, "", new Integer(KeyEvent.VK_D)) {

        public void actionPerformed(ActionEvent event) {

            new DownloadManagerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration())
                    .setVisible(true);

        }

    });

    fileMenu.add(new MenuAction("GoBack...", null, "", new Integer(KeyEvent.VK_G)) {

        public void actionPerformed(ActionEvent event) {

            new GoBackDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    fileMenu.add(new MenuAction("Music Player...", null, "", new Integer(KeyEvent.VK_M)) {

        public void actionPerformed(ActionEvent event) {

            new MusicPlayerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    fileMenu.add(new MenuAction("ToGo...", null, "", new Integer(KeyEvent.VK_T)) {

        public void actionPerformed(ActionEvent event) {

            new ToGoDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    fileMenu.addSeparator();

    fileMenu.add(new MenuAction("Exit", null, "", new Integer(KeyEvent.VK_X)) {

        public void actionPerformed(ActionEvent event) {

            System.exit(0);

        }

    });

    menuBar.add(fileMenu);

    JMenu tutorialMenu = new JMenu("Tutorials");

    tutorialMenu.setMnemonic('T');

    tutorialMenu.putClientProperty("jgoodies.noIcons", Boolean.TRUE);

    tutorialMenu.add(new MenuAction("Properties", null, "", new Integer(KeyEvent.VK_P)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("Music Player", null, "", new Integer(KeyEvent.VK_M)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.addSeparator();

    tutorialMenu.add(new MenuAction("Email", null, "", new Integer(KeyEvent.VK_E)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("Music", null, "", new Integer(KeyEvent.VK_U)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("Podcasting", null, "", new Integer(KeyEvent.VK_O)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("ToGo", null, "", new Integer(KeyEvent.VK_T)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    menuBar.add(tutorialMenu);

    JMenu helpMenu = new JMenu("Help");

    helpMenu.setMnemonic('H');

    helpMenu.putClientProperty("jgoodies.noIcons", Boolean.TRUE);

    helpMenu.add(new MenuAction("Homepage", null, "", new Integer(KeyEvent.VK_H)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("Configuration", null, "", new Integer(KeyEvent.VK_C)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/93/52/");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("FAQ", null, "", new Integer(KeyEvent.VK_F)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/section/3/47/");

            } catch (Exception ex) {

            }

        }

    });

    /*
            
    helpMenu.add(new MenuAction("TiVo Community Forum", null, "", new Integer(KeyEvent.VK_T)) {
            
            
            
       public void actionPerformed(ActionEvent event) {
            
    try {
            
       BrowserLauncher.openURL("http://www.tivocommunity.com/tivo-vb/forumdisplay.php?f=35");
            
    } catch (Exception ex) {
            
    }
            
       }
            
            
            
    });
            
    */

    helpMenu.add(new MenuAction("Galleon Forum", null, "", new Integer(KeyEvent.VK_G)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/component/option,com_joomlaboard/Itemid,26/");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("File a bug", null, "", new Integer(KeyEvent.VK_B)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher
                        .openURL("http://sourceforge.net/tracker/?atid=705256&group_id=126291&func=browse");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("Request a feature", null, "", new Integer(KeyEvent.VK_E)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher
                        .openURL("http://sourceforge.net/tracker/?atid=705259&group_id=126291&func=browse");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.addSeparator();

    helpMenu.add(new MenuAction("About...", null, "", new Integer(KeyEvent.VK_A)) {

        public void actionPerformed(ActionEvent event) {

            JOptionPane

                    .showMessageDialog(

                            Galleon.getMainFrame(),

                            "Galleon Version "

                                    + Tools.getVersion()

                                    + "\nJava Version "

                                    + System.getProperty("java.vm.version")

                                    + "\nPublishing Port "

                                    + Galleon.getHttpPort()

                                    + "\nApplication Port "

                                    + Galleon.getPort()

                                    + "\nhttp://galleon.tv\njavahmo@users.sourceforge.net\nCopyright \251 2005, 2006 Leon Nicholls. All Rights Reserved.",

                            "About", JOptionPane.INFORMATION_MESSAGE);

        }

    });

    menuBar.add(helpMenu);

    setJMenuBar(menuBar);

    JComponent content = createContentPane();

    setContentPane(content);

    pack();

    Dimension paneSize = getSize();

    Dimension screenSize = getToolkit().getScreenSize();

    setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2);

    URL url = getClass().getClassLoader().getResource("guiicon.gif");

    ImageIcon logo = new ImageIcon(url);

    if (logo != null)

        setIconImage(logo.getImage());

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {

            System.exit(0);

        }

    });

}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup Menu Bar// w w w.j a va  2s.com
 * @return JMenu Bar
 */
private JMenuBar setupMenu() {
    JMenuBar menuBar = new JMenuBar();

    /* -- GridNode Menu -- */

    JMenu gridNodeMenu = new JMenu("GridNode");
    gridNodeMenu.setMnemonic(KeyEvent.VK_N);
    menuBar.add(gridNodeMenu);

    // Discover 
    JMenuItem clusterDiscoverItem = new JMenuItem("Disover and Connect Clusters");
    clusterDiscoverItem.setMnemonic(KeyEvent.VK_D);
    clusterDiscoverItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    gridNodeMenu.add(clusterDiscoverItem);
    clusterDiscoverItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doDiscover(false);
            ((JCheckBoxMenuItem) getUIElement("menu.node.autodiscover")).setSelected(false);
        }
    });
    addUIElement("menu.node.discover", clusterDiscoverItem); // Add to components map

    // Auto-Discovery
    final JCheckBoxMenuItem autodiscoveryItem = new JCheckBoxMenuItem("Auto Discover");
    autodiscoveryItem.setMnemonic(KeyEvent.VK_A);
    autodiscoveryItem.setSelected(true);
    gridNodeMenu.add(autodiscoveryItem);
    autodiscoveryItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            autodiscover = autodiscoveryItem.isSelected();
        }
    });
    addUIElement("menu.node.autodiscover", autodiscoveryItem); // Add to components map

    gridNodeMenu.addSeparator();

    // Cluster-> Shutdown
    JMenuItem nodeShutdownItem = new JMenuItem("Shutdown", 'u');
    nodeShutdownItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0));
    nodeShutdownItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doShutdownNode();
        }
    });
    gridNodeMenu.add(nodeShutdownItem);
    addUIElement("menu.node.shutdown", nodeShutdownItem); // Add to components map

    /* -- Options Menu -- */
    JMenu optionsMenu = new JMenu("Options");
    optionsMenu.setMnemonic(KeyEvent.VK_O);
    menuBar.add(optionsMenu);

    // Configuration
    JMenuItem optionsConfigItem = new JMenuItem("Configuration...", 'C');
    optionsConfigItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showConfiguration();
        }
    });
    optionsMenu.add(optionsConfigItem);
    optionsConfigItem.setEnabled(false); // TODO Create Configuration Options

    /* -- Help Menu -- */
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(helpMenu);

    // Help Contents
    JMenuItem helpContentsItem = new JMenuItem("Help Contents", 'H');
    helpContentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    helpContentsItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showHelp();
        }
    });
    helpMenu.add(helpContentsItem);

    helpMenu.addSeparator();

    JMenuItem helpAboutItem = new JMenuItem("About", 'A');
    helpAboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showAbout();
        }
    });
    helpMenu.add(helpAboutItem);

    return menuBar;
}

From source file:org.omegat.gui.issues.IssuesPanelController.java

JMenuBar generateMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = menuBar.add(new JMenu(OStrings.getString("ISSUES_WINDOW_MENU_OPTIONS")));

    {/*from w ww .  ja  v  a2  s.  c o m*/
        // Tags item is hard-coded because it is not disableable and is implemented differently from all
        // others.
        JCheckBoxMenuItem tagsItem = new JCheckBoxMenuItem(OStrings.getString(
                "ISSUES_WINDOW_MENU_OPTIONS_TOGGLE_PROVIDER", OStrings.getString("ISSUES_TAGS_PROVIDER_NAME")));
        tagsItem.setSelected(true);
        tagsItem.setEnabled(false);
        menu.add(tagsItem);
    }

    Set<String> disabledProviders = IssueProviders.getDisabledProviderIds();
    IssueProviders.getIssueProviders().stream().sorted(Comparator.comparing(IIssueProvider::getId))
            .forEach(provider -> {
                String label = StringUtil.format(
                        OStrings.getString("ISSUES_WINDOW_MENU_OPTIONS_TOGGLE_PROVIDER"), provider.getName());
                JCheckBoxMenuItem item = new JCheckBoxMenuItem(label);
                item.addActionListener(e -> {
                    IssueProviders.setProviderEnabled(provider.getId(), item.isSelected());
                    refreshData(selectedEntry, selectedType);
                });
                item.setSelected(!disabledProviders.contains(provider.getId()));
                menu.add(item);
            });

    menu.addSeparator();

    {
        JCheckBoxMenuItem askItem = new JCheckBoxMenuItem(OStrings.getString("ISSUES_WINDOW_MENU_DONT_ASK"));
        askItem.setSelected(Preferences.isPreference(Preferences.ISSUE_PROVIDERS_DONT_ASK));
        askItem.addActionListener(
                e -> Preferences.setPreference(Preferences.ISSUE_PROVIDERS_DONT_ASK, askItem.isSelected()));
        menu.add(askItem);
    }
    return menuBar;
}

From source file:org.omegat.gui.scripting.ScriptingWindow.java

private JMenuBar createMenuBar() {

    mb = new JMenuBar();
    JMenu menu = new JMenu();
    Mnemonics.setLocalizedText(menu, OStrings.getString("SCW_MENU_TITLE"));

    JMenuItem item;/* w ww  .j a v a  2  s  .c  o m*/

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_NEW_SCRIPT"));
    item.addActionListener(new NewScriptAction());
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(item);

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_SAVE_SCRIPT"));
    item.addActionListener(new SaveScriptAction());
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(item);

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_RUN_SCRIPT"));
    item.addActionListener(new RunScriptAction());
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(item);

    menu.addSeparator();

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_SET_SCRIPTS_FOLDER"));
    item.addActionListener(new SelectScriptFolderAction());
    menu.add(item);

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_ACCESS_FOLDER"));
    item.addActionListener(new ExploreScriptFolderAction());
    menu.add(item);

    menu.addSeparator();

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_CLOSE"));
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(e -> {
        frame.setVisible(false);
        frame.dispose();
    });
    menu.add(item);

    PropertiesShortcuts.MainMenuShortcuts.bindKeyStrokes(menu);

    mb.add(menu);

    // Edit Menu
    m_txtScriptEditor.enhanceMenu(mb);

    buildSetsMenu(mb);

    return mb;
}

From source file:org.openscience.jmol.app.Jmol.java

/**
 * Create a menu for the app.  By default this pulls the
 * definition of the menu from the associated resource file.
 * @param key//from  ww w  . j  av a2 s .  c o  m
 * @return Menu created
 */
protected JMenu createMenu(String key) {

    // Get list of items from resource file:
    String[] itemKeys = tokenize(JmolResourceHandler.getStringX(key));

    // Get label associated with this menu:
    JMenu menu = guimap.newJMenu(key);
    ImageIcon f = JmolResourceHandler.getIconX(key + "Image");
    if (f != null) {
        menu.setHorizontalTextPosition(SwingConstants.RIGHT);
        menu.setIcon(f);
    }

    // Loop over the items in this menu:
    for (int i = 0; i < itemKeys.length; i++) {

        String item = itemKeys[i];
        if (item.equals("-")) {
            menu.addSeparator();
            continue;
        }
        if (item.endsWith("Menu")) {
            JMenu pm;
            if ("recentFilesMenu".equals(item)) {
                /*recentFilesMenu = */pm = createMenu(item);
            } else {
                pm = createMenu(item);
            }
            menu.add(pm);
            continue;
        }
        JMenuItem mi = createMenuItem(item);
        menu.add(mi);
    }
    menu.addMenuListener(display.getMenuListener());
    return menu;
}

From source file:org.parosproxy.paros.extension.ExtensionLoader.java

private void addMenuHelper(JMenu menu, List<JMenuItem> items, int existingCount) {
    for (JMenuItem item : items) {
        if (item != null) {
            if (item == ExtensionHookMenu.MENU_SEPARATOR) {
                menu.addSeparator();
                continue;
            }/* ww  w.j  ava2  s.  c om*/

            menu.add(item, menu.getItemCount() - existingCount);
        }
    }

    menu.revalidate();
}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

private void createMorphMenu() {
    final JMenu morphMenu = context.getView().getComponent("format-morph-menu", JMenu.class);// NON-NLS     PRD-4452
    if (morphMenu == null) {
        return;/*from www  .  j  a  v  a 2 s.c  om*/
    }

    final ElementMetaData[] datas = ElementTypeRegistry.getInstance().getAllElementTypes();
    Arrays.sort(datas, new GroupedMetaDataComparator());
    Object grouping = null;
    boolean firstElement = true;
    for (int i = 0; i < datas.length; i++) {
        final ElementMetaData data = datas[i];
        if (data.isHidden()) {
            continue;
        }
        final String currentGrouping = data.getGrouping(Locale.getDefault());
        if (firstElement == false) {
            if (ObjectUtilities.equal(currentGrouping, grouping) == false) {
                grouping = currentGrouping;
                morphMenu.addSeparator();
            }
        } else {
            grouping = currentGrouping;
            firstElement = false;
        }

        try {
            final MorphAction action = new MorphAction(data.create());
            action.setReportDesignerContext(context);
            morphMenu.add(new JMenuItem(action));
        } catch (InstantiationException e) {
            UncaughtExceptionsModel.getInstance().addException(e);
        }
    }
}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

private void initAddElements(final String id) {
    final JMenu menu = context.getView().getComponent(id, JMenu.class);
    if (menu == null) {
        return;/*w  ww . j  a v  a  2  s . c  o  m*/
    }

    final ElementMetaData[] datas = ElementTypeRegistry.getInstance().getAllElementTypes();
    Arrays.sort(datas, new GroupedMetaDataComparator());
    Object grouping = null;
    boolean firstElement = true;
    for (int i = 0; i < datas.length; i++) {
        final ElementMetaData data = datas[i];
        if (data.isHidden()) {
            continue;
        }
        if (!WorkspaceSettings.getInstance().isVisible(data)) {
            continue;
        }

        final String currentGrouping = data.getGrouping(Locale.getDefault());
        if (firstElement == false) {
            if (ObjectUtilities.equal(currentGrouping, grouping) == false) {
                grouping = currentGrouping;
                menu.addSeparator();
            }
        } else {
            grouping = currentGrouping;
            firstElement = false;
        }
        final InsertElementAction action = new InsertElementAction(data);
        action.setReportDesignerContext(context);
        menu.add(new JMenuItem(action));
    }
}

From source file:org.pentaho.reporting.engine.classic.demo.ancient.demo.layouts.internalframe.InternalFrameDemoFrame.java

protected JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();

    //Set up the lone menu.
    final JMenu menu = new JMenu("Document");
    menu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(menu);//from   w  w  w .  j a v a  2 s  .c om

    menu.add(new JMenuItem(new NewFrameAction()));
    menu.add(new JMenuItem(getPreviewAction()));
    menu.addSeparator();
    menu.add(new JMenuItem(getCloseAction()));

    final JMenu helpmenu = new JMenu("Help");
    helpmenu.setMnemonic(KeyEvent.VK_H);
    helpmenu.add(new JMenuItem(getAboutAction()));
    return menuBar;
}