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