use of javax.swing.tree.DefaultTreeModel in project intellij-community by JetBrains.
the class CommittedChangesTreeBrowser method buildTreeModel.
private TreeModel buildTreeModel(final List<CommittedChangeList> filteredChangeLists) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
DefaultTreeModel model = new DefaultTreeModel(root);
Collections.sort(filteredChangeLists, myGroupingStrategy.getComparator());
myGroupingStrategy.beforeStart();
DefaultMutableTreeNode lastGroupNode = null;
String lastGroupName = null;
for (CommittedChangeList list : filteredChangeLists) {
String groupName = StringUtil.notNullize(myGroupingStrategy.getGroupName(list));
if (!Comparing.equal(groupName, lastGroupName)) {
lastGroupName = groupName;
lastGroupNode = new DefaultMutableTreeNode(lastGroupName);
root.add(lastGroupNode);
}
assert lastGroupNode != null;
lastGroupNode.add(new DefaultMutableTreeNode(list));
}
return model;
}
use of javax.swing.tree.DefaultTreeModel in project intellij-plugins by JetBrains.
the class DartConfigurable method initModulesPanel.
private void initModulesPanel() {
if (!DartSdkLibUtil.isIdeWithMultipleModuleSupport()) {
myModulesPanel.setVisible(false);
return;
}
final Module[] modules = ModuleManager.getInstance(myProject).getModules();
Arrays.sort(modules, Comparator.comparing(module -> module.getName().toLowerCase(Locale.US)));
final CheckedTreeNode rootNode = new CheckedTreeNode(myProject);
((DefaultTreeModel) myModulesCheckboxTreeTable.getTree().getModel()).setRoot(rootNode);
myModulesCheckboxTreeTable.getTree().setRootVisible(true);
myModulesCheckboxTreeTable.getTree().setShowsRootHandles(false);
for (final Module module : modules) {
rootNode.add(new CheckedTreeNode(module));
}
((DefaultTreeModel) myModulesCheckboxTreeTable.getTree().getModel()).reload(rootNode);
}
use of javax.swing.tree.DefaultTreeModel in project android by JetBrains.
the class AndroidModelView method updateContents.
private void updateContents() {
myTree.setRootVisible(true);
if (GradleSyncState.getInstance(myProject).isSyncInProgress()) {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Gradle project sync in progress ...")));
return;
} else {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Loading ...")));
}
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(myProject.getName());
String projectPath = myProject.getBasePath();
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel != null) {
DefaultMutableTreeNode moduleNode = new ModuleNodeBuilder(module.getName(), androidModel, projectPath).getNode();
rootNode.add(moduleNode);
}
// TODO: Also add NativeAndroidGradleModel to the view.
}
UIUtil.invokeLaterIfNeeded(() -> {
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(AllIcons.Nodes.NewFolder);
renderer.setClosedIcon(AllIcons.Nodes.NewFolder);
renderer.setLeafIcon(AllIcons.ObjectBrowser.ShowModules);
myTree.setCellRenderer(renderer);
DefaultTreeModel model = new DefaultTreeModel(rootNode);
myTree.setRootVisible(false);
myTree.setModel(model);
});
});
}
use of javax.swing.tree.DefaultTreeModel in project android by JetBrains.
the class InternalAndroidModelView method updateContents.
private void updateContents() {
myTree.setRootVisible(true);
if (GradleSyncState.getInstance(myProject).isSyncInProgress()) {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Gradle project sync in progress ...")));
return;
} else {
myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Loading ...")));
}
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(myProject.getName());
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel != null) {
DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(module.getName());
AndroidProject androidProject = androidModel.waitForAndGetProxyAndroidProject();
addProxyObject(moduleNode, androidProject);
rootNode.add(moduleNode);
}
NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
if (ndkModuleModel != null) {
String nodeName = androidModel == null ? module.getName() : module.getName() + " (native)";
DefaultMutableTreeNode nativeModuleNode = new DefaultMutableTreeNode(nodeName);
NativeAndroidProject nativeAndroidProject = ndkModuleModel.waitForAndGetProxyAndroidProject();
addProxyObject(nativeModuleNode, nativeAndroidProject);
rootNode.add(nativeModuleNode);
}
}
invokeLaterIfNeeded(() -> {
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(AllIcons.Nodes.NewFolder);
renderer.setClosedIcon(AllIcons.Nodes.NewFolder);
renderer.setLeafIcon(AllIcons.ObjectBrowser.ShowModules);
myTree.setCellRenderer(renderer);
DefaultTreeModel model = new DefaultTreeModel(rootNode);
myTree.setRootVisible(false);
myTree.setModel(model);
});
});
}
use of javax.swing.tree.DefaultTreeModel in project android by JetBrains.
the class ClassHistogramView method createComponentsList.
@Override
public void createComponentsList(@NotNull List<Animatable> animatables) {
myTreeModel = new DefaultTreeModel(myRoot);
myTree = new Tree(myTreeModel);
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Class").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(0, myRoot))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Count").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(1, myRoot)).setInitialOrder(SortOrder.DESCENDING).setComparator((MemoryInfoTreeNode a, MemoryInfoTreeNode b) -> a.getCount() - b.getCount()));
builder.setTreeSorter((Comparator<MemoryInfoTreeNode> comparator, SortOrder sortOrder) -> {
myRoot.sort(comparator);
myTreeModel.nodeStructureChanged(myRoot);
});
myColumnTree = builder.build();
}
Aggregations