private HistoryPopupMenu() { super("History"); detailsMI = add(MenuFactory.getInstance().getMenuAction(new Integer(186))); detailsMI.setFont(Utilities.MENU_FONT); detailsMI.setForeground(Color.black); undoMI = add(MenuFactory.getInstance().getMenuAction(new Integer(187))); undoMI.setFont(Utilities.MENU_FONT); undoMI.setForeground(Color.black); FontEngine.getInstance().addPropertyChangeListener(this); }
/** * Adds an executable menu item * * @param name Item name * @param text Text on menu item * @param command Command to execute */ public void addExecutableMenuItem(final String name, final String text, final Command command) { final ExecutableMenuItem item = MenuFactory.newExecutableMenuItem(); item.setCommand(command); item.setText(text); item.setIcon(IconFactory.getInstance().getIcon(name)); addMenuItem(item); }
/** Loads the menu */ public void loadMenu() { PluginManager.getInstance().beforeQuickAccess(this); loadQuickAccessMenu(); boolean addSeparator = false; for (final File root : roots) { if (cfg.getBlackList().contains(root)) { continue; } if (cfg.isFloppyDrivesDisplayed() || !PathUtils.isFloppy(root)) { if (log.isDebugEnabled()) { log.debug("Generating menu for: " + root.getAbsolutePath()); } final FolderMenu item = MenuFactory.newFolderMenu(root); item.setText(PathUtils.getFileName(root)); item.setIcon(IconFactory.getInstance().getIcon(root)); addMenuItem(item); addSeparator = true; } } if (addSeparator) { addSeparator(); } addStaticItems(); reloadRoots(); }
/** Loads quick access menu */ private void loadQuickAccessMenu() { final List<File> quick = cfg.getQuickAccessList(); if (quick != null && quick.size() > 0) { final List<String> quickRaw = cfg.getRawQuickAccessList(); final Map<String, String> qaNames = cfg.getQuickAccessNames(); for (int i = 0; i < quick.size(); i++) { File custom = quick.get(i); String customEntry = quickRaw.get(i); try { final FolderMenu fm = MenuFactory.newFolderMenu(custom); if (qaNames.containsKey(customEntry)) { fm.setText(qaNames.get(customEntry)); } PluginManager.getInstance().enhanceQuickAccessItem(fm, custom); addMenuItem(fm); } catch (final Exception e) { log.warn("Skipping unloadable Quick Access List item", e); } } addSeparator(); } }
EditMenu(ComboFrame frame) { super(frame, "Edit"); add(new UndoMenuItem(frame)); add(new RedoMenuItem(frame)); addSeparator(); // Copy and paste is an elaborate dance: final JMenuItem cutItem = MenuFactory.createMenuItem("Cut"); final JMenuItem copyItem = MenuFactory.createMenuItem("Copy"); final JMenuItem pasteItem = MenuFactory.createMenuItem("Paste"); final JMenuItem pasteRefItem = MenuFactory.createMenuItem("PasteRef"); cutItem.setEnabled(false); copyItem.setEnabled(false); pasteItem.setEnabled(false); pasteRefItem.setEnabled(false); put("cut", cutItem); put("copy", copyItem); put("paste", pasteItem); put("pasteRef", pasteRefItem); add(cutItem); add(copyItem); add(pasteItem); add(pasteRefItem); // Enable "paste" after "cut": cutItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { RegionManager regions = (RegionManager) get("regions"); CurveIterator selection = (CurveIterator) get("selection"); regions.unShareShapes(selection); put("clipboard", selection); updatePasteEnabled(); } }); // Enable "paste" after "copy": copyItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { final Object selection = get("selection"); put("clipboard", selection); updatePasteEnabled(); } }); // And "paste" does the deed: pasteItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { CurveIterator selection = (CurveIterator) get("clipboard"); RegionManager regions = (RegionManager) get("regions"); regions.shareShapes(selection, true); } }); pasteRefItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { CurveIterator selection = (CurveIterator) get("clipboard"); RegionManager regions = (RegionManager) get("regions"); regions.shareShapes(selection, false); } }); if (Platform.getType() != Platform.MacOSX) { // On the Mac, the "Preferences" item lies under the app menu. addSeparator(); add(new PrefsMenuItem(frame)); } }