Example usage for javax.swing JMenu removeAll

List of usage examples for javax.swing JMenu removeAll

Introduction

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

Prototype

public void removeAll() 

Source Link

Document

Removes all menu items from this menu.

Usage

From source file:com.opendoorlogistics.studio.AppFrame.java

private void initFileMenu(JMenu mnFile) {
    mnFile.removeAll();

    // non-dynamic
    for (MyAction action : fileActions) {
        if (action == null) {
            mnFile.addSeparator();/*from  ww w.  j  av  a 2s .  c o  m*/
        } else {
            JMenuItem item = mnFile.add(action);
            if (action.accelerator != null) {
                item.setAccelerator(action.accelerator);
            }
        }
    }

    // import (not in action list as doesn't appear on toolbar)
    mnFile.addSeparator();
    JMenu mnImport = new JMenu("Import");
    mnFile.add(mnImport);

    class ImportPair {
        String menuString;
        SupportedFileType type;

        public ImportPair(String menuString, SupportedFileType type) {
            super();
            this.menuString = menuString;
            this.type = type;
        }
    }
    for (final ImportPair type : new ImportPair[] {
            new ImportPair("Comma separated (CSV) text", SupportedFileType.CSV),
            new ImportPair("Tab separated text", SupportedFileType.TABBED),
            new ImportPair("Excel", SupportedFileType.EXCEL),
            new ImportPair("Shapefile (link geometry to original file)",
                    SupportedFileType.SHAPEFILE_LINKED_GEOM),
            new ImportPair("Shapefile (copy geometry into spreadsheet)",
                    SupportedFileType.SHAPEFILE_COPIED_GEOM), }) {
        mnImport.add(new AbstractAction(type.menuString) {

            @Override
            public void actionPerformed(ActionEvent e) {
                importFile(type.type);
            }
        });
    }

    // dynamic
    mnFile.addSeparator();
    List<File> recent = PreferencesManager.getSingleton().getRecentFiles();
    for (int i = 0; i < recent.size(); i++) {
        final File file = recent.get(i);
        String s = Integer.toString(i + 1) + ". " + file.getAbsolutePath();
        int maxLen = 100;
        if (s.length() > maxLen) {
            s = s.substring(0, maxLen) + "...";
        }
        mnFile.add(new MyAction(s, "Load file " + file.getAbsolutePath(), null, null, false, null) {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (!canCloseDatastore()) {
                    return;
                }

                openFile(file);
                updateAppearance();
            }

        });
    }

    // clear recent
    mnFile.addSeparator();
    mnFile.add(new MyAction("Clear recent files", "Clear recent files", null, null, false, null) {

        @Override
        public void actionPerformed(ActionEvent e) {
            PreferencesManager.getSingleton().clearRecentFiles();
        }
    });

    // finally exit
    mnFile.addSeparator();
    JMenuItem item = mnFile.add(new MyAction("Exit", "Exit", null, null, false,
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.Event.CTRL_MASK)) {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            System.exit(0);
        }
    });
    item.setAccelerator(((MyAction) item.getAction()).accelerator);
    mnFile.validate();
}

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

