com.intellij.openapi.actionSystem.AnAction Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.AnAction.
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: SimpleThreesideDiffViewer.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override protected List<AnAction> createPopupActions() { List<AnAction> group = new ArrayList<>(); group.add(AnSeparator.getInstance()); group.add(new MyIgnorePolicySettingAction().getPopupGroup()); //group.add(Separator.getInstance()); //group.add(new MyHighlightPolicySettingAction().getPopupGroup()); group.add(AnSeparator.getInstance()); group.add(new MyToggleAutoScrollAction()); group.add(new MyToggleExpandByDefaultAction()); group.add(AnSeparator.getInstance()); group.addAll(super.createPopupActions()); return group; }
Example #2
Source File: ActionTracker.java From consulo with Apache License 2.0 | 6 votes |
ActionTracker(Editor editor, Disposable parentDisposable) { myEditor = editor; myProject = editor.getProject(); ActionManager.getInstance().addAnActionListener(new AnActionListener.Adapter() { @Override public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) { myActionsHappened = true; } }, parentDisposable); myEditor.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { if (!myIgnoreDocumentChanges) { myActionsHappened = true; } } }, parentDisposable); }
Example #3
Source File: SelectedTestRunLineMarkerContributorTest.java From buck with Apache License 2.0 | 6 votes |
private AnAction findActionAtCaretWithText(Predicate<String> textMatcher) { List<GutterMark> gutterMarks = myFixture.findGuttersAtCaret(); for (GutterMark gutterMark : gutterMarks) { if (!(gutterMark instanceof GutterIconRenderer)) { continue; } GutterIconRenderer renderer = (GutterIconRenderer) gutterMark; ActionGroup group = renderer.getPopupMenuActions(); for (AnAction action : group.getChildren(new TestActionEvent())) { TestActionEvent actionEvent = new TestActionEvent(); action.update(actionEvent); String actualText = actionEvent.getPresentation().getText(); if (actualText == null) { actualText = action.getTemplatePresentation().getText(); if (actualText == null) { continue; } } if (textMatcher.test(actualText)) { return action; } } } return null; }
Example #4
Source File: WinDockDelegate.java From consulo with Apache License 2.0 | 6 votes |
@Override public void updateRecentProjectsMenu() { if (ApplicationProperties.isInSandbox()) { return; } // we need invoke it in own thread, due we don't want it call inside UI thread, or Write thread (if it separate) myExecutorService.execute(() -> { final AnAction[] recentProjectActions = RecentProjectsManager.getInstance().getRecentProjectsActions(false); RecentTasks.clear(); String name = ApplicationNamesInfo.getInstance().getProductName().toLowerCase(Locale.US); File exePath = new File(ContainerPathManager.get().getAppHomeDirectory(), name + (SystemInfo.is64Bit ? "64" : "") + ".exe"); if (!exePath.exists()) { throw new IllegalArgumentException("Executable is not exists. Path: " + exePath.getPath()); } String launcher = RecentTasks.getShortenPath(exePath.getPath()); Task[] tasks = new Task[recentProjectActions.length]; for (int i = 0; i < recentProjectActions.length; i++) { ReopenProjectAction rpa = (ReopenProjectAction)recentProjectActions[i]; tasks[i] = new Task(launcher, RecentTasks.getShortenPath(rpa.getProjectPath()), rpa.getTemplatePresentation().getText()); } RecentTasks.addTasks(tasks); }); }
Example #5
Source File: CustomizableActionsPanel.java From consulo with Apache License 2.0 | 6 votes |
protected void doOKAction() { if (myNode != null) { if (!doSetIcon(myNode, myTextField.getText(), getContentPane())) { return; } final Object userObject = myNode.getUserObject(); if (userObject instanceof Pair) { String actionId = (String)((Pair)userObject).first; final AnAction action = ActionManager.getInstance().getAction(actionId); final Icon icon = (Icon)((Pair)userObject).second; action.getTemplatePresentation().setIcon(icon); action.setDefaultIcon(icon == null); editToolbarIcon(actionId, myNode); } myActionsTree.repaint(); } setCustomizationSchemaForCurrentProjects(); super.doOKAction(); }
Example #6
Source File: HighlightersActionGroup.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { List<AnAction> actions = ContainerUtil.newArrayList(); if (e != null) { if (e.getData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES) != null) { actions.add(new AnSeparator("Highlight")); for (VcsLogHighlighterFactory factory : Extensions.getExtensions(VcsLogUiImpl.LOG_HIGHLIGHTER_FACTORY_EP, e.getProject())) { if (factory.showMenuItem()) { actions.add(new EnableHighlighterAction(factory)); } } } } return actions.toArray(new AnAction[actions.size()]); }
Example #7
Source File: ReplaceActionHelper.java From intellij with Apache License 2.0 | 5 votes |
/** * Conditionally replaces the action with the given ID with the new action. If there's no existing * action with the given ID, the new action is registered, and conditionally visible. */ public static void conditionallyReplaceAction( String actionId, AnAction newAction, Predicate<Project> shouldReplace) { ActionManager actionManager = ActionManager.getInstance(); AnAction oldAction = actionManager.getAction(actionId); if (oldAction == null) { oldAction = new EmptyAction(false); } replaceAction(actionId, new ReplacedAction(oldAction, newAction, shouldReplace)); }
Example #8
Source File: TestExecutionState.java From buck with Apache License 2.0 | 5 votes |
@Nullable @Override public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException { final ProcessHandler processHandler = runBuildCommand(executor); final TestConsoleProperties properties = new BuckTestConsoleProperties( processHandler, mProject, mConfiguration, "Buck test", executor); final ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("buck test", processHandler, properties); return new DefaultExecutionResult(console, processHandler, AnAction.EMPTY_ARRAY); }
Example #9
Source File: KeyPromoterAction.java From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Information extraction for buttons on the toolbar * * @param source source of the action */ private void analyzeActionButton(ActionButton source) { final AnAction action = source.getAction(); if (action != null) { fixValuesFromAction(action); } mySource = ActionSource.MAIN_TOOLBAR; }
Example #10
Source File: TaskDefaultFavoriteListProvider.java From consulo with Apache License 2.0 | 5 votes |
private void showNotePopup(Project project, final DnDAwareTree tree, final Consumer<String> after, final String initText) { final JTextArea textArea = new JTextArea(3, 50); textArea.setFont(UIUtil.getTreeFont()); textArea.setText(initText); final JBScrollPane pane = new JBScrollPane(textArea); final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(pane, textArea) .setCancelOnClickOutside(true) .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish") .setTitle("Comment") .setMovable(true) .setRequestFocus(true).setResizable(true).setMayBeParent(true); final JBPopup popup = builder.createPopup(); final JComponent content = popup.getContent(); final AnAction action = new AnAction() { @Override public void actionPerformed(AnActionEvent e) { popup.closeOk(e.getInputEvent()); unregisterCustomShortcutSet(content); after.consume(textArea.getText()); } }; action.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { popup.showInCenterOf(tree); } }, ModalityState.NON_MODAL, project.getDisposed()); }
Example #11
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 #12
Source File: MacrosGroup.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public AnAction[] getChildren(@Nullable AnActionEvent e) { ArrayList<AnAction> actions = new ArrayList<AnAction>(); final ActionManagerEx actionManager = ((ActionManagerEx) ActionManager.getInstance()); String[] ids = actionManager.getActionIds(ActionMacro.MACRO_ACTION_PREFIX); for (String id : ids) { actions.add(actionManager.getAction(id)); } return actions.toArray(new AnAction[actions.size()]); }
Example #13
Source File: SqlGeneratorAction.java From idea-sql-generator-tool with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent anActionEvent) { return new AnAction[] {new SelectSqlGeneratorAction(), new SelectSqlGeneratorAction.NamedParameterSqlGeneratorAction(), new InsertSqlGeneratorAction(), new InsertSqlGeneratorAction.NamedParameterSqlGeneratorAction(), new DeleteSqlGeneratorAction(), new DeleteSqlGeneratorAction.NamedParameterSqlGeneratorAction(), new UpdateSqlGeneratorAction(), new UpdateSqlGeneratorAction.NamedParameterSqlGeneratorAction(), new DuplicateKeyUpdateSqlGeneratorAction(), new DuplicateKeyUpdateSqlGeneratorAction.NamedParameterSqlGeneratorAction(), }; }
Example #14
Source File: SlackSettings.java From SlackStorm with GNU General Public License v2.0 | 5 votes |
@NotNull @Override public AnAction[] getChildren(AnActionEvent anActionEvent) { final AnAction[] children = new AnAction[4]; children[0] = new addChannel(); children[1] = new editChannel(); children[2] = new removeChannel(); children[3] = new removeChannels(); return children; }
Example #15
Source File: CommandExecutor.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unused") // ECJ compiler for some reason thinks handlerService == null is always false private static boolean executeCommandClientSide(Command command, Document document) { Application workbench = ApplicationManager.getApplication(); if (workbench == null) { return false; } URI context = LSPIJUtils.toUri(document); AnAction parameterizedCommand = createEclipseCoreCommand(command, context, workbench); if (parameterizedCommand == null) { return false; } DataContext dataContext = createDataContext(command, context, workbench); ActionUtil.invokeAction(parameterizedCommand, dataContext, ActionPlaces.UNKNOWN, null, null); return true; }
Example #16
Source File: DynamicActionGroup.java From haystack with MIT License | 5 votes |
@NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent anActionEvent) { String menuPath = System.getProperty("user.home") + "/.haystack_template_cache/popmenu"; ObjectMapper mapper = new ObjectMapper(); if (new File(menuPath).exists()) { try { List<MyAction> actions = mapper.readValue(new File(menuPath), new TypeReference<List<MyAction>>() { }); // for (MyAction action : actions) { // action.setWidgets(mapper.readValue(action.getWidgets().toString(), new TypeReference<List<Widget>>() { // })); // for (Widget code : action.getWidgets()) { // code.setTexts(mapper.readValue(action.getWidgets().toString(), new TypeReference<List<MyCode>>() { // })); // } // } AnAction[] list = new AnAction[actions.size()]; for (int i = 0; i < actions.size(); i++) { MyAction action = actions.get(i); list[i] = new SimplePopDialogAction(action.getTitle(), action.getDescription(), action); } return list; // return new AnAction[]{new SimplePopDialogAction(BUTTON, "Insert a Button"), // new SimplePopDialogAction(TEXT_FIELD, "Insert an TextField"), // new SimplePopDialogAction(IMAGE_VIEW, "Insert an ImageView"), // new SimplePopDialogAction(BOTTOM_SHEET, "insert a Bottom Sheet"), // // }; } catch (IOException e) { e.printStackTrace(); } } return new AnAction[]{}; }
Example #17
Source File: NavigationGutterIconRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public AnAction getClickAction() { return new AnAction() { public void actionPerformed(AnActionEvent e) { navigate(e == null ? null : (MouseEvent)e.getInputEvent(), null); } }; }
Example #18
Source File: RecentProjectPanel.java From consulo with Apache License 2.0 | 5 votes |
private MyList(Dimension size, @Nonnull AnAction... listData) { super(listData); mySize = size; setEmptyText(" No Project Open Yet "); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); getAccessibleContext().setAccessibleName(RECENT_PROJECTS_LABEL); final MouseHandler handler = new MouseHandler(); addMouseListener(handler); addMouseMotionListener(handler); }
Example #19
Source File: ShortcutStartupActivity.java From StringManipulation with Apache License 2.0 | 5 votes |
private static void unRegisterAction(ActionManager instance, String actionId, DefaultActionGroup group) { AnAction action = instance.getActionOrStub(actionId); if (action != null) { LOG.info("Unregistering " + action + " id:" + actionId); group.remove(action); instance.unregisterAction(actionId); } }
Example #20
Source File: TemplateAddAction.java From CodeGen with MIT License | 5 votes |
@Override public void run(AnActionButton button) { // 获取选中节点 final DefaultMutableTreeNode selectedNode = getSelectedNode(); List<AnAction> actions = getMultipleActions(selectedNode); if (actions == null || actions.isEmpty()) { return; } // 显示新增按钮 final DefaultActionGroup group = new DefaultActionGroup(actions); JBPopupFactory.getInstance() .createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(button.getContextComponent()), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show(button.getPreferredPopupPoint()); }
Example #21
Source File: SimpleChange.java From consulo with Apache License 2.0 | 5 votes |
@Override public void onApplied() { myType = ChangeType.deriveApplied(myType); for (SimpleChangeSide side : mySides) { ChangeHighlighterHolder highlighterHolder = side.getHighlighterHolder(); highlighterHolder.setActions(new AnAction[0]); highlighterHolder.updateHighlighter(side, myType); } myChangeList.apply(this); }
Example #22
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 #23
Source File: RecentProjectPanel.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private AnAction performSelectedAction(@Nonnull InputEvent event, AnAction selection) { String actionPlace = UIUtil.uiParents(myList, true).filter(FlatWelcomeFrame.class).isEmpty() ? ActionPlaces.POPUP : ActionPlaces.WELCOME_SCREEN; AnActionEvent actionEvent = AnActionEvent.createFromInputEvent(event, actionPlace, selection.getTemplatePresentation(), DataManager.getInstance().getDataContext(myList), false, false); ActionUtil.performActionDumbAwareWithCallbacks(selection, actionEvent, actionEvent.getDataContext()); return selection; }
Example #24
Source File: SlingServerTreeManager.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public void adjustToolbar(DefaultActionGroup group) { AnAction action = CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, tree); action.getTemplatePresentation().setDescription(AEMBundle.message("action.expand.all.nodes.description")); group.add(action); action = CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, tree); action.getTemplatePresentation().setDescription(AEMBundle.message("action.collapse.all.nodes.description")); group.add(action); }
Example #25
Source File: CommonActionsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public AnAction installAutoscrollToSourceHandler(Project project, JTree tree, final AutoScrollToSourceOptionProvider optionProvider) { AutoScrollToSourceHandler handler = new AutoScrollToSourceHandler() { public boolean isAutoScrollMode() { return optionProvider.isAutoScrollMode(); } public void setAutoScrollMode(boolean state) { optionProvider.setAutoScrollMode(state); } }; handler.install(tree); return handler.createToggleAction(); }
Example #26
Source File: DiffUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void addActionBlock(@Nonnull DefaultActionGroup group, @Nullable List<? extends AnAction> actions) { if (actions == null || actions.isEmpty()) return; group.addSeparator(); AnAction[] children = group.getChildren(null); for (AnAction action : actions) { if (!ArrayUtil.contains(action, children)) { group.add(action); } } }
Example #27
Source File: ExecuteQueryActionPromoter.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@Override public List<AnAction> promote(List<AnAction> actions, DataContext context) { PsiFile psiFile = PlatformDataKeys.PSI_FILE.getData(context); if (psiFile != null) { String languageId = psiFile.getLanguage().getID(); if (isSupported(languageId)) { return checkForExecuteQueryAction(actions); } } return Collections.emptyList(); }
Example #28
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 #29
Source File: FlutterRetargetAppAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { final AnAction action = getAction(e.getProject()); if (action != null) { action.actionPerformed(e); } }
Example #30
Source File: UnwrapHandler.java From consulo with Apache License 2.0 | 5 votes |
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) { if (options.isEmpty()) return; if (!getUnwrapDescription(file).showOptionsDialog() || ApplicationManager.getApplication().isUnitTestMode() ) { options.get(0).actionPerformed(null); return; } showPopup(options, editor); }