Search in sources :

Example 1 with AbstractTreeStructure

use of com.intellij.ide.util.treeView.AbstractTreeStructure in project intellij-community by JetBrains.

the class ToDoTreeStructureTest method testToDo.

//todo kirillk
public void testToDo() throws Exception {
    AllTodosTreeBuilder all = new AllTodosTreeBuilder(new Tree(), new DefaultTreeModel(new DefaultMutableTreeNode()), myProject);
    all.init();
    AbstractTreeStructure structure = all.getTreeStructure();
    ProjectViewTestUtil.assertStructureEqual(structure, "Root\n" + " Summary\n" + "  toDo\n" + "   xmlFile.xml\n" + "    Item: (12,16)\n" + "  package1 toDoFileCount=2,toDoItemCount=4\n" + "   package2 toDoFileCount=1,toDoItemCount=2\n" + "    JavaClass.java\n" + "     Item: (62,78)\n" + "     Item: (145,162)\n" + "   JavaClass.java\n" + "    Item: (52,68)\n" + "    Item: (134,151)\n" + "  package3 toDoFileCount=1,toDoItemCount=2\n" + "   JavaClass.java\n" + "    Item: (53,69)\n" + "    Item: (136,153)\n", myPrintInfo);
    checkOccurrences(all, new String[] { "Item: (12,16)", "Item: (62,78)", "Item: (145,162)", "Item: (52,68)", "Item: (134,151)", "Item: (53,69)", "Item: (136,153)" });
    final DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    final JTree currentFileTree = new Tree(treeModel);
    CurrentFileTodosTreeBuilder builder = new CurrentFileTodosTreeBuilder(currentFileTree, treeModel, myProject);
    builder.init();
    builder.setFile(getSrcDirectory().findSubdirectory("package1").findFile("JavaClass.java"));
    builder.updateFromRoot();
    ProjectViewTestUtil.assertStructureEqual(builder.getTreeStructure(), "JavaClass.java\n" + " JavaClass.java\n" + "  Item: (52,68)\n" + "  Item: (134,151)\n", myPrintInfo);
    Disposer.dispose(builder);
    Disposer.dispose(all);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AllTodosTreeBuilder(com.intellij.ide.todo.AllTodosTreeBuilder) Tree(com.intellij.ui.treeStructure.Tree) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure) CurrentFileTodosTreeBuilder(com.intellij.ide.todo.CurrentFileTodosTreeBuilder)

Example 2 with AbstractTreeStructure

use of com.intellij.ide.util.treeView.AbstractTreeStructure in project intellij-community by JetBrains.

the class SMTRunnerTreeBuilder method isAutoExpandNode.

protected boolean isAutoExpandNode(final NodeDescriptor nodeDescriptor) {
    final AbstractTreeStructure treeStructure = getTreeStructure();
    final Object rootElement = treeStructure.getRootElement();
    final Object nodeElement = nodeDescriptor.getElement();
    if (nodeElement == rootElement) {
        return true;
    }
    if (((SMTestProxy) nodeElement).getParent() == rootElement && ((SMTestProxy) rootElement).getChildren().size() == 1) {
        return true;
    }
    return false;
}
Also used : AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure)

Example 3 with AbstractTreeStructure

use of com.intellij.ide.util.treeView.AbstractTreeStructure in project intellij-community by JetBrains.

the class StructureTreeBuilder method addRootToUpdate.

final void addRootToUpdate() {
    final AbstractTreeStructure structure = getTreeStructure();
    structure.asyncCommit().doWhenDone(() -> {
        ((SmartTreeStructure) structure).rebuildTree();
        if (!isDisposed()) {
            getUpdater().addSubtreeToUpdate(getRootNode());
        }
    });
}
Also used : SmartTreeStructure(com.intellij.ide.util.treeView.smartTree.SmartTreeStructure) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure)

Example 4 with AbstractTreeStructure

use of com.intellij.ide.util.treeView.AbstractTreeStructure in project intellij-community by JetBrains.

the class ContentEntryTreeEditor method setContentEntryEditor.

/**
   * @param contentEntryEditor : null means to clear the editor
   */