private JToggleButton createMoreMenuButton() {
    final JMenuItem optionsMenuItem = WidgetFactory.createMenuItem("Options", IconUtils.MENU_OPTIONS);
    optionsMenuItem.addActionListener(new ActionListener() {
        @Override/*from w w w.  j  a v  a 2  s .  c om*/
        public void actionPerformed(ActionEvent e) {
            OptionsDialog optionsDialog = _optionsDialogProvider.get();
            optionsDialog.open();
        }
    });

    final JMenuItem monitorMenuItem = WidgetFactory.createMenuItem("DataCleaner monitor",
            IconUtils.MENU_DQ_MONITOR);
    monitorMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            MonitorConnectionDialog dialog = _monitorConnectionDialogProvider.get();
            dialog.open();
        }
    });

    final JMenuItem dictionariesMenuItem = WidgetFactory.createMenuItem("Dictionaries",
            IconUtils.DICTIONARY_IMAGEPATH);
    dictionariesMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get();
            referenceDataDialog.selectDictionariesTab();
            referenceDataDialog.open();
        }
    });

    final JMenuItem synonymCatalogsMenuItem = WidgetFactory.createMenuItem("Synonyms",
            IconUtils.SYNONYM_CATALOG_IMAGEPATH);
    synonymCatalogsMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get();
            referenceDataDialog.selectSynonymsTab();
            referenceDataDialog.open();
        }
    });

    final JMenuItem stringPatternsMenuItem = WidgetFactory.createMenuItem("String patterns",
            IconUtils.STRING_PATTERN_IMAGEPATH);
    stringPatternsMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get();
            referenceDataDialog.selectStringPatternsTab();
            referenceDataDialog.open();
        }
    });

    final PopupButton popupButton = new PopupButton("More",
            imageManager.getImageIcon(IconUtils.ACTION_SCROLLDOWN_BRIGHT));
    applyMenuPopupButttonStyling(popupButton);

    final JMenu windowsMenuItem = WidgetFactory.createMenu("Windows", 'w');
    windowsMenuItem.setIcon(imageManager.getImageIcon("images/menu/windows.png", IconUtils.ICON_SIZE_SMALL));
    final List<DCWindow> windows = getWindowContext().getWindows();

    getWindowContext().addWindowListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            windowsMenuItem.removeAll();
            for (final DCWindow window : windows) {
                final Image windowIcon = window.getWindowIcon();
                final String title = window.getWindowTitle();
                final ImageIcon icon = new ImageIcon(windowIcon.getScaledInstance(IconUtils.ICON_SIZE_SMALL,
                        IconUtils.ICON_SIZE_SMALL, Image.SCALE_DEFAULT));
                final JMenuItem switchToWindowItem = WidgetFactory.createMenuItem(title, icon);
                switchToWindowItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        window.toFront();
                    }
                });
                windowsMenuItem.add(switchToWindowItem);
            }

            windowsMenuItem.add(new JSeparator());

            JMenuItem closeAllWindowsItem = WidgetFactory.createMenuItem("Close all dialogs", (ImageIcon) null);
            closeAllWindowsItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    List<DCWindow> windows = new ArrayList<>(getWindowContext().getWindows());
                    for (DCWindow window : windows) {
                        if (window instanceof AbstractDialog) {
                            window.close();
                        }
                    }
                }
            });
            windowsMenuItem.add(closeAllWindowsItem);
        }

    });

    popupButton.getMenu().removeAll();
    popupButton.getMenu().add(dictionariesMenuItem);
    popupButton.getMenu().add(synonymCatalogsMenuItem);
    popupButton.getMenu().add(stringPatternsMenuItem);
    popupButton.getMenu().add(new JSeparator());
    popupButton.getMenu().add(windowsMenuItem);
    popupButton.getMenu().add(new JSeparator());
    popupButton.getMenu().add(monitorMenuItem);
    popupButton.getMenu().add(optionsMenuItem);

    return popupButton;
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterControl.java

/** 
 * Creates the windowsMenuItems. /*from  ww w .j  av  a2 s  .  co  m*/
 * 
 * @param menu The menu to handle.
 */
