List of usage examples for javax.swing Action isEnabled
public boolean isEnabled();
From source file:org.nuclos.client.main.MainController.java
private List<Pair<String[], Action>> getCustomComponentMenuActions(List<GenericAction> genericActions) { List<Pair<String[], Action>> customComponentMenuAction = new ArrayList<Pair<String[], Action>>(); for (CustomComponentVO ccvo : CustomComponentCache.getInstance().getAll()) { String[] menuPath = splitMenuPath(getSpringLocaleDelegate() .getTextFallback(ccvo.getMenupathResourceId(), ccvo.getMenupathResourceId())); Action action = new ResPlanAction(ccvo); // If the component is not allowed to run (due to missing permissions), the action is disabled and skipped if (menuPath != null && menuPath.length > 0 && action != null && action.isEnabled()) { customComponentMenuAction.add(Pair.makePair(menuPath, action)); if (genericActions != null) { WorkspaceDescription.Action wa = new WorkspaceDescription.Action(); wa.setAction(GENERIC_CUSTOMCOMPONENT_ACTION); wa.putStringParameter("customcomponent", "resPlan"); genericActions.add(new GenericAction(wa, new ActionWithMenuPath(menuPath, action))); }//from w ww . j ava 2s .co m } } ; return customComponentMenuAction; }
From source file:org.openscience.jmol.app.Jmol.java
/** * This is the hook through which all menu items are * created. It registers the result with the menuitem * hashtable so that it can be fetched with getMenuItem(). * @param cmd/*www .ja v a 2s . c om*/ * @return Menu item created * @see #getMenuItem */ protected JMenuItem createMenuItem(String cmd) { JMenuItem mi; if (cmd.endsWith("Check")) { mi = guimap.newJCheckBoxMenuItem(cmd, false); } else { mi = guimap.newJMenuItem(cmd); } ImageIcon f = JmolResourceHandler.getIconX(cmd + "Image"); if (f != null) { mi.setHorizontalTextPosition(SwingConstants.RIGHT); mi.setIcon(f); } if (cmd.endsWith("Script")) { mi.setActionCommand(JmolResourceHandler.getStringX(cmd)); mi.addActionListener(executeScriptAction); } else { mi.setActionCommand(cmd); Action a = getAction(cmd); if (a != null) { mi.addActionListener(a); a.addPropertyChangeListener(new ActionChangedListener(mi)); mi.setEnabled(a.isEnabled()); } else { mi.setEnabled(false); } } menuItems.put(cmd, mi); return mi; }
From source file:org.openscience.jmol.app.Jmol.java
/** * Create a button to go inside of the toolbar. By default this * will load an image resource. The image filename is relative to * the classpath (including the '.' directory if its a part of the * classpath), and may either be in a JAR file or a separate file. * * @param key The key in the resource file to serve as the basis * of lookups./*from w ww . j a v a 2s .c om*/ * @return Button */ protected AbstractButton createToolbarButton(String key) { ImageIcon ii = JmolResourceHandler.getIconX(key + "Image"); AbstractButton b = new JButton(ii); String isToggleString = JmolResourceHandler.getStringX(key + "Toggle"); if (isToggleString != null) { boolean isToggle = Boolean.valueOf(isToggleString).booleanValue(); if (isToggle) { b = new JToggleButton(ii); if (key.equals("rotate")) buttonRotate = b; toolbarButtonGroup.add(b); String isSelectedString = JmolResourceHandler.getStringX(key + "ToggleSelected"); if (isSelectedString != null) { boolean isSelected = Boolean.valueOf(isSelectedString).booleanValue(); b.setSelected(isSelected); } } } b.setRequestFocusEnabled(false); b.setMargin(new Insets(1, 1, 1, 1)); Action a = null; String actionCommand = null; if (key.endsWith("Script")) { actionCommand = JmolResourceHandler.getStringX(key); a = executeScriptAction; } else { actionCommand = key; a = getAction(key); } if (a != null) { b.setActionCommand(actionCommand); b.addActionListener(a); a.addPropertyChangeListener(new ActionChangedListener(b)); b.setEnabled(a.isEnabled()); } else { b.setEnabled(false); } String tip = guimap.getLabel(key + "Tip"); if (tip != null) { b.setToolTipText(tip); } return b; }
From source file:org.wings.SAbstractButton.java
protected void configurePropertiesFromAction(Action a) { // uncomment if compiled against < jdk 1.3 // setActionCommand((a != null // ? (String)a.getValue(Action.ACTION_COMMAND_KEY) // : null)); setText((a != null ? (String) a.getValue(Action.NAME) : null)); setIcon((a != null ? (SIcon) a.getValue(Action.SMALL_ICON) : null)); setEnabled((a != null ? a.isEnabled() : true)); setToolTipText((a != null ? (String) a.getValue(Action.SHORT_DESCRIPTION) : null)); }
From source file:tk.tomby.tedit.gui.MenuItem.java
/** * DOCUMENT ME!//from w w w.ja v a 2 s. c o m * * @param action DOCUMENT ME! */ public void setAction(Action action) { action.addPropertyChangeListener(createActionPropertyChangeListener(action)); this.setEnabled(action.isEnabled()); this.addActionListener(action); }