Java Code Examples for com.intellij.openapi.actionSystem.AnActionEvent#getPresentation()
The following examples show how to use
com.intellij.openapi.actionSystem.AnActionEvent#getPresentation() .
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: FlutterBuildActionGroup.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void actionPerformed(@NotNull AnActionEvent event) { Presentation presentation = event.getPresentation(); Project project = event.getProject(); if (project == null) { return; } FlutterSdk sdk = FlutterSdk.getFlutterSdk(project); if (sdk == null) { return; } PubRoot pubRoot = PubRoot.forEventWithRefresh(event); if (pubRoot == null) { return; } BuildType buildType = buildType(); build(project, pubRoot, sdk, buildType, presentation.getDescription()); }
Example 2
Source File: PasteFromX11Action.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor == null || !SystemInfo.isXWindow) { presentation.setEnabled(false); } else { boolean rightPlace = true; final InputEvent inputEvent = e.getInputEvent(); if (inputEvent instanceof MouseEvent) { rightPlace = false; final MouseEvent me = (MouseEvent)inputEvent; if (editor.getMouseEventArea(me) == EditorMouseEventArea.EDITING_AREA) { final Component component = SwingUtilities.getDeepestComponentAt(me.getComponent(), me.getX(), me.getY()); rightPlace = !(component instanceof JScrollBar); } } presentation.setEnabled(rightPlace); } }
Example 3
Source File: LocalHistoryAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(@Nonnull AnActionEvent e) { Presentation p = e.getPresentation(); if (e.getProject() == null) { p.setEnabledAndVisible(false); } else { p.setVisible(true); p.setText(getText(e), true); LocalHistoryFacade vcs = getVcs(); IdeaGateway gateway = getGateway(); p.setEnabled(vcs != null && gateway != null && isEnabled(vcs, gateway, e)); } }
Example 4
Source File: FlutterViewLocalToggleableAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public final void update(@NotNull AnActionEvent e) { // selected final boolean selected = this.isSelected(); final Presentation presentation = e.getPresentation(); presentation.putClientProperty("selected", selected); if (!app.isSessionActive()) { if (subscription != null) { subscription.dispose(); subscription = null; } e.getPresentation().setEnabled(false); return; } if (subscription == null) { subscription = stream.listen((value) -> { this.setSelected(e, value); }, true); } }
Example 5
Source File: ToggleWindowedModeAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent event) { super.update(event); Presentation presentation = event.getPresentation(); if (SystemInfo.isMac) { presentation.setEnabledAndVisible(false); return; } Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { presentation.setEnabled(false); return; } ToolWindowManager mgr = ToolWindowManager.getInstance(project); String id = mgr.getActiveToolWindowId(); presentation.setEnabled(id != null && mgr.getToolWindow(id).isAvailable()); }
Example 6
Source File: FileDeleteAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); final Boolean available = event.getData(FileChooserKeys.DELETE_ACTION_AVAILABLE); if (available != null && !available) { presentation.setEnabled(false); presentation.setVisible(false); return; } super.update(event); }
Example 7
Source File: RevertSelectedChangesAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setIcon(AllIcons.Actions.Rollback); presentation.setText(VcsBundle.message("action.revert.selected.changes.text")); super.update(e); presentation.setEnabled(allSelectedChangeListsAreRevertable(e)); }
Example 8
Source File: ShowLibraryFramesAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(@Nonnull final AnActionEvent e) { super.update(e); Presentation presentation = e.getPresentation(); Object isSupported = presentation.getClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED); XDebugSession session = e.getData(XDebugSession.DATA_KEY); if (isSupported == null) { if (session == null) { // if session is null and isSupported is null - just return, it means that action created initially not in the xdebugger tab presentation.setVisible(false); return; } isSupported = session.getDebugProcess().isLibraryFrameFilterSupported(); presentation.putClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED, isSupported); } if (Boolean.TRUE.equals(isSupported)) { presentation.setVisible(true); final boolean shouldShow = !Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY)); presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff); } else { presentation.setVisible(false); } }
Example 9
Source File: AddLibraryTargetDirectoryToProjectViewAction.java From intellij with Apache License 2.0 | 5 votes |
@Override protected void updateForBlazeProject(Project project, AnActionEvent e) { Presentation presentation = e.getPresentation(); boolean visible = false; boolean enabled = false; Library library = LibraryActionHelper.findLibraryForAction(e); if (library != null) { visible = true; if (getDirectoryToAddForLibrary(project, library) != null) { enabled = true; } } presentation.setVisible(visible); presentation.setEnabled(enabled); }
Example 10
Source File: NewFileAction.java From consulo with Apache License 2.0 | 5 votes |
protected void update(FileSystemTree fileSystemTree, AnActionEvent e) { Presentation presentation = e.getPresentation(); final FileType fileType = e.getData(FileChooserKeys.NEW_FILE_TYPE); if (fileType != null) { presentation.setVisible(true); VirtualFile selectedFile = fileSystemTree.getNewFileParent(); presentation.setEnabled(selectedFile != null && selectedFile.isDirectory()); presentation.setIcon(ImageEffects.layered(fileType.getIcon(), AllIcons.Actions.New)); } else { presentation.setVisible(false); } }
Example 11
Source File: OpenSelectedProjectsAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(@Nonnull AnActionEvent e) { final Presentation presentation = e.getPresentation(); List<AnAction> selectedElements = getSelectedElements(e); boolean hasProject = false; boolean hasGroup = false; for (AnAction element : selectedElements) { if (element instanceof ReopenProjectAction) { hasProject = true; } if (element instanceof ProjectGroupActionGroup) { hasGroup = true; } if (hasGroup && hasProject) { e.getPresentation().setEnabled(false); return; } } if (ActionPlaces.WELCOME_SCREEN.equals(e.getPlace())) { presentation.setEnabledAndVisible(true); if (selectedElements.size() == 1 && selectedElements.get(0) instanceof ProjectGroupActionGroup) { presentation.setText("Open All Projects in Group"); } else { presentation.setText("Open Selected"); } } else { presentation.setEnabledAndVisible(false); } }
Example 12
Source File: RestoreViewAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(final AnActionEvent e) { Presentation p = e.getPresentation(); p.setText(ActionsBundle.message("action.Runner.RestoreView.text", myContent.getDisplayName())); p.setDescription(ActionsBundle.message("action.Runner.RestoreView.description")); p.setIcon(myContent.getIcon()); }
Example 13
Source File: Unity3dShowMetaFileProjectViewPaneOptionProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override @RequiredUIAccess public void update(AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); final ProjectView projectView = ProjectView.getInstance(e.getProject()); presentation.setVisible(projectView.getCurrentProjectViewPane() == myPane && Unity3dModuleExtensionUtil.getRootModuleExtension(myPane.getProject()) != null); }
Example 14
Source File: ToggleDumbModeAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(final AnActionEvent e) { final Presentation presentation = e.getPresentation(); final Project project = e.getData(CommonDataKeys.PROJECT); presentation.setEnabled(project != null && myDumb == DumbServiceImpl.getInstance(project).isDumb()); if (myDumb) { presentation.setText("Exit Dumb Mode"); } else { presentation.setText("Enter Dumb Mode"); } }
Example 15
Source File: RevealFileAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { VirtualFile file = ShowFilePathAction.findLocalFile(e.getData(CommonDataKeys.VIRTUAL_FILE)); Presentation presentation = e.getPresentation(); presentation.setText(getActionName()); presentation.setEnabled(file != null); }
Example 16
Source File: FlutterViewLocalToggleableAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void actionPerformed(@NotNull AnActionEvent event) { this.setSelected(event, !isSelected()); final Presentation presentation = event.getPresentation(); presentation.putClientProperty("selected", isSelected()); super.actionPerformed(event); }
Example 17
Source File: FocusDebuggerAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(final AnActionEvent e) { final Presentation presentation = e.getPresentation(); if (myFocusDrawer == null) { presentation.setText("Start Focus Debugger"); } else { presentation.setText("Stop Focus Debugger"); } }
Example 18
Source File: TestRuleAction.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** Only show if selection is a grammar and in a rule */ @Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setText("Test ANTLR Rule"); // default text VirtualFile grammarFile = MyActionUtils.getGrammarFileFromEvent(e); if ( grammarFile==null ) { // we clicked somewhere outside text or non grammar file presentation.setEnabled(false); presentation.setVisible(false); return; } ParserRuleRefNode r = null; InputEvent inputEvent = e.getInputEvent(); if ( inputEvent instanceof MouseEvent ) { // this seems to be after update() called 2x and we have selected the action r = MyActionUtils.getParserRuleSurroundingRef(e); } else { // If editor component, mouse event not happened yet to update caret so must ask for mouse position Editor editor = e.getData(PlatformDataKeys.EDITOR); if ( editor!=null ) { Point mousePosition = editor.getContentComponent().getMousePosition(); if ( mousePosition!=null ) { LogicalPosition pos = editor.xyToLogicalPosition(mousePosition); int offset = editor.logicalPositionToOffset(pos); PsiFile file = e.getData(LangDataKeys.PSI_FILE); if ( file!=null ) { PsiElement el = file.findElementAt(offset); if ( el!=null ) { r = MyActionUtils.getParserRuleSurroundingRef(el); } } } } if ( r==null ) { r = MyActionUtils.getParserRuleSurroundingRef(e); } } if ( r==null ) { presentation.setEnabled(false); return; } presentation.setVisible(true); String ruleName = r.getText(); if ( Character.isLowerCase(ruleName.charAt(0)) ) { presentation.setEnabled(true); presentation.setText("Test Rule "+ruleName); } else { presentation.setEnabled(false); } }
Example 19
Source File: MoveModulesToSubGroupAction.java From consulo with Apache License 2.0 | 4 votes |
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); String description = IdeBundle.message("action.description.create.new.module.group"); presentation.setDescription(description); }
Example 20
Source File: RecentProjectsGroup.java From consulo with Apache License 2.0 | 4 votes |
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); presentation.setEnabled(RecentProjectsManagerBase.getInstance().getRecentProjectsActions(true).length > 0); }