private void createWindowsMenuItems(JMenu menu) {
    menu.removeAll();
    menu.add(new ActivateAction(model));
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Removes all the elements from the passed menu and button group.
 * //from   w w  w. ja v a 2 s. c  om
 * @param group The group to handle.
 * @param menu  The menu to handle.
 */
private void clearZoomMenu(ButtonGroup group, JMenu menu) {
    menu.removeAll();
    for (Enumeration<AbstractButton> e = group.getElements(); e.hasMoreElements();)
        group.remove(e.nextElement());
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerControl.java

/** 
 * Creates the windowsMenuItems. /* ww  w . j a v a  2  s . co m*/
 * 
 * @param menu The menu to handle.
 */
private void createWindowsMenuItems(JMenu menu) {
    Set viewers = TreeViewerFactory.getViewers();
    Iterator i = viewers.iterator();
    menu.removeAll();
    while (i.hasNext())
        menu.add(new JMenuItem(new ActivationAction((TreeViewer) i.next())));
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Create the application./*from  ww w  .ja  v  a 2 s . co  m*/
 * 
 * @param name
 *          the name
 */
public MainWindow(String name) {
    super(name);
    setName("mainWindow");
    setMinimumSize(new Dimension(1000, 700));

    instance = this;

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnTmm = new JMenu("tinyMediaManager");
    mnTmm.setMnemonic(KeyEvent.VK_T);
    menuBar.add(mnTmm);

    if (!Globals.isDonator()) {
        mnTmm.add(new RegisterDonatorVersionAction());
    }

    mnTmm.add(new SettingsAction());
    mnTmm.addSeparator();
    mnTmm.add(new LaunchUpdaterAction());
    mnTmm.addSeparator();
    mnTmm.add(new ExitAction());
    initialize();

    // tools menu
    JMenu tools = new JMenu(BUNDLE.getString("tmm.tools")); //$NON-NLS-1$
    tools.setMnemonic(KeyEvent.VK_O);
    tools.add(new ClearDatabaseAction());

    JMenu cache = new JMenu(BUNDLE.getString("tmm.cache")); //$NON-NLS-1$
    cache.setMnemonic(KeyEvent.VK_C);
    tools.add(cache);
    JMenuItem clearImageCache = new JMenuItem(new ClearImageCacheAction());
    clearImageCache.setMnemonic(KeyEvent.VK_I);
    cache.add(clearImageCache);

    JMenuItem rebuildImageCache = new JMenuItem(new RebuildImageCacheAction());
    rebuildImageCache.setMnemonic(KeyEvent.VK_R);
    cache.add(rebuildImageCache);

    JMenuItem tmmFolder = new JMenuItem(BUNDLE.getString("tmm.gotoinstalldir")); //$NON-NLS-1$
    tmmFolder.setMnemonic(KeyEvent.VK_I);
    tools.add(tmmFolder);
    tmmFolder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path path = Paths.get(System.getProperty("user.dir"));
            try {
                // check whether this location exists
                if (Files.exists(path)) {
                    TmmUIHelper.openFile(path);
                }
            } catch (Exception ex) {
                LOGGER.error("open filemanager", ex);
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path,
                        "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() }));
            }
        }
    });

    JMenuItem tmmLogs = new JMenuItem(BUNDLE.getString("tmm.errorlogs")); //$NON-NLS-1$
    tmmLogs.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmLogs);
    tmmLogs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog logDialog = new LogDialog();
            logDialog.setLocationRelativeTo(MainWindow.getActiveInstance());
            logDialog.setVisible(true);
        }
    });

    JMenuItem tmmMessages = new JMenuItem(BUNDLE.getString("tmm.messages")); //$NON-NLS-1$
    tmmMessages.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmMessages);
    tmmMessages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog messageDialog = MessageHistoryDialog.getInstance();
            messageDialog.setVisible(true);
        }
    });

    tools.addSeparator();
    final JMenu menuWakeOnLan = new JMenu(BUNDLE.getString("tmm.wakeonlan")); //$NON-NLS-1$
    menuWakeOnLan.setMnemonic(KeyEvent.VK_W);
    menuWakeOnLan.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuWakeOnLan.removeAll();
            for (final WolDevice device : Globals.settings.getWolDevices()) {
                JMenuItem item = new JMenuItem(device.getName());
                item.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        Utils.sendWakeOnLanPacket(device.getMacAddress());
                    }
                });
                menuWakeOnLan.add(item);
            }
        }
    });
    tools.add(menuWakeOnLan);

    // activate/deactivate WakeOnLan menu item
    tools.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            if (Globals.settings.getWolDevices().size() > 0) {
                menuWakeOnLan.setEnabled(true);
            } else {
                menuWakeOnLan.setEnabled(false);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

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

    if (Globals.isDebug()) {
        final JMenu debugMenu = new JMenu("Debug"); //$NON-NLS-1$

        JMenuItem trace = new JMenuItem("set Logger to TRACE"); //$NON-NLS-1$
        trace.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
                lc.getLogger("org.tinymediamanager").setLevel(Level.TRACE);
                MessageManager.instance.pushMessage(new Message("Trace levels set!", ""));
                LOGGER.trace("if you see that, we're now on TRACE logging level ;)");
            }
        });

        debugMenu.add(trace);
        tools.add(debugMenu);
    }

    menuBar.add(tools);

    mnTmm = new JMenu(BUNDLE.getString("tmm.contact")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_C);
    mnTmm.add(new FeedbackAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new BugReportAction()).setMnemonic(KeyEvent.VK_B);
    menuBar.add(mnTmm);

    mnTmm = new JMenu(BUNDLE.getString("tmm.help")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_H);
    menuBar.add(mnTmm);

    mnTmm.add(new WikiAction()).setMnemonic(KeyEvent.VK_W);
    mnTmm.add(new FaqAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new ForumAction()).setMnemonic(KeyEvent.VK_O);
    mnTmm.addSeparator();

    mnTmm.add(new AboutAction()).setMnemonic(KeyEvent.VK_A);

    menuBar.add(Box.createGlue());

    if (!Globals.isDonator()) {
        JButton btnDonate = new JButton(new DonateAction());
        btnDonate.setBorderPainted(false);
        btnDonate.setFocusPainted(false);
        btnDonate.setContentAreaFilled(false);
        menuBar.add(btnDonate);
    }

    checkForUpdate();
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

