Java Code Examples for com.intellij.ui.CheckedTreeNode#add()

The following examples show how to use com.intellij.ui.CheckedTreeNode#add() . 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 vote down vote up
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: BreakpointItemsTreeController.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 3
Source File: BreakpointItemsTreeController.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 4
Source File: PushController.java    From consulo with Apache License 2.0 4 votes vote down vote up
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);
}