Java Code Examples for com.intellij.util.ui.tree.TreeUtil#sort()
The following examples show how to use
com.intellij.util.ui.tree.TreeUtil#sort() .
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: ModulesDependenciesPanel.java From consulo with Apache License 2.0 | 6 votes |
private static void sortSubTree(final DefaultMutableTreeNode root) { TreeUtil.sort(root, new Comparator() { @Override public int compare(final Object o1, final Object o2) { DefaultMutableTreeNode node1 = (DefaultMutableTreeNode)o1; DefaultMutableTreeNode node2 = (DefaultMutableTreeNode)o2; if (!(node1.getUserObject() instanceof MyUserObject)){ return 1; } else if (!(node2.getUserObject() instanceof MyUserObject)){ return -1; } return (node1.getUserObject().toString().compareToIgnoreCase(node2.getUserObject().toString())); } }); }
Example 2
Source File: RunConfigurable.java From consulo with Apache License 2.0 | 6 votes |
private void sortTopLevelBranches() { List<TreePath> expandedPaths = TreeUtil.collectExpandedPaths(myTree); TreeUtil.sort(myRoot, new Comparator() { @Override public int compare(final Object o1, final Object o2) { final Object userObject1 = ((DefaultMutableTreeNode)o1).getUserObject(); final Object userObject2 = ((DefaultMutableTreeNode)o2).getUserObject(); if (userObject1 instanceof ConfigurationType && userObject2 instanceof ConfigurationType) { return ((ConfigurationType)userObject1).getDisplayName().compareTo(((ConfigurationType)userObject2).getDisplayName()); } else if (userObject1 == DEFAULTS && userObject2 instanceof ConfigurationType) { return 1; } return 0; } }); TreeUtil.restoreExpandedPaths(myTree, expandedPaths); }
Example 3
Source File: ScopeChooserConfigurable.java From consulo with Apache License 2.0 | 6 votes |
private void reloadTree() { myRoot.removeAllChildren(); loadScopes(mySharedScopesManager); loadScopes(myLocalScopesManager); if (isModified()) { loadStateOrder(); } final List<String> order = getScopesState().myOrder; TreeUtil.sort(myRoot, new Comparator<DefaultMutableTreeNode>() { @Override public int compare(final DefaultMutableTreeNode o1, final DefaultMutableTreeNode o2) { final int idx1 = order.indexOf(((MyNode)o1).getDisplayName()); final int idx2 = order.indexOf(((MyNode)o2).getDisplayName()); return idx1 - idx2; } }); }
Example 4
Source File: BaseLibrariesConfigurable.java From consulo with Apache License 2.0 | 5 votes |
private void createLibrariesNode(final StructureLibraryTableModifiableModelProvider modelProvider) { final Library[] libraries = modelProvider.getModifiableModel().getLibraries(); for (Library library : libraries) { myRoot.add(new MyNode(new LibraryConfigurable(modelProvider, library, myContext, TREE_UPDATER))); } TreeUtil.sort(myRoot, new Comparator() { @Override public int compare(final Object o1, final Object o2) { MyNode node1 = (MyNode)o1; MyNode node2 = (MyNode)o2; return node1.getDisplayName().compareToIgnoreCase(node2.getDisplayName()); } }); ((DefaultTreeModel)myTree.getModel()).reload(myRoot); }
Example 5
Source File: SingleInspectionProfilePanel.java From consulo with Apache License 2.0 | 5 votes |
private void fillTreeData(@Nullable String filter, boolean forceInclude) { if (mySelectedProfile == null) return; myRoot.removeAllChildren(); myRoot.dropCache(); List<Set<String>> keySetList = new ArrayList<Set<String>>(); final Set<String> quoted = new HashSet<String>(); if (filter != null && !filter.isEmpty()) { keySetList.addAll(SearchUtil.findKeys(filter, quoted)); } Project project = myProjectProfileManager.getProject(); final boolean emptyFilter = myInspectionsFilter.isEmptyFilter(); for (ToolDescriptors toolDescriptors : myInitialToolDescriptors) { final Descriptor descriptor = toolDescriptors.getDefaultDescriptor(); if (filter != null && !filter.isEmpty() && !isDescriptorAccepted(descriptor, filter, forceInclude, keySetList, quoted)) { continue; } if (!emptyFilter && !myInspectionsFilter.matches(mySelectedProfile.getTools(toolDescriptors.getDefaultDescriptor().getKey().toString(), project))) { continue; } final InspectionConfigTreeNode node = new InspectionConfigTreeNode(toolDescriptors); getGroupNode(myRoot, toolDescriptors.getDefaultDescriptor().getGroup()).add(node); myRoot.dropCache(); } if (filter != null && forceInclude && myRoot.getChildCount() == 0) { final Set<String> filters = SearchableOptionsRegistrar.getInstance().getProcessedWords(filter); if (filters.size() > 1 || !quoted.isEmpty()) { fillTreeData(filter, false); } } TreeUtil.sort(myRoot, new InspectionsConfigTreeComparator()); }
Example 6
Source File: FileTreeModelBuilder.java From consulo with Apache License 2.0 | 5 votes |
private TreeModel build(final Set<PsiFile> files, boolean showProgress) { if (files.size() == 1) { myShowFiles = true; } Runnable buildingRunnable = new Runnable() { @Override public void run() { for (final PsiFile file : files) { if (file != null) { buildFileNode(file.getVirtualFile(), null); } } } }; if (showProgress) { ProgressManager.getInstance().runProcessWithProgressSynchronously(buildingRunnable, AnalysisScopeBundle .message("package.dependencies.build.process.title"), false, myProject); } else { buildingRunnable.run(); } TreeUtil.sort(myRoot, new DependencyNodeComparator()); return new TreeModel(myRoot, myTotalFileCount, myMarkedFileCount); }
Example 7
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
private void reload(@Nullable final DefaultMutableTreeNode rootToReload) { final DefaultTreeModel treeModel = (DefaultTreeModel)myTree.getModel(); if (rootToReload != null && rootToReload != treeModel.getRoot()) { final List<TreePath> treePaths = TreeUtil.collectExpandedPaths(myTree, new TreePath(rootToReload.getPath())); final List<TreePath> selectionPaths = TreeUtil.collectSelectedPaths(myTree, new TreePath(rootToReload.getPath())); final TreePath path = new TreePath(rootToReload.getPath()); final boolean wasCollapsed = myTree.isCollapsed(path); final Runnable runnable = new Runnable() { @Override public void run() { if (!isTreeShowing() || rootToReload.getParent() == null) return; TreeUtil.sort(rootToReload, getNodeComparator()); treeModel.reload(rootToReload); if (!wasCollapsed) { myTree.collapsePath(path); for (TreePath treePath : treePaths) { myTree.expandPath(treePath); } for (TreePath selectionPath : selectionPaths) { TreeUtil.selectPath(myTree, selectionPath); } } } }; if (ApplicationManager.getApplication().isUnitTestMode()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } } else { TreeUtil.sort(treeModel, getNodeComparator()); treeModel.reload(); } }
Example 8
Source File: MasterDetailsComponent.java From consulo with Apache License 2.0 | 4 votes |
protected void addNode(MyNode nodeToAdd, MyNode parent) { parent.add(nodeToAdd); TreeUtil.sort(parent, getNodeComparator()); ((DefaultTreeModel)myTree.getModel()).reload(parent); }
Example 9
Source File: TreeModelBuilder.java From consulo with Apache License 2.0 | 4 votes |
private void sortNodes() { TreeUtil.sort(myModel, BROWSER_NODE_COMPARATOR); myModel.nodeStructureChanged((TreeNode)myModel.getRoot()); }