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);
}
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;
}
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());
}
});
}
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);
}
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;
}
}
Aggregations