public void setContentEntryEditor(final ContentEntryEditor contentEntryEditor) {
    if (myContentEntryEditor != null && myContentEntryEditor.equals(contentEntryEditor)) {
        return;
    }
    if (myFileSystemTree != null) {
        Disposer.dispose(myFileSystemTree);
        myFileSystemTree = null;
    }
    if (myContentEntryEditor != null) {
        myContentEntryEditor.removeContentEntryEditorListener(myContentEntryEditorListener);
        myContentEntryEditor = null;
    }
    if (contentEntryEditor == null) {
        ((DefaultTreeModel) myTree.getModel()).setRoot(EMPTY_TREE_ROOT);
        myTreePanel.setVisible(false);
        if (myFileSystemTree != null) {
            Disposer.dispose(myFileSystemTree);
        }
        return;
    }
    myTreePanel.setVisible(true);
    myContentEntryEditor = contentEntryEditor;
    myContentEntryEditor.addContentEntryEditorListener(myContentEntryEditorListener);
    final ContentEntry entry = contentEntryEditor.getContentEntry();
    assert entry != null : contentEntryEditor;
    final VirtualFile file = entry.getFile();
    if (file != null) {
        myDescriptor.setRoots(file);
    } else {
        String path = VfsUtilCore.urlToPath(entry.getUrl());
        myDescriptor.setTitle(FileUtil.toSystemDependentName(path));
    }
    final Runnable init = () -> {
        //noinspection ConstantConditions
        myFileSystemTree.updateTree();
        myFileSystemTree.select(file, null);
    };
    myFileSystemTree = new FileSystemTreeImpl(myProject, myDescriptor, myTree, getContentEntryCellRenderer(), init, null) {

        @Override
        protected AbstractTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, AbstractTreeStructure treeStructure, Comparator<NodeDescriptor> comparator, FileChooserDescriptor descriptor, final Runnable onInitialized) {
            return new MyFileTreeBuilder(tree, treeModel, treeStructure, comparator, descriptor, onInitialized);
        }
    };
    myFileSystemTree.showHiddens(true);
    Disposer.register(myProject, myFileSystemTree);
    final NewFolderAction newFolderAction = new MyNewFolderAction();
    final DefaultActionGroup mousePopupGroup = new DefaultActionGroup();
    mousePopupGroup.add(myEditingActionsGroup);
    mousePopupGroup.addSeparator();
    mousePopupGroup.add(newFolderAction);
    myFileSystemTree.registerMouseListener(mousePopupGroup);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AbstractTreeBuilder(com.intellij.ide.util.treeView.AbstractTreeBuilder) NodeDescriptor(com.intellij.ide.util.treeView.NodeDescriptor) FileSystemTreeImpl(com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl) NewFolderAction(com.intellij.openapi.fileChooser.actions.NewFolderAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ContentEntry(com.intellij.openapi.roots.ContentEntry) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure)

Example 5 with AbstractTreeStructure

use of com.intellij.ide.util.treeView.AbstractTreeStructure in project intellij-community by JetBrains.

the class PsiViewerDialog method findBlockNode.

@Nullable
private BlockTreeNode findBlockNode(TextRange range, boolean selectParentIfNotFound) {
    final BlockTreeBuilder builder = myBlockTreeBuilder;
    if (builder == null || !myBlockStructurePanel.isVisible()) {
        return null;
    }
    AbstractTreeStructure treeStructure = builder.getTreeStructure();
    if (treeStructure == null)
        return null;
    BlockTreeNode node = (BlockTreeNode) treeStructure.getRootElement();
    main_loop: while (true) {
        if (node.getBlock().getTextRange().equals(range)) {
            return node;
        }
        for (BlockTreeNode child : node.getChildren()) {
            if (child.getBlock().getTextRange().contains(range)) {
                node = child;
                continue main_loop;
            }
        }
        return selectParentIfNotFound ? node : null;
    }
}
Also used : BlockTreeBuilder(com.intellij.internal.psiView.formattingblocks.BlockTreeBuilder) BlockTreeNode(com.intellij.internal.psiView.formattingblocks.BlockTreeNode) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AbstractTreeStructure (com.intellij.ide.util.treeView.AbstractTreeStructure)14 AllTodosTreeBuilder (com.intellij.ide.todo.AllTodosTreeBuilder)2 SmartTreeStructure (com.intellij.ide.util.treeView.smartTree.SmartTreeStructure)2 Tree (com.intellij.ui.treeStructure.Tree)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 Nullable (org.jetbrains.annotations.Nullable)2 StructureView (com.intellij.ide.structureView.StructureView)1 StructureViewModel (com.intellij.ide.structureView.StructureViewModel)1 CurrentFileTodosTreeBuilder (com.intellij.ide.todo.CurrentFileTodosTreeBuilder)1 TodoTreeStructure (com.intellij.ide.todo.TodoTreeStructure)1 TodoItemNode (com.intellij.ide.todo.nodes.TodoItemNode)1 AbstractTreeBuilder (com.intellij.ide.util.treeView.AbstractTreeBuilder)1 NodeDescriptor (com.intellij.ide.util.treeView.NodeDescriptor)1 BlockTreeBuilder (com.intellij.internal.psiView.formattingblocks.BlockTreeBuilder)1 BlockTreeNode (com.intellij.internal.psiView.formattingblocks.BlockTreeNode)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ModalityState (com.intellij.openapi.application.ModalityState)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1