Java Code Examples for com.intellij.util.ui.tree.TreeUtil#selectFirstNode()
The following examples show how to use
com.intellij.util.ui.tree.TreeUtil#selectFirstNode() .
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: MasterDetailsComponent.java From consulo with Apache License 2.0 | 6 votes |
protected void initSelection() { final Enumeration enumeration = myRoot.breadthFirstEnumeration(); boolean selected = false; while (enumeration.hasMoreElements()) { final MyNode node = (MyNode)enumeration.nextElement(); if (node instanceof MyRootNode) continue; final String path = getNodePathString(node); if (!selected && Comparing.strEqual(path, myState.getLastEditedConfigurable())) { TreeUtil.selectInTree(node, false, myTree); selected = true; } } if (!selected) { TreeUtil.selectFirstNode(myTree); } updateSelectionFromTree(); }
Example 2
Source File: NewErrorTreeViewPanel.java From consulo with Apache License 2.0 | 6 votes |
public void selectFirstMessage() { final ErrorTreeElement firstError = myErrorViewStructure.getFirstMessage(ErrorTreeElementKind.ERROR); if (firstError != null) { selectElement(firstError, new Runnable() { @Override public void run() { if (shouldShowFirstErrorInEditor()) { navigateToSource(false); } } }); } else { ErrorTreeElement firstWarning = myErrorViewStructure.getFirstMessage(ErrorTreeElementKind.WARNING); if (firstWarning == null) firstWarning = myErrorViewStructure.getFirstMessage(ErrorTreeElementKind.NOTE); if (firstWarning != null) { selectElement(firstWarning, null); } else { TreeUtil.selectFirstNode(myTree); } } }
Example 3
Source File: ViewOfflineResultsAction.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static InspectionResultsView showOfflineView(@Nonnull Project project, @Nonnull Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap, @Nonnull InspectionProfile inspectionProfile, @Nonnull String title) { final AnalysisScope scope = new AnalysisScope(project); final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project); final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false); context.setExternalProfile(inspectionProfile); context.setCurrentScope(scope); context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>()); final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context, new OfflineInspectionRVContentProvider(resMap, project)); ((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted(); view.update(); TreeUtil.selectFirstNode(view.getTree()); context.addView(view, title); return view; }
Example 4
Source File: GeneratorDialog.java From idea-gitignore with MIT License | 5 votes |
/** * Filters templates tree. * * @param filter text */ private void filterTree(@Nullable String filter) { if (tree != null) { fillTreeData(filter, true); reloadModel(); TreeUtil.expandAll(tree); if (tree.getSelectionPath() == null) { TreeUtil.selectFirstNode(tree); } } }
Example 5
Source File: CoverageSuiteChooserDialog.java From consulo with Apache License 2.0 | 5 votes |
public CoverageSuiteChooserDialog(Project project) { super(project, true); myProject = project; myCoverageManager = CoverageDataManager.getInstance(project); myRootNode = new CheckedTreeNode(""); initTree(); mySuitesTree = new CheckboxTree(new SuitesRenderer(), myRootNode) { protected void installSpeedSearch() { new TreeSpeedSearch(this, new Convertor<TreePath, String>() { public String convert(TreePath path) { final DefaultMutableTreeNode component = (DefaultMutableTreeNode)path.getLastPathComponent(); final Object userObject = component.getUserObject(); if (userObject instanceof CoverageSuite) { return ((CoverageSuite)userObject).getPresentableName(); } return userObject.toString(); } }); } }; mySuitesTree.getEmptyText().appendText("No coverage suites configured."); mySuitesTree.setRootVisible(false); mySuitesTree.setShowsRootHandles(false); TreeUtil.installActions(mySuitesTree); TreeUtil.expandAll(mySuitesTree); TreeUtil.selectFirstNode(mySuitesTree); mySuitesTree.setMinimumSize(new Dimension(25, -1)); setOKButtonText("Show selected"); init(); setTitle("Choose Coverage Suite to Display"); }
Example 6
Source File: MasterDetailsComponent.java From consulo with Apache License 2.0 | 5 votes |
public ActionCallback selectNodeInTree(final DefaultMutableTreeNode nodeToSelect, boolean center, final boolean requestFocus) { if (requestFocus) { IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myTree); } if (nodeToSelect != null) { return TreeUtil.selectInTree(nodeToSelect, requestFocus, myTree, center); } else { return TreeUtil.selectFirstNode(myTree); } }
Example 7
Source File: VisibleTreeState.java From consulo with Apache License 2.0 | 5 votes |
public void restoreVisibleState(Tree tree) { ArrayList<TreePath> pathsToExpand = new ArrayList<TreePath>(); ArrayList<TreePath> toSelect = new ArrayList<TreePath>(); traverseNodes((DefaultMutableTreeNode)tree.getModel().getRoot(), pathsToExpand, toSelect); TreeUtil.restoreExpandedPaths(tree, pathsToExpand); if (toSelect.isEmpty()) { TreeUtil.selectFirstNode(tree); } else { for (final TreePath aToSelect : toSelect) { TreeUtil.selectPath(tree, aToSelect); } } }
Example 8
Source File: SingleInspectionProfilePanel.java From consulo with Apache License 2.0 | 5 votes |
private void filterTree(@Nullable String filter) { if (myTreeTable != null) { getExpandedNodes(mySelectedProfile).saveVisibleState(myTreeTable.getTree()); fillTreeData(filter, true); reloadModel(); restoreTreeState(); if (myTreeTable.getTree().getSelectionPath() == null) { TreeUtil.selectFirstNode(myTreeTable.getTree()); } } }
Example 9
Source File: ImageDuplicateResultsDialog.java From consulo with Apache License 2.0 | 5 votes |
public ImageDuplicateResultsDialog(Project project, List<VirtualFile> images, Map<String, Set<VirtualFile>> duplicates) { super(project); myProject = project; myImages = images; PropertiesComponent.getInstance(myProject).loadFields(myResourceModules); myDuplicates = duplicates; setModal(false); myTree = new Tree(new MyRootNode()); myTree.setRootVisible(true); myTree.setCellRenderer(new MyCellRenderer()); init(); TreeUtil.expandAll(myTree); setTitle("Image Duplicates"); TreeUtil.selectFirstNode(myTree); }
Example 10
Source File: FileTemplateTabAsTree.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void initSelection(FileTemplate selection) { if (selection != null) { selectTemplate(selection); } else { TreeUtil.selectFirstNode(myTree); } }
Example 11
Source File: MasterDetailsComponent.java From consulo with Apache License 2.0 | 4 votes |
protected void removePaths(final TreePath... paths) { MyNode parentNode = null; int idx = -1; for (TreePath path : paths) { final MyNode node = (MyNode)path.getLastPathComponent(); final NamedConfigurable namedConfigurable = node.getConfigurable(); final Object editableObject = namedConfigurable.getEditableObject(); parentNode = (MyNode)node.getParent(); idx = parentNode.getIndex(node); ((DefaultTreeModel)myTree.getModel()).removeNodeFromParent(node); myHasDeletedItems |= wasObjectStored(editableObject); fireItemsChangeListener(editableObject); onItemDeleted(editableObject); namedConfigurable.disposeUIResources(); } if (paths.length > 0) { if (parentNode != null && idx != -1) { DefaultMutableTreeNode toSelect = null; if (idx < parentNode.getChildCount()) { toSelect = (DefaultMutableTreeNode) parentNode.getChildAt(idx); } else { if (idx > 0 && parentNode.getChildCount() > 0) { if (idx - 1 < parentNode.getChildCount()) { toSelect = (DefaultMutableTreeNode) parentNode.getChildAt(idx - 1); } else { toSelect = (DefaultMutableTreeNode) parentNode.getFirstChild(); } } else { if (parentNode.isRoot() && myTree.isRootVisible()) { toSelect = parentNode; } else if (parentNode.getChildCount() > 0) { toSelect = (DefaultMutableTreeNode) parentNode.getFirstChild(); } } } if (toSelect != null) { TreeUtil.selectInTree(toSelect, true, myTree); } } else { TreeUtil.selectFirstNode(myTree); } } }
Example 12
Source File: ModulesDependenciesPanel.java From consulo with Apache License 2.0 | 4 votes |
@Override public void rootsChanged(ModuleRootEvent event) { initLeftTreeModel(); TreeUtil.selectFirstNode(myLeftTree); }