public HierarchyBrowserBaseEx(@NotNull Project project, @NotNull PsiElement element) { super(project); setHierarchyBase(element); myCardLayout = new CardLayout(); myTreePanel = new JPanel(myCardLayout); createTrees(myType2TreeMap); final HierarchyBrowserManager.State state = HierarchyBrowserManager.getInstance(project).getState(); for (String type : myType2TreeMap.keySet()) { myType2ScopeMap.put(type, state.SCOPE != null ? state.SCOPE : SCOPE_ALL); } final Enumeration<String> keys = myType2TreeMap.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); final JTree tree = myType2TreeMap.get(key); myOccurrenceNavigators.put( key, new OccurenceNavigatorSupport(tree) { @Override @Nullable protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) { final HierarchyNodeDescriptor descriptor = getDescriptor(node); if (descriptor == null) return null; PsiElement psiElement = getOpenFileElementFromDescriptor(descriptor); if (psiElement == null || !psiElement.isValid()) return null; final VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile(); if (virtualFile == null) return null; return new OpenFileDescriptor( psiElement.getProject(), virtualFile, psiElement.getTextOffset()); } @Override public String getNextOccurenceActionName() { return getNextOccurenceActionNameImpl(); } @Override public String getPreviousOccurenceActionName() { return getPrevOccurenceActionNameImpl(); } }); myTreePanel.add(ScrollPaneFactory.createScrollPane(tree), key); } final JPanel legendPanel = createLegendPanel(); final JPanel contentPanel; if (legendPanel != null) { contentPanel = new JPanel(new BorderLayout()); contentPanel.add(myTreePanel, BorderLayout.CENTER); contentPanel.add(legendPanel, BorderLayout.SOUTH); } else { contentPanel = myTreePanel; } buildUi(createToolbar(getActionPlace(), HELP_ID).getComponent(), contentPanel); }
@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); } }
private void selectScope(final String scopeType) { myType2ScopeMap.put(myCurrentViewType, scopeType); HierarchyBrowserManager.getInstance(myProject).getState().SCOPE = scopeType; // invokeLater is called to update state of button before long tree building operation ApplicationManager.getApplication() .invokeLater( () -> { doRefresh( true); // scope is kept per type so other builders doesn't need to be refreshed }); }
@Override public final boolean isSelected(final AnActionEvent event) { return HierarchyBrowserManager.getInstance(myProject).getState().SORT_ALPHABETICALLY; }