Java Code Examples for com.intellij.util.ui.tree.TreeUtil#selectNode()

The following examples show how to use com.intellij.util.ui.tree.TreeUtil#selectNode() . 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: PushLog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@javax.annotation.Nullable
private DefaultMutableTreeNode getFirstNodeToEdit() {
  // start edit last selected component if editable
  if (myTree.getLastSelectedPathComponent() instanceof RepositoryNode) {
    RepositoryNode selectedNode = ((RepositoryNode)myTree.getLastSelectedPathComponent());
    if (selectedNode.isEditableNow()) return selectedNode;
  }
  List<RepositoryNode> repositoryNodes = getChildNodesByType((DefaultMutableTreeNode)myTree.getModel().getRoot(),
                                                             RepositoryNode.class, false);
  RepositoryNode editableNode = ContainerUtil.find(repositoryNodes, new Condition<RepositoryNode>() {
    @Override
    public boolean value(RepositoryNode repositoryNode) {
      return repositoryNode.isEditableNow();
    }
  });
  if (editableNode != null) {
    TreeUtil.selectNode(myTree, editableNode);
  }
  return editableNode;
}
 
Example 2
Source File: WatchesRootNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void addWatchExpression(@Nullable XStackFrame stackFrame,
                               @Nonnull XExpression expression,
                               int index,
                               boolean navigateToWatchNode) {
  WatchNodeImpl message = new WatchNodeImpl(myTree, this, expression, stackFrame);
  if (index == -1) {
    myChildren.add(message);
    index = myChildren.size() - 1;
  }
  else {
    myChildren.add(index, message);
  }
  fireNodeInserted(index);
  TreeUtil.selectNode(myTree, message);
  if (navigateToWatchNode) {
    myTree.scrollPathToVisible(message.getPath());
  }
}
 
Example 3
Source File: ShelvedChangesViewManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void activateView(final ShelvedChangeList list) {
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      if (list != null) {
        TreeUtil.selectNode(myTree, TreeUtil.findNodeWithObject(myRoot, list));
      }
      myContentManager.setSelectedContent(myContent);
      ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
      if (!window.isVisible()) {
        window.activate(null);
      }
    }
  };
  if (myUpdatePending) {
    myPostUpdateRunnable = runnable;
  }
  else {
    runnable.run();
  }
}
 
Example 4
Source File: RunConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void applyConfiguration(DefaultMutableTreeNode typeNode, SingleConfigurationConfigurable<?> configurable) throws ConfigurationException {
  try {
    if (configurable != null) {
      configurable.apply();
      RunManagerImpl.getInstanceImpl(myProject).fireRunConfigurationChanged(configurable.getSettings());
    }
  }
  catch (ConfigurationException e) {
    for (int i = 0; i < typeNode.getChildCount(); i++) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)typeNode.getChildAt(i);
      if (Comparing.equal(configurable, node.getUserObject())) {
        TreeUtil.selectNode(myTree, node);
        break;
      }
    }
    throw e;
  }
}
 
Example 5
Source File: BreakpointItemsTreeController.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void selectBreakpointItem(@Nullable final BreakpointItem breakpoint, TreePath path) {
  BreakpointItemNode node = myNodes.get(breakpoint);
  if (node != null) {
    TreeUtil.selectNode(myTreeView, node);
  }
  else {
    TreeUtil.selectPath(myTreeView, path);
  }
}
 
Example 6
Source File: WatchInplaceEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void cancelEditing() {
  if (!isShown()) return;
  super.cancelEditing();
  int index = myRootNode.getIndex(myNode);
  if (myOldNode == null && index != -1) {
    myRootNode.removeChildNode(myNode);
  }
  TreeUtil.selectNode(myTree, myNode);
}
 
Example 7
Source File: WatchInplaceEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void doOKAction() {
  XExpression expression = getExpression();
  super.doOKAction();
  int index = myRootNode.removeChildNode(myNode);
  if (!XDebuggerUtilImpl.isEmptyExpression(expression) && index != -1) {
    myWatchesView.addWatchExpression(expression, index, false);
  }
  TreeUtil.selectNode(myTree, myNode);
}
 
Example 8
Source File: ChangesViewManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void selectFile(@Nullable VirtualFile vFile) {
  if (vFile == null) return;
  Change change = ChangeListManager.getInstance(myProject).getChange(vFile);
  Object objectToFind = change != null ? change : vFile;

  DefaultMutableTreeNode root = (DefaultMutableTreeNode)myView.getModel().getRoot();
  DefaultMutableTreeNode node = TreeUtil.findNodeWithObject(root, objectToFind);
  if (node != null) {
    TreeUtil.selectNode(myView, node);
  }
}
 
Example 9
Source File: SingleInspectionProfilePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void updateSelection() {
  if (myTreeTable != null) {
    final TreePath selectionPath = myTreeTable.getTree().getSelectionPath();
    if (selectionPath != null) {
      TreeUtil.selectNode(myTreeTable.getTree(), (TreeNode) selectionPath.getLastPathComponent());
      final int rowForPath = myTreeTable.getTree().getRowForPath(selectionPath);
      TableUtil.selectRows(myTreeTable, new int[]{rowForPath});
      scrollToCenter();
    }
  }
}
 
Example 10
Source File: SingleInspectionProfilePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void selectInspectionTool(String name) {
  final InspectionConfigTreeNode node = findNodeByKey(name, myRoot);
  if (node != null) {
    TreeUtil.selectNode(myTreeTable.getTree(), node);
    final int rowForPath = myTreeTable.getTree().getRowForPath(new TreePath(node.getPath()));
    TableUtil.selectRows(myTreeTable, new int[]{rowForPath});
    scrollToCenter();
  }
}
 
Example 11
Source File: RunConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private SingleConfigurationConfigurable<RunConfiguration> createNewConfiguration(final RunnerAndConfigurationSettings settings, final DefaultMutableTreeNode node) {
  final SingleConfigurationConfigurable<RunConfiguration> configurationConfigurable =
          SingleConfigurationConfigurable.editSettings(settings, null);
  installUpdateListeners(configurationConfigurable);
  DefaultMutableTreeNode nodeToAdd = new DefaultMutableTreeNode(configurationConfigurable);
  myTreeModel.insertNodeInto(nodeToAdd, node, node.getChildCount());
  TreeUtil.selectNode(myTree, nodeToAdd);
  return configurationConfigurable;
}
 
Example 12
Source File: FileTemplateTabAsTree.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void selectTemplate(FileTemplate template) {
  String name = template.getName();
  if (template.getExtension().length() > 0) {
    name += "." + template.getExtension();
  }

  final FileTemplateNode node = (FileTemplateNode)TreeUtil.findNodeWithObject(myRoot, name);
  if (node != null) {
    TreeUtil.selectNode(myTree, node);
    onTemplateSelected(); // this is important because we select different Template for the same node
  }
}
 
Example 13
Source File: PushLog.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void restoreSelection(@javax.annotation.Nullable DefaultMutableTreeNode node) {
  if (node != null) {
    TreeUtil.selectNode(myTree, node);
  }
}