コード例 #1
0
  private static UsageGroupingRule[] getActiveGroupingRules(final Project project) {
    final UsageGroupingRuleProvider[] providers =
        Extensions.getExtensions(UsageGroupingRuleProvider.EP_NAME);
    List<UsageGroupingRule> list = new ArrayList<UsageGroupingRule>(providers.length);
    for (UsageGroupingRuleProvider provider : providers) {
      ContainerUtil.addAll(list, provider.getActiveRules(project));
    }

    Collections.sort(
        list,
        new Comparator<UsageGroupingRule>() {
          @Override
          public int compare(final UsageGroupingRule o1, final UsageGroupingRule o2) {
            return getRank(o1) - getRank(o2);
          }

          private int getRank(final UsageGroupingRule rule) {
            if (rule instanceof OrderableUsageGroupingRule) {
              return ((OrderableUsageGroupingRule) rule).getRank();
            }

            return Integer.MAX_VALUE;
          }
        });

    return list.toArray(new UsageGroupingRule[list.size()]);
  }
コード例 #2
0
 @Override
 @NotNull
 public List<Usage> getSortedUsages() {
   List<Usage> usages = new ArrayList<Usage>(getUsages());
   Collections.sort(usages, USAGE_COMPARATOR);
   return usages;
 }
コード例 #3
0
 private void rulesChanged() {
   ApplicationManager.getApplication().assertIsDispatchThread();
   final ArrayList<UsageState> states = new ArrayList<UsageState>();
   captureUsagesExpandState(new TreePath(myTree.getModel().getRoot()), states);
   final List<Usage> allUsages = new ArrayList<Usage>(myUsageNodes.keySet());
   Collections.sort(allUsages, USAGE_COMPARATOR);
   final Set<Usage> excludedUsages = getExcludedUsages();
   reset();
   myBuilder.setGroupingRules(getActiveGroupingRules(myProject));
   myBuilder.setFilteringRules(getActiveFilteringRules(myProject));
   ApplicationManager.getApplication()
       .runReadAction(
           new Runnable() {
             @Override
             public void run() {
               for (Usage usage : allUsages) {
                 if (!usage.isValid()) {
                   continue;
                 }
                 if (usage instanceof MergeableUsage) {
                   ((MergeableUsage) usage).reset();
                 }
                 appendUsage(usage);
               }
             }
           });
   excludeUsages(excludedUsages.toArray(new Usage[excludedUsages.size()]));
   if (myCentralPanel != null) {
     setupCentralPanel();
   }
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           if (isDisposed) return;
           restoreUsageExpandState(states);
           updateImmediately();
         }
       });
 }