private void buildMenu() {
    menu.setMnemonic(KeyEvent.VK_M);

    // menu items
    JMenuItem menuItem = menu.add(actionUpdateDataSources2);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(/*from  ww  w  . jav  a 2s  .  com*/
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    final JMenu menuUpdateDatasources = new JMenu(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    final JMenu menuFindMissingMovies = new JMenu(BUNDLE.getString("movie.findmissing")); //$NON-NLS-1$
    menuUpdateDatasources.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuUpdateDatasources.removeAll();
            menuFindMissingMovies.removeAll();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                JMenuItem item = new JMenuItem(new MovieUpdateSingleDatasourceAction(ds));
                menuUpdateDatasources.add(item);

                item = new JMenuItem(new MovieFindMissingAction(ds));
                menuFindMissingMovies.add(item);

            }
        }
    });
    menu.add(menuUpdateDatasources);

    menu.add(new MovieFindMissingAction());
    menu.add(menuFindMissingMovies);
    menu.add(new MovieCreateOfflineAction(true));

    menu.addSeparator();

    JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
    menuScrape.setMnemonic(KeyEvent.VK_S);
    menuItem = menuScrape.add(actionScrape2);
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeSelected);
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeUnscraped);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeMetadataSelected);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuScrape.add(actionAssignMovieSets);
    menu.add(menuScrape);

    JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$
    menuEdit.setMnemonic(KeyEvent.VK_E);
    menuItem = menuEdit.add(actionEditMovie2);
    menuItem.setMnemonic(KeyEvent.VK_E);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionBatchEdit);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionSetWatchedFlag);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRename2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRenamerPreview);
    menuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(menuEdit);

    menuItem = menu.add(actionRewriteNfo);
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem = menu.add(actionTrailerDownload);
    menuItem = menu.add(actionSearchSubtitle);
    menuItem = menu.add(actionDownloadSubtitle);

    menu.addSeparator();
    menuItem = menu.add(actionMediaInformation2);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionExport);
    menuItem.setMnemonic(KeyEvent.VK_X);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionRemove2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE));
    menuItem = menu.add(actionDelete2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK));
    menu.addSeparator();
    menuItem = menu.add(actionSyncTrakt);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem = menu.add(actionSyncWatchedTrakt);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem = menu.add(actionSyncSelectedTrakt);

    menu.addSeparator();
    menuItem = menu.add(actionClearImageCache);
    menuItem.setMnemonic(KeyEvent.VK_C);

    // popup menu
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.add(actionScrape2);
    popupMenu.add(actionScrapeSelected);
    popupMenu.add(actionScrapeUnscraped);
    popupMenu.add(actionScrapeMetadataSelected);
    popupMenu.add(actionAssignMovieSets);
    popupMenu.addSeparator();
    popupMenu.add(actionEditMovie2);
    popupMenu.add(actionBatchEdit);
    popupMenu.add(actionSetWatchedFlag);
    popupMenu.add(actionRewriteNfo);
    popupMenu.add(actionRename2);
    popupMenu.add(actionRenamerPreview);
    popupMenu.add(actionMediaInformation2);
    popupMenu.add(actionExport);
    popupMenu.add(actionTrailerDownload);
    popupMenu.add(actionSearchSubtitle);
    popupMenu.add(actionDownloadSubtitle);
    popupMenu.addSeparator();
    popupMenu.add(actionSyncTrakt);
    popupMenu.add(actionSyncWatchedTrakt);
    popupMenu.add(actionSyncSelectedTrakt);
    popupMenu.addSeparator();
    popupMenu.add(actionClearImageCache);
    popupMenu.addSeparator();
    popupMenu.add(actionRemove2);
    popupMenu.add(actionDelete2);

    if (Globals.isDebug()) {
        JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$
        menuDebug.add(debugDumpMovie);
        menuDebug.addSeparator();
        menuDebug.add(new FakeTmmTaskAction("download", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("download", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 10, 10));
        popupMenu.add(menuDebug);
    }

    MouseListener mouseListener = new MovieTableMouseListener(popupMenu, table);
    table.addMouseListener(mouseListener);
}

