Search in sources :

Example 51 with DefaultTreeModel

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;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 52 with DefaultTreeModel

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);
}
Also used : FileUtilRt(com.intellij.openapi.util.io.FileUtilRt) UIUtil(com.intellij.util.ui.UIUtil) java.util(java.util) AllIcons(com.intellij.icons.AllIcons) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) FlutterUtil(com.jetbrains.lang.dart.flutter.FlutterUtil) WebBrowser(com.intellij.ide.browsers.WebBrowser) ModuleManager(com.intellij.openapi.module.ModuleManager) ExpandVetoException(javax.swing.tree.ExpandVetoException) ModalityState(com.intellij.openapi.application.ModalityState) Computable(com.intellij.openapi.util.Computable) ColumnInfo(com.intellij.util.ui.ColumnInfo) THashSet(gnu.trove.THashSet) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) JBLabel(com.intellij.ui.components.JBLabel) TreeColumnInfo(com.intellij.ui.treeStructure.treetable.TreeColumnInfo) Nls(org.jetbrains.annotations.Nls) ShowSettingsUtilImpl(com.intellij.ide.actions.ShowSettingsUtilImpl) NoScroll(com.intellij.openapi.options.Configurable.NoScroll) ChromeSettings(com.intellij.ide.browsers.chrome.ChromeSettings) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) ModuleType(com.intellij.openapi.module.ModuleType) Module(com.intellij.openapi.module.Module) DocumentEvent(javax.swing.event.DocumentEvent) TreeWillExpandListener(javax.swing.event.TreeWillExpandListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ComboBox(com.intellij.openapi.ui.ComboBox) JBCheckBox(com.intellij.ui.components.JBCheckBox) StringUtil(com.intellij.openapi.util.text.StringUtil) com.intellij.ui(com.intellij.ui) JTextComponent(javax.swing.text.JTextComponent) DartBundle(com.jetbrains.lang.dart.DartBundle) File(java.io.File) DartiumUtil(com.jetbrains.lang.dart.ide.runner.client.DartiumUtil) Nullable(org.jetbrains.annotations.Nullable) IconLoader(com.intellij.openapi.util.IconLoader) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) BrowserSpecificSettings(com.intellij.ide.browsers.BrowserSpecificSettings) ApplicationManager(com.intellij.openapi.application.ApplicationManager) XmlStringUtil(com.intellij.xml.util.XmlStringUtil) ApplicationManagerEx(com.intellij.openapi.application.ex.ApplicationManagerEx) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) javax.swing(javax.swing) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Module(com.intellij.openapi.module.Module)

Example 53 with DefaultTreeModel

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);
        });
    });
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Module(com.intellij.openapi.module.Module) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 54 with DefaultTreeModel

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);
        });
    });
}
Also used : NativeAndroidProject(com.android.builder.model.NativeAndroidProject) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) NativeAndroidProject(com.android.builder.model.NativeAndroidProject) AndroidProject(com.android.builder.model.AndroidProject) Module(com.intellij.openapi.module.Module) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 55 with DefaultTreeModel

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();
}
Also used : ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) MemoryInfoTreeNode(com.android.tools.idea.monitor.ui.memory.model.MemoryInfoTreeNode) Tree(com.intellij.ui.treeStructure.Tree) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Aggregations

DefaultTreeModel (javax.swing.tree.DefaultTreeModel)196 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)99 TreePath (javax.swing.tree.TreePath)50 Tree (com.intellij.ui.treeStructure.Tree)22 Test (org.junit.Test)21 JTree (javax.swing.JTree)17 MockTreeModelListener (com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener)16 JScrollPane (javax.swing.JScrollPane)16 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)15 TreeSelectionListener (javax.swing.event.TreeSelectionListener)14 ArrayList (java.util.ArrayList)10 TreeNode (javax.swing.tree.TreeNode)10 NotNull (org.jetbrains.annotations.NotNull)10 Module (com.intellij.openapi.module.Module)9 MouseEvent (java.awt.event.MouseEvent)9 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)9 Project (com.intellij.openapi.project.Project)7 javax.swing (javax.swing)7 JPanel (javax.swing.JPanel)7 ColumnTreeBuilder (com.android.tools.adtui.common.ColumnTreeBuilder)6