Java Code Examples for com.intellij.util.ui.tree.TreeUtil#installActions()
The following examples show how to use
com.intellij.util.ui.tree.TreeUtil#installActions() .
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: LiteralChooser.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Nullable @Override protected JComponent createCenterPanel() { JPanel panel = new JPanel(new BorderLayout()); 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); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree); // scrollPane.setPreferredSize(new Dimension(350, 450)); panel.add(scrollPane, BorderLayout.CENTER); return panel; }
Example 4
Source File: StructureViewComponent.java From consulo with Apache License 2.0 | 6 votes |
private void setupTree() { myTree.setCellRenderer(new NodeRenderer()); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); myTree.setShowsRootHandles(true); registerPsiListener(myProject, this, this::queueUpdate); myProject.getMessageBus().connect(this).subscribe(UISettingsListener.TOPIC, o -> rebuild()); if (showScrollToFromSourceActions()) { myAutoScrollToSourceHandler.install(myTree); myAutoScrollFromSourceHandler.install(); } TreeUtil.installActions(getTree()); new TreeSpeedSearch(getTree(), treePath -> { Object userObject = TreeUtil.getLastUserObject(treePath); return userObject != null ? FileStructurePopup.getSpeedSearchText(userObject) : null; }); addTreeKeyListener(); addTreeMouseListeners(); restoreState(); }
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: 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 7
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
private void initTree() { myTree.setCellRenderer(new MyTreeCellRenderer()); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); TreeUtil.installActions(myTree); EditSourceOnDoubleClickHandler.install(myTree); new TreeSpeedSearch(myTree); myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) { @Override @Nonnull protected PsiElement[] getSelectedElements() { return getSelectedPsiElements(); } }; myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject); final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject); for (ScopeTreeStructureExpander expander : extensions) { myTree.addTreeWillExpandListener(expander); } if (extensions.length == 0) { myTree.addTreeWillExpandListener(new SortingExpandListener()); } myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { final Object component = myTree.getLastSelectedPathComponent(); if (component instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component; if (selectedNode.isLeaf()) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false); } } } } }); CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP); }
Example 8
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 9
Source File: AbstractProjectViewPSIPane.java From consulo with Apache License 2.0 | 5 votes |
private void initTree() { myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.expandPath(new TreePath(myTree.getModel().getRoot())); EditSourceOnDoubleClickHandler.install(myTree); ToolTipManager.sharedInstance().registerComponent(myTree); TreeUtil.installActions(myTree); new MySpeedSearch(myTree); myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { TreePath path = getSelectedPath(); if (path != null && !myTree.getModel().isLeaf(path.getLastPathComponent())) { return; } DataContext dataContext = DataManager.getInstance().getDataContext(myTree); OpenSourceUtil.openSourcesFrom(dataContext, ScreenReader.isActive()); } else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) { if (e.isConsumed()) return; PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance(); boolean[] isCopied = new boolean[1]; if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) { copyPasteManager.clear(); e.consume(); } } } }); CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP); }
Example 10
Source File: HierarchyBrowserBase.java From consulo with Apache License 2.0 | 5 votes |
protected void configureTree(@Nonnull Tree tree) { tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.setToggleClickCount(-1); tree.setCellRenderer(new HierarchyNodeRenderer()); UIUtil.setLineStyleAngled(tree); new TreeSpeedSearch(tree); TreeUtil.installActions(tree); myAutoScrollToSourceHandler.install(tree); }
Example 11
Source File: DependenciesPanel.java From consulo with Apache License 2.0 | 5 votes |
private void initTree(final MyTree tree, boolean isRightTree) { tree.setCellRenderer(new MyTreeCellRenderer()); tree.setRootVisible(false); tree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(tree); TreeUtil.installActions(tree); SmartExpander.installOn(tree); EditSourceOnDoubleClickHandler.install(tree); new TreeSpeedSearch(tree); PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree), ActionManager.getInstance()); }
Example 12
Source File: PsiViewerDialog.java From consulo with Apache License 2.0 | 5 votes |
private static void initTree(JTree tree) { UIUtil.setLineStyleAngled(tree); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.updateUI(); ToolTipManager.sharedInstance().registerComponent(tree); TreeUtil.installActions(tree); new TreeSpeedSearch(tree); }
Example 13
Source File: InspectionTree.java From consulo with Apache License 2.0 | 5 votes |
public InspectionTree(@Nonnull Project project, @Nonnull GlobalInspectionContextImpl context) { super(new InspectionRootNode(project)); myContext = context; setCellRenderer(new CellRenderer()); setShowsRootHandles(true); UIUtil.setLineStyleAngled(this); addTreeWillExpandListener(new ExpandListener()); myExpandedUserObjects = new HashSet<Object>(); myExpandedUserObjects.add(project); TreeUtil.installActions(this); new TreeSpeedSearch(this, new Convertor<TreePath, String>() { @Override public String convert(TreePath o) { return InspectionsConfigTreeComparator.getDisplayTextToSort(o.getLastPathComponent().toString()); } }); addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath newSelection = e.getNewLeadSelectionPath(); if (newSelection != null) { mySelectionPath = new SelectionPath(newSelection); } } }); }
Example 14
Source File: CheckboxTreeNoPolicy.java From consulo with Apache License 2.0 | 5 votes |
public CheckboxTreeNoPolicy(CheckboxTreeCellRendererBase cellRenderer, @Nullable CheckedTreeNode root) { setRootVisible(false); setShowsRootHandles(true); setLineStyleAngled(); TreeUtil.installActions(this); installRenderer(cellRenderer); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (isToggleEvent(e)) { TreePath treePath = getLeadSelectionPath(); if (treePath == null) return; final Object o = treePath.getLastPathComponent(); if (!(o instanceof CheckedTreeNode)) return; CheckedTreeNode firstNode = (CheckedTreeNode)o; boolean checked = toggleNode(firstNode); TreePath[] selectionPaths = getSelectionPaths(); for (int i = 0; selectionPaths != null && i < selectionPaths.length; i++) { final TreePath selectionPath = selectionPaths[i]; final Object o1 = selectionPath.getLastPathComponent(); if (!(o1 instanceof CheckedTreeNode)) continue; CheckedTreeNode node = (CheckedTreeNode)o1; checkNode(node, checked); ((DefaultTreeModel)getModel()).nodeChanged(node); } e.consume(); } } }); setSelectionRow(0); if (root != null) { setModel(new DefaultTreeModel(root)); } }
Example 15
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 16
Source File: TestTreeView.java From consulo with Apache License 2.0 | 5 votes |
protected void installHandlers() { EditSourceOnDoubleClickHandler.install(this); new TreeSpeedSearch(this, new Convertor<TreePath, String>() { public String convert(final TreePath path) { final AbstractTestProxy testProxy = getSelectedTest(path); if (testProxy == null) return null; return testProxy.getName(); } }); TreeUtil.installActions(this); PopupHandler.installPopupHandler(this, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP); }
Example 17
Source File: UpdateInfoTree.java From consulo with Apache License 2.0 | 4 votes |
private void createTree() { SmartExpander.installOn(myTree); SelectionSaver.installOn(myTree); createTreeModel(); myTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { AbstractTreeNode treeNode = (AbstractTreeNode)e.getPath().getLastPathComponent(); VirtualFilePointer pointer = null; if (treeNode instanceof FileTreeNode) { pointer = ((FileTreeNode)treeNode).getFilePointer(); if (!pointer.isValid()) pointer = null; } if (pointer != null) { mySelectedUrl = getFilePath(pointer); mySelectedFile = pointer.getFile(); } else { mySelectedUrl = null; mySelectedFile = null; } } }); myTree.setCellRenderer(new UpdateTreeCellRenderer()); TreeUtil.installActions(myTree); new TreeSpeedSearch(myTree, path -> { Object last = path.getLastPathComponent(); if (last instanceof AbstractTreeNode) { return ((AbstractTreeNode)last).getText(); } return TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING.convert(path); }, true); myTree.addMouseListener(new PopupHandler() { public void invokePopup(Component comp, int x, int y) { final DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction("UpdateActionGroup"); if (group != null) { //if no UpdateActionGroup was configured ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UPDATE_POPUP, group); popupMenu.getComponent().show(comp, x, y); } } }); EditSourceOnDoubleClickHandler.install(myTree); EditSourceOnEnterKeyHandler.install(myTree); myTree.setSelectionRow(0); }
Example 18
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 19
Source File: GeneratorDialog.java From idea-gitignore with MIT License | 4 votes |
/** * Creates scroll panel with templates tree in it. * * @return scroll panel */ private JScrollPane createTreeScrollPanel() { fillTreeData(null, true); final TemplateTreeRenderer renderer = new TemplateTreeRenderer() { protected String getFilter() { return profileFilter != null ? profileFilter.getFilter() : null; } }; tree = new CheckboxTree(renderer, root) { public Dimension getPreferredScrollableViewportSize() { Dimension size = super.getPreferredScrollableViewportSize(); size = new Dimension(size.width + 10, size.height); return size; } @Override protected void onNodeStateChanged(CheckedTreeNode node) { super.onNodeStateChanged(node); Resources.Template template = ((TemplateTreeNode) node).getTemplate(); if (node.isChecked()) { checked.add(template); } else { checked.remove(template); } } }; tree.setCellRenderer(renderer); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.addTreeSelectionListener(treeSelectionListener); TreeUtil.installActions(tree); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); TreeUtil.expandAll(tree); treeExpander = new DefaultTreeExpander(tree); profileFilter = new TemplatesFilterComponent(); return scrollPane; }
Example 20
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); }