com.intellij.openapi.actionSystem.ActionPlaces Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.ActionPlaces.
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: CopyReferenceAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent e) { boolean plural = false; boolean enabled; DataContext dataContext = e.getDataContext(); Editor editor = dataContext.getData(CommonDataKeys.EDITOR); if (editor != null && FileDocumentManager.getInstance().getFile(editor.getDocument()) != null) { enabled = true; } else { List<PsiElement> elements = getElementsToCopy(editor, dataContext); enabled = !elements.isEmpty(); plural = elements.size() > 1; } e.getPresentation().setEnabled(enabled); if (ActionPlaces.isPopupPlace(e.getPlace())) { e.getPresentation().setVisible(enabled); } else { e.getPresentation().setVisible(true); } e.getPresentation().setText(plural ? "Cop&y References" : "Cop&y Reference"); }
Example #2
Source File: EmbeddedLinuxJVMConsoleView.java From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 | 6 votes |
/** * Creats the tool window content * @param toolWindow */ public void createToolWindowContent(@NotNull ToolWindow toolWindow) { //Create runner UI layout RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(project); RunnerLayoutUi layoutUi = factory.create("", "", "session", project); // Adding actions DefaultActionGroup group = new DefaultActionGroup(); layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN); Content console = layoutUi.createContent(EmbeddedLinuxJVMToolWindowFactory.ID, consoleView.getComponent(), "", null, null); AnAction[] consoleActions = consoleView.createConsoleActions(); for (AnAction action : consoleActions) { if (!shouldIgnoreAction(action)) { group.add(action); } } layoutUi.addContent(console, 0, PlaceInGrid.right, false); JComponent layoutComponent = layoutUi.getComponent(); myConsolePanel.add(layoutComponent, BorderLayout.CENTER); Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true); toolWindow.getContentManager().addContent(content); }
Example #3
Source File: ContextMenuPopupHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean handlePopup(@Nonnull EditorMouseEvent event) { ActionGroup group = getActionGroup(event); if (group != null) { ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group); MouseEvent e = event.getMouseEvent(); final Component c = e.getComponent(); if (c != null && c.isShowing()) { JPopupMenu popupComponent = popupMenu.getComponent(); EditorMouseHoverPopupControl.disablePopupsWhileShowing(event.getEditor(), popupComponent); popupComponent.show(c, e.getX(), e.getY()); event.consume(); } } return true; }
Example #4
Source File: MacDockDelegate.java From consulo with Apache License 2.0 | 6 votes |
@Override public void updateRecentProjectsMenu() { RecentProjectsManager projectsManager = RecentProjectsManager.getInstance(); if (projectsManager == null) return; final AnAction[] recentProjectActions = projectsManager.getRecentProjectsActions(false); recentProjectsMenu.removeAll(); for (final AnAction action : recentProjectActions) { MenuItem menuItem = new MenuItem(((ReopenProjectAction)action).getProjectName()); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { action.actionPerformed(AnActionEvent.createFromAnAction(action, null, ActionPlaces.DOCK_MENU, DataManager.getInstance().getDataContext((Component)null))); } }); recentProjectsMenu.add(menuItem); } }
Example #5
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 #6
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 #7
Source File: OpenCorrespondingBuildFile.java From intellij with Apache License 2.0 | 6 votes |
@Override protected void updateForBlazeProject(Project project, AnActionEvent e) { Presentation presentation = e.getPresentation(); DataContext dataContext = e.getDataContext(); VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext); BlazePackage blazePackage = BuildFileUtils.getBuildFile(project, virtualFile); if (blazePackage != null && virtualFile.equals(blazePackage.buildFile.getVirtualFile())) { presentation.setEnabledAndVisible(false); return; } boolean enabled = blazePackage != null; presentation.setVisible(enabled || !ActionPlaces.isPopupPlace(e.getPlace())); presentation.setEnabled(enabled); }
Example #8
Source File: BuckToolWindowFactory.java From Buck-IntelliJ-Plugin with Apache License 2.0 | 6 votes |
@Override public void createToolWindowContent( @NotNull final Project project, @NotNull ToolWindow toolWindow) { toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project); Content consoleContent = createConsoleContent(runnerLayoutUi, project); runnerLayoutUi.addContent(consoleContent, 0, PlaceInGrid.center, false); runnerLayoutUi.getOptions().setLeftToolbar( getLeftToolbarActions(project), ActionPlaces.UNKNOWN); runnerLayoutUi.updateActionsNow(); final ContentManager contentManager = toolWindow.getContentManager(); Content content = contentManager.getFactory().createContent( runnerLayoutUi.getComponent(), "", true); contentManager.addContent(content); updateBuckToolWindowTitle(project); }
Example #9
Source File: AbstractCommitChangesAction.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(final VcsContext vcsContext, final Presentation presentation) { super.update(vcsContext, presentation); if (presentation.isVisible() && presentation.isEnabled()) { final ChangeList[] selectedChangeLists = vcsContext.getSelectedChangeLists(); final Change[] selectedChanges = vcsContext.getSelectedChanges(); if (vcsContext.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) { if (selectedChangeLists != null && selectedChangeLists.length > 0) { presentation.setEnabled(selectedChangeLists.length == 1); } else { presentation.setEnabled (selectedChanges != null && selectedChanges.length > 0); } } if (presentation.isEnabled() && selectedChanges != null) { final ChangeListManager changeListManager = ChangeListManager.getInstance(vcsContext.getProject()); for(Change c: selectedChanges) { if (c.getFileStatus() == FileStatus.HIJACKED && changeListManager.getChangeList(c) == null) { presentation.setEnabled(false); break; } } } } }
Example #10
Source File: Notification.java From consulo with Apache License 2.0 | 6 votes |
public static void fire(@Nonnull final Notification notification, @Nonnull AnAction action, @Nullable DataContext context) { AnActionEvent event = AnActionEvent.createFromAnAction(action, null, ActionPlaces.UNKNOWN, new DataContext() { @Nullable @Override @SuppressWarnings("unchecked") public <T> T getData(@Nonnull Key<T> dataId) { if (KEY == dataId) { return (T)notification; } return context == null ? null : context.getData(dataId); } }); if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) { ActionUtil.performActionDumbAware(action, event); } }
Example #11
Source File: OpenAndroidModule.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { final VirtualFile projectFile = findProjectFile(e); if (projectFile == null) { FlutterMessages.showError("Error Opening Android Studio", "Project not found."); return; } final int modifiers = e.getModifiers(); // From ReopenProjectAction. final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK) || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK) || e.getPlace() == ActionPlaces.WELCOME_SCREEN; VirtualFile sourceFile = e.getData(CommonDataKeys.VIRTUAL_FILE); // Using: //ProjectUtil.openOrImport(projectFile.getPath(), e.getProject(), forceOpenInNewFrame); // presents the user with a really imposing Gradle project import dialog. openOrImportProject(projectFile, e.getProject(), sourceFile, forceOpenInNewFrame); }
Example #12
Source File: OpenAndroidModule.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { final VirtualFile projectFile = findProjectFile(e); if (projectFile == null) { FlutterMessages.showError("Error Opening Android Studio", "Project not found."); return; } final int modifiers = e.getModifiers(); // From ReopenProjectAction. final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK) || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK) || e.getPlace() == ActionPlaces.WELCOME_SCREEN; VirtualFile sourceFile = e.getData(CommonDataKeys.VIRTUAL_FILE); // Using: //ProjectUtil.openOrImport(projectFile.getPath(), e.getProject(), forceOpenInNewFrame); // presents the user with a really imposing Gradle project import dialog. openOrImportProject(projectFile, e.getProject(), sourceFile, forceOpenInNewFrame); }
Example #13
Source File: BrowseMethodHierarchyAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public final void update(final AnActionEvent event){ final Presentation presentation = event.getPresentation(); if (!ActionPlaces.MAIN_MENU.equals(event.getPlace())) { presentation.setText(IdeBundle.message("action.browse.method.hierarchy")); } super.update(event); }
Example #14
Source File: Java9DockDelegateImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void updateRecentProjectsMenu() { RecentProjectsManager projectsManager = RecentProjectsManager.getInstance(); final AnAction[] recentProjectActions = projectsManager.getRecentProjectsActions(false); recentProjectsMenu.removeAll(); for (final AnAction action : recentProjectActions) { MenuItem menuItem = new MenuItem(((ReopenProjectAction)action).getProjectName()); menuItem.addActionListener(e -> action.actionPerformed(AnActionEvent.createFromAnAction(action, null, ActionPlaces.DOCK_MENU, DataManager.getInstance().getDataContext((Component)null)))); recentProjectsMenu.add(menuItem); } }
Example #15
Source File: ShowDiffAction.java From consulo with Apache License 2.0 | 5 votes |
public void update(@Nonnull AnActionEvent e) { Change[] changes = e.getData(VcsDataKeys.CHANGES); Project project = e.getData(CommonDataKeys.PROJECT); if (ActionPlaces.MAIN_MENU.equals(e.getPlace())) { e.getPresentation().setEnabled(project != null && changes != null && changes.length > 0); } else { e.getPresentation().setEnabled(project != null && canShowDiff(project, changes)); } }
Example #16
Source File: ChooseLibrariesDialogBase.java From consulo with Apache License 2.0 | 5 votes |
@Override protected JComponent createNorthPanel() { final DefaultActionGroup group = new DefaultActionGroup(); final TreeExpander expander = new DefaultTreeExpander(myTree); final CommonActionsManager actionsManager = CommonActionsManager.getInstance(); group.add(actionsManager.createExpandAllAction(expander, myTree)); group.add(actionsManager.createCollapseAllAction(expander, myTree)); final JComponent component = ActionManager.getInstance().createActionToolbar(ActionPlaces.PROJECT_VIEW_TOOLBAR, group, true).getComponent(); component.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.darkGray), component.getBorder())); return component; }
Example #17
Source File: MoveChangesDialog.java From consulo with Apache License 2.0 | 5 votes |
@Override protected JComponent createCenterPanel() { JPanel panel = new JPanel(new BorderLayout()); panel.add(ScrollPaneFactory.createScrollPane(myTreeList), BorderLayout.CENTER); DefaultActionGroup actionGroup = new DefaultActionGroup(myTreeList.getTreeActions()); panel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true).getComponent(), BorderLayout.NORTH); myTreeList.expandAll(); myTreeList.repaint(); return panel; }
Example #18
Source File: ScheduleForAdditionAction.java From consulo with Apache License 2.0 | 5 votes |
public void update(@Nonnull AnActionEvent e) { boolean enabled = e.getProject() != null && !isEmpty(getUnversionedFiles(e, e.getProject())); e.getPresentation().setEnabled(enabled); if (ActionPlaces.ACTION_PLACE_VCS_QUICK_LIST_POPUP_ACTION.equals(e.getPlace()) || ActionPlaces.CHANGES_VIEW_POPUP.equals(e.getPlace())) { e.getPresentation().setVisible(enabled); } }
Example #19
Source File: BrowseCallHierarchyAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public final void update(final AnActionEvent event){ final Presentation presentation = event.getPresentation(); if (!ActionPlaces.MAIN_MENU.equals(event.getPlace())) { presentation.setText(IdeBundle.message("action.browse.call.hierarchy")); } super.update(event); }
Example #20
Source File: BaseShowDiffAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent e) { Presentation presentation = e.getPresentation(); boolean canShow = isAvailable(e); presentation.setEnabled(canShow); if (ActionPlaces.isPopupPlace(e.getPlace())) { presentation.setVisible(canShow); } }
Example #21
Source File: ToolbarPanel.java From consulo with Apache License 2.0 | 5 votes |
public ToolbarPanel(JComponent contentComponent, ActionGroup actions) { super(new GridBagLayout()); setBorder(new CustomLineBorder(1, 0, 0, 0)); if (contentComponent.getBorder() != null) { contentComponent.setBorder(BorderFactory.createEmptyBorder()); } final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actions, true); add(actionToolbar.getComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(contentComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); }
Example #22
Source File: SimplePasteAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { super.update(e); if (ActionPlaces.isPopupPlace(e.getPlace())) { Presentation presentation = e.getPresentation(); presentation.setVisible(presentation.isEnabled()); } }
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: 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 #25
Source File: ToggleUseSoftWrapsMenuAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e){ super.update(e); if (!ActionPlaces.isToolbarPlace(e.getPlace())) { e.getPresentation().setIcon(null); } e.getPresentation().setEnabled(getEditor(e) != null); }
Example #26
Source File: TabLabel.java From consulo with Apache License 2.0 | 5 votes |
private void handlePopup(final MouseEvent e) { if (e.getClickCount() != 1 || !e.isPopupTrigger()) return; if (e.getX() < 0 || e.getX() >= e.getComponent().getWidth() || e.getY() < 0 || e.getY() >= e.getComponent().getHeight()) { return; } String place = myTabs.getPopupPlace(); place = place != null ? place : ActionPlaces.UNKNOWN; myTabs.myPopupInfo = myInfo; final DefaultActionGroup toShow = new DefaultActionGroup(); if (myTabs.getPopupGroup() != null) { toShow.addAll(myTabs.getPopupGroup()); toShow.addSeparator(); } JBTabsImpl tabs = DataManager.getInstance().getDataContext(e.getComponent(), e.getX(), e.getY()).getData(JBTabsImpl.NAVIGATION_ACTIONS_KEY); if (tabs == myTabs && myTabs.myAddNavigationGroup) { toShow.addAll(myTabs.myNavigationActions); } if (toShow.getChildrenCount() == 0) return; myTabs.myActivePopup = myTabs.myActionManager.createActionPopupMenu(place, toShow).getComponent(); myTabs.myActivePopup.addPopupMenuListener(myTabs.myPopupListener); myTabs.myActivePopup.addPopupMenuListener(myTabs); myTabs.myActivePopup.show(e.getComponent(), e.getX(), e.getY()); }
Example #27
Source File: EditorNotificationPanel.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess protected void executeAction(final String actionId) { final AnAction action = ActionManager.getInstance().getAction(actionId); final AnActionEvent event = new AnActionEvent(null, DataManager.getInstance().getDataContext(this), ActionPlaces.UNKNOWN, action.getTemplatePresentation(), ActionManager.getInstance(), 0); action.beforeActionPerformedUpdate(event); action.update(event); if (event.getPresentation().isEnabled() && event.getPresentation().isVisible()) { action.actionPerformed(event); } }
Example #28
Source File: CheckForUpdateAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent e) { String place = e.getPlace(); if (ActionPlaces.WELCOME_SCREEN.equals(place)) { e.getPresentation().setEnabledAndVisible(true); } else { e.getPresentation().setVisible(!TopApplicationMenuUtil.isMacSystemMenu || !ActionPlaces.MAIN_MENU.equals(place)); } }
Example #29
Source File: RemoteFilePanel.java From consulo with Apache License 2.0 | 5 votes |
private void initToolbar(Project project) { DefaultActionGroup group = new DefaultActionGroup(); group.add(new RefreshRemoteFileAction(myVirtualFile)); for (RemoteFileEditorActionProvider actionProvider : RemoteFileEditorActionProvider.EP_NAME.getExtensions()) { group.addAll(actionProvider.createToolbarActions(project, myVirtualFile)); } final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); myToolbarPanel.add(actionToolbar.getComponent(), BorderLayout.CENTER); }
Example #30
Source File: InfoAndProgressPanel.java From consulo with Apache License 2.0 | 5 votes |
private void handle(MouseEvent e) { if (UIUtil.isActionClick(e, MouseEvent.MOUSE_PRESSED)) { if (!myPopup.isShowing()) { openProcessPopup(true); } else { hideProcessPopup(); } } else if (e.isPopupTrigger()) { ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction("BackgroundTasks"); ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group).getComponent().show(e.getComponent(), e.getX(), e.getY()); } }