Search in sources :

Example 21 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project jdk8u_jdk by JetBrains.

the class Test8015926 method run.

@Override
public void run() {
    Thread.currentThread().setUncaughtExceptionHandler(this);
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    DefaultMutableTreeNode child = new DefaultMutableTreeNode("Child");
    DefaultTreeModel model = new DefaultTreeModel(root);
    this.tree = new JTree();
    this.tree.setModel(model);
    JFrame frame = new JFrame(getClass().getSimpleName());
    frame.add(this.tree);
    // frame is not visible yet
    model.addTreeModelListener(this);
    model.insertNodeInto(child, root, root.getChildCount());
    model.removeNodeFromParent(child);
    frame.setSize(640, 480);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    frame.setVisible(true);
}
Also used : JTree(javax.swing.JTree) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JFrame(javax.swing.JFrame) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 22 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project intellij-community by JetBrains.

the class TestTreeView method attachToModel.

public void attachToModel(final TestFrameworkRunningModel model) {
    setModel(new DefaultTreeModel(new DefaultMutableTreeNode(model.getRoot())));
    getSelectionModel().setSelectionMode(model.getProperties().getSelectionMode());
    myModel = model;
    Disposer.register(myModel, myModel.getRoot());
    Disposer.register(myModel, new Disposable() {

        public void dispose() {
            setModel(null);
            myModel = null;
        }
    });
    installHandlers();
    setCellRenderer(getRenderer(myModel.getProperties()));
}
Also used : Disposable(com.intellij.openapi.Disposable) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 23 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project intellij-community by JetBrains.

the class AbstractTestTreeBuilder method repaintWithParents.

public void repaintWithParents(final AbstractTestProxy testProxy) {
    AbstractTestProxy current = testProxy;
    do {
        DefaultMutableTreeNode node = getNodeForElement(current);
        if (node != null) {
            JTree tree = getTree();
            ((DefaultTreeModel) tree.getModel()).nodeChanged(node);
        }
        current = current.getParent();
    } while (current != null);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 24 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project intellij-community by JetBrains.

the class SpecificFilesViewDialog method initData.

private void initData(@NotNull final List<VirtualFile> files) {
    final TreeState state = TreeState.createOn(myView, (ChangesBrowserNode) myView.getModel().getRoot());
    final DefaultTreeModel model = TreeModelBuilder.buildFromVirtualFiles(myProject, myView.isShowFlatten(), files);
    myView.setModel(model);
    myView.expandPath(new TreePath(((ChangesBrowserNode) model.getRoot()).getPath()));
    state.applyTo(myView);
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) TreePath(javax.swing.tree.TreePath) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ChangesBrowserNode(com.intellij.openapi.vcs.changes.ui.ChangesBrowserNode)

Example 25 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project intellij-community by JetBrains.

the class ShelvedChangesViewManager method buildChangesModel.

private TreeModel buildChangesModel() {
    // not null for TreeState matching to work
    myRoot = new DefaultMutableTreeNode(ROOT_NODE_VALUE);
    DefaultTreeModel model = new DefaultTreeModel(myRoot);
    final List<ShelvedChangeList> changeLists = new ArrayList<>(myShelveChangesManager.getShelvedChangeLists());
    Collections.sort(changeLists, ChangelistComparator.getInstance());
    if (myShelveChangesManager.isShowRecycled()) {
        ArrayList<ShelvedChangeList> recycled = new ArrayList<>(myShelveChangesManager.getRecycledShelvedChangeLists());
        changeLists.addAll(recycled);
        Collections.sort(changeLists, ChangelistComparator.getInstance());
    }
    myMoveRenameInfo.clear();
    for (ShelvedChangeList changeList : changeLists) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(changeList);
        model.insertNodeInto(node, myRoot, myRoot.getChildCount());
        final List<Object> shelvedFilesNodes = new ArrayList<>();
        List<ShelvedChange> changes = changeList.getChanges(myProject);
        for (ShelvedChange change : changes) {
            putMovedMessage(change.getBeforePath(), change.getAfterPath());
            shelvedFilesNodes.add(change);
        }
        List<ShelvedBinaryFile> binaryFiles = changeList.getBinaryFiles();
        for (ShelvedBinaryFile file : binaryFiles) {
            putMovedMessage(file.BEFORE_PATH, file.AFTER_PATH);
            shelvedFilesNodes.add(file);
        }
        Collections.sort(shelvedFilesNodes, ShelvedFilePatchComparator.getInstance());
        for (int i = 0; i < shelvedFilesNodes.size(); i++) {
            final Object filesNode = shelvedFilesNodes.get(i);
            final DefaultMutableTreeNode pathNode = new DefaultMutableTreeNode(filesNode);
            model.insertNodeInto(pathNode, node, i);
        }
    }
    return model;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Aggregations

DefaultTreeModel (javax.swing.tree.DefaultTreeModel)362 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)204 TreePath (javax.swing.tree.TreePath)99 JTree (javax.swing.JTree)30 JScrollPane (javax.swing.JScrollPane)25 Test (org.junit.Test)24 Tree (com.intellij.ui.treeStructure.Tree)23 TreeNode (javax.swing.tree.TreeNode)22 ArrayList (java.util.ArrayList)21 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)20 TreeSelectionListener (javax.swing.event.TreeSelectionListener)18 MockTreeModelListener (com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener)16 MouseEvent (java.awt.event.MouseEvent)16 List (java.util.List)16 JPanel (javax.swing.JPanel)16 BorderLayout (java.awt.BorderLayout)14 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)14 IOException (java.io.IOException)12 Dimension (java.awt.Dimension)11 ActionEvent (java.awt.event.ActionEvent)11