@NotNull
 public static FindUsagesProcessPresentation setupProcessPresentation(
     @NotNull final Project project,
     final boolean showPanelIfOnlyOneUsage,
     @NotNull final UsageViewPresentation presentation) {
   FindUsagesProcessPresentation processPresentation =
       new FindUsagesProcessPresentation(presentation);
   processPresentation.setShowNotFoundMessage(true);
   processPresentation.setShowPanelIfOnlyOneUsage(showPanelIfOnlyOneUsage);
   processPresentation.setProgressIndicatorFactory(
       () -> new FindProgressIndicator(project, presentation.getScopeText()));
   return processPresentation;
 }
Esempio n. 2
0
  public UsageView searchAndShowUsages(
      @NotNull final UsageTarget[] searchFor,
      final Factory<UsageSearcher> searcherFactory,
      final boolean showPanelIfOnlyOneUsage,
      final boolean showNotFoundMessage,
      @NotNull final UsageViewPresentation presentation,
      final UsageViewStateListener listener) {
    final AtomicReference<UsageViewImpl> usageView = new AtomicReference<UsageViewImpl>();

    final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation();
    processPresentation.setShowNotFoundMessage(showNotFoundMessage);
    processPresentation.setShowPanelIfOnlyOneUsage(showPanelIfOnlyOneUsage);

    Task task =
        new Task.Backgroundable(
            myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) {
          public void run(@NotNull final ProgressIndicator indicator) {
            new SearchForUsagesRunnable(
                    usageView,
                    presentation,
                    searchFor,
                    searcherFactory,
                    processPresentation,
                    listener)
                .run();
          }

          @Override
          public DumbModeAction getDumbModeAction() {
            return DumbModeAction.CANCEL;
          }

          @Nullable
          public NotificationInfo getNotificationInfo() {
            String notification =
                usageView.get() != null
                    ? usageView.get().getUsagesCount() + " Usage(s) Found"
                    : "No Usages Found";
            return new NotificationInfo("Find Usages", "Find Usages Finished", notification);
          }
        };
    ProgressManager.getInstance().run(task);
    return usageView.get();
  }