Java Code Examples for com.intellij.ui.treeStructure.Tree#setShowsRootHandles()
The following examples show how to use
com.intellij.ui.treeStructure.Tree#setShowsRootHandles() .
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: InspectorPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void initTree(final Tree tree) { tree.setCellRenderer(new DiagnosticsTreeCellRenderer(this)); tree.setShowsRootHandles(true); TreeUtil.installActions(tree); PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(), ActionManager.getInstance()); new TreeSpeedSearch(tree) { @Override protected String getElementText(Object element) { final TreePath path = (TreePath)element; final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); final Object object = node.getUserObject(); if (object instanceof DiagnosticsNode) { // TODO(pq): consider a specialized String for matching. return object.toString(); } return null; } }; }
Example 2
Source File: InspectorPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void initTree(final Tree tree) { tree.setCellRenderer(new DiagnosticsTreeCellRenderer(this)); tree.setShowsRootHandles(true); TreeUtil.installActions(tree); PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(), ActionManager.getInstance()); new TreeSpeedSearch(tree) { @Override protected String getElementText(Object element) { final TreePath path = (TreePath)element; final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); final Object object = node.getUserObject(); if (object instanceof DiagnosticsNode) { // TODO(pq): consider a specialized String for matching. return object.toString(); } return null; } }; }
Example 3
Source File: StructureFilteringStrategy.java From consulo with Apache License 2.0 | 6 votes |
public MyUI() { myStructureTree = new Tree(); myStructureTree.setRootVisible(false); myStructureTree.setShowsRootHandles(true); myStructureTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(final TreeSelectionEvent e) { final List<FilePath> filePaths = new ArrayList<>(mySelection); mySelection.clear(); final TreePath[] selectionPaths = myStructureTree.getSelectionPaths(); if (selectionPaths != null) { for (TreePath selectionPath : selectionPaths) { mySelection.addAll(getFilePathsUnder((ChangesBrowserNode<?>)selectionPath.getLastPathComponent())); } } if (Comparing.haveEqualElements(filePaths, mySelection)) return; for (ChangeListener listener : myListeners) { listener.stateChanged(new ChangeEvent(this)); } } }); myScrollPane = ScrollPaneFactory.createScrollPane(myStructureTree); }
Example 4
Source File: ModulesDependenciesPanel.java From consulo with Apache License 2.0 | 6 votes |
private static void initTree(Tree tree, boolean isRightTree) { tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setCellRenderer(new MyTreeCellRenderer()); tree.setRootVisible(false); tree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(tree); TreeUtil.installActions(tree); new TreeSpeedSearch(tree, new Convertor<TreePath, String>() { @Override public String convert(TreePath o) { return o.getLastPathComponent().toString(); } }, true); PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree, tree), ActionManager.getInstance()); }
Example 5
Source File: ContentEntryTreeEditor.java From consulo with Apache License 2.0 | 6 votes |
public ContentEntryTreeEditor(Project project, ModuleConfigurationState state) { myProject = project; myState = state; myTree = new Tree(); myTree.setRootVisible(true); myTree.setShowsRootHandles(true); myEditingActionsGroup = new DefaultActionGroup(); TreeUtil.installActions(myTree); new TreeSpeedSearch(myTree); myTreePanel = new MyPanel(new BorderLayout()); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree); myTreePanel.add(scrollPane, BorderLayout.CENTER); myTreePanel.setVisible(false); myDescriptor = FileChooserDescriptorFactory.createMultipleFoldersDescriptor(); myDescriptor.setShowFileSystemRoots(false); }
Example 6
Source File: FileTemplateTabAsTree.java From consulo with Apache License 2.0 | 6 votes |
protected FileTemplateTabAsTree(String title) { super(title); myRoot = initModel(); myTreeModel = new MyTreeModel(myRoot); myTree = new Tree(myTreeModel); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); myTree.expandPath(TreeUtil.getPathFromRoot(myRoot)); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myTree.setCellRenderer(new MyTreeCellRenderer()); myTree.expandRow(0); myTree.addTreeSelectionListener(e -> onTemplateSelected()); new TreeSpeedSearch(myTree); }
Example 7
Source File: DirectoryChooserModuleTreeView.java From consulo with Apache License 2.0 | 6 votes |
public DirectoryChooserModuleTreeView(@Nonnull Project project) { myRootNode = new DefaultMutableTreeNode(); myTree = new Tree(myRootNode); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); myProject = project; myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setCellRenderer(new MyTreeCellRenderer()); new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() { @Override public String convert(final TreePath o) { final Object userObject = ((DefaultMutableTreeNode)o.getLastPathComponent()).getUserObject(); if (userObject instanceof Module) { return ((Module)userObject).getName(); } else { if (userObject == null) return ""; return userObject.toString(); } } }, true); }
Example 8
Source File: IMContactView.java From SmartIM4IntelliJ with Apache License 2.0 | 5 votes |
protected void initTree(Tree tree) { tree.setCellRenderer(getContactRenderer()); tree.setShowsRootHandles(false); tree.setRootVisible(false); tree.addMouseListener(new IMContactDoubleClicker(getImPanel())); tree.setUI(new WideSelectionTreeUI() { }); }
Example 9
Source File: VcsPullRequestsForm.java From azure-devops-intellij with MIT License | 5 votes |
protected void createCustomView() { //Tree in a scroll panel pullRequestsTree = new Tree(); pullRequestsTree.setCellRenderer(new PRTreeCellRenderer()); pullRequestsTree.setShowsRootHandles(true); pullRequestsTree.setRootVisible(false); pullRequestsTree.setRowHeight(0); //dynamically have row height computed for each row scrollPanel = new JBScrollPane(pullRequestsTree); }
Example 10
Source File: ActionsTree.java From consulo with Apache License 2.0 | 5 votes |
public ActionsTree() { myRoot = new DefaultMutableTreeNode(ROOT); myTree = new Tree(new MyModel(myRoot)) { @Override public void paint(Graphics g) { super.paint(g); Rectangle visibleRect = getVisibleRect(); Rectangle clip = g.getClipBounds(); for (int row = 0; row < getRowCount(); row++) { Rectangle rowBounds = getRowBounds(row); rowBounds.x = 0; rowBounds.width = Integer.MAX_VALUE; if (rowBounds.intersects(clip)) { Object node = getPathForRow(row).getLastPathComponent(); if (node instanceof DefaultMutableTreeNode) { Object data = ((DefaultMutableTreeNode)node).getUserObject(); Rectangle fullRowRect = new Rectangle(visibleRect.x, rowBounds.y, visibleRect.width, rowBounds.height); paintRowData(this, data, fullRowRect, (Graphics2D)g); } } } } }; myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.putClientProperty(WideSelectionTreeUI.STRIPED_CLIENT_PROPERTY, Boolean.TRUE); myTree.setCellRenderer(new KeymapsRenderer()); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myComponent = ScrollPaneFactory.createScrollPane(myTree, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); }
Example 11
Source File: MemberChooser.java From consulo with Apache License 2.0 | 5 votes |
protected Tree createTree() { final Tree tree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode())); tree.setCellRenderer(getTreeCellRenderer()); UIUtil.setLineStyleAngled(tree); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.addKeyListener(new TreeKeyListener()); tree.addTreeSelectionListener(new MyTreeSelectionListener()); if (!myAllowMultiSelection) { tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); } new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent e) { if (tree.getPathForLocation(e.getX(), e.getY()) != null) { doOKAction(); return true; } return false; } }.installOn(tree); TreeUtil.installActions(tree); return tree; }
Example 12
Source File: PantsConsoleViewPanel.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
public PantsConsoleViewPanel(Project project, ConsoleView console) { myProject = project; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); AutoScrollToSourceHandler autoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } @Override protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; JPanel myMessagePanel = new JPanel(new BorderLayout()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); final DefaultTreeModel treeModel = new DefaultTreeModel(root); Tree tree = createTree(treeModel); tree.getEmptyText().setText(IdeBundle.message("errortree.noMessages")); autoScrollToSourceHandler.install(tree); TreeUtil.installActions(tree); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(tree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(console.getComponent(), BorderLayout.CENTER); add(createToolbarPanel(), BorderLayout.WEST); add(myMessagePanel, BorderLayout.CENTER); EditSourceOnDoubleClickHandler.install(tree); }
Example 13
Source File: ServersToolWindowContent.java From consulo with Apache License 2.0 | 4 votes |
public ServersToolWindowContent(@Nonnull Project project) { super(new BorderLayout()); myProject = project; myTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode()); myTree = new Tree(myTreeModel); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setCellRenderer(new NodeRenderer()); myTree.setLineStyleAngled(); getMainPanel().add(createToolbar(), BorderLayout.WEST); Splitter splitter = new OnePixelSplitter(false, 0.3f); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree, SideBorder.LEFT)); myPropertiesPanelLayout = new CardLayout(); myPropertiesPanel = new JPanel(myPropertiesPanelLayout); myMessageLabel = new JLabel(EMPTY_SELECTION_MESSAGE, SwingConstants.CENTER); myPropertiesPanel.add(MESSAGE_CARD, new Wrapper(myMessageLabel)); splitter.setSecondComponent(myPropertiesPanel); getMainPanel().add(splitter, BorderLayout.CENTER); setupBuilder(project); for (RemoteServersViewContributor contributor : RemoteServersViewContributor.EP_NAME.getExtensionList()) { contributor.setupTree(myProject, myTree, myBuilder); } myTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { onSelectionChanged(); } }); new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent event) { Set<ServersTreeStructure.RemoteServerNode> nodes = getSelectedRemoteServerNodes(); if (nodes.size() == 1) { RemoteServer<?> server = nodes.iterator().next().getValue(); ServerConnectionManager.getInstance().getOrCreateConnection(server).computeDeployments(EmptyRunnable.INSTANCE); return true; } return false; } }.installOn(myTree); }
Example 14
Source File: NewErrorTreeViewPanel.java From consulo with Apache License 2.0 | 4 votes |
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) { myProject = project; myHelpId = helpId; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } @Override protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; myMessagePanel = new JPanel(new BorderLayout()); myErrorViewStructure = new ErrorViewStructure(project, canHideWarningsOrInfos()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); root.setUserObject(myErrorViewStructure.createDescriptor(myErrorViewStructure.getRootElement(), null)); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = new Tree(treeModel) { @Override public void setRowHeight(int i) { super.setRowHeight(0); // this is needed in order to make UI calculate the height for each particular row } }; myBuilder = new ErrorViewTreeBuilder(myTree, treeModel, myErrorViewStructure); myExporterToTextFile = new ErrorViewTextExporter(myErrorViewStructure); myOccurenceNavigatorSupport = new MyOccurenceNavigatorSupport(myTree); myAutoScrollToSourceHandler.install(myTree); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(scrollPane, BorderLayout.CENTER); if (createToolbar) { add(createToolbarPanel(rerunAction), BorderLayout.WEST); } add(myMessagePanel, BorderLayout.CENTER); myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { navigateToSource(false); } } }); myTree.addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { popupInvoked(comp, x, y); } }); EditSourceOnDoubleClickHandler.install(myTree); }
Example 15
Source File: FileChooserDialogImpl.java From consulo with Apache License 2.0 | 4 votes |
protected JTree createTree() { Tree internalTree = createInternalTree(); myFileSystemTree = new FileSystemTreeImpl(myProject, myChooserDescriptor, internalTree, null, null, null); internalTree.setRootVisible(myChooserDescriptor.isTreeRootVisible()); internalTree.setShowsRootHandles(true); Disposer.register(myDisposable, myFileSystemTree); myFileSystemTree.addOkAction(new Runnable() { public void run() { doOKAction(); } }); JTree tree = myFileSystemTree.getTree(); if (!Registry.is("file.chooser.async.tree.model")) tree.setCellRenderer(new NodeRenderer()); tree.getSelectionModel().addTreeSelectionListener(new FileTreeSelectionListener()); tree.addTreeExpansionListener(new FileTreeExpansionListener()); setOKActionEnabled(false); myFileSystemTree.addListener(new FileSystemTree.Listener() { public void selectionChanged(final List<? extends VirtualFile> selection) { updatePathFromTree(selection, false); } }, myDisposable); new FileDrop(tree, new FileDrop.Target() { public FileChooserDescriptor getDescriptor() { return myChooserDescriptor; } public boolean isHiddenShown() { return myFileSystemTree.areHiddensShown(); } public void dropFiles(final List<VirtualFile> files) { if (!myChooserDescriptor.isChooseMultiple() && files.size() > 0) { selectInTree(new VirtualFile[]{files.get(0)}, true); } else { selectInTree(VfsUtilCore.toVirtualFileArray(files), true); } } }); return tree; }