@Override public Action[] getActions(boolean context) { if (!context) { Action copyPath = Actions.forID("Edit", //NOI18N "org.netbeans.modules.utilities.CopyPathToClipboard"); //NOI18N return new Action[]{ SystemAction.get(OpenMatchingObjectsAction.class), replacing && !matchingObject.isObjectValid() ? new RefreshAction(matchingObject) : null, null, copyPath == null ? new CopyPathAction() : copyPath, SystemAction.get(HideResultAction.class), null, SystemAction.get(SelectInAction.class), SystemAction.get(MoreAction.class) }; } else { return new Action[0]; } }
public Action[] getActions(VCSContext ctx, VCSAnnotator.ActionDestination destination) { Lookup context = ctx.getElements(); List<Action> actions = new ArrayList<Action>(); if (destination == VCSAnnotator.ActionDestination.MainMenu) { actions.add(SystemAction.get(ShowHistoryAction.class)); actions.add(SystemAction.get(RevertDeletedAction.class)); } else { actions.add(SystemActionBridge.createAction( SystemAction.get(ShowHistoryAction.class), NbBundle.getMessage(ShowHistoryAction.class, "CTL_ShowHistory"), context)); actions.add(SystemActionBridge.createAction( SystemAction.get(RevertDeletedAction.class), NbBundle.getMessage(RevertDeletedAction.class, "CTL_ShowRevertDeleted"), context)); } return actions.toArray(new Action[actions.size()]); }
private FindSupport(TopComponent tc) { this.tc = tc; bar = new FindBar(this); ActionMap actionMap = tc.getActionMap(); CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class); actionMap.put(a.getActionMapKey(), new FindAction(true)); actionMap.put(FIND_NEXT_ACTION, new FindAction(true)); actionMap.put(FIND_PREVIOUS_ACTION, new FindAction(false)); // Hack ensuring the same shortcuts as editor JEditorPane pane = new JEditorPane(); for (Action action : pane.getEditorKitForContentType("text/x-java").getActions()) { // NOI18N Object name = action.getValue(Action.NAME); if (FIND_NEXT_ACTION.equals(name) || FIND_PREVIOUS_ACTION.equals(name)) { reuseShortcut(action); } } // PENDING the colors below should not be hardcoded highlighterAll = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,180,66)); highlighterCurrent = new DefaultHighlighter.DefaultHighlightPainter(new Color(176,197,227)); pattern = Pattern.compile("$^"); // NOI18N }
@Override public void performAction(SystemAction action) { Node[] selected = getSelectedRootNodes(); if (selected == null || selected.length == 0) return; for (int i=0; i < selected.length; i++) if (!selected[i].canDestroy()) return; try { // clear nodes selection first getExplorerManager().setSelectedNodes(new Node[0]); } catch (PropertyVetoException e) {} // cannot be vetoed nodesToDestroy = selected; if (java.awt.EventQueue.isDispatchThread()) doDelete(); else // reinvoke synchronously in AWT thread Mutex.EVENT.readAccess(this); }
@Override public void performAction(SystemAction action) { Transferable trans; Node[] selected = getSelectedRootNodes(); if (selected == null || selected.length == 0) trans = null; else if (selected.length == 1) trans = getTransferableOwner(selected[0]); else { Transferable[] transArray = new Transferable[selected.length]; for (int i=0; i < selected.length; i++) if ((transArray[i] = getTransferableOwner(selected[i])) == null) return; trans = new ExTransferable.Multi(transArray); } if (trans != null) { Clipboard clipboard = getClipboard(); clipboard.setContents(trans, new StringSelection("")); // NOI18N } }
@Override public Action[] getActions(boolean context) { Action[] res = new Action[2]; res[0] = new AbstractAction(NbBundle.getMessage(HiddenDataObject.class, "LBL_restore")) { //NOI18N @Override public void actionPerformed(ActionEvent e) { try { destroy(); } catch( IOException ex ) { Exceptions.printStackTrace(ex); } } }; res[0].setEnabled(canDestroy()); res[1] = SystemAction.get(OpenLayerFilesAction.class); return res; }
/** * Test whether pressed, rollover and disabled icons * work for SystemAction. */ public void testIconsSystemAction() throws Exception { Action saInstance = SystemAction.get(TestSystemAction.class); JButton jb = new JButton(); Actions.connect(jb, saInstance); Icon icon = jb.getIcon(); assertNotNull(icon); checkIfLoadedCorrectIcon(icon, jb, 0, "Enabled icon"); Icon rolloverIcon = jb.getRolloverIcon(); assertNotNull(rolloverIcon); checkIfLoadedCorrectIcon(rolloverIcon, jb, 1, "Rollover icon"); Icon pressedIcon = jb.getPressedIcon(); assertNotNull(pressedIcon); checkIfLoadedCorrectIcon(pressedIcon, jb, 2, "Pressed icon"); Icon disabledIcon = jb.getDisabledIcon(); assertNotNull(disabledIcon); checkIfLoadedCorrectIcon(disabledIcon, jb, 3, "Disabled icon"); }
void createExtendedPopup(int xpos, int ypos, JMenu newMenu) { Node[] ns = manager.getSelectedNodes(); JPopupMenu popup = null; if (ns.length > 0) { // if any nodes are selected --> find theirs actions Action[] actions = NodeOp.findActions(ns); popup = Utilities.actionsToPopup(actions, this); } else { // if none node is selected --> get context actions from view's root if (manager.getRootContext() != null) { popup = manager.getRootContext().getContextMenu(); } } int cnt = 0; if (popup == null) { popup = SystemAction.createPopupMenu(new SystemAction[] { }); } popup.add(newMenu); createPopup(xpos, ypos, popup); }
public final Action[] getActions(boolean context) { if (isUISettingCategoryNode()) { return new Action[0]; } else { return new Action[] { SystemAction.get(FileSystemAction.class), null, SystemAction.get(PasteAction.class), null, SystemAction.get(MoveUpAction.class), SystemAction.get(MoveDownAction.class), SystemAction.get(ReorderAction.class), null, SystemAction.get(NewTemplateAction.class), null, SystemAction.get(ToolsAction.class), SystemAction.get(PropertiesAction.class), }; } }
public void testNewLoaderThatChangesActionsBecomesModified () throws Exception { assertFalse("Not modified at begining", NbLoaderPool.isModified(newL)); Object actions = newL.getActions (); assertNotNull ("Some actions there", actions); assertTrue ("Default actions called", newL.defaultActionsCalled); assertFalse("Still not modified", NbLoaderPool.isModified(newL)); List<SystemAction> list = new ArrayList<SystemAction>(); list.add(SystemAction.get(OpenAction.class)); list.add(SystemAction.get(NewAction.class)); newL.setActions(list.toArray(new SystemAction[0])); assertFalse("Even if we changed actions, it is not modified", NbLoaderPool.isModified(newL)); List l = Arrays.asList (newL.getActions ()); assertEquals ("But actions are changed", list, l); }
@NonNull @Override public Action[] getActions(final boolean context) { if (context) { return super.getActions(context); } else { if (actions == null) { actions = new Action[] { CommonProjectActions.newFileAction(), null, SystemAction.get(FindAction.class), null, SystemAction.get(PasteAction.class ), null, SystemAction.get(FileSystemAction.class ), null, SystemAction.get(ToolsAction.class ) }; } return actions; } }
/** * Permanently ignores (modifies ignore file) topmost not-sharable ancestor of a given file. * @param topFile * @param notSharableFile */ private static void ignoreNotSharableAncestor (File topFile, File notSharableFile) { if (topFile.equals(notSharableFile)) { throw new IllegalStateException("Trying to ignore " + notSharableFile + " in " + topFile); //NOI18N } File parent; // find the topmost while (!topFile.equals(parent = notSharableFile.getParentFile()) && SharabilityQuery.getSharability(FileUtil.normalizeFile(parent)) == SharabilityQuery.NOT_SHARABLE) { notSharableFile = parent; } addNotSharable(topFile, notSharableFile.getAbsolutePath()); // ignore only folders if (notSharableFile.isDirectory()) { for (File f : Git.getInstance().getCreatedFolders()) { if (Utils.isAncestorOrEqual(f, notSharableFile)) { SystemAction.get(IgnoreAction.class).ignoreFolders(topFile, new File[] { notSharableFile }); } } } }
public static ShelveChangesActionProvider getProvider () { if (ACTION_PROVIDER == null) { ACTION_PROVIDER = new ShelveChangesActionProvider() { @Override public Action getAction () { Action a = SystemAction.get(SaveStashAction.class); Utils.setAcceleratorBindings("Actions/Git", a); //NOI18N return a; } @Override public JComponent[] getUnshelveActions (VCSContext ctx, boolean popup) { JComponent[] cont = UnshelveMenu.getInstance().getMenu(ctx, popup); if (cont == null) { cont = super.getUnshelveActions(ctx, popup); } return cont; } }; } return ACTION_PROVIDER; }
/** Implements superclass abstract method. Creates nodes from key. * @return <code>PendingActionNode</code> if key is of * <code>Action</code> type otherwise <code>null</code> */ protected Node[] createNodes(Object key) { Node n = null; if(key instanceof Action) { Action action = (Action)key; Icon icon = (action instanceof SystemAction) ? ((SystemAction)action).getIcon() : null; String actionName = (String)action.getValue(Action.NAME); if (actionName == null) actionName = ""; // NOI18N actionName = org.openide.awt.Actions.cutAmpersand(actionName); n = new NoActionNode(icon, actionName, NbBundle.getMessage( Install.class, "CTL_ActionInProgress", actionName)); } else if (key instanceof ExecutorTask) { n = new NoActionNode(null, key.toString(), NbBundle.getMessage(Install.class, "CTL_PendingExternalProcess2", // getExecutionEngine() had better be non-null, since getPendingTasks gave an ExecutorTask: ExecutionEngine.getExecutionEngine().getRunningTaskName((ExecutorTask) key)) ); } else if (key instanceof InternalHandle) { n = new NoActionNode(null, ((InternalHandle)key).getDisplayName(), null); } return n == null ? null : new Node[] { n }; }
public static void performUpdate(final Context context, final String contextDisplayName) { if(!Subversion.getInstance().checkClientAvailable()) { return; } if (context == null || context.getRoots().size() == 0) { return; } SVNUrl repository; try { repository = getSvnUrl(context); } catch (SVNClientException ex) { SvnClientExceptionHandler.notifyException(ex, true, true); return; } RequestProcessor rp = Subversion.getInstance().getRequestProcessor(repository); SvnProgressSupport support = new SvnProgressSupport() { public void perform() { SystemAction.get(UpdateAction.class).update(context, this, contextDisplayName, null); } }; support.start(rp, repository, org.openide.util.NbBundle.getMessage(UpdateAction.class, "MSG_Update_Progress")); // NOI18N }
private static Action[] loadActions(String[] names) { ArrayList<Action> arr = new ArrayList<Action>(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); for (int i = 0; i < names.length; i++) { if (names[i] == null) { arr.add(null); continue; } try { Class<? extends SystemAction> sa = Class.forName("org.openide.actions." + names[i] + "Action", true, loader).asSubclass(SystemAction.class); arr.add(SystemAction.get(sa)); // NOI18N } catch (ClassNotFoundException e) { // ignore it, missing org-openide-actions.jar } } return arr.toArray(new Action[0]); }
@Override public Action[] getActions(boolean context) { if (context) { return super.getActions(context); } else { return new Action[] { SystemAction.get (ShowJavadocAction.class), SystemAction.get (RemoveClassPathRootAction.class) }; } }
/** Perform the callback action */ public void performAction(SystemAction action) { JTextComponent component = getComponent(); Action ea = getEditorAction(); if (component != null && ea != null) { ea.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N } }
public JMenuItem getPopupPresenter() { JMenuItem prop = new Actions.MenuItem(this, false); Action customizeAction = SystemAction.get(CustomizeAction.class); // Retrieve context sensitive action instance if possible. if (lookup != null) { customizeAction = ((ContextAwareAction) customizeAction).createContextAwareInstance(lookup); } if (customizeAction.isEnabled()) { JInlineMenu mi = new JInlineMenu(); mi.setMenuItems(new JMenuItem[] { new Actions.MenuItem(customizeAction, false), prop }); return mi; } else { for (Node n : nodes()) { for (Node.PropertySet ps : n.getPropertySets()) { if (ps.getProperties().length > 0) { // OK, we have something to show! return prop; } } } // else nothing to show, so show nothing return new JInlineMenu(); } }
/** Get actions. * These actions are used to compose * a popup menu for the data object. Also these actions should * be customizable by the user, so he can modify the popup menu on a * data object. * * @return array of system actions or <CODE>null</CODE> if this loader does not have any * actions */ public final SystemAction[] getActions () { Action[] arr = getSwingActions (); List<SystemAction> list = new ArrayList<SystemAction>(); for (int i = 0; i < arr.length; i++) { if (arr[i] instanceof SystemAction || arr[i] == null) { list.add((SystemAction) arr[i]); } } return list.toArray(new SystemAction[list.size()]); }
@Override public Action[] getActions(boolean context) { if ( context ) { return super.getActions(context); } else { return new SystemAction[] { SystemAction.get(ConnectDatabaseAction.class), SystemAction.get(DeleteAction.class) }; } }
/** Tests whether the cut, copy (callback) actions are enabled/disabled * in the right time, see # */ public void testCutCopyActionsEnabling() throws Exception { assertTrue ("Can run only in AWT thread", java.awt.EventQueue.isDispatchThread()); TestNode enabledNode = new TestNode(true, true, true); TestNode disabledNode = new TestNode(false, false, false); manager.setRootContext(new TestRoot( new Node[] {enabledNode, disabledNode})); Action copy = ((ContextAwareAction)SystemAction.get(CopyAction.class)).createContextAwareInstance(context); Action cut = ((ContextAwareAction)SystemAction.get(CutAction.class)).createContextAwareInstance(context); assertTrue("Copy action has to be disabled", !copy.isEnabled()); assertTrue("Cut action has to be disabled", !cut.isEnabled()); manager.setSelectedNodes(new Node[] {enabledNode}); manager.waitActionsFinished(); assertTrue("Copy action has to be enabled", copy.isEnabled()); assertTrue("Cut action has to be enabled", cut.isEnabled()); copy.actionPerformed (new java.awt.event.ActionEvent (this, 0, "waitFinished")); assertEquals ("clipboardCopy invoked", 1, enabledNode.countCopy); cut.actionPerformed (new java.awt.event.ActionEvent (this, 0, "waitFinished")); assertEquals ("clipboardCut invoked", 1, enabledNode.countCut); manager.setSelectedNodes(new Node[] {disabledNode}); manager.waitActionsFinished(); assertTrue("Copy action has to be disabled", !copy.isEnabled()); assertTrue("Cut action has to be disabled", !cut.isEnabled()); }
/** Constructs image node. */ public ImageNode(ImageDataObject obj) { super(obj, Children.LEAF); //setIconBase(IMAGE_ICON_BASE); setIconBaseWithExtension(IMAGE_ICON_BASE); setDefaultAction (SystemAction.get (OpenAction.class)); }
@Override public Action[] getActions(boolean context) { List<Action> actions = SaasNode.getActions(getLookup()); actions.add(SystemAction.get(AddServiceAction.class)); actions.add(SystemAction.get(AddGroupAction.class)); actions.add(SystemAction.get(DeleteGroupAction.class)); actions.add(SystemAction.get(RenameGroupAction.class)); return actions.toArray(new Action[actions.size()]); }
@Override public Action[] getActions(boolean context) { return new Action[]{ SystemAction.get(SaveAsAction.class), SystemAction.get(InstallApkAction.class), SystemAction.get(CopyAction.class), SystemAction.get(DeleteAction.class), SystemAction.get(PropertiesAction.class) }; }
@Override public Void call () throws HgException { OutputLogger logger = supp.getLogger(); topPatch = FetchAction.selectPatch(root); if (topPatch != null) { supp.setDisplayName(Bundle.MSG_PullAction_popingPatches()); SystemAction.get(QGoToPatchAction.class).popAllPatches(root, logger); supp.setDisplayName(Bundle.MSG_PullAction_pulling()); logger.output(""); // NOI18N } if (supp.isCanceled()) { return null; } List<String> list; if(type == PullType.LOCAL){ supp.setDisplayName(Bundle.MSG_PullAction_progress_pullingFromLocal()); list = HgCommand.doPull(root, revision, branch, logger); }else{ supp.setDisplayName(Bundle.MSG_PullAction_progress_unbundling()); list = HgCommand.doUnbundle(root, fileToUnbundle, false, logger); } if (list != null && !list.isEmpty()) { annotateChangeSets(HgUtils.replaceHttpPassword(listIncoming), PullAction.class, "MSG_CHANGESETS_TO_PULL", logger); // NOI18N handlePulledChangesets(list); } return null; }
@Override public Action[] getActions(boolean context) { List<Action> actions = SaasNode.getActions(getLookup()); actions.add(SystemAction.get(AddServiceAction.class)); actions.add(SystemAction.get(AddGroupAction.class)); return actions.toArray(new Action[actions.size()]); }
public ContextAction(Lookup lkp) { super(SystemAction.get(RunTargetsAction.class).getName()); Collection<? extends AntProjectCookie> apcs = lkp.lookupAll(AntProjectCookie.class); AntProjectCookie _project = null; if (apcs.size() == 1) { _project = apcs.iterator().next(); if (_project.getParseException() != null) { _project = null; } } project = _project; super.setEnabled(project != null); }
@Override protected SystemAction[] defaultActions() { return new SystemAction[] { SystemAction.get(CutAction.class), null, SystemAction.get(CopyAction.class), null, SystemAction.get(DeleteAction.class), }; }
public @Override JMenuItem createPopupPresenter(Action action) { JMenuItem item; if (action instanceof BooleanStateAction) { BooleanStateAction b = (BooleanStateAction)action; item = new Actions.CheckboxMenuItem (b, false); } else if (action instanceof SystemAction) { SystemAction s = (SystemAction)action; item = new Actions.MenuItem (s, false); } else { item = new Actions.MenuItem (action, false); } return item; }
@Override public javax.swing.Action[] getActions(boolean context) { if (actions == null) { actions = new Action[] { SystemAction.get(PropertiesAction.class) }; } return actions; }
private void addLayoutActions(List<Action> actions) { if (component.getParentComponent() instanceof RADVisualContainer) { actions.add(SystemAction.get(AlignAction.class)); actions.add(SystemAction.get(SetAnchoringAction.class)); actions.add(SystemAction.get(SetResizabilityAction.class)); actions.add(SystemAction.get(ChooseSameSizeAction.class)); actions.add(SystemAction.get(DefaultSizeAction.class)); actions.add(SystemAction.get(EncloseAction.class)); actions.add(SystemAction.get(CustomizeEmptySpaceAction.class)); actions.add(null); } }
private Action[] initActions () { if (actionCache == null) { List<Action> result = new ArrayList<Action>(2); if (mode == Mode.FILE) { for (Action superAction : super.getActions(false)) { if (isOpenAction(superAction)) { result.add(superAction); } } result.add (SystemAction.get(ShowJavadocAction.class)); } else if (mode.isFolder()) { result.add (SystemAction.get(ShowJavadocAction.class)); Action[] superActions = super.getActions(false); for (int i=0; i<superActions.length; i++) { if (superActions[i] instanceof FindAction) { result.add (superActions[i]); } } if (mode.isRoot()) { result.add (SystemAction.get(RemoveClassPathRootAction.class)); } if (mode == Mode.EDITABLE_ROOT) { result.add (SystemAction.get(EditRootAction.class)); } } actionCache = result.toArray(new Action[result.size()]); } return actionCache; }
/** * Creates and initializes preview/test layout button. * * @param toolBar toolbar where the button should be added. * @param metaComp meta-component to preview. */ private void initPreviewButton(JToolBar toolBar, final RADVisualComponent metaComp) { TestAction testAction = SystemAction.get(TestAction.class); JButton button = toolBar.add(testAction); button.setToolTipText(NbBundle.getMessage(GridDesigner.class, "GridDesigner.previewLayout")); // NOI18N button.setFocusPainted(false); }
private XmlMultiViewEditorSupport.XmlCloneableEditor getXmlEditor() { if (xmlEditor == null) { xmlEditor = (XmlMultiViewEditorSupport.XmlCloneableEditor) dObj.getEditorSupport().createCloneableEditor(); final ActionMap map = xmlEditor.getActionMap(); SaveAction act = (SaveAction) SystemAction.get(SaveAction.class); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); xmlEditor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(stroke, "save"); //NOI18N map.put("save", act); //NOI18N } return xmlEditor; }
/** Creates the actions. */ private synchronized static SystemAction[] createActions () { Iterator<List<ManifestSection.ActionSection>> it = map.values ().iterator (); ArrayList<Object> arr = new ArrayList<Object> (map.size () * 5); while (it.hasNext ()) { List<ManifestSection.ActionSection> l = it.next (); Iterator<ManifestSection.ActionSection> actions = l.iterator (); while (actions.hasNext()) { ManifestSection.ActionSection s = actions.next(); try { arr.add (s.getInstance ()); } catch (Exception ex) { Logger.getLogger(ModuleActions.class.getName()).log(Level.WARNING, null, ex); } } if (it.hasNext ()) { // add separator between modules arr.add (null); } } return (SystemAction[])arr.toArray (new SystemAction[arr.size ()]); }
private static JPopupMenu createPopupMenu(MergePanel panel) { JPopupMenu popup = new JPopupMenuPlus(); SystemAction[] actions = panel.getSystemActions(); for (int i = 0; i < actions.length; i++) { if (actions[i] == null) { popup.addSeparator(); } else if (actions[i] instanceof CallableSystemAction) { popup.add(((CallableSystemAction)actions[i]).getPopupPresenter()); //add FileSystemAction to pop-up menu } else if (actions[i] instanceof FileSystemAction) { popup.add(((FileSystemAction)actions[i]).getPopupPresenter()); } } return popup; }
public Action[] getActions(boolean context) { Action[] result = new Action[] { SystemAction.get(DeleteAction.class), SystemAction.get(RenameAction.class), null, SystemAction.get(ToolsAction.class), SystemAction.get(PropertiesAction.class), }; return result; }
/** Get actions for this data object. * @deprecated Use getActions(boolean) * @return array of actions or <code>null</code> */ @Deprecated @Override public SystemAction[] getActions () { if (systemActions == null) { systemActions = createActions (); } if (systemActions != null) { return systemActions; } return obj.getLoader ().getActions (); }
/** Warms up tools action popup menu item. */ private static void warmUpToolsPopupMenuItem() { SystemAction toolsAction = SystemAction.get(ToolsAction.class); if(toolsAction instanceof ContextAwareAction) { // Here is important to create proper lookup // to warm up Tools sub actions. Lookup lookup = new org.openide.util.lookup.ProxyLookup( new Lookup[] { // This part of lookup causes warm up of Node (cookie) actions. new AbstractNode(Children.LEAF).getLookup(), // This part of lookup causes warm up of Callback actions. new TopComponent().getLookup() } ); Action action = ((ContextAwareAction)toolsAction) .createContextAwareInstance(lookup); if(action instanceof Presenter.Popup) { JMenuItem toolsMenuItem = ((Presenter.Popup)action) .getPopupPresenter(); if(toolsMenuItem instanceof Runnable) { // This actually makes the warm up. // See ToolsAction.Popup impl. ((Runnable)toolsMenuItem).run(); } } } }