/** Constructs a new menu item with the specified label * and no keyboard shortcut and connects it to the given SystemAction. * @param aAction the action to which this menu item should be connected * @param useMnemonic if true, the menu try to find mnemonic in action label */ public MenuItem(SystemAction aAction, boolean useMnemonic) { Actions.connect(this, aAction, !useMnemonic); }
/** Sets the text for the menu item or other subclass of AbstractButton. * Cut from the name '&' char. * @param item AbstractButton * @param text new label * @param useMnemonic if true and '&' char found in new text, next char is used * as Mnemonic. * @deprecated Use either {@link AbstractButton#setText} or {@link Mnemonics#setLocalizedText(AbstractButton, String)} as appropriate. */ @Deprecated public static void setMenuText(AbstractButton item, String text, boolean useMnemonic) { String msg = NbBundle.getMessage(Actions.class, "USE_MNEMONICS"); // NOI18N if ("always".equals(msg)) { // NOI18N useMnemonic = true; } else if ("never".equals(msg)) { // NOI18N useMnemonic = false; } else { assert "default".equals(msg); // NOI18N } if (useMnemonic) { Mnemonics.setLocalizedText(item, text); } else { item.setText(cutAmpersand(text)); } }
/** @param changedProperty the name of property that has changed * or null if it is not known */ @Override public void updateState(String changedProperty) { super.updateState(changedProperty); if ((changedProperty == null) || !changedProperty.equals(Action.ACCELERATOR_KEY)) { updateKey((JMenuItem) comp, action); } if ((changedProperty == null) || changedProperty.equals(Action.NAME)) { Object s = action.getValue(Action.NAME); if (s instanceof String) { setMenuText(((JMenuItem) comp), (String) s, true); } } }
/** Constructor. */ public SubMenuBridge(JMenuItem one, JMenu more, Action action, SubMenuModel model, boolean popup) { super(one, action, popup); single = one; multi = more; setMenuText(multi, (String)action.getValue(Action.NAME), popup); prepareMargins(one, action); prepareMargins(more, action); currentOnes = new ArrayList<JMenuItem>(); this.model = model; }
@Override protected JMenu createMenu() { JMenu menu = new JMenu(this); JMenuItem item; if (lkp == null) { org.openide.awt.Mnemonics.setLocalizedText(menu, Bundle.CTL_MenuItem_ConflictsMenu()); item = new JMenuItem(); Action action = SystemAction.get(ResolveConflictsAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); item = new JMenuItem(); action = (Action) SystemAction.get(ConflictResolvedAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); } else { item = menu.add(SystemActionBridge.createAction(SystemAction.get(ResolveConflictsAction.class), NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Resolve"), lkp, MercurialAnnotator.ACTIONS_PATH_PREFIX)); //NOI18N org.openide.awt.Mnemonics.setLocalizedText(item, item.getText()); item = menu.add(SystemActionBridge.createAction(SystemAction.get(ConflictResolvedAction.class), NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_MarkResolved"), lkp, MercurialAnnotator.ACTIONS_PATH_PREFIX)); //NOI18N org.openide.awt.Mnemonics.setLocalizedText(item, item.getText()); } return menu; }
JMenuItem item = new JMenuItem(); Mnemonics.setLocalizedText(item, label); if (i == 0) updateKey(item, action); item.addActionListener(new ISubActionListener(i, model)); HelpCtx help = model.getHelpCtx (i); associateHelp (item, help == null ? findHelp (action) : help);
currentOnes.add(single); single.setEnabled(false); } else if (cnt == 1) { updateState(null); currentOnes.add(single); single.setEnabled(action.isEnabled()); JMenuItem item = new JMenuItem(); Mnemonics.setLocalizedText(item, label); updateKey(item, action);
private JPopupMenu createPopupMenu() { if (popupActions.isEmpty()) { return null; } JPopupMenu pm = new JPopupMenu(); for (Action action : popupActions) { JMenuItem menuItem = new JMenuItem(); Actions.connect(menuItem, action, true); // Actions.connect() takes care of mnemonics pm.add(menuItem); } return pm; }
JMenuItem item = new JMenuItem( NbBundle.getMessage(DataObject.class, "CTL_EmptyMenu")); item.setEnabled(false); m.add(item); JMenuItem item = new JMenuItem (); Actions.connect (item, a, false); m.add (item);
org.openide.awt.Mnemonics.setLocalizedText(menu, Bundle.CTL_MenuItem_RecoverMenu()); item = new JMenuItem(); Action action = (Action) SystemAction.get(StripAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); item = new JMenuItem(); action = (Action) SystemAction.get(BackoutAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); item = new JMenuItem(); action = (Action) SystemAction.get(RollbackAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); item = new JMenuItem(); action = (Action) SystemAction.get(VerifyAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); } else {
@Override public Action[] getActions(VCSContext ctx, VCSAnnotator.ActionDestination destination) { ResourceBundle loc = NbBundle.getBundle(MercurialAnnotator.class); Node [] nodes = ctx.getElements().lookupAll(Node.class).toArray(new Node[0]); Set<File> files = ctx.getRootFiles(); Lookup context = ctx.getElements(); if (noneVersioned){ Action a = Actions.forID("Mercurial", "org.netbeans.modules.mercurial.ui.create.CreateAction"); if(a instanceof ContextAwareAction) { a = ((ContextAwareAction)a).createContextAwareInstance(Lookups.fixed(files.toArray())); actions.add(SystemActionBridge.createAction(SystemAction.get(StatusAction.class), loc.getString("CTL_PopupMenuItem_Status"), context)); //NOI18N actions.add(new DiffMenu(context)); actions.add(SystemActionBridge.createAction(SystemAction.get(AddAction.class), NbBundle.getMessage(AddAction.class, "CTL_PopupMenuItem_Add"), context)); //NOI18N actions.add(SystemActionBridge.createAction(SystemAction.get(CommitAction.class), loc.getString("CTL_PopupMenuItem_Commit"), context)); //NOI18N actions.add(SystemActionBridge.createAction(SystemAction.get(UpdateAction.class), loc.getString("CTL_PopupMenuItem_Update"), context)); //NOI18N
CheckedDisplayAction checkedDisplayAction = (CheckedDisplayAction)displayAction; JMenuItem menuItem = new JCheckBoxMenuItem(); Actions.connect(menuItem, new SingleDisplayActionAction(displayAction, designBean), !isMenu); menuItem.setSelected(checkedDisplayAction.isChecked()); return new JComponent[] {menuItem}; } else {
/** Constructor. * @param popup pop-up menu */ public MenuBridge(JMenuItem item, Action action, boolean popup) { super(item, action); this.popup = popup; if (popup) { prepareMargins(item, action); } else { // #40824 hack item.putClientProperty("menubridgeresizehack", this); // #40824 hack end. } }
/** Sets the text for the menu item or other subclass of AbstractButton. * Cut from the name '&' char. * @param item AbstractButton * @param text new label * @param useMnemonic if true and '&' char found in new text, next char is used * as Mnemonic. * @deprecated Use either {@link AbstractButton#setText} or {@link Mnemonics#setLocalizedText(AbstractButton, String)} as appropriate. */ public static void setMenuText(AbstractButton item, String text, boolean useMnemonic) { if (useMnemonic) { Mnemonics.setLocalizedText(item, text); } else { item.setText(cutAmpersand(text)); } }
public MenuWithRecent(Node n, boolean writable) { super(); //NewTemplateAction.this.getName()); Actions.setMenuText(this, NewTemplateAction.this.getName(), false); node = n; canWrite = writable; }
/** Popup menu */ public CheckMenuBridge(JCheckBoxMenuItem item, BooleanStateAction action, boolean popup) { super(item, action); this.popup = popup; if (popup) { prepareMargins(item, action); } Object base = action.getValue("iconBase"); //NOI18N Object i = null; if (action instanceof SystemAction) { i = action.getValue(SystemAction.PROP_ICON); } else { i = action.getValue(Action.SMALL_ICON); } hasOwnIcon = (base != null) || (i != null); }
/** Method that finds the keydescription assigned to this action. * @param action action to find key for * @return the text representing the key or null if there is no text assigned */ public static String findKey(SystemAction action) { return findKey((Action) action); }
public static Action forID(String id) { return Actions.forID(CATEGORY, id); } }
@Override protected JMenu createMenu() { JMenu menu = new JMenu(this); JMenuItem item; if (lkp == null) { org.openide.awt.Mnemonics.setLocalizedText(menu, Bundle.CTL_MenuItem_DiffMenu()); item = new JMenuItem(); Action action = SystemAction.get(DiffAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); item = new JMenuItem(); action = SystemAction.get(DiffToRevisionAction.class); Utils.setAcceleratorBindings(MercurialAnnotator.ACTIONS_PATH_PREFIX, action); Actions.connect(item, action, false); menu.add(item); } else { item = menu.add(SystemActionBridge.createAction(SystemAction.get(DiffAction.class), NbBundle.getMessage(DiffAction.class, "CTL_PopupMenuItem_Diff"), lkp)); //NOI18N org.openide.awt.Mnemonics.setLocalizedText(item, item.getText()); item = menu.add(SystemActionBridge.createAction(SystemAction.get(DiffToRevisionAction.class), NbBundle.getMessage(DiffAction.class, "CTL_PopupMenuItem_DiffToRevision"), lkp)); //NOI18N org.openide.awt.Mnemonics.setLocalizedText(item, item.getText()); } return menu; }
JMenuItem item = new JMenuItem(); Mnemonics.setLocalizedText(item, label); if (i == 0) updateKey(item, action); item.addActionListener(new ISubActionListener(i, model)); HelpCtx help = model.getHelpCtx (i); associateHelp (item, help == null ? findHelp (action) : help);