Пример #1
0
 private UsageViewImpl getUsageView() {
   UsageViewImpl usageView = myUsageViewRef.get();
   if (usageView != null) return usageView;
   int usageCount = myUsageCountWithoutDefinition.get();
   if (usageCount >= 2 || usageCount == 1 && myProcessPresentation.isShowPanelIfOnlyOneUsage()) {
     usageView = new UsageViewImpl(myProject, myPresentation, mySearchFor, mySearcherFactory);
     if (myUsageViewRef.compareAndSet(null, usageView)) {
       openView(usageView);
       Usage firstUsage = myFirstUsage.get();
       if (firstUsage != null) {
         usageView.appendUsageLater(firstUsage);
       }
     } else {
       Disposer.dispose(usageView);
     }
     return myUsageViewRef.get();
   }
   return null;
 }
Пример #2
0
    private void endSearchForUsages() {
      int usageCount = myUsageCountWithoutDefinition.get();
      if (usageCount == 0 && myProcessPresentation.isShowNotFoundMessage()) {
        ApplicationManager.getApplication()
            .invokeLater(
                new Runnable() {
                  public void run() {
                    final List<Action> notFoundActions = myProcessPresentation.getNotFoundActions();
                    final String message =
                        UsageViewBundle.message(
                            "dialog.no.usages.found.in",
                            StringUtil.decapitalize(myPresentation.getUsagesString()),
                            myPresentation.getScopeText());

                    if (notFoundActions == null || notFoundActions.isEmpty()) {
                      ToolWindowManager.getInstance(myProject)
                          .notifyByBalloon(
                              ToolWindowId.FIND,
                              MessageType.INFO,
                              XmlStringUtil.escapeString(message),
                              IconLoader.getIcon("/actions/find.png"),
                              null);
                    } else {
                      List<String> titles = new ArrayList<String>(notFoundActions.size() + 1);
                      titles.add(UsageViewBundle.message("dialog.button.ok"));
                      for (Action action : notFoundActions) {
                        Object value =
                            action.getValue(FindUsagesProcessPresentation.NAME_WITH_MNEMONIC_KEY);
                        if (value == null) value = action.getValue(Action.NAME);

                        titles.add((String) value);
                      }

                      int option =
                          Messages.showDialog(
                              myProject,
                              message,
                              UsageViewBundle.message("dialog.title.information"),
                              titles.toArray(new String[titles.size()]),
                              0,
                              Messages.getInformationIcon());

                      if (option > 0) {
                        notFoundActions
                            .get(option - 1)
                            .actionPerformed(new ActionEvent(this, 0, titles.get(option)));
                      }
                    }
                  }
                },
                ModalityState.NON_MODAL,
                myProject.getDisposed());
      } else if (usageCount == 1 && !myProcessPresentation.isShowPanelIfOnlyOneUsage()) {
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                Usage usage = myFirstUsage.get();
                if (usage.canNavigate()) {
                  usage.navigate(true);
                  flashUsageScriptaculously(usage);
                }
              }
            });
      } else {
        final UsageViewImpl usageView = myUsageViewRef.get();
        if (usageView != null) usageView.setSearchInProgress(false);
      }

      if (myListener != null) {
        myListener.findingUsagesFinished(myUsageViewRef.get());
      }
    }