com.intellij.ui.CheckedTreeNode Java Examples
The following examples show how to use
com.intellij.ui.CheckedTreeNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiteralChooser.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Tree createTree(java.util.List<String> literals) { final CheckedTreeNode rootNode = new CheckedTreeNode("all literals not defined"); for (String literal : literals) { CheckedTreeNode child = new CheckedTreeNode(new LiteralChooserObject(literal, Icons.LEXER_RULE)); child.setChecked(true); rootNode.add(child); } DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); selectedElements.addAll(literals); // all are "on" by default Tree tree = new Tree(treeModel); tree.setRootVisible(false); tree.setCellRenderer(new LiteralChooserRenderer()); tree.addTreeSelectionListener(new MyTreeSelectionListener()); return tree; }
Example #2
Source File: CustomizePluginsStepPanel.java From consulo with Apache License 2.0 | 6 votes |
private static void setupChecked(DefaultMutableTreeNode treeNode, Set<String> set, Boolean state) { Object userObject = treeNode.getUserObject(); if (userObject instanceof PluginDescriptor) { String id = ((PluginDescriptor)userObject).getPluginId().getIdString(); boolean contains = set.contains(id); if(state == null) { ((CheckedTreeNode)treeNode).setChecked(contains); } else if(contains) { ((CheckedTreeNode)treeNode).setChecked(state); } } int childCount = treeNode.getChildCount(); for (int i = 0; i < childCount; i++) { DefaultMutableTreeNode childAt = (DefaultMutableTreeNode)treeNode.getChildAt(i); setupChecked(childAt, set, state); } }
Example #3
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 6 votes |
private void adjustParentsAndChildren(final CheckedTreeNode node, final boolean checked) { changeNodeState(node, checked); if (!checked) { TreeNode parent = node.getParent(); while (parent != null) { if (parent instanceof CheckedTreeNode) { changeNodeState((CheckedTreeNode)parent, false); } parent = parent.getParent(); } uncheckChildren(node); } else { checkChildren(node); } repaint(); }
Example #4
Source File: BreakpointsFavoriteListProvider.java From consulo with Apache License 2.0 | 6 votes |
private void updateChildren() { if (myProject.isDisposed()) return; myChildren.clear(); List<BreakpointItem> items = new ArrayList<BreakpointItem>(); for (final BreakpointPanelProvider provider : myBreakpointPanelProviders) { provider.provideBreakpointItems(myProject, items); } getEnabledGroupingRules(myRulesEnabled); myTreeController.setGroupingRules(myRulesEnabled); myTreeController.rebuildTree(items); CheckedTreeNode root = myTreeController.getRoot(); for (int i = 0; i < root.getChildCount(); i++) { TreeNode child = root.getChildAt(i); if (child instanceof DefaultMutableTreeNode) { replicate((DefaultMutableTreeNode)child, myNode, myChildren); } } FavoritesManager.getInstance(myProject).fireListeners(getListName(myProject)); }
Example #5
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 6 votes |
private static BreakpointsGroupNode getOrCreateGroupNode(CheckedTreeNode parent, final XBreakpointGroup group, final int level) { Enumeration children = parent.children(); while (children.hasMoreElements()) { Object element = children.nextElement(); if (element instanceof BreakpointsGroupNode) { XBreakpointGroup groupFound = ((BreakpointsGroupNode)element).getGroup(); if (groupFound.equals(group)) { return (BreakpointsGroupNode)element; } } } BreakpointsGroupNode groupNode = new BreakpointsGroupNode<>(group, level); parent.add(groupNode); return groupNode; }
Example #6
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 6 votes |
public void buildTree(@Nonnull Collection<? extends BreakpointItem> breakpoints) { final TreeState state = TreeState.createOn(myTreeView, myRoot); myRoot.removeAllChildren(); myNodes.clear(); for (BreakpointItem breakpoint : breakpoints) { BreakpointItemNode node = new BreakpointItemNode(breakpoint); CheckedTreeNode parent = getParentNode(breakpoint); parent.add(node); myNodes.put(breakpoint, node); } TreeUtil.sortRecursively(myRoot, COMPARATOR); myInBuild = true; ((DefaultTreeModel)(myTreeView.getModel())).nodeStructureChanged(myRoot); state.applyTo(myTreeView, myRoot); myInBuild = false; }
Example #7
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public <T> T[] getCheckedNodes(final Class<T> nodeType) { final ArrayList<T> nodes = new ArrayList<T>(); final Object root = getTree().getModel().getRoot(); if (!(root instanceof CheckedTreeNode)) { throw new IllegalStateException("The root must be instance of the " + CheckedTreeNode.class.getName() + ": " + root.getClass().getName()); } new Object() { @SuppressWarnings("unchecked") public void collect(CheckedTreeNode node) { if (node.isLeaf()) { Object userObject = node.getUserObject(); if (node.isChecked() && userObject != null && nodeType.isAssignableFrom(userObject.getClass())) { final T value = (T)userObject; nodes.add(value); } } else { for (int i = 0; i < node.getChildCount(); i++) { final TreeNode child = node.getChildAt(i); if (child instanceof CheckedTreeNode) { collect((CheckedTreeNode)child); } } } } }.collect((CheckedTreeNode)root); T[] result = (T[])Array.newInstance(nodeType, nodes.size()); nodes.toArray(result); return result; }
Example #8
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 5 votes |
private static void checkChildren(final CheckedTreeNode node) { final Enumeration children = node.children(); while (children.hasMoreElements()) { final Object o = children.nextElement(); if (!(o instanceof CheckedTreeNode)) continue; CheckedTreeNode child = (CheckedTreeNode)o; changeNodeState(child, true); checkChildren(child); } }
Example #9
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 5 votes |
private static void uncheckChildren(final CheckedTreeNode node) { final Enumeration children = node.children(); while (children.hasMoreElements()) { final Object o = children.nextElement(); if (!(o instanceof CheckedTreeNode)) continue; CheckedTreeNode child = (CheckedTreeNode)o; changeNodeState(child, false); uncheckChildren(child); } }
Example #10
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 5 votes |
protected boolean toggleNode(CheckedTreeNode node) { boolean checked = !node.isChecked(); checkNode(node, checked); // notify model listeners about model change final TreeModel model = getTree().getModel(); model.valueForPathChanged(new TreePath(node.getPath()), node.getUserObject()); return checked; }
Example #11
Source File: BreakpointsCheckboxTree.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void onNodeStateChanged(CheckedTreeNode node) { super.onNodeStateChanged(node); if (myDelegate != null) { myDelegate.nodeStateDidChange(node); } }
Example #12
Source File: BreakpointsCheckboxTree.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void nodeStateWillChange(CheckedTreeNode node) { super.nodeStateWillChange(node); if (myDelegate != null) { myDelegate.nodeStateWillChange(node); } }
Example #13
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 5 votes |
private static Collection<XBreakpointGroup> getGroupNodes(CheckedTreeNode parent) { Collection<XBreakpointGroup> nodes = new ArrayList<>(); Enumeration children = parent.children(); while (children.hasMoreElements()) { Object element = children.nextElement(); if (element instanceof BreakpointsGroupNode) { nodes.add(((BreakpointsGroupNode)element).getGroup()); } } return nodes; }
Example #14
Source File: LiteralChooser.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void valueChanged(TreeSelectionEvent e) { // System.out.println("select event ----------"); TreePath[] paths = e.getPaths(); if (paths == null) return; for (int i = 0; i < paths.length; i++) { Object node = paths[i].getLastPathComponent(); if (node instanceof CheckedTreeNode) { Object userObject = ((DefaultMutableTreeNode) node).getUserObject(); if (userObject instanceof LiteralChooserObject) { LiteralChooserObject literalObject = (LiteralChooserObject) userObject; String text = literalObject.getText(); // System.out.println("selected " + text); if ( e.isAddedPath(paths[i]) ) { if ( selectedElements.contains(text) ) { selectedElements.remove(text); } else { selectedElements.add(text); } // System.out.println("added path: "+text); CheckedTreeNode checkedNode = (CheckedTreeNode) node; checkedNode.setChecked(!checkedNode.isChecked()); // toggle } } } } }
Example #15
Source File: CustomizePluginsStepPanel.java From consulo with Apache License 2.0 | 5 votes |
private static void collect(DefaultMutableTreeNode treeNode, Set<PluginDescriptor> set) { Object userObject = treeNode.getUserObject(); if (userObject instanceof PluginDescriptor) { CheckedTreeNode checkedTreeNode = (CheckedTreeNode)treeNode; if (checkedTreeNode.isChecked()) { set.add(((PluginDescriptor)userObject)); } } int childCount = treeNode.getChildCount(); for (int i = 0; i < childCount; i++) { DefaultMutableTreeNode childAt = (DefaultMutableTreeNode)treeNode.getChildAt(i); collect(childAt, set); } }
Example #16
Source File: PushController.java From consulo with Apache License 2.0 | 5 votes |
public PushController(@Nonnull Project project, @Nonnull VcsPushDialog dialog, @Nonnull List<? extends Repository> preselectedRepositories, @javax.annotation.Nullable Repository currentRepo) { myProject = project; myPushSettings = ServiceManager.getService(project, PushSettings.class); myGlobalRepositoryManager = VcsRepositoryManager.getInstance(project); myExcludedRepositoryRoots = ContainerUtil.newHashSet(myPushSettings.getExcludedRepoRoots()); myPreselectedRepositories = preselectedRepositories; myCurrentlyOpenedRepository = currentRepo; myPushSupports = getAffectedSupports(); mySingleRepoProject = isSingleRepoProject(); myDialog = dialog; CheckedTreeNode rootNode = new CheckedTreeNode(null); createTreeModel(rootNode); myPushLog = new PushLog(myProject, rootNode, isSyncStrategiesAllowed()); myPushLog.getTree().addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // when user starts edit we need to force disable ok actions, because tree.isEditing() still false; // after editing completed okActions will be enabled automatically by dialog validation Boolean isEditMode = (Boolean)evt.getNewValue(); if (isEditMode) { myDialog.disableOkActions(); } } }); startLoadingCommits(); Disposer.register(dialog.getDisposable(), this); }
Example #17
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private CheckedTreeNode getParentNode(final BreakpointItem breakpoint) { CheckedTreeNode parent = myRoot; for (int i = 0; i < myGroupingRules.size(); i++) { XBreakpointGroup group = myGroupingRules.get(i).getGroup(breakpoint.getBreakpoint(), Collections.emptyList()); if (group != null) { parent = getOrCreateGroupNode(parent, group, i); if (breakpoint.isEnabled()) { parent.setChecked(true); } } } return parent; }
Example #18
Source File: ExtensionEditor.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override protected JComponent createComponentImpl() { JPanel rootPane = new JPanel(new BorderLayout()); mySplitter = new OnePixelSplitter(); myTree = new CheckboxTreeNoPolicy(new ExtensionTreeCellRenderer(), new ExtensionCheckedTreeNode(null, myState, this)) { @Override protected void adjustParentsAndChildren(CheckedTreeNode node, boolean checked) { if (!checked) { changeNodeState(node, false); checkOrUncheckChildren(node, false); } else { // we need collect parents, and enable it in right order // A // - B // -- C // when we enable C, ill be calls like A -> B -> C List<CheckedTreeNode> parents = new ArrayList<>(); TreeNode parent = node.getParent(); while (parent != null) { if (parent instanceof CheckedTreeNode) { parents.add((CheckedTreeNode)parent); } parent = parent.getParent(); } Collections.reverse(parents); for (CheckedTreeNode checkedTreeNode : parents) { checkNode(checkedTreeNode, true); } changeNodeState(node, true); } repaint(); } }; myTree.setRootVisible(false); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myTree.addTreeSelectionListener(new TreeSelectionListener() { @Override @RequiredUIAccess public void valueChanged(final TreeSelectionEvent e) { final List<MutableModuleExtension> selected = TreeUtil.collectSelectedObjectsOfType(myTree, MutableModuleExtension.class); updateSecondComponent(ContainerUtil.<MutableModuleExtension>getFirstItem(selected)); } }); TreeUtil.expandAll(myTree); mySplitter.setFirstComponent(myTree); rootPane.add(new JBScrollPane(mySplitter), BorderLayout.CENTER); return rootPane; }
Example #19
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 4 votes |
private static void changeNodeState(final CheckedTreeNode node, final boolean checked) { if (node.isChecked() != checked) { node.setChecked(checked); } }
Example #20
Source File: PushController.java From consulo with Apache License 2.0 | 4 votes |
private void createTreeModel(@Nonnull CheckedTreeNode rootNode) { for (Repository repository : DvcsUtil.sortRepositories(myGlobalRepositoryManager.getRepositories())) { createRepoNode(repository, rootNode); } }
Example #21
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 4 votes |
private void checkNode(CheckedTreeNode node, boolean checked) { adjustParentsAndChildren(node, checked); repaint(); }
Example #22
Source File: PushController.java From consulo with Apache License 2.0 | 4 votes |
private <R extends Repository, S extends PushSource, T extends PushTarget> void createRepoNode(@Nonnull final R repository, @Nonnull final CheckedTreeNode rootNode) { PushSupport<R, S, T> support = getPushSupportByRepository(repository); if (support == null) return; T target = support.getDefaultTarget(repository); String repoName = getDisplayedRepoName(repository); S source = support.getSource(repository); final MyRepoModel<R, S, T> model = new MyRepoModel<R, S, T>(repository, support, mySingleRepoProject, source, target); if (target == null) { model.setError(VcsError.createEmptyTargetError(repoName)); } final PushTargetPanel<T> pushTargetPanel = support.createTargetPanel(repository, target); final RepositoryWithBranchPanel<T> repoPanel = new RepositoryWithBranchPanel<T>(myProject, repoName, source.getPresentation(), pushTargetPanel); CheckBoxModel checkBoxModel = model.getCheckBoxModel(); final RepositoryNode repoNode = mySingleRepoProject ? new SingleRepositoryNode(repoPanel, checkBoxModel) : new RepositoryNode(repoPanel, checkBoxModel, target != null); pushTargetPanel.setFireOnChangeAction(new Runnable() { @Override public void run() { repoPanel.fireOnChange(); ((DefaultTreeModel)myPushLog.getTree().getModel()).nodeChanged(repoNode); // tell the tree to repaint the changed node } }); myView2Model.put(repoNode, model); repoPanel.addRepoNodeListener(new RepositoryNodeListener<T>() { @Override public void onTargetChanged(T newTarget) { repoNode.setChecked(true); myExcludedRepositoryRoots.remove(model.getRepository().getRoot().getPath()); if (!newTarget.equals(model.getTarget()) || model.hasError() || !model.hasCommitInfo()) { model.setTarget(newTarget); model.clearErrors(); loadCommits(model, repoNode, false); } } @Override public void onSelectionChanged(boolean isSelected) { myDialog.updateOkActions(); if (isSelected) { boolean forceLoad = myExcludedRepositoryRoots.remove(model.getRepository().getRoot().getPath()); if (!model.hasCommitInfo() && (forceLoad || !model.getSupport().shouldRequestIncomingChangesForNotCheckedRepositories())) { loadCommits(model, repoNode, false); } } else { myExcludedRepositoryRoots.add(model.getRepository().getRoot().getPath()); } } @Override public void onTargetInEditMode(@Nonnull String currentValue) { myPushLog.fireEditorUpdated(currentValue); } }); rootNode.add(repoNode); }
Example #23
Source File: CheckboxTreeTable.java From consulo with Apache License 2.0 | 4 votes |
public CheckboxTreeTable(CheckedTreeNode root, CheckboxTree.CheckboxTreeCellRenderer renderer, final ColumnInfo[] columns) { super(new ListTreeTableModelOnColumns(root, columns)); initTree(getTree(), renderer); }
Example #24
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 4 votes |
public BreakpointItemsTreeController(Collection<XBreakpointGroupingRule> groupingRules) { myRoot = new CheckedTreeNode("root"); setGroupingRulesInternal(groupingRules); }
Example #25
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 4 votes |
@Override public void nodeStateDidChange(CheckedTreeNode node) { if (myInBuild) return; nodeStateDidChangeImpl(node); }
Example #26
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 4 votes |
protected void nodeStateDidChangeImpl(CheckedTreeNode node) { if (node instanceof BreakpointItemNode) { ((BreakpointItemNode)node).getBreakpointItem().setEnabled(node.isChecked()); } }
Example #27
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 4 votes |
public CheckedTreeNode getRoot() { return myRoot; }
Example #28
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 4 votes |
@Override public void nodeStateWillChange(CheckedTreeNode node) { if (myInBuild) return; nodeStateWillChangeImpl(node); }
Example #29
Source File: BreakpointItemsTreeController.java From consulo with Apache License 2.0 | 4 votes |
protected void nodeStateWillChangeImpl(CheckedTreeNode node) { }
Example #30
Source File: BreakpointsCheckboxTree.java From consulo with Apache License 2.0 | votes |
void nodeStateWillChange(CheckedTreeNode node);