@Nullable public static Object getTagAtForRenderer(CheckboxTree.CheckboxTreeCellRenderer renderer, MouseEvent e) { JTree tree = (JTree)e.getSource(); Object tag = null; final TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path != null) { final Rectangle rectangle = tree.getPathBounds(path); assert rectangle != null; int dx = e.getX() - rectangle.x; final TreeNode treeNode = (TreeNode)path.getLastPathComponent(); final int row = tree.getRowForLocation(e.getX(), e.getY()); tree.getCellRenderer().getTreeCellRendererComponent(tree, treeNode, false, false, true, row, true); if (treeNode instanceof RepositoryNode) { RepositoryNode repositoryNode = (RepositoryNode)treeNode; int checkBoxWidth = repositoryNode.isCheckboxVisible() ? renderer.getCheckbox().getWidth() : 0; tag = renderer.getTextRenderer().getFragmentTagAt(dx - checkBoxWidth); } else { tag = renderer.getTextRenderer().getFragmentTagAt(dx); } } return tag; }
/** * Creates scroll panel with templates tree in it. * * @return scroll panel */ private JScrollPane createTreeScrollPanel() { for (Map.Entry<VirtualFile, VcsRoot> entry : files.entrySet()) { createDirectoryNodes(entry.getKey(), entry.getValue()); } final FileTreeRenderer renderer = new FileTreeRenderer(); tree = new CheckboxTree(renderer, root); tree.setCellRenderer(renderer); tree.setRootVisible(true); tree.setShowsRootHandles(false); UIUtil.setLineStyleAngled(tree); TreeUtil.installActions(tree); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); TreeUtil.expandAll(tree); tree.getModel().addTreeModelListener(treeModelListener); treeExpander = new DefaultTreeExpander(tree); return scrollPane; }
public VcsBranchEditorListener(final CheckboxTree.CheckboxTreeCellRenderer renderer) { myRenderer = renderer; }
public CheckboxTreeTable(CheckedTreeNode root, CheckboxTree.CheckboxTreeCellRenderer renderer, final ColumnInfo[] columns) { super(new ListTreeTableModelOnColumns(root, columns)); initTree(getTree(), renderer); }