Java Code Examples for com.intellij.openapi.actionSystem.Presentation#setText()
The following examples show how to use
com.intellij.openapi.actionSystem.Presentation#setText() .
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: FlutterRetargetAppAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); final Project project = e.getProject(); if (project == null || !FlutterModuleUtils.hasFlutterModule(project) || !myPlaces.contains(e.getPlace())) { presentation.setVisible(false); return; } presentation.setVisible(true); presentation.setEnabled(false); // Retargeted actions defer to their targets for presentation updates. final AnAction action = getAction(project); if (action != null) { final Presentation template = action.getTemplatePresentation(); final String text = template.getTextWithMnemonic(); if (text != null) { presentation.setText(text, true); } action.update(e); } }
Example 2
Source File: AttachSourceJarAction.java From intellij with Apache License 2.0 | 6 votes |
@Override protected void updateForBlazeProject(Project project, AnActionEvent e) { Presentation presentation = e.getPresentation(); BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (projectData == null) { hideAction(presentation); return; } BlazeJarLibrary library = LibraryActionHelper.findBlazeLibraryForAction(project, e); if (library == null || library.libraryArtifact.getSourceJars().isEmpty()) { hideAction(presentation); return; } presentation.setEnabledAndVisible(true); boolean attached = AttachedSourceJarManager.getInstance(project).hasSourceJarAttached(library.key); presentation.setText(attached ? "Detach Source Jar" : "Attach Source Jar"); }
Example 3
Source File: UndoRedoAction.java From consulo with Apache License 2.0 | 6 votes |
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); DataContext dataContext = event.getDataContext(); FileEditor editor = event.getData(PlatformDataKeys.FILE_EDITOR); // do not allow global undo in dialogs if (editor == null) { final Boolean isModalContext = event.getData(PlatformDataKeys.IS_MODAL_CONTEXT); if (isModalContext != null && isModalContext) { presentation.setEnabled(false); return; } } UndoManager undoManager = getUndoManager(editor, dataContext); if (undoManager == null) { presentation.setEnabled(false); return; } presentation.setEnabled(isAvailable(editor, undoManager)); Pair<String, String> pair = getActionNameAndDescription(editor, undoManager); presentation.setText(pair.first); presentation.setDescription(pair.second); }
Example 4
Source File: Action.java From GitLink with MIT License | 6 votes |
@Override public void update(@NotNull final AnActionEvent event) { super.update(event); if (event.getProject() == null) { event.getPresentation().setEnabled(false); return; } Presentation presentation = event.getPresentation(); Preferences preferences = Preferences.getInstance(event.getProject()); if (!preferences.isEnabled()) { presentation.setEnabledAndVisible(false); return; } RemoteHost remoteHost = preferences.getRemoteHost(); presentation.setText(this.displayName(remoteHost)); presentation.setIcon(remoteHost.icon()); presentation.setEnabledAndVisible(this.shouldActionBeEnabled(event)); }
Example 5
Source File: AbstractCommonCheckinAction.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(@Nonnull VcsContext vcsContext, @Nonnull Presentation presentation) { Project project = vcsContext.getProject(); if (project == null || !ProjectLevelVcsManager.getInstance(project).hasActiveVcss()) { presentation.setEnabledAndVisible(false); } else if (!approximatelyHasRoots(vcsContext)) { presentation.setEnabled(false); } else { presentation.setText(getActionName(vcsContext) + "..."); presentation.setEnabled(!ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning()); presentation.setVisible(true); } }
Example 6
Source File: FavoritesCompactEmptyMiddlePackagesAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void updateButton(AnActionEvent e) { super.updateButton(e); Presentation presentation = e.getPresentation(); if (getViewSettings().isFlattenPackages()) { presentation.setText(IdeBundle.message("action.hide.empty.middle.packages")); presentation.setDescription(IdeBundle.message("action.show.hide.empty.middle.packages")); } else { presentation.setText(IdeBundle.message("action.compact.empty.middle.packages")); presentation.setDescription(IdeBundle.message("action.show.compact.empty.middle.packages")); } }
Example 7
Source File: PackAndPutIntoDefaultLocationAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { final String jarName = suggestJarName(); final String pathForJars = myArtifactEditor.getArtifact().getArtifactType().getDefaultPathFor(PackagingElementOutputKind.JAR_FILES); final Presentation presentation = e.getPresentation(); if (jarName != null && pathForJars != null) { presentation.setText("Pack Into " + DeploymentUtil.appendToPath(pathForJars, jarName + ".jar")); presentation.setVisible(true); } else { presentation.setVisible(false); } }
Example 8
Source File: ShowLogAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setVisible(ShowFilePathAction.isSupported()); presentation.setText(getActionName()); }
Example 9
Source File: MyActionUtils.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Only show if selection is a lexer or parser rule */ public static void showOnlyIfSelectionIsRule(AnActionEvent e, String title) { Presentation presentation = e.getPresentation(); VirtualFile grammarFile = getGrammarFileFromEvent(e); if ( grammarFile==null ) { presentation.setEnabled(false); return; } PsiElement el = getSelectedPsiElement(e); if ( el==null ) { presentation.setEnabled(false); return; } ParserRuleRefNode parserRule = getParserRuleSurroundingRef(e); LexerRuleRefNode lexerRule = getLexerRuleSurroundingRef(e); if ( (lexerRule!=null && el instanceof LexerRuleRefNode) || (parserRule!=null && el instanceof ParserRuleRefNode) ) { String ruleName = el.getText(); presentation.setText(String.format(title,ruleName)); } else { presentation.setEnabled(false); } }
Example 10
Source File: UpdateRoutesListAction.java From railways with MIT License | 5 votes |
private static void updatePresentation(@NotNull Project project, Presentation presentation) { RoutesManager rm = RoutesView.getInstance(project).getCurrentRoutesManager(); if (rm == null) return; if (rm.isUpdating()) { presentation.setIcon(RailwaysIcons.SUSPEND); presentation.setText("Cancel Route List Update"); presentation.setDescription("Stops updating the list of routes"); } else { presentation.setIcon(RailwaysIcons.UPDATE); presentation.setText("Update Route List"); presentation.setDescription("Update the list of routes"); } }
Example 11
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 12
Source File: NewBlazePackageAction.java From intellij with Apache License 2.0 | 5 votes |
@Override protected void updateForBlazeProject(Project project, AnActionEvent event) { Presentation presentation = event.getPresentation(); String buildSystem = Blaze.buildSystemName(project); presentation.setEnabledAndVisible(isEnabled(event)); presentation.setText(String.format("%s Package", buildSystem)); presentation.setDescription(String.format("Create a new %s package", buildSystem)); presentation.setIcon(PlatformIcons.PACKAGE_ICON); }
Example 13
Source File: GotoTestOrCodeAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void update(AnActionEvent event) { Presentation p = event.getPresentation(); if (TestFinderHelper.getFinders().length == 0) { p.setVisible(false); return; } p.setEnabled(false); Project project = event.getData(CommonDataKeys.PROJECT); Editor editor = event.getData(PlatformDataKeys.EDITOR); if (editor == null || project == null) return; PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project); if (psiFile == null) return; PsiElement element = GotoTestOrCodeHandler.getSelectedElement(editor, psiFile); if (TestFinderHelper.findSourceElement(element) == null) return; p.setEnabled(true); if (TestFinderHelper.isTest(element)) { p.setText(ActionsBundle.message("action.GotoTestSubject.text")); p.setDescription(ActionsBundle.message("action.GotoTestSubject.description")); } else { p.setText(ActionsBundle.message("action.GotoTest.text")); p.setDescription(ActionsBundle.message("action.GotoTest.description")); } }
Example 14
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 15
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 16
Source File: GoToBuckFile.java From buck with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); VirtualFile buckFile = findBuckFile(e.getProject()); if (buckFile == null) { presentation.setEnabledAndVisible(false); } else { presentation.setText("Go to " + buckFile.getName() + " file"); presentation.setEnabledAndVisible(true); } }
Example 17
Source File: FakeRerunAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent event) { Presentation presentation = event.getPresentation(); ExecutionEnvironment environment = getEnvironment(event); if (environment != null) { presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", environment.getRunProfile().getName())); presentation.setIcon(ExecutionManagerImpl.isProcessRunning(getDescriptor(event)) ? AllIcons.Actions.Restart : environment.getExecutor().getIcon()); presentation.setEnabled(isEnabled(event)); return; } presentation.setEnabled(false); }
Example 18
Source File: IgnoreFileGroupAction.java From idea-gitignore with MIT License | 5 votes |
/** * Creates subactions bound to the specified Gitignore {@link VirtualFile}s using {@link IgnoreFileAction}. * * @param e action event * @return actions list */ @NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { AnAction[] actions; int count = countFiles(); if (count == 0 || baseDir == null) { actions = new AnAction[0]; } else { actions = new AnAction[count]; final Project project = getEventProject(e); int i = 0; for (Map.Entry<IgnoreFileType, List<VirtualFile>> entry : files.entrySet()) { for (VirtualFile file : entry.getValue()) { IgnoreFileAction action = createAction(file); actions[i++] = action; VirtualFile directory = project == null ? null : Utils.getModuleRootForFile(file, project); String name = directory == null ? file.getName() : Utils.getRelativePath(directory, file); if (StringUtil.isNotEmpty(name)) { name = StringUtil.shortenPathWithEllipsis(name, FILENAME_MAX_LENGTH); } if (count == 1) { name = IgnoreBundle.message(presentationTextSingleKey, name); } Presentation presentation = action.getTemplatePresentation(); presentation.setIcon(entry.getKey().getIcon()); presentation.setText(name); } } } return actions; }
Example 19
Source File: FlutterPopFrameAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
public FlutterPopFrameAction() { final Presentation presentation = getTemplatePresentation(); presentation.setText(FlutterBundle.message("flutter.pop.frame.action.text")); presentation.setDescription(FlutterBundle.message("flutter.pop.frame.action.description")); presentation.setIcon(AllIcons.Actions.PopFrame); }
Example 20
Source File: CreateAction.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void updateText(final Presentation presentation, final String actionText) { presentation.setText(actionText.length() > 0 ? ExecutionBundle.message("create.run.configuration.for.item.action.name", actionText) + "..." : ExecutionBundle.message("create.run.configuration.action.name"), false); }