use of com.intellij.ui.treeStructure.Tree in project intellij-community by JetBrains.
the class RepositoryBrowserComponent method createComponent.
private void createComponent() {
setLayout(new BorderLayout());
myRepositoryTree = new Tree();
myRepositoryTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
myRepositoryTree.setRootVisible(false);
myRepositoryTree.setShowsRootHandles(true);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myRepositoryTree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(scrollPane, BorderLayout.CENTER);
myRepositoryTree.setCellRenderer(new SvnRepositoryTreeCellRenderer());
TreeSpeedSearch search = new TreeSpeedSearch(myRepositoryTree, o -> {
Object component = o.getLastPathComponent();
if (component instanceof RepositoryTreeNode) {
return ((RepositoryTreeNode) component).getURL().toDecodedString();
}
return null;
});
search.setComparator(new SpeedSearchComparator(false, true));
EditSourceOnDoubleClickHandler.install(myRepositoryTree);
}
use of com.intellij.ui.treeStructure.Tree in project intellij-community by JetBrains.
the class ExistingTemplatesComponent method createTree.
private static Tree createTree(TreeModel treeModel) {
final Tree tree = new Tree(treeModel);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.setDragEnabled(false);
tree.setEditable(false);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
final TreeSpeedSearch speedSearch = new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
public String convert(TreePath object) {
final Object userObject = ((DefaultMutableTreeNode) object.getLastPathComponent()).getUserObject();
return (userObject instanceof Configuration) ? ((Configuration) userObject).getName() : userObject.toString();
}
});
tree.setCellRenderer(new ExistingTemplatesTreeCellRenderer(speedSearch));
return tree;
}
use of com.intellij.ui.treeStructure.Tree in project intellij-community by JetBrains.
the class DetailsComponentTest method main.
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
final JPanel content = new JPanel(new BorderLayout());
final DetailsComponent d = new DetailsComponent();
content.add(d.getComponent(), BorderLayout.CENTER);
d.setText("This is a Tree");
final JTree c = new Tree();
c.setBorder(new LineBorder(Color.red));
d.setContent(c);
frame.getContentPane().add(content, BorderLayout.CENTER);
final JCheckBox details = new JCheckBox("Details");
details.setSelected(true);
frame.getContentPane().add(details, BorderLayout.SOUTH);
details.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
d.setDetailsModeEnabled(details.isSelected());
}
});
frame.setBounds(300, 300, 300, 300);
frame.show();
}
use of com.intellij.ui.treeStructure.Tree 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.ui.treeStructure.Tree in project intellij-community by JetBrains.
the class AntExplorer method dispose.
public void dispose() {
final KeymapListener listener = myKeymapListener;
if (listener != null) {
myKeymapListener = null;
listener.stopListen();
}
final AntExplorerTreeBuilder builder = myBuilder;
if (builder != null) {
Disposer.dispose(builder);
myBuilder = null;
}
final Tree tree = myTree;
if (tree != null) {
ToolTipManager.sharedInstance().unregisterComponent(tree);
for (KeyStroke keyStroke : tree.getRegisteredKeyStrokes()) {
tree.unregisterKeyboardAction(keyStroke);
}
myTree = null;
}
myProject = null;
myConfig = null;
}
Aggregations