Search in sources :

Example 1 with TreeState

use of com.intellij.ide.util.treeView.TreeState in project intellij-community by JetBrains.

the class MavenProjectsNavigator method scheduleStructureRequest.

private void scheduleStructureRequest(final Runnable r) {
    if (isUnitTestMode()) {
        if (myStructure != null) {
            r.run();
        }
        return;
    }
    if (myToolWindow == null)
        return;
    MavenUtil.invokeLater(myProject, () -> {
        if (!myToolWindow.isVisible())
            return;
        boolean shouldCreate = myStructure == null;
        if (shouldCreate) {
            initStructure();
        }
        r.run();
        if (shouldCreate) {
            if (myState.treeState != null) {
                TreeState treeState = new TreeState();
                try {
                    treeState.readExternal(myState.treeState);
                    treeState.applyTo(myTree);
                } catch (InvalidDataException e) {
                    MavenLog.LOG.info(e);
                }
            }
        }
    });
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 2 with TreeState

use of com.intellij.ide.util.treeView.TreeState in project intellij-community by JetBrains.

the class ExternalProjectsViewImpl method restoreTreeState.

private void restoreTreeState() {
    if (myState.treeState != null) {
        TreeState treeState = new TreeState();
        try {
            treeState.readExternal(myState.treeState);
            treeState.applyTo(myTree);
        } catch (InvalidDataException e) {
            LOG.info(e);
        }
    }
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 3 with TreeState

use of com.intellij.ide.util.treeView.TreeState in project intellij-community by JetBrains.

the class PostfixTemplatesCheckboxTree method setState.

public void setState(@NotNull final Map<String, Set<String>> langToDisabledTemplates) {
    final TreeState treeState = TreeState.createOn(this, myRoot);
    Consumer<PostfixTemplateCheckedTreeNode> consumer = template -> {
        Set<String> disabledTemplates = langToDisabledTemplates.get(template.getLang());
        String key = template.getTemplate().getKey();
        if (disabledTemplates != null && disabledTemplates.contains(key)) {
            template.setChecked(false);
            return;
        }
        template.setChecked(true);
    };
    visit(consumer);
    myModel.nodeStructureChanged(myRoot);
    treeState.applyTo(this);
    TreeUtil.expandAll(this);
}
Also used : Language(com.intellij.lang.Language) UIUtil(com.intellij.util.ui.UIUtil) TreeUtil(com.intellij.util.ui.tree.TreeUtil) PostfixTemplate(com.intellij.codeInsight.template.postfix.templates.PostfixTemplate) TreePath(javax.swing.tree.TreePath) Enumeration(java.util.Enumeration) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) TreeState(com.intellij.ide.util.treeView.TreeState) Set(java.util.Set) ContainerUtil(com.intellij.util.containers.ContainerUtil) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) java.awt(java.awt) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Map(java.util.Map) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) NotNull(org.jetbrains.annotations.NotNull) MultiMap(com.intellij.util.containers.MultiMap) CheckboxTree(com.intellij.ui.CheckboxTree) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) JBColor(com.intellij.ui.JBColor) Consumer(com.intellij.util.Consumer) javax.swing(javax.swing) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreeState(com.intellij.ide.util.treeView.TreeState) Set(java.util.Set)

Example 4 with TreeState

use of com.intellij.ide.util.treeView.TreeState in project intellij-community by JetBrains.

the class CommittedChangesTreeBrowser method append.

public void append(final List<CommittedChangeList> list) {
    final TreeState state = myChangeLists.isEmpty() && myState != null ? myState : TreeState.createOn(myChangesTree, (DefaultMutableTreeNode) myChangesTree.getModel().getRoot());
    state.setScrollToSelection(false);
    myChangeLists.addAll(list);
    myFilteringStrategy.appendFilterBase(list);
    myChangesTree.setModel(buildTreeModel(myFilteringStrategy.filterChangeLists(myChangeLists)));
    state.applyTo(myChangesTree, (DefaultMutableTreeNode) myChangesTree.getModel().getRoot());
    TreeUtil.expandAll(myChangesTree);
    myProject.getMessageBus().syncPublisher(ITEMS_RELOADED).itemsReloaded();
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 5 with TreeState

use of com.intellij.ide.util.treeView.TreeState 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)

Aggregations

TreeState (com.intellij.ide.util.treeView.TreeState)11 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)4 InvalidDataException (com.intellij.openapi.util.InvalidDataException)3 TreePath (javax.swing.tree.TreePath)3 ChangesBrowserNode (com.intellij.openapi.vcs.changes.ui.ChangesBrowserNode)2 CheckedTreeNode (com.intellij.ui.CheckedTreeNode)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 PostfixTemplate (com.intellij.codeInsight.template.postfix.templates.PostfixTemplate)1 Language (com.intellij.lang.Language)1 EmptyRunnable (com.intellij.openapi.util.EmptyRunnable)1 WriteExternalException (com.intellij.openapi.util.WriteExternalException)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 CheckboxTree (com.intellij.ui.CheckboxTree)1 JBColor (com.intellij.ui.JBColor)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 Consumer (com.intellij.util.Consumer)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 MultiMap (com.intellij.util.containers.MultiMap)1 UIUtil (com.intellij.util.ui.UIUtil)1 TreeUtil (com.intellij.util.ui.tree.TreeUtil)1