Java Code Examples for com.intellij.openapi.actionSystem.AnAction
The following examples show how to use
com.intellij.openapi.actionSystem.AnAction. These examples are extracted from open source projects.
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 Project: buck Source File: SelectedTestRunLineMarkerContributorTest.java License: 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 2
Source Project: consulo Source File: ActionTracker.java License: 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 Project: consulo Source File: SimpleThreesideDiffViewer.java License: 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 4
Source Project: consulo Source File: HighlightersActionGroup.java License: 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 5
Source Project: consulo Source File: WinDockDelegate.java License: 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 6
Source Project: consulo Source File: CustomizableActionsPanel.java License: 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 7
Source Project: consulo Source File: TaskDefaultFavoriteListProvider.java License: 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 8
Source Project: haystack Source File: DynamicActionGroup.java License: 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 9
Source Project: intellij-quarkus Source File: CommandExecutor.java License: 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 10
Source Project: consulo Source File: MacGestureAdapter.java License: 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 11
Source Project: SlackStorm Source File: SlackSettings.java License: 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 12
Source Project: idea-sql-generator-tool Source File: SqlGeneratorAction.java License: 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 13
Source Project: consulo Source File: MacrosGroup.java License: 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 14
Source Project: intellij Source File: ReplaceActionHelper.java License: 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 15
Source Project: react-native-console Source File: RunGradleTaskAction.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { if (e == null) return EMPTY_ARRAY; final Project project = e.getProject(); if (project == null) return EMPTY_ARRAY; String[] devices = {"build", "integTest", "test", "bootJar", "checkstyleMain", "spotbugsMain"}; if (devices == null || devices.length == 0) return EMPTY_ARRAY; final AnAction[] actions = new AnAction[devices.length]; String inputDir = project.getBasePath(); for (int i = 0; i < devices.length; i++) { String scriptName = devices[i]; actions[i] = new BaseRNConsoleAction(terminal, "gradle " + scriptName, "gradle '" + scriptName + "'", PluginIcons.Gradle) { @Override public void doAction(AnActionEvent anActionEvent) { RNConsole consoleView = terminal.getRNConsole(getText(), getIcon()); consoleView.executeShell( command(), inputDir); } protected String command() { if (OSUtils.isWindows()) {// https://github.com/beansoftapp/react-native-console/issues/8 return "gradlew.bat " + scriptName; } return "." + File.separator + "gradlew " + scriptName; } }; } return actions; }
Example 16
Source Project: consulo Source File: LightToolWindowManager.java License: Apache License 2.0 | 5 votes |
protected final LightToolWindow createContent(@Nonnull DesignerEditorPanelFacade designer, @Nonnull LightToolWindowContent content, @Nonnull String title, @Nonnull Icon icon, @Nonnull JComponent component, @Nonnull JComponent focusedComponent, int defaultWidth, @Nullable AnAction[] actions) { return new LightToolWindow(content, title, icon, component, focusedComponent, designer.getContentSplitter(), getEditorMode(), this, myProject, myPropertiesComponent, getComponentName(), defaultWidth, actions); }
Example 17
Source Project: consulo Source File: NavigationGutterIconRenderer.java License: 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 Project: consulo Source File: RecentProjectPanel.java License: 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 Project: IntelliJ-Key-Promoter-X Source File: KeyPromoterAction.java License: 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 20
Source Project: CodeGen Source File: TemplateAddAction.java License: 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 Project: consulo Source File: CommonActionsManagerImpl.java License: 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 22
Source Project: consulo Source File: DiffUtil.java License: 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 23
Source Project: intellij Source File: ReplaceActionHelper.java License: 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 24
Source Project: flutter-intellij Source File: FlutterRetargetAppAction.java License: 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 25
Source Project: consulo Source File: MacGestureAdapter.java License: 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 26
Source Project: consulo Source File: SimpleChange.java License: 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 27
Source Project: StringManipulation Source File: ShortcutStartupActivity.java License: 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 28
Source Project: consulo Source File: RecentProjectPanel.java License: 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 29
Source Project: consulo Source File: UnwrapHandler.java License: 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); }
Example 30
Source Project: jetbrains-plugin-graph-database-support Source File: ExecuteQueryActionPromoter.java License: 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(); }