Java Code Examples for com.intellij.util.IconUtil#addText()

The following examples show how to use com.intellij.util.IconUtil#addText() . 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: ExecutorRegistryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private Icon getInformativeIcon(Project project, final RunnerAndConfigurationSettings selectedConfiguration) {
  final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);

  List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(s -> s == selectedConfiguration);
  runningDescriptors = ContainerUtil.filter(runningDescriptors, descriptor -> {
    RunContentDescriptor contentDescriptor = executionManager.getContentManager().findContentDescriptor(myExecutor, descriptor.getProcessHandler());
    return contentDescriptor != null && executionManager.getExecutors(contentDescriptor).contains(myExecutor);
  });

  if (!runningDescriptors.isEmpty() && DefaultRunExecutor.EXECUTOR_ID.equals(myExecutor.getId()) && selectedConfiguration.isSingleton()) {
    return AllIcons.Actions.Restart;
  }
  if (runningDescriptors.isEmpty()) {
    return TargetAWT.to(myExecutor.getIcon());
  }

  if (runningDescriptors.size() == 1) {
    return TargetAWT.to(ExecutionUtil.getIconWithLiveIndicator(myExecutor.getIcon()));
  }
  else {
    // FIXME [VISTALL] not supported by UI framework
    return IconUtil.addText(TargetAWT.to(myExecutor.getIcon()), String.valueOf(runningDescriptors.size()));
  }
}
 
Example 2
Source File: RunConfigurationsComboBoxAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void setConfigurationIcon(final Presentation presentation, final RunnerAndConfigurationSettings settings, final Project project) {
  try {
    Icon icon = TargetAWT.to(RunManagerEx.getInstanceEx(project).getConfigurationIcon(settings));
    ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);
    List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(s -> s == settings);
    if (runningDescriptors.size() == 1) {
      icon = ExecutionUtil.getLiveIndicator(icon);
    }
    // FIXME [VISTALL] not supported by UI framework
    if (runningDescriptors.size() > 1) {
      icon = IconUtil.addText(icon, String.valueOf(runningDescriptors.size()));
    }
    presentation.setIcon(icon);
  }
  catch (IndexNotReadyException ignored) {
  }
}
 
Example 3
Source File: StopAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(final AnActionEvent e) {
  boolean enable = false;
  Icon icon = getTemplatePresentation().getIcon();
  String description = getTemplatePresentation().getDescription();
  Presentation presentation = e.getPresentation();
  if (isPlaceGlobal(e)) {
    List<RunContentDescriptor> stoppableDescriptors = getActiveStoppableDescriptors(e.getDataContext());
    List<Pair<TaskInfo, ProgressIndicator>> cancellableProcesses = getCancellableProcesses(e.getProject());
    int todoSize = stoppableDescriptors.size() + cancellableProcesses.size();
    if (todoSize > 1) {
      presentation.setText(getTemplatePresentation().getText() + "...");
    }
    else if (todoSize == 1) {
      if (stoppableDescriptors.size() == 1) {
        presentation
                .setText(ExecutionBundle.message("stop.configuration.action.name", StringUtil.escapeMnemonics(stoppableDescriptors.get(0).getDisplayName())));
      }
      else {
        TaskInfo taskInfo = cancellableProcesses.get(0).first;
        presentation.setText(taskInfo.getCancelText() + " " + taskInfo.getTitle());
      }
    }
    else {
      presentation.setText(getTemplatePresentation().getText());
    }
    enable = todoSize > 0;
    if (todoSize > 1) {
      icon = IconUtil.addText(icon, String.valueOf(todoSize));
    }
  }
  else {
    RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
    ProcessHandler processHandler = contentDescriptor == null ? null : contentDescriptor.getProcessHandler();
    if (processHandler != null && !processHandler.isProcessTerminated()) {
      if (!processHandler.isProcessTerminating()) {
        enable = true;
      }
      else if (processHandler instanceof KillableProcess && ((KillableProcess)processHandler).canKillProcess()) {
        enable = true;
        icon = AllIcons.Debugger.KillProcess;
        description = "Kill process";
      }
    }

    RunProfile runProfile = e.getData(LangDataKeys.RUN_PROFILE);
    if (runProfile == null && contentDescriptor == null) {
      presentation.setText(getTemplatePresentation().getText());
    }
    else {
      presentation.setText(ExecutionBundle.message("stop.configuration.action.name", StringUtil
              .escapeMnemonics(runProfile == null ? contentDescriptor.getDisplayName() : runProfile.getName())));
    }
  }

  presentation.setEnabled(enable);
  presentation.setIcon(icon);
  presentation.setDescription(description);
}