Java Code Examples for com.intellij.openapi.actionSystem.Presentation#setDescription()

The following examples show how to use com.intellij.openapi.actionSystem.Presentation#setDescription() . 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: OpenInAndroidStudioAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void updatePresentation(AnActionEvent event, Presentation state) {
  if (findProjectFile(event) == null) {
    state.setVisible(false);
  }
  else {
    VirtualFile file = event.getData(CommonDataKeys.VIRTUAL_FILE);
    String label, descr;
    if (file != null && !file.isDirectory()) {
      // The file will be opened in an editor in the new IDE window.
      label = LABEL_FILE;
      descr = DESCR_FILE;
    }
    else {
      // The new IDE window will be opened on the Android module but there is no file selected for editing.
      label = LABEL_MODULE;
      descr = DESCR_MODULE;
    }
    state.setVisible(true);
    state.setText(label);
    state.setDescription(descr);
  }
}
 
Example 2
Source File: OpenInAndroidStudioAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void updatePresentation(AnActionEvent event, Presentation state) {
  if (findProjectFile(event) == null) {
    state.setVisible(false);
  }
  else {
    VirtualFile file = event.getData(CommonDataKeys.VIRTUAL_FILE);
    String label, descr;
    if (file != null && !file.isDirectory()) {
      // The file will be opened in an editor in the new IDE window.
      label = LABEL_FILE;
      descr = DESCR_FILE;
    }
    else {
      // The new IDE window will be opened on the Android module but there is no file selected for editing.
      label = LABEL_MODULE;
      descr = DESCR_MODULE;
    }
    state.setVisible(true);
    state.setText(label);
    state.setDescription(descr);
  }
}
 
Example 3
Source File: StopProcessAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void update(@Nonnull Presentation presentation,
                          @Nonnull Presentation templatePresentation,
                          @Nullable ProcessHandler processHandler) {
  boolean enable = false;
  Icon icon = templatePresentation.getIcon();
  String description = templatePresentation.getDescription();
  if (processHandler != null && !processHandler.isProcessTerminated()) {
    enable = true;
    if (processHandler.isProcessTerminating() && processHandler instanceof KillableProcess) {
      KillableProcess killableProcess = (KillableProcess) processHandler;
      if (killableProcess.canKillProcess()) {
        // 'force quite' action presentation
        icon = AllIcons.Debugger.KillProcess;
        description = "Kill process";
      }
    }
  }
  presentation.setEnabled(enable);
  presentation.setIcon(icon);
  presentation.setDescription(description);
}
 
Example 4
Source File: UndoRedoAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 5
Source File: FavoritesCompactEmptyMiddlePackagesAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: BlazeProblemsViewPanel.java    From intellij with Apache License 2.0 5 votes vote down vote up
protected OpenInConsoleAction() {
  super(true);
  Presentation presentation = getTemplatePresentation();
  presentation.setText("Jump to console");
  presentation.setDescription("Open console view and navigate to the selected problem");
  presentation.setIcon(AllIcons.Actions.EditSource);
}
 
Example 7
Source File: NewBlazePackageAction.java    From intellij with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: GotoTestOrCodeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: RestoreViewAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: UpdateRoutesListAction.java    From railways with MIT License 5 votes vote down vote up
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: IgnoreFileGroupAction.java    From idea-gitignore with MIT License 5 votes vote down vote up
/**
 * Builds a new instance of {@link IgnoreFileGroupAction}.
 * Describes action's presentation.
 *
 * @param textKey        Action presentation's text key
 * @param descriptionKey Action presentation's description key
 */
public IgnoreFileGroupAction(@PropertyKey(resourceBundle = BUNDLE_NAME) String textKey,
                             @PropertyKey(resourceBundle = BUNDLE_NAME) String descriptionKey,
                             @PropertyKey(resourceBundle = BUNDLE_NAME) String textSingleKey) {
    final Presentation p = getTemplatePresentation();
    p.setText(IgnoreBundle.message(textKey));
    p.setDescription(IgnoreBundle.message(descriptionKey));
    this.presentationTextSingleKey = textSingleKey;
}
 
Example 12
Source File: CloseTabToolbarAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public CloseTabToolbarAction() {
  copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_CLOSE_ACTIVE_TAB));
  Presentation presentation = getTemplatePresentation();
  presentation.setIcon(AllIcons.Actions.Cancel);
  presentation.setText(CommonBundle.getCloseButtonText());
  presentation.setDescription(null);
}
 
Example 13
Source File: InstallPluginAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  PluginDescriptor[] selection = getPluginTable().getSelectedObjects();
  boolean enabled = (selection != null);

  if (enabled) {
    for (PluginDescriptor descr : selection) {
      presentation.setText(IdeBundle.message("action.download.and.install.plugin"));
      presentation.setDescription(IdeBundle.message("action.download.and.install.plugin"));
      enabled &= !ourInstallingNodes.contains(descr);
      if (descr instanceof PluginNode) {
        enabled &= !PluginManagerColumnInfo.isDownloaded(descr);
        if (((PluginNode)descr).getStatus() == PluginNode.STATUS_INSTALLED) {
          presentation.setText(IdeBundle.message("action.update.plugin"));
          presentation.setDescription(IdeBundle.message("action.update.plugin"));
          enabled &= InstalledPluginsTableModel.hasNewerVersion(descr.getPluginId());
        }
      }
      else if (descr.isLoaded()) {
        presentation.setText(IdeBundle.message("action.update.plugin"));
        presentation.setDescription(IdeBundle.message("action.update.plugin"));
        PluginId id = descr.getPluginId();
        enabled = enabled && InstalledPluginsTableModel.hasNewerVersion(id);
      }
    }
  }

  presentation.setEnabled(enabled);
}
 
Example 14
Source File: MoveModulesToSubGroupAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  String description = IdeBundle.message("action.description.create.new.module.group");
  presentation.setDescription(description);
}
 
Example 15
Source File: ChooseTargetAction.java    From buck with Apache License 2.0 4 votes vote down vote up
public ChooseTargetAction() {
  Presentation presentation = this.getTemplatePresentation();
  presentation.setText(ACTION_TITLE);
  presentation.setDescription(ACTION_DESCRIPTION);
  presentation.setIcon(BuckIcons.ACTION_FIND);
}
 
Example 16
Source File: ChooseTargetAction.java    From Buck-IntelliJ-Plugin with Apache License 2.0 4 votes vote down vote up
public ChooseTargetAction() {
  Presentation presentation = this.getTemplatePresentation();
  presentation.setText(ACTION_TITLE);
  presentation.setDescription(ACTION_DESCRIPTION);
  presentation.setIcon(AllIcons.Actions.Preview);
}
 
Example 17
Source File: ReplaceActionHelper.java    From intellij with Apache License 2.0 4 votes vote down vote up
private static void applyPresentation(
    Presentation presentation, Presentation templatePresentation) {
  presentation.restoreTextWithMnemonic(templatePresentation);
  presentation.setDescription(templatePresentation.getDescription());
  presentation.setIcon(templatePresentation.getIcon());
}
 
Example 18
Source File: FlutterPopFrameAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
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 19
Source File: FlutterPopFrameAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
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);
}