com.intellij.ide.util.treeView.AbstractTreeBuilder Java Examples
The following examples show how to use
com.intellij.ide.util.treeView.AbstractTreeBuilder.
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: TreeUtil.java From consulo with Apache License 2.0 | 6 votes |
private static void scrollToVisible(JTree tree, TreePath path, Rectangle bounds, int offset, long expected, Runnable done, AbstractTreeBuilder builder, int attempt) { Runnable scroll = () -> { Rectangle pathBounds = attempt <= 0 ? null : tree.getPathBounds(path); if (pathBounds != null) { Object property = tree.getClientProperty(TREE_UTIL_SCROLL_TIME_STAMP); long stamp = property instanceof Long ? (Long)property : Long.MAX_VALUE; LOG.debug("tree scroll ", attempt, stamp == expected ? ": try again: " : ": ignore: ", path); if (stamp == expected) { bounds.y = pathBounds.y - offset; // restore bounds according to the current row Rectangle visible = tree.getVisibleRect(); if (bounds.y < visible.y || bounds.y > visible.y + Math.max(0, visible.height - bounds.height)) { tree.scrollRectToVisible(bounds); scrollToVisible(tree, path, bounds, offset, expected, done, builder, attempt - 1); return; // try to scroll again } } } done.run(); }; //noinspection SSBasedInspection SwingUtilities.invokeLater(builder == null ? scroll : () -> builder.getReady(TreeUtil.class).doWhenDone(scroll)); }
Example #2
Source File: ProjectViewImpl.java From consulo with Apache License 2.0 | 5 votes |
public void apply(final AbstractProjectViewPane viewPane) { if (viewPane == null) { return; } AbstractTreeBuilder treeBuilder = viewPane.getTreeBuilder(); JTree tree = viewPane.myTree; if (treeBuilder != null) { DefaultTreeModel treeModel = (DefaultTreeModel)tree.getModel(); List<TreePath> paths = new ArrayList<>(myElements.length); for (final Object element : myElements) { DefaultMutableTreeNode node = treeBuilder.getNodeForElement(element); if (node == null) { treeBuilder.buildNodeForElement(element); node = treeBuilder.getNodeForElement(element); } if (node != null) { paths.add(new TreePath(treeModel.getPathToRoot(node))); } } if (!paths.isEmpty()) { tree.setSelectionPaths(paths.toArray(new TreePath[0])); } } else { List<TreeVisitor> visitors = AbstractProjectViewPane.createVisitors(myElements); if (1 == visitors.size()) { TreeUtil.promiseSelect(tree, visitors.get(0)); } else if (!visitors.isEmpty()) { TreeUtil.promiseSelect(tree, visitors.stream()); } } }
Example #3
Source File: SimpleTree.java From consulo with Apache License 2.0 | 5 votes |
public boolean accept(AbstractTreeBuilder builder, final SimpleNodeVisitor visitor) { return builder.accept(SimpleNode.class, new TreeVisitor<SimpleNode>() { @Override public boolean visit(@Nonnull SimpleNode node) { return visitor.accept(node); } }) != null; }
Example #4
Source File: SimpleTree.java From consulo with Apache License 2.0 | 5 votes |
public boolean select(AbstractTreeBuilder aBuilder, final SimpleNodeVisitor aVisitor, boolean shouldExpand) { return aBuilder.select(SimpleNode.class, new TreeVisitor<SimpleNode>() { @Override public boolean visit(@Nonnull SimpleNode node) { return aVisitor.accept(node); } }, null, false); }
Example #5
Source File: FileSystemTreeImpl.java From consulo with Apache License 2.0 | 5 votes |
protected AbstractTreeBuilder createTreeBuilder(final JTree tree, DefaultTreeModel treeModel, final AbstractTreeStructure treeStructure, final Comparator<NodeDescriptor> comparator, FileChooserDescriptor descriptor, @Nullable final Runnable onInitialized) { return new FileTreeBuilder(tree, treeModel, treeStructure, comparator, descriptor, onInitialized); }
Example #6
Source File: ProjectViewPane.java From consulo with Apache License 2.0 | 4 votes |
private ProjectViewTreeUpdater(final AbstractTreeBuilder treeBuilder) { super(treeBuilder); }
Example #7
Source File: KnowledgeViewPane.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
private AbstractTreeUpdater createTreeUpdater(final AbstractTreeBuilder builder) { return new AbstractTreeUpdater(builder); }
Example #8
Source File: ProjectViewPane.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override protected AbstractTreeUpdater createTreeUpdater(@Nonnull AbstractTreeBuilder treeBuilder) { return new ProjectViewTreeUpdater(treeBuilder); }
Example #9
Source File: PackageViewPane.java From consulo with Apache License 2.0 | 4 votes |
private PackageViewTreeUpdater(final AbstractTreeBuilder treeBuilder) { super(treeBuilder); }
Example #10
Source File: PackageViewPane.java From consulo with Apache License 2.0 | 4 votes |
@Override protected AbstractTreeUpdater createTreeUpdater(AbstractTreeBuilder treeBuilder) { return new PackageViewTreeUpdater(treeBuilder); }
Example #11
Source File: LayoutTree.java From consulo with Apache License 2.0 | 4 votes |
public void addSubtreeToUpdate(DefaultMutableTreeNode newNode) { AbstractTreeBuilder.getBuilderFor(this).addSubtreeToUpdate(newNode); }
Example #12
Source File: TreeContent.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull AbstractTreeBuilder getBuilder();
Example #13
Source File: FileSystemTreeImpl.java From consulo with Apache License 2.0 | 4 votes |
public AbstractTreeBuilder getTreeBuilder() { return myTreeBuilder; }
Example #14
Source File: SimpleTree.java From consulo with Apache License 2.0 | 4 votes |
public void setSelectedNode(AbstractTreeBuilder builder, SimpleNode node, boolean expand) { builder.select(node.getElement(), null, false); }
Example #15
Source File: TestProjectViewPSIPane.java From consulo with Apache License 2.0 | 4 votes |
@Override protected AbstractTreeUpdater createTreeUpdater(AbstractTreeBuilder treeBuilder) { return new AbstractTreeUpdater(treeBuilder); }
Example #16
Source File: TestTreeUpdater.java From consulo with Apache License 2.0 | 4 votes |
public TestTreeUpdater(AbstractTreeBuilder treeBuilder) { super(treeBuilder); }
Example #17
Source File: CruciblePanel.java From Crucible4IDEA with MIT License | 4 votes |
public CruciblePanel(@NotNull final Project project) { super(false); myProject = project; final JBSplitter splitter = new JBSplitter(false, 0.2f); myReviewModel = new CrucibleReviewModel(project); myReviewTable = new JBTable(myReviewModel); myReviewTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myReviewTable.setStriped(true); myReviewTable.setExpandableItemsEnabled(false); final TableColumnModel columnModel = myReviewTable.getColumnModel(); columnModel.getColumn(1).setCellRenderer(new DescriptionCellRenderer()); setUpColumnWidths(myReviewTable); myReviewTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { final int viewRow = myReviewTable.getSelectedRow(); if (viewRow >= 0 && viewRow < myReviewTable.getRowCount()) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { final Review review = CrucibleManager.getInstance(myProject).getDetailsForReview((String)myReviewTable. getValueAt(viewRow, myReviewTable.getColumnModel().getColumnIndex(CrucibleBundle.message("crucible.id")))); if (review != null) { openDetailsToolWindow(review); myReviewTable.clearSelection(); } } }, ModalityState.stateForComponent(myReviewTable)); } } }}); final TableRowSorter<TableModel> rowSorter = new TableRowSorter<TableModel>(myReviewModel); rowSorter.setSortKeys(Collections.singletonList(new RowSorter.SortKey(4, SortOrder.ASCENDING))); rowSorter.sort(); myReviewTable.setRowSorter(rowSorter); final JScrollPane detailsScrollPane = ScrollPaneFactory.createScrollPane(myReviewTable); final SimpleTreeStructure reviewTreeStructure = createTreeStructure(); final DefaultTreeModel model = new CrucibleTreeModel(); final SimpleTree reviewTree = new SimpleTree(model); new AbstractTreeBuilder(reviewTree, model, reviewTreeStructure, null); reviewTree.invalidate(); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(reviewTree); splitter.setFirstComponent(scrollPane); splitter.setSecondComponent(detailsScrollPane); setContent(splitter); }
Example #18
Source File: ImagesProjectViewPane.java From intellij-sdk-docs with Apache License 2.0 | 4 votes |
@NotNull @Override protected AbstractTreeUpdater createTreeUpdater(@NotNull AbstractTreeBuilder builder) { return new AbstractTreeUpdater(builder); }
Example #19
Source File: ProjectFilesViewPane.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
@Override protected AbstractTreeUpdater createTreeUpdater(AbstractTreeBuilder treeBuilder) { return new AbstractTreeUpdater(treeBuilder); }
Example #20
Source File: DashboardTreeAction.java From consulo with Apache License 2.0 | 2 votes |
/** * This implementation returns a set of selected nodes. * Subclasses may override this method to return modified nodes set. * * @param treeBuilder Tree builder. * @return Set of tree nodes for which action should be performed. */ @Nonnull protected Set<?> collectNodes(@Nonnull AbstractTreeBuilder treeBuilder) { return treeBuilder.getSelectedElements(); }