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();
}
use of javax.swing.tree.DefaultTreeModel in project poi by apache.
the class POIBrowser method run.
protected void run(String[] args) {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
/* Create the tree model with a root node. The latter is
* invisible but it must be present because a tree model
* always needs a root. */
rootNode = new DefaultMutableTreeNode("POI Filesystems");
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
/* Create the tree UI element. */
final JTree treeUI = new JTree(treeModel);
getContentPane().add(new JScrollPane(treeUI));
/* Add the POI filesystems to the tree. */
int displayedFiles = 0;
for (int i = 0; i < args.length; i++) {
final String filename = args[i];
try {
FileInputStream fis = new FileInputStream(filename);
POIFSReader r = new POIFSReader();
r.registerListener(new TreeReaderListener(filename, rootNode));
r.read(fis);
fis.close();
displayedFiles++;
} catch (IOException ex) {
System.err.println(filename + ": " + ex);
} catch (Exception t) {
System.err.println("Unexpected exception while reading \"" + filename + "\":");
t.printStackTrace(System.err);
}
}
/* Exit if there is no file to display (none specified or only
* files with problems). */
if (displayedFiles == 0) {
System.out.println("No POI filesystem(s) to display.");
System.exit(0);
}
/* Make the tree UI element visible. */
treeUI.setRootVisible(true);
treeUI.setShowsRootHandles(true);
ExtendableTreeCellRenderer etcr = new ExtendableTreeCellRenderer();
etcr.register(DocumentDescriptor.class, new DocumentDescriptorRenderer());
etcr.register(PropertySetDescriptor.class, new PropertySetDescriptorRenderer());
treeUI.setCellRenderer(etcr);
setSize(600, 450);
setTitle("POI Browser 0.09");
setVisible(true);
}
Aggregations