private void createTreeStatsMenu() { treeStatsMenu = new JMenu("Tree Stats"); menuBar.add(treeStatsMenu); utilItem = new JMenuItem("Utilization"); treeStatsMenu.add(utilItem); utilItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Libgist.getWkldNodeStats(Libgist.NODEUTIL, 0, false); treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, utilItem.getText()); } }); slotCntItem = new JMenuItem("Slot Count"); treeStatsMenu.add(slotCntItem); slotCntItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Libgist.getWkldNodeStats(Libgist.SLOTCNT, 0, false); treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, slotCntItem.getText()); } }); predSzItem = new JMenuItem("Predicate Size"); treeStatsMenu.add(predSzItem); predSzItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Libgist.getWkldNodeStats(Libgist.PREDSIZE, 0, false); treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, predSzItem.getText()); } }); }
/** * initialize the symbols menu * * @param m menu */ public void initSymbolsMenu(JMenu m) { m.removeAll(); for (int i = 0; i < glyphs.size(); i++) { final MetSymbol metSymbol = (MetSymbol) glyphs.get(i); JMenuItem mi = GuiUtils.makeMenuItem(metSymbol.getLabel(), this, "showProperties", metSymbol); mi.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { highlightedMetSymbol = null; StationModelCanvas.this.repaint(); } public void mouseReleased(MouseEvent e) { highlightedMetSymbol = null; StationModelCanvas.this.repaint(); } public void mouseEntered(MouseEvent e) { highlightedMetSymbol = metSymbol; StationModelCanvas.this.repaint(); } public void mouseExited(MouseEvent e) { highlightedMetSymbol = null; StationModelCanvas.this.repaint(); } }); m.add(mi); } }
/* * The following method creates the font menu * postcondition: returns the JMenu for the font menu. */ public JMenu createFontMenu() { JMenu menu = new JMenu(new String("Font")); menu.add(createFontNameMenu()); menu.add(createFontSizeMenu()); menu.add(createFontStyleMenu()); return menu; } // end createFontMenu method
void initControls() { JMenuItem jmi; jmi = new JMenuItem("JImage Menu"); jmi.setEnabled(false); popupMenu.add(jmi); jmi = new JMenuItem("Fit"); jmi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fit = true; repaint(); } }); popupMenu.add(jmi); JMenu scaleMenu = new JMenu("Set Scale"); popupMenu.add(scaleMenu); int scales[] = new int[] {25, 50, 100, 200, 400, 800}; for (int i = 0; i < scales.length; i++) { jmi = new JMenuItem(scales[i] + " %"); jmi.addActionListener(new ScaleAction(scales[i])); scaleMenu.add(jmi); } MyListener l = new MyListener(); addMouseMotionListener(l); addMouseListener(l); addMouseWheelListener(l); addKeyListener(l); }
/** * Make the edit menu * * @param editMenu edit menu * @return edit menu */ public JMenu makeEditMenu(JMenu editMenu) { editMenu.add(GuiUtils.makeDynamicMenu("Symbols", this, "initSymbolsMenu")); editMenu.add( GuiUtils.makeMenuItem("Set properties on selected", this, "setPropertiesOnSelected")); editMenu.addSeparator(); return super.makeEditMenu(editMenu); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddSecGroupMember = new ActionAddSecGroupMember(); if (container instanceof ICFSecuritySecGroupObj) { menuItem = new JMenuItem(actionAddSecGroupMember); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddTopProject = new ActionAddTopProject(); if (container instanceof ICFInternetDomainBaseObj) { menuItem = new JMenuItem(actionAddTopProject); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionTopProject(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionTopProject(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionTopProject(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
private void enableAnalysis() { setAllEnabled(false); analysisMenu.setEnabled(true); // get info on state of analysis String scriptFile; Libgist.getAnalysisInfo(analysisInfo); // newAnalysisItem not enabled: can't create new profile, we just closed the index newAnalysisItem.setEnabled(false); openAnalysisItem.setEnabled(true); completeAnalysisItem.setEnabled(true); wkldStatsItem.setEnabled(analysisInfo.actualHasWkldStats); splitStatsItem.setEnabled(analysisInfo.actualHasSplitStats); penaltyStatsItem.setEnabled(analysisInfo.actualHasPenaltyStats); // general tree statistics are okay treeStatsMenu.setEnabled(true); utilItem.setEnabled(true); predSzItem.setEnabled(true); slotCntItem.setEnabled(true); // can always select another index or exit fileMenu.setEnabled(true); newItem.setEnabled(true); openItem.setEnabled(true); exitItem.setEnabled(true); }
public void adjustListMenuBar() { JMenuItem menuItem; Action act; String itemLabel; boolean enableState; boolean inEditState; boolean allowAdds; ICFInternetTopProjectObj selectedObj = getSwingFocusAsTopProject(); CFJPanel.PanelMode mode = getPanelMode(); if (mode == CFJPanel.PanelMode.Edit) { inEditState = true; if (getSwingContainer() != null) { allowAdds = true; } else { allowAdds = false; } } else { inEditState = false; allowAdds = false; } if (selectedObj == null) { enableState = false; } else { enableState = true; } if (actionViewSelected != null) { actionViewSelected.setEnabled(enableState); } if (actionEditSelected != null) { actionEditSelected.setEnabled(inEditState && enableState); } if (actionDeleteSelected != null) { actionDeleteSelected.setEnabled(inEditState && enableState); } if (actionAddTopProject != null) { actionAddTopProject.setEnabled(allowAdds); } if (menuAdd != null) { menuAdd.setEnabled(allowAdds); } if (menuSelected != null) { menuSelected.setEnabled(enableState); int itemCount = menuSelected.getItemCount(); for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) { menuItem = menuSelected.getItem(itemIdx); act = menuItem.getAction(); if (act != null) { if (act == actionViewSelected) { menuItem.setEnabled(enableState); } else if (act == actionEditSelected) { menuItem.setEnabled(inEditState && enableState); } else if (act == actionDeleteSelected) { menuItem.setEnabled(inEditState && enableState); } } } } }
/* * The following method creates the submenu to choose a font style * postcondition: returns the JMenu for the font style submenu. */ public JMenu createFontStyleMenu() { JMenu menu = new JMenu(new String("Style")); menu.add(createFontStyleItem(new String("Plain"))); menu.add(createFontStyleItem(new String("Italic"))); menu.add(createFontStyleItem(new String("Bold"))); menu.add(createFontStyleItem(new String("Bold Italic"))); return menu; } // end createFontStyleMenu method
/** * _more_ * * @param symbols _more_ * @param listener _more_ * @param smm _more_ * @return _more_ */ public static List makeStationModelMenuItems( List symbols, final ObjectListener listener, StationModelManager smm) { List items = new ArrayList(); List subMenus = new ArrayList(); Hashtable categories = new Hashtable(); for (int i = 0; i < symbols.size(); i++) { StationModel sm = (StationModel) symbols.get(i); boolean isUsers = smm.isUsers(sm); String name = sm.getName(); if (name.equals("")) continue; List toks = StringUtil.split(name, ">", true, true); if (toks.size() > 0) { name = (String) toks.get(toks.size() - 1); } JMenuItem item = new JMenuItem(GuiUtils.getLocalName(name, isUsers)); item.addActionListener( new ObjectListener(sm) { public void actionPerformed(ActionEvent ae) { listener.setObject(this.theObject); listener.actionPerformed(ae); } }); toks.remove(toks.size() - 1); if (toks.size() == 0) { items.add(item); continue; } JMenu categoryMenu = null; String catSoFar = ""; String menuCategory = ""; for (int catIdx = 0; catIdx < toks.size(); catIdx++) { String subCat = (String) toks.get(catIdx); catSoFar = catSoFar + "/" + subCat; JMenu m = (JMenu) categories.get(catSoFar); if (m == null) { m = new JMenu(subCat); menuCategory = catSoFar; categories.put(catSoFar, m); if (categoryMenu != null) { categoryMenu.add(m, 0); } else { subMenus.add(m); } } categoryMenu = m; } if (categoryMenu == null) { categoryMenu = new JMenu(""); categories.put(toks.toString(), categoryMenu); subMenus.add(categoryMenu); menuCategory = toks.toString(); } categoryMenu.add(item); } items.addAll(subMenus); return items; }
/** * Define the main About menu. * * @param al the action listener to associate to the menu. * @return the menu. */ public JMenu defineAboutMenu(ActionListener al) { JMenu about = new JMenu(Globals.messages.getString("About")); JMenuItem aboutMenu = new JMenuItem(Globals.messages.getString("About_menu")); about.add(aboutMenu); aboutMenu.addActionListener(al); return about; }
/** * Messaged when the menubar selection changes to activate or deactivate this menu. This * implements the <code>javax.swing.MenuElement</code> interface. Overrides <code> * MenuElement.menuSelectionChanged</code>. * * @param isIncluded true if this menu is active, false if it is not * @see MenuElement#menuSelectionChanged(boolean) */ public void menuSelectionChanged(boolean isIncluded) { if (DEBUG) { System.out.println("In JPopupMenu.menuSelectionChanged " + isIncluded); } if (invoker instanceof JMenu) { JMenu m = (JMenu) invoker; if (isIncluded) m.setPopupMenuVisible(true); else m.setPopupMenuVisible(false); } if (isPopupMenu() && !isIncluded) setVisible(false); }
/** * Define the main View menu. * * @param al the action listener to associate to the menu. * @return the menu. */ public JMenu defineViewMenu(ActionListener al) { JMenu viewMenu = new JMenu(Globals.messages.getString("View")); JMenuItem layerOptions = new JMenuItem(Globals.messages.getString("Layer_opt")); layerOptions.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, Globals.shortcutKey)); viewMenu.add(layerOptions); layerOptions.addActionListener(al); return viewMenu; }
/** * Create a menu for the app. By default this pulls the definition of the menu from the associated * resource file. */ protected JMenu createMenu(String key) { JMenu menu = new JMenu(getResourceString(key + labelSuffix)); for (String itemKey : getItemKeys(key)) { if (itemKey.equals("-")) { menu.addSeparator(); } else { JMenuItem mi = createMenuItem(itemKey); menu.add(mi); } } return menu; }
/* * Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent). */ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { createOtrContactMenus(currentContact); JMenu menu = getMenu(); menu.addSeparator(); whatsThis = new JMenuItem(); whatsThis.setIcon(OtrActivator.resourceService.getImage("plugin.otr.HELP_ICON_15x15")); whatsThis.setText(OtrActivator.resourceService.getI18NString("plugin.otr.menu.WHATS_THIS")); whatsThis.addActionListener(this); menu.add(whatsThis); }
/* * The following method creates the submenu to choose a font size * postcondition: returns the JMenu for the font size submenu. */ public JMenu createFontSizeMenu() { JMenu menu = new JMenu(new String("Size")); menu.add(createFontSizeItem(SMALLEST)); menu.add(createFontSizeItem(SMALL)); menu.add(createFontSizeItem(SMALL_MEDIUM)); menu.add(createFontSizeItem(MEDIUM)); menu.add(createFontSizeItem(MEDIUM_LARGE)); menu.add(createFontSizeItem(LARGE)); menu.add(createFontSizeItem(LARGEST)); menu.add(createFontSizeItem(HUGE)); menu.add(createFontSizeItem(WOW)); return menu; } // end createFontSizeMenu method
// set all menu items related to debugging enabled, all else disabled; // for insert, remove and fetch: continue, step // additionally for scripts: next and sometimes cancel private void enableDebug(boolean isScript, boolean enableCancel) { setAllEnabled(false); debugMenu.setEnabled(true); stepAction.setEnabled(true); cancelAction.setEnabled(enableCancel); nextAction.setEnabled(isScript); contAction.setEnabled(true); breakpointsItem.setEnabled(true); treeStatsMenu.setEnabled(true); utilItem.setEnabled(true); predSzItem.setEnabled(true); slotCntItem.setEnabled(true); }
/* * Creates the JMenuBar for the GUI. */ private JMenuBar menuBar() { menuBar = new JMenuBar(); menu = new JMenu("Menu"); load = new JMenuItem("Load..."); saveAs = new JMenuItem("Save As..."); load.addActionListener(new ActionListenerLoad()); saveAs.addActionListener(new ActionListenerSave()); // responseArea.addActionListener(new ActionListenerArea()); menu.add(load); menu.add(saveAs); menuBar.add(menu); return menuBar; }
/** * Examines the list of menu items to determine whether <code>popup</code> is a popup menu. * * @param popup a <code>JPopupMenu</code> * @return true if <code>popup</code> */ boolean isSubPopupMenu(JPopupMenu popup) { int ncomponents = this.getComponentCount(); Component[] component = this.getComponents(); for (int i = 0; i < ncomponents; i++) { Component comp = component[i]; if (comp instanceof JMenu) { JMenu menu = (JMenu) comp; JPopupMenu subPopup = menu.getPopupMenu(); if (subPopup == popup) return true; if (subPopup.isSubPopupMenu(popup)) return true; } } return false; }
/** * Create a menu for the app. By default this pulls the definition of the menu from the associated * resource file. */ protected JMenu createMenu(String key) { String[] itemKeys = SCSUtility.tokenize(getResourceString(key)); JMenu menu = new JMenu(getResourceString(key + "Label")); for (int i = 0; i < itemKeys.length; i++) { if (itemKeys[i].equals("-")) { menu.addSeparator(); } else { // System.out.println("Debug:TextViewer:itemkey: "+itemKeys[i]); JMenuItem mi = createMenuItem(itemKeys[i]); menu.add(mi); } } return menu; }
/** * Gets the <tt>JMenu</tt> which is the component of this plug-in. If it still doesn't exist, it's * created. * * @return the <tt>JMenu</tt> which is the component of this plug-in */ private JMenu getMenu() { if (menu == null) { menu = new SIPCommMenu(); menu.setText(getName()); if (Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.equals(getContainer())) { Icon icon = OtrActivator.resourceService.getImage("plugin.otr.MENU_ITEM_ICON_16x16"); if (icon != null) menu.setIcon(icon); } if (!inMacOSXScreenMenuBar) menu.getPopupMenu().addPopupMenuListener(this); } return menu; }
private void createJMenuBar() { menubar = new JMenuBar(); JMenu menu = null; JMenuItem item = null; menubar.add(menu = new JMenu("Edit")); menu.add(item = new JMenuItem("Edit Object...")); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { browser.editSelected(); } }); }
private void addProfiles(JMenu menu, String[] profileNames, ActionListener listener) { for (int i = 0; i < profileNames.length; i++) { JMenuItem item = new JMenuItem(profileNames[i]); item.addActionListener(listener); menu.add(item); } }
public void populateMenu(JMenu menu, int flags) { if (flags == (Plugin.MENU_TOOLS | Plugin.MENU_MID)) { Sketch sketch = editor.getSketch(); JMenuItem item = new JMenu("Program Bootloader"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { run(); } }); menu.add(item); PropertyFile props = sketch.mergeAllProperties(); String blProgs = props.get("bootloader.upload"); if (blProgs == null) { JMenuItem sub = new JMenuItem("No bootloader programmer defined!"); item.add(sub); return; } String[] progs = blProgs.split("::"); for (String prog : progs) { JMenuItem sub = new JMenuItem(sketch.parseString(props.get("upload." + prog + ".name"))); sub.setActionCommand(prog); sub.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doProgram(e.getActionCommand()); } }); item.add(sub); } } }
// enable startup menu items that don't require an index or profile to work with private void enableInit() { setAllEnabled(false); // we can create and open indices fileMenu.setEnabled(true); newItem.setEnabled(true); openItem.setEnabled(true); // we can execute scripts opsMenu.setEnabled(true); executeItem.setEnabled(true); // we can open profile analysisMenu.setEnabled(true); openAnalysisItem.setEnabled(true); }
/** * Make the view menu * * @param viewMenu view menu * @return The view menu */ public JMenu makeViewMenu(JMenu viewMenu) { showAlignmentPointsMI = new JCheckBoxMenuItem("Show Alignment Points", true); viewMenu.add(showAlignmentPointsMI); showAlignmentPointsMI.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { repaint(); } }); viewMenu.addSeparator(); super.makeViewMenu(viewMenu); viewMenu.addSeparator(); viewMenu.add(makeMenuItem("Black background", CMD_BLACKBG)); viewMenu.add(makeMenuItem("White background", CMD_WHITEBG)); return viewMenu; }
private void buildMenu() { jMenuBar = new javax.swing.JMenuBar(); mainMenu = new javax.swing.JMenu(); mainMenu.setText("Main"); loginMenuItem = new JMenuItem("Login..."); loginMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { headerPanel.handleLoginLogout(); } }); mainMenu.add(loginMenuItem); exitMenuItem = new JMenuItem("Exit"); exitMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { if (qsadminMain.isConnected() == true) { headerPanel.handleLoginLogout(); } System.exit(0); } }); mainMenu.add(exitMenuItem); helpMenu = new javax.swing.JMenu(); helpMenu.setText("Help"); aboutMenuItem = new JMenuItem("About..."); aboutMenuItem.setEnabled(true); aboutMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { about(); } }); helpMenu.add(aboutMenuItem); jMenuBar.add(mainMenu); jMenuBar.add(helpMenu); parentFrame.setJMenuBar(jMenuBar); }
public DescPropPopup() { super("Descriptor Properties"); v = new JCheckBoxMenuItem("Valid"); v.addActionListener(new ValidAction()); p = new JCheckBoxMenuItem("Propagating"); p.addActionListener(new PropAction()); delete = new JMenuItem("Delete"); delete.addActionListener(new DeleteAction()); duplicate = new JMenuItem("Duplicate"); duplicate.addActionListener(new DuplicateAction()); interp = new JMenuItem("Interpolate..."); interp.addActionListener(new InterpAction()); interpToMark = new JMenu("Interpolate to Mark"); interpToMark.setEnabled(false); itmAction = new InterpToMarkAction(); shift = new JMenuItem("Shift..."); shift.addActionListener(new ShiftAction()); shiftToMark = new JMenu("Shift to Mark"); shiftToMark.setEnabled(false); stmAction = new ShiftToMarkAction(); occlusions = new JMenuItem("Occlusions..."); occAction = new OccAction(); occlusions.addActionListener(occAction); occSeparator = new JSeparator(); wrt = new JCheckBoxMenuItem("Display with Respect To", false); wrt.addActionListener(new WithRespectToAction()); add(occlusions); add(occSeparator); add(v); add(p); add(occSeparator); add(delete); add(duplicate); add(occSeparator); add(interp); add(interpToMark); add(occSeparator); add(shift); add(shiftToMark); add(occSeparator); add(wrt); }
/** * Creates an {@link OtrContactMenu} for each {@link Contact} contained in the * <tt>metaContact</tt>. * * @param metaContact The {@link MetaContact} this {@link OtrMetaContactMenu} refers to. */ private void createOtrContactMenus(MetaContact metaContact) { JMenu menu = getMenu(); // Remove any existing OtrContactMenu items. menu.removeAll(); // Create the new OtrContactMenu items. if (metaContact != null) { Iterator<Contact> contacts = metaContact.getContacts(); if (metaContact.getContactCount() == 1) { new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, false); } else while (contacts.hasNext()) { new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, true); } } }