com.intellij.openapi.actionSystem.ActionManager Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.ActionManager.
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: RunnerLayoutUiImpl.java From consulo with Apache License 2.0 | 6 votes |
public RunnerLayoutUiImpl(@Nonnull Project project, @Nonnull Disposable parent, @Nonnull String runnerId, @Nonnull String runnerTitle, @Nonnull String sessionName) { myLayout = RunnerLayoutSettings.getInstance().getLayout(runnerId); consulo.disposer.Disposer.register(parent, this); myContentUI = new RunnerContentUi(project, this, ActionManager.getInstance(), IdeFocusManager.getInstance(project), myLayout, runnerTitle + " - " + sessionName); consulo.disposer.Disposer.register(this, myContentUI); myViewsContentManager = getContentFactory().createContentManager(myContentUI.getContentUI(), true, project); myViewsContentManager.addDataProvider(this); consulo.disposer.Disposer.register(this, myViewsContentManager); }
Example #2
Source File: GraphQLIntrospectionHelper.java From js-graphql-intellij-plugin with MIT License | 6 votes |
void setEditorTextAndFormatLines(String text, FileEditor fileEditor) { if (fileEditor instanceof TextEditor) { final Editor editor = ((TextEditor) fileEditor).getEditor(); editor.getDocument().setText(text); AnAction reformatCode = ActionManager.getInstance().getAction("ReformatCode"); if (reformatCode != null) { final AnActionEvent actionEvent = AnActionEvent.createFromDataContext( ActionPlaces.UNKNOWN, null, new DataManagerImpl.MyDataContext(editor.getComponent()) ); reformatCode.actionPerformed(actionEvent); } } }
Example #3
Source File: StatusPanel.java From consulo with Apache License 2.0 | 6 votes |
private Action createCopyAction() { ActionManager actionManager = ActionManager.getInstance(); if (actionManager == null) return null; AnAction action = actionManager.getAction(IdeActions.ACTION_COPY); if (action == null) return null; return new AbstractAction(action.getTemplatePresentation().getText(), action.getTemplatePresentation().getIcon()) { @Override public void actionPerformed(ActionEvent e) { StringSelection content = new StringSelection(getText()); ClipboardSynchronizer.getInstance().setContent(content, content); } @Override public boolean isEnabled() { return !getText().isEmpty(); } }; }
Example #4
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 #5
Source File: PopupHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static MouseListener installPopupHandler(@Nonnull JComponent component, @Nonnull ActionGroup group, @NonNls String place, @Nonnull ActionManager actionManager, @Nullable PopupMenuListener menuListener) { if (ApplicationManager.getApplication() == null) return new MouseAdapter() { }; PopupHandler popupHandler = new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group); popupMenu.setTargetComponent(component); JPopupMenu menu = popupMenu.getComponent(); if (menuListener != null) menu.addPopupMenuListener(menuListener); menu.show(comp, x, y); } }; component.addMouseListener(popupHandler); return popupHandler; }
Example #6
Source File: ActiveConnectionPanel.java From p4ic4idea with Apache License 2.0 | 6 votes |
private void setup() { root = new JPanel(new BorderLayout()); JScrollPane scroll = new JBScrollPane(); root.add(scroll, BorderLayout.CENTER); connectionTree = new Tree(); scroll.setViewportView(connectionTree); connectionTree.getEmptyText().setText(P4Bundle.getString("connection.tree.initial")); connectionTree.setEditable(false); connectionTreeModel = new DefaultTreeModel(treeNode); connectionTree.setModel(connectionTreeModel); connectionTree.setCellRenderer(new ConnectionTreeCellRenderer()); connectionTree.setRootVisible(false); DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel(); selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); connectionTree.setSelectionModel(selectionModel); ActionGroup actionButtons = createActionGroup(); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("p4.active-connection", actionButtons, false); root.add(toolbar.getComponent(), BorderLayout.WEST); // TODO add context menu support for each selected node type. // TODO add support for navigating to a file if a FilePath is selected. }
Example #7
Source File: BPMNEditor.java From intellij-bpmn-editor with GNU General Public License v3.0 | 6 votes |
public void initBPMNModelMenu() { DefaultActionGroup modelMenu = (DefaultActionGroup) ActionManager.getInstance().getAction("yaoqiang.actions.BPMNModelMenu"); AppMenu model = new ModelMenu(); for (int i = 0; i < model.getItemCount(); i++) { JMenuItem item = model.getItem(i); if (item == null) { modelMenu.addSeparator(); } else { AnAction action = new AnAction(item.getText()) { @Override public void actionPerformed(AnActionEvent e) { item.getAction().actionPerformed(new ActionEvent(e, 0, "")); } }; modelMenu.add(action); } } }
Example #8
Source File: ActionUrl.java From consulo with Apache License 2.0 | 6 votes |
public void readExternal(Element element) throws InvalidDataException { myGroupPath = new ArrayList<String>(); for (Object o : element.getChildren(PATH)) { myGroupPath.add(((Element)o).getAttributeValue(VALUE)); } final String attributeValue = element.getAttributeValue(VALUE); if (element.getAttributeValue(IS_ACTION) != null) { myComponent = attributeValue; } else if (element.getAttributeValue(SEPARATOR) != null) { myComponent = AnSeparator.getInstance(); } else if (element.getAttributeValue(IS_GROUP) != null) { final AnAction action = ActionManager.getInstance().getAction(attributeValue); myComponent = action instanceof ActionGroup ? ActionsTreeUtil.createGroup((ActionGroup)action, true, null) : new Group(attributeValue, attributeValue, null); } myActionType = Integer.parseInt(element.getAttributeValue(ACTION_TYPE)); myAbsolutePosition = Integer.parseInt(element.getAttributeValue(POSITION)); DefaultJDOMExternalizer.readExternal(this, element); }
Example #9
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 #10
Source File: CustomActionsSchema.java From consulo with Apache License 2.0 | 6 votes |
public AnAction getCorrectedAction(String id) { if (!myIdToNameList.contains(new Pair(id, ""))) { return ActionManager.getInstance().getAction(id); } if (myIdToActionGroup.get(id) == null) { for (Pair pair : myIdToNameList) { if (pair.first.equals(id)) { final ActionGroup actionGroup = (ActionGroup)ActionManager.getInstance().getAction(id); if (actionGroup != null) { //J2EE/Commander plugin was disabled myIdToActionGroup.put(id, CustomizationUtil.correctActionGroup(actionGroup, this, pair.second)); } } } } return myIdToActionGroup.get(id); }
Example #11
Source File: SlingServerTreeManager.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 6 votes |
private void popupInvoked(final Component comp, final int x, final int y) { Object userObject = null; final TreePath path = tree.getSelectionPath(); if(path != null) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if(node != null) { userObject = node.getUserObject(); } } ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup group = new DefaultActionGroup(); if( userObject instanceof SlingServerNodeDescriptor || userObject instanceof SlingServerModuleNodeDescriptor ) { group.add(actionManager.getAction("AEM.Connection.Popup")); } else { group.add(actionManager.getAction("AEM.Root.Popup")); } final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.ANT_EXPLORER_POPUP, group); popupMenu.getComponent().show(comp, x, y); }
Example #12
Source File: DebuggerUIUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void registerExtraHandleShortcuts(final ListPopupImpl popup, String... actionNames) { for (String name : actionNames) { KeyStroke stroke = KeymapUtil.getKeyStroke(ActionManager.getInstance().getAction(name).getShortcutSet()); if (stroke != null) { popup.registerAction("handleSelection " + stroke, stroke, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { popup.handleSelect(true); } }); } } }
Example #13
Source File: FindUIHelper.java From consulo with Apache License 2.0 | 5 votes |
private void registerAction(String actionName, boolean replace, JComponent component, FindUI ui) { AnAction action = ActionManager.getInstance().getAction(actionName); new AnAction() { @Override public boolean isDumbAware() { return action.isDumbAware(); } @Override public void actionPerformed(@Nonnull AnActionEvent e) { ui.saveSettings(); myModel.copyFrom(FindManager.getInstance(myProject).getFindInProjectModel()); FindUtil.initStringToFindWithSelection(myModel, e.getData(CommonDataKeys.EDITOR)); myModel.setReplaceState(replace); ui.initByModel(); } //@NotNull //private DataContextWrapper prepareDataContextForFind(@NotNull AnActionEvent e) { // DataContext dataContext = e.getDataContext(); // Project project = CommonDataKeys.PROJECT.getData(dataContext); // Editor editor = CommonDataKeys.EDITOR.getData(dataContext); // final String selection = editor != null ? editor.getSelectionModel().getSelectedText() : null; // // return new DataContextWrapper(dataContext) { // @Nullable // @Override // public Object getData(@NonNls String dataId) { // if (CommonDataKeys.PROJECT.is(dataId)) return project; // if (PlatformDataKeys.PREDEFINED_TEXT.is(dataId)) return selection; // return super.getData(dataId); // } // }; //} }.registerCustomShortcutSet(action.getShortcutSet(), component); }
Example #14
Source File: FileTextFieldImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public String getAdText(CompletionResult result) { if (result.myCompletionBase == null) return null; if (result.myCompletionBase.length() == result.myFieldText.length()) return null; String strokeText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction("EditorChooseLookupItemReplace")); return IdeBundle.message("file.chooser.completion.ad.text", strokeText); }
Example #15
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 #16
Source File: TemplateKindProvider.java From consulo with Apache License 2.0 | 5 votes |
public static void addAdditionalKinds(AnAction action, PsiDirectory dir, CreateFileFromTemplateDialog.Builder builder) { String id = ActionManager.getInstance().getId(action); for (TemplateKindProvider provider : Extensions.getExtensions(EP_NAME)) { for (Kind kind : provider.getAdditionalKinds(dir)) { builder.addKind(kind.name, kind.icon, kind.templateName); } } }
Example #17
Source File: JBTabsPaneImpl.java From consulo with Apache License 2.0 | 5 votes |
public JBTabsPaneImpl(@Nullable Project project, int tabPlacement, @Nonnull Disposable parent) { myTabs = new JBEditorTabs(project, ActionManager.getInstance(), project == null ? null : IdeFocusManager.getInstance(project), parent) { @Override public boolean isAlphabeticalMode() { return false; } @Override public boolean supportsCompression() { return false; } }; myTabs.setFirstTabOffset(10); myTabs.addListener(new TabsListener.Adapter() { @Override public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) { fireChanged(new ChangeEvent(myTabs)); } }).getPresentation() .setPaintBorder(1, 1, 1, 1) .setTabSidePaintBorder(2) .setPaintFocus(UIUtil.isUnderBuildInLaF()) .setAlwaysPaintSelectedTab(UIUtil.isUnderBuildInLaF()) .setGhostsAlwaysVisible(true); setTabPlacement(tabPlacement); }
Example #18
Source File: MongoEditionPanel.java From nosql4idea with Apache License 2.0 | 5 votes |
void buildPopupMenu() { DefaultActionGroup actionPopupGroup = new DefaultActionGroup("MongoEditorPopupGroup", true); if (ApplicationManager.getApplication() != null) { actionPopupGroup.add(new AddKeyAction(this)); actionPopupGroup.add(new AddValueAction(this)); actionPopupGroup.add(new DeleteKeyAction(this)); } PopupHandler.installPopupHandler(editTableView, actionPopupGroup, "POPUP", ActionManager.getInstance()); }
Example #19
Source File: GuiUtils.java From nosql4idea with Apache License 2.0 | 5 votes |
public static void installActionGroupInToolBar(DefaultActionGroup actionGroup, JPanel toolBarPanel, ActionManager actionManager, String toolbarName, boolean horizontal) { if (actionManager == null) { return; } JComponent actionToolbar = ActionManager.getInstance().createActionToolbar(toolbarName, actionGroup, horizontal).getComponent(); toolBarPanel.add(actionToolbar, BorderLayout.CENTER); }
Example #20
Source File: ShortcutStartupActivity.java From StringManipulation with Apache License 2.0 | 5 votes |
public static void registerActions() { ActionManager actionManager = ActionManager.getInstance(); DefaultActionGroup group = (DefaultActionGroup) actionManager.getAction("StringManipulation.Group.SwitchCase"); List<CustomActionModel> customActionModels = PluginPersistentStateComponent.getInstance().getCustomActionModels(); unRegisterActions(customActionModels); for (int i = customActionModels.size() - 1; i >= 0; i--) { CustomActionModel customActionModel = customActionModels.get(i); registerAction(actionManager, group, customActionModel); } }
Example #21
Source File: IncomingChangesViewProvider.java From consulo with Apache License 2.0 | 5 votes |
public JComponent initContent() { myBrowser = new CommittedChangesTreeBrowser(myProject, Collections.<CommittedChangeList>emptyList()); myBrowser.getEmptyText().setText(VcsBundle.message("incoming.changes.not.loaded.message")); ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("IncomingChangesToolbar"); final ActionToolbar toolbar = myBrowser.createGroupFilterToolbar(myProject, group, null, Collections.<AnAction>emptyList()); myBrowser.setToolBar(toolbar.getComponent()); myBrowser.setTableContextMenu(group, Collections.<AnAction>emptyList()); myConnection = myBus.connect(); myConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new MyCommittedChangesListener()); loadChangesToBrowser(false, true); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(myBrowser, BorderLayout.CENTER); return contentPane; }
Example #22
Source File: NavigateAction.java From consulo with Apache License 2.0 | 5 votes |
public NavigateAction(@Nonnull String text, @Nonnull LineMarkerInfo<T> info, @Nullable String originalActionId) { super(text); myInfo = info; if (originalActionId != null) { ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet(); setShortcutSet(set); } }
Example #23
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 #24
Source File: MindMapDocumentEditor.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Nullable private ShortcutSet getFindAtMindMapShortcutSet() { ShortcutSet result = null; final AnAction findAction = ActionManager.getInstance().getAction("FindTextAtMindMap"); if (findAction != null) { result = findAction.getShortcutSet(); } return result; }
Example #25
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 #26
Source File: BlazeProblemsViewPanel.java From intellij with Apache License 2.0 | 5 votes |
/** A custom toolbar panel, without most of the irrelevant built-in items. */ private JComponent createToolbarPanel() { DefaultActionGroup group = new DefaultActionGroup(); group.add(new PreviousOccurenceToolbarAction(this)); // NOTYPO group.add(new NextOccurenceToolbarAction(this)); // NOTYPO fillRightToolbarGroup(group); ActionToolbar toolbar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.COMPILER_MESSAGES_TOOLBAR, group, false); return toolbar.getComponent(); }
Example #27
Source File: BlazeHotSwapAction.java From intellij with Apache License 2.0 | 5 votes |
private static void replaceAction() { AnAction delegate = ActionManager.getInstance().getAction(ACTION_ID); if (delegate == null) { // HotSwapAction not registered by default for Android Studio, though still in the classpath delegate = new HotSwapAction(); } ReplaceActionHelper.conditionallyReplaceAction( ACTION_ID, new BlazeHotSwapAction(delegate), Blaze::isBlazeProject); }
Example #28
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 #29
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 #30
Source File: SwitchToFind.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { if (KeymapUtil.isEmacsKeymap()) { // Emacs users are accustomed to the editor that executes 'find next' on subsequent pressing of shortcut that // activates 'incremental search'. Hence, we do the similar hack here for them. ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT).update(e); } else { EditorSearchSession search = e.getData(EditorSearchSession.SESSION_KEY); e.getPresentation().setEnabledAndVisible(search != null); } }