コード例 #1
0
  void doRefresh(boolean currentBuilderOnly) {
    if (currentBuilderOnly) LOG.assertTrue(myCurrentViewType != null);

    if (!isValidBase()) return;

    if (getCurrentBuilder() == null) return; // seems like we are in the middle of refresh already

    final Ref<Pair<List<Object>, List<Object>>> storedInfo =
        new Ref<Pair<List<Object>, List<Object>>>();
    if (myCurrentViewType != null) {
      final HierarchyTreeBuilder builder = getCurrentBuilder();
      storedInfo.set(builder.storeExpandedAndSelectedInfo());
    }

    final PsiElement element = mySmartPsiElementPointer.getElement();
    if (element == null || !isApplicableElement(element)) {
      return;
    }
    final String currentViewType = myCurrentViewType;

    if (currentBuilderOnly) {
      Disposer.dispose(getCurrentBuilder());
    } else {
      disposeBuilders();
    }
    setHierarchyBase(element);
    validate();
    ApplicationManager.getApplication()
        .invokeLater(
            () -> {
              changeView(currentViewType);
              final HierarchyTreeBuilder builder = getCurrentBuilder();
              builder.restoreExpandedAndSelectedInfo(storedInfo.get());
            });
  }
コード例 #2
0
 @Override
 public final void setSelected(final AnActionEvent event, final boolean flag) {
   final HierarchyBrowserManager hierarchyBrowserManager =
       HierarchyBrowserManager.getInstance(myProject);
   hierarchyBrowserManager.getState().SORT_ALPHABETICALLY = flag;
   final Comparator<NodeDescriptor> comparator = getComparator();
   final Collection<HierarchyTreeBuilder> builders = myBuilders.values();
   for (final HierarchyTreeBuilder builder : builders) {
     builder.setNodeDescriptorComparator(comparator);
   }
 }
コード例 #3
0
  public final void changeView(@NotNull final String typeName) {
    myCurrentViewType = typeName;

    final PsiElement element = mySmartPsiElementPointer.getElement();
    if (element == null || !isApplicableElement(element)) {
      return;
    }

    if (myContent != null) {
      final String displayName = getContentDisplayName(typeName, element);
      if (displayName != null) {
        myContent.setDisplayName(displayName);
      }
    }

    myCardLayout.show(myTreePanel, typeName);

    if (!myBuilders.containsKey(typeName)) {
      try {
        setWaitCursor();
        // create builder
        final JTree tree = myType2TreeMap.get(typeName);
        final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode(""));
        tree.setModel(model);

        final HierarchyTreeStructure structure = createHierarchyTreeStructure(typeName, element);
        if (structure == null) {
          return;
        }
        final Comparator<NodeDescriptor> comparator = getComparator();
        final HierarchyTreeBuilder builder =
            new HierarchyTreeBuilder(myProject, tree, model, structure, comparator);

        myBuilders.put(typeName, builder);
        Disposer.register(this, builder);
        Disposer.register(builder, () -> myBuilders.remove(typeName));

        final HierarchyNodeDescriptor descriptor = structure.getBaseDescriptor();
        builder.select(descriptor, () -> builder.expand(descriptor, null));
      } finally {
        restoreCursor();
      }
    }

    getCurrentTree().requestFocus();
  }