From source file:processing.app.Base.java

protected void rebuildToolbarMenu(JMenu menu) {
    JMenuItem item;/*ww w .ja v  a  2s. co  m*/
    menu.removeAll();

    // Add the single "Open" item
    item = Editor.newJMenuItem(tr("Open..."), 'O');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                handleOpenPrompt();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    menu.add(item);
    menu.addSeparator();

    // Add a list of all sketches and subfolders
    boolean sketches = addSketches(menu, BaseNoGui.getSketchbookFolder());
    if (sketches)
        menu.addSeparator();

    // Add each of the subfolders of examples directly to the menu
    boolean found = addSketches(menu, BaseNoGui.getExamplesFolder());
    if (found)
        menu.addSeparator();
}

From source file:processing.app.Base.java

protected void rebuildSketchbookMenu(JMenu menu) {
    menu.removeAll();
    addSketches(menu, BaseNoGui.getSketchbookFolder());

    JMenu librariesMenu = JMenuUtils.findSubMenuWithLabel(menu, "libraries");
    if (librariesMenu != null) {
        menu.remove(librariesMenu);// w  w  w.  j  av a  2 s . com
    }
    JMenu hardwareMenu = JMenuUtils.findSubMenuWithLabel(menu, "hardware");
    if (hardwareMenu != null) {
        menu.remove(hardwareMenu);
    }
}

From source file:processing.app.Base.java

public void rebuildImportMenu(JMenu importMenu) {
    if (importMenu == null)
        return;//from   w w  w.jav a2 s. c  o m
    importMenu.removeAll();

    JMenuItem menu = new JMenuItem(tr("Manage Libraries..."));
    // Ctrl+Shift+I on Windows and Linux, Command+Shift+I on macOS
    menu.setAccelerator(KeyStroke.getKeyStroke('I',
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | ActionEvent.SHIFT_MASK));
    menu.addActionListener(e -> openLibraryManager("", ""));
    importMenu.add(menu);
    importMenu.addSeparator();

    JMenuItem addLibraryMenuItem = new JMenuItem(tr("Add .ZIP Library..."));
    addLibraryMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Base.this.handleAddLibrary();
            BaseNoGui.librariesIndexer.rescanLibraries();
            Base.this.onBoardOrPortChange();
            Base.this.rebuildImportMenu(Editor.importMenu);
            Base.this.rebuildExamplesMenu(Editor.examplesMenu);
        }
    });
    importMenu.add(addLibraryMenuItem);
    importMenu.addSeparator();

    // Split between user supplied libraries and IDE libraries
    TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();

    if (targetPlatform != null) {
        LibraryList libs = getSortedLibraries();
        String lastLibType = null;
        for (UserLibrary lib : libs) {
            String libType = lib.getTypes().get(0);
            if (!libType.equals(lastLibType)) {
                if (lastLibType != null) {
                    importMenu.addSeparator();
                }
                lastLibType = libType;
                JMenuItem platformItem = new JMenuItem(I18n.format(tr("{0} libraries"), tr(lastLibType)));
                platformItem.setEnabled(false);
                importMenu.add(platformItem);
            }

            AbstractAction action = new AbstractAction(lib.getName()) {
                public void actionPerformed(ActionEvent event) {
                    UserLibrary l = (UserLibrary) getValue("library");
                    try {
                        activeEditor.getSketchController().importLibrary(l);
                    } catch (IOException e) {
                        showWarning(tr("Error"),
                                I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
                    }
                }
            };
            action.putValue("library", lib);

            // Add new element at the bottom
            JMenuItem item = new JMenuItem(action);
            item.putClientProperty("library", lib);
            importMenu.add(item);
        }
    }
}