Java Code Examples for com.intellij.openapi.actionSystem.ActionManager#getAction()
The following examples show how to use
com.intellij.openapi.actionSystem.ActionManager#getAction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomizableActionsPanel.java From consulo with Apache License 2.0 | 6 votes |
protected void enableSetIconButton(ActionManager actionManager) { final TreePath selectionPath = myTree.getSelectionPath(); Object userObject = null; if (selectionPath != null) { userObject = ((DefaultMutableTreeNode)selectionPath.getLastPathComponent()).getUserObject(); if (userObject instanceof String) { final AnAction action = actionManager.getAction((String)userObject); if (action != null && action.getTemplatePresentation() != null && action.getTemplatePresentation().getIcon() != null) { mySetIconButton.setEnabled(true); return; } } } mySetIconButton.setEnabled(myTextField.getText().length() != 0 && selectionPath != null && new DefaultMutableTreeNode(selectionPath).isLeaf() && !(userObject instanceof AnSeparator)); }
Example 2
Source File: AbstractConnectionAction.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 6 votes |
protected void doPurge(@NotNull final Project project, @NotNull final ProgressHandler progressHandler) { // First Run the Purge Cache ActionManager actionManager = ActionManager.getInstance(); final ResetConfigurationAction resetConfigurationAction = (ResetConfigurationAction) actionManager.getAction("AEM.Purge.Cache.Action"); WaitableRunner<Void> runner; if(resetConfigurationAction != null) { runner = new WaitableRunner<Void>() { @Override public void run() { resetConfigurationAction.doReset(project, progressHandler); } @Override public void handleException(Exception e) { // Catch and report unexpected exception as debug message to keep it going getMessageManager(project).sendErrorNotification("server.configuration.purge.failed.unexpected", e); } @Override public boolean isAsynchronous() { return AbstractConnectionAction.this.isAsynchronous(); } }; runAndWait(runner); } }
Example 3
Source File: CsvTableEditorMouseListener.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
protected JPopupMenu getRowPopupMenu() { if (rowPopupMenu == null) { ActionManager actionManager = ActionManager.getInstance(); ActionGroup rowContextMenu = (ActionGroup) actionManager.getAction(ROW_CONTEXT_MENU_ID); ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(ROW_CONTEXT_MENU_ID, rowContextMenu); // popupMenu.setTargetComponent(csvTableEditor.getComponent()); rowPopupMenu = popupMenu.getComponent(); } return rowPopupMenu; }
Example 4
Source File: ShortcutStartupActivity.java From StringManipulation with Apache License 2.0 | 5 votes |
public static void unRegisterActions(List<CustomActionModel> customActionModels) { ActionManager instance = ActionManager.getInstance(); DefaultActionGroup group = (DefaultActionGroup) instance.getAction("StringManipulation.Group.SwitchCase"); for (CustomActionModel actionModel : customActionModels) { String id = actionModel.getId(); if (StringUtils.isNotBlank(id)) { unRegisterAction(instance, id, group); unRegisterAction(instance, id + CustomActionModel.REVERSE, group); } } }
Example 5
Source File: MacGestureAdapter.java From consulo with Apache License 2.0 | 5 votes |
@Override public void swipedLeft(SwipeEvent event) { ActionManager actionManager = ActionManager.getInstance(); AnAction forward = actionManager.getAction("Forward"); if (forward == null) return; actionManager.tryToExecute(forward, createMouseEventWrapper(myFrame), null, null, false); }
Example 6
Source File: CustomActionsSchema.java From consulo with Apache License 2.0 | 5 votes |
public void fillActionGroups(DefaultMutableTreeNode root) { final ActionManager actionManager = ActionManager.getInstance(); for (Pair pair : myIdToNameList) { final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(pair.first); if (actionGroup != null) { //J2EE/Commander plugin was disabled root.add(ActionsTreeUtil.createNode(ActionsTreeUtil.createGroup(actionGroup, pair.second, null, null, true, null, false))); } } }
Example 7
Source File: NewBashFileActionTest.java From BashSupport with Apache License 2.0 | 5 votes |
@Test public void testNewFile() throws Exception { ActionManager actionManager = ActionManager.getInstance(); final NewBashFileAction action = (NewBashFileAction) actionManager.getAction("Bash.NewBashScript"); // @see https://devnet.jetbrains.com/message/5539349#5539349 VirtualFile directoryVirtualFile = myFixture.getTempDirFixture().findOrCreateDir(""); final PsiDirectory directory = myFixture.getPsiManager().findDirectory(directoryVirtualFile); Assert.assertEquals(BashStrings.message("newfile.command.name"), action.getCommandName()); Assert.assertEquals(BashStrings.message("newfile.menu.action.text"), action.getActionName(directory, "")); PsiElement result = ApplicationManager.getApplication().runWriteAction(new Computable<PsiElement>() { @Override public PsiElement compute() { try { PsiElement[] elements = action.create("bash_file", directory); return elements.length >= 1 ? elements[0] : null; //the firet element is the BashFile } catch (Exception e) { return null; } } }); assertNotNull("Expected a newly created bash file", result); assertTrue("Expected a newly created bash file", result instanceof BashFile); VirtualFile vFile = ((BashFile) result).getVirtualFile(); File ioFile = VfsUtilCore.virtualToIoFile(vFile); assertTrue("Expected that the new file is executable", ioFile.canExecute()); Assert.assertEquals("Expected default bash file template content", "#!/usr/bin/env bash", result.getText()); }
Example 8
Source File: MacGestureAdapter.java From consulo with Apache License 2.0 | 5 votes |
@Override public void swipedRight(SwipeEvent event) { ActionManager actionManager = ActionManager.getInstance(); AnAction back = actionManager.getAction("Back"); if (back == null) return; actionManager.tryToExecute(back, createMouseEventWrapper(myFrame), null, null, false); }
Example 9
Source File: FindViewByIdFieldTemplate.java From android-postfix-plugin with Apache License 2.0 | 5 votes |
@Override protected void onTemplateFinished(final TemplateManager manager, final Editor editor, Template template) { final ActionManager actionManager = ActionManagerImpl.getInstance(); final String editorCompleteStatementText = "IntroduceField"; final AnAction action = actionManager.getAction(editorCompleteStatementText); actionManager.tryToExecute(action, ActionCommand.getInputEvent(editorCompleteStatementText), null, ActionPlaces.UNKNOWN, true); }
Example 10
Source File: CustomActionsSchema.java From consulo with Apache License 2.0 | 5 votes |
private void initActionIcons() { ActionManager actionManager = ActionManager.getInstance(); for (String actionId : myIconCustomizations.keySet()) { final AnAction anAction = actionManager.getAction(actionId); if (anAction != null) { Icon icon; final String iconPath = myIconCustomizations.get(actionId); if (iconPath != null && new File(FileUtil.toSystemDependentName(iconPath)).exists()) { Image image = null; try { image = ImageLoader.loadFromStream(VfsUtil.convertToURL(VfsUtil.pathToUrl(iconPath)).openStream()); } catch (IOException e) { LOG.debug(e); } icon = image != null ? IconLoader.getIcon(image) : null; } else { icon = AllIcons.Toolbar.Unknown; } if (anAction.getTemplatePresentation() != null) { anAction.getTemplatePresentation().setIcon(icon); anAction.setDefaultIcon(false); } } } final IdeFrameEx frame = WindowManagerEx.getInstanceEx().getIdeFrame(null); if (frame != null) { frame.updateView(); } }
Example 11
Source File: SlingServerTreeBuilder.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public SlingServerTreeBuilder(Project project, JTree tree, DefaultTreeModel treeModel) { super(tree, treeModel, new SlingServerTreeStructure(project), IndexComparator.INSTANCE); myProject = project; myConfigurationListener = new ConfigurationListenerImpl(); myConfig = ComponentProvider.getComponent(project, ServerConfigurationManager.class); myExpansionListener = new ExpandedStateUpdater(); tree.addTreeExpansionListener(myExpansionListener); initRootNode(); myConfig.addConfigurationListener(myConfigurationListener); getTree().getModel().addTreeModelListener(new ChangeListener()); ActionManager actionManager = ActionManager.getInstance(); checkAction = (StartRunConnectionAction) actionManager.getAction("AEM.Check.Action"); }
Example 12
Source File: ReplaceActionHelper.java From intellij with Apache License 2.0 | 5 votes |
/** * Registers a new action against the provided action ID, unregistering any existing action with * this ID, if one exists. */ public static void replaceAction(String actionId, AnAction newAction) { ActionManager actionManager = ActionManager.getInstance(); AnAction oldAction = actionManager.getAction(actionId); if (oldAction != null) { newAction.getTemplatePresentation().setIcon(oldAction.getTemplatePresentation().getIcon()); ActionManager.getInstance().replaceAction(actionId, newAction); } else { actionManager.registerAction(actionId, newAction); } }
Example 13
Source File: TitleWithToolbar.java From consulo with Apache License 2.0 | 5 votes |
public TitleWithToolbar(@Nonnull String title, @Nonnull String actionGroupId, @Nonnull String place, @Nonnull JComponent targetComponent) { super(new GridBagLayout()); ActionManager actionManager = ActionManager.getInstance(); ActionGroup group = (ActionGroup)actionManager.getAction(actionGroupId); ActionToolbar actionToolbar = actionManager.createActionToolbar(place, group, true); actionToolbar.setTargetComponent(targetComponent); actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY); add(new MyTitleComponent(title), new GridBag().weightx(1).anchor(GridBagConstraints.WEST).fillCellHorizontally()); add(actionToolbar.getComponent(), new GridBag().anchor(GridBagConstraints.CENTER)); }
Example 14
Source File: AbstractRichStringBasedPostfixTemplate.java From HakunaMatataIntelliJPlugin with Apache License 2.0 | 5 votes |
protected void onTemplateFinished(TemplateManager manager, Editor editor, Template template) { // format and add ; final ActionManager actionManager = ActionManagerImpl.getInstance(); final String editorCompleteStatementText = "EditorCompleteStatement"; final AnAction action = actionManager.getAction(editorCompleteStatementText); actionManager.tryToExecute(action, ActionCommand.getInputEvent(editorCompleteStatementText), null, ActionPlaces.UNKNOWN, true); }
Example 15
Source File: CsvTableEditorMouseListener.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
protected JPopupMenu getColumnPopupMenu() { if (columnPopupMenu == null) { ActionManager actionManager = ActionManager.getInstance(); ActionGroup columnContextMenu = (ActionGroup) actionManager.getAction(COLUMN_CONTEXT_MENU_ID); ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(COLUMN_CONTEXT_MENU_ID, columnContextMenu); // popupMenu.setTargetComponent(csvTableEditor.getComponent()); columnPopupMenu = popupMenu.getComponent(); } return columnPopupMenu; }
Example 16
Source File: TreeMouseListener.java From leetcode-editor with Apache License 2.0 | 5 votes |
@Override public void mouseClicked(MouseEvent e) { TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); if (selPath != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent(); Question question = (Question) node.getUserObject(); if ("lock".equals(question.getStatus())) { return; } if (question.isLeaf()) { if (e.getButton() == 3) { //鼠标右键 final ActionManager actionManager = ActionManager.getInstance(); final ActionGroup actionGroup = (ActionGroup) actionManager.getAction("leetcode.NavigatorActionsMenu"); if (actionGroup != null) { actionManager.createActionPopupMenu("", actionGroup).getComponent().show(e.getComponent(), e.getX(), e.getY()); } } else if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { ProgressManager.getInstance().run(new Task.Backgroundable(project,"leetcode.editor.openCode",false) { @Override public void run(@NotNull ProgressIndicator progressIndicator) { CodeManager.openCode(question, project); } }); } } } }
Example 17
Source File: WindowDressing.java From consulo with Apache License 2.0 | 4 votes |
public static ProjectWindowActionGroup getWindowActionGroup(ActionManager actionManager1) { return (ProjectWindowActionGroup)actionManager1.getAction("OpenProjectWindows"); }
Example 18
Source File: PopupHandler.java From consulo with Apache License 2.0 | 4 votes |
public static void installPopupHandler(JComponent component, @NonNls String groupId, @NonNls String place) { ActionManager actionManager = ActionManager.getInstance(); ActionGroup group = (ActionGroup)actionManager.getAction(groupId); installPopupHandler(component, group, place, actionManager); }
Example 19
Source File: PantsCompileActionGroup.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
@NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent event) { // Deletes existing make and compile options. ActionManager actionManager = ActionManager.getInstance(); // TODO: don't remove these actions or put on our own unless we're in a // pants project, so we don't clobber these actions in a non-pants project DefaultActionGroup actionGroup = (DefaultActionGroup) actionManager.getAction(PantsConstants.ACTION_COMPILE_GROUP_ID); actionGroup.remove(actionManager.getAction(IdeActions.ACTION_MAKE_MODULE)); actionGroup.remove(actionManager.getAction(IdeActions.ACTION_COMPILE)); final AnAction[] emptyAction = new AnAction[0]; if (event == null) { return emptyAction; } Project project = event.getProject(); Optional<VirtualFile> eventFile = PantsUtil.getFileForEvent(event); // TODO: signal if no project found? if (project == null || !eventFile.isPresent()) { return emptyAction; } VirtualFile file = eventFile.get(); List<AnAction> actions = new LinkedList<>(); Module module = ModuleUtil.findModuleForFile(file, project); if (module == null) { return emptyAction; } List<String> targetAddresses = PantsUtil.getNonGenTargetAddresses(module); // TODO: signal if no addresses found? if (targetAddresses.isEmpty()) { return emptyAction; } actions.add(new PantsLintTargetAction(targetAddresses)); // Adds compile all option for modules with multiple targets. if (targetAddresses.size() > 1) { actions.add(new PantsCompileAllTargetsInModuleAction(Optional.of(module))); } targetAddresses.forEach(target -> actions.add(new PantsCompileTargetAction(target))); return actions.toArray(emptyAction); }
Example 20
Source File: WindowTool.java From ADB-Duang with MIT License | 4 votes |
private boolean isEnable(String action) { ActionManager am = ActionManager.getInstance(); return am.getAction(action) != null; }