Java Code Examples for com.intellij.ui.treeStructure.Tree#setCellRenderer()
The following examples show how to use
com.intellij.ui.treeStructure.Tree#setCellRenderer() .
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: 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 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: 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 4
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 5
Source File: ActiveConnectionPanel.java From p4ic4idea with Apache License 2.0 | 6 votes |
private void setup() { root = new JPanel(new BorderLayout()); JScrollPane scroll = new JBScrollPane(); root.add(scroll, BorderLayout.CENTER); connectionTree = new Tree(); scroll.setViewportView(connectionTree); connectionTree.getEmptyText().setText(P4Bundle.getString("connection.tree.initial")); connectionTree.setEditable(false); connectionTreeModel = new DefaultTreeModel(treeNode); connectionTree.setModel(connectionTreeModel); connectionTree.setCellRenderer(new ConnectionTreeCellRenderer()); connectionTree.setRootVisible(false); DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel(); selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); connectionTree.setSelectionModel(selectionModel); ActionGroup actionButtons = createActionGroup(); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("p4.active-connection", actionButtons, false); root.add(toolbar.getComponent(), BorderLayout.WEST); // TODO add context menu support for each selected node type. // TODO add support for navigating to a file if a FilePath is selected. }
Example 6
Source File: LiteralChooser.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Tree createTree(java.util.List<String> literals) { final CheckedTreeNode rootNode = new CheckedTreeNode("all literals not defined"); for (String literal : literals) { CheckedTreeNode child = new CheckedTreeNode(new LiteralChooserObject(literal, Icons.LEXER_RULE)); child.setChecked(true); rootNode.add(child); } DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); selectedElements.addAll(literals); // all are "on" by default Tree tree = new Tree(treeModel); tree.setRootVisible(false); tree.setCellRenderer(new LiteralChooserRenderer()); tree.addTreeSelectionListener(new MyTreeSelectionListener()); return tree; }
Example 7
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 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: 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 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: ImageDuplicateResultsDialog.java From consulo with Apache License 2.0 | 5 votes |
public ImageDuplicateResultsDialog(Project project, List<VirtualFile> images, Map<String, Set<VirtualFile>> duplicates) { super(project); myProject = project; myImages = images; PropertiesComponent.getInstance(myProject).loadFields(myResourceModules); myDuplicates = duplicates; setModal(false); myTree = new Tree(new MyRootNode()); myTree.setRootVisible(true); myTree.setCellRenderer(new MyCellRenderer()); init(); TreeUtil.expandAll(myTree); setTitle("Image Duplicates"); TreeUtil.selectFirstNode(myTree); }
Example 12
Source File: AnalyzeDependenciesComponent.java From consulo with Apache License 2.0 | 5 votes |
/** * @return a created tree component (to be used as */ private JComponent createTreeComponent() { myExplanationTree = new Tree(new DefaultTreeModel(buildTree())); myExplanationTree.setRootVisible(false); myExplanationTree.setCellRenderer(new ExplanationTreeRenderer()); DataManager.registerDataProvider(myExplanationTree, this); TreeUtil.expandAll(myExplanationTree); final NavigateAction navigateAction = new NavigateAction(); navigateAction.registerCustomShortcutSet(new CustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1.getShortcuts()[0]), myExplanationTree); DefaultActionGroup group = new DefaultActionGroup(); group.addAction(navigateAction); PopupHandler.installUnknownPopupHandler(myExplanationTree, group, ActionManager.getInstance()); return new JBScrollPane(myExplanationTree); }
Example 13
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 14
Source File: ArmaAddonsSettingsForm.java From arma-intellij-plugin with MIT License | 5 votes |
private void createUIComponents() { bundle = ResourceBundle.getBundle("com.kaylerrenslow.armaplugin.ProjectSettingsBundle"); tfWithBrowseReferenceDirectory = new TextFieldWithBrowseButton(new JTextField(40)); treeAddonsRoots_rootNode = new RootTreeNode(); treeAddonsRoots = new Tree(treeAddonsRoots_rootNode); treeAddonsRoots.setCellRenderer(new MyColoredTreeCellRenderer()); treeAddonsRoots.setHoldSize(true); treeAddonsRoots.addTreeSelectionListener(e -> { System.out.println("ArmaAddonsSettingsForm.createUIComponents e=" + e); }); }
Example 15
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 16
Source File: ArmaAddonsSettingsForm.java From arma-intellij-plugin with MIT License | 5 votes |
private void createUIComponents() { bundle = ResourceBundle.getBundle("com.kaylerrenslow.armaplugin.ProjectSettingsBundle"); tfWithBrowseReferenceDirectory = new TextFieldWithBrowseButton(new JTextField(40)); treeAddonsRoots_rootNode = new RootTreeNode(); treeAddonsRoots = new Tree(treeAddonsRoots_rootNode); treeAddonsRoots.setCellRenderer(new MyColoredTreeCellRenderer()); treeAddonsRoots.setHoldSize(true); treeAddonsRoots.addTreeSelectionListener(e -> { System.out.println("ArmaAddonsSettingsForm.createUIComponents e=" + e); }); }
Example 17
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 18
Source File: AnalyzeSizeToolWindow.java From size-analyzer with Apache License 2.0 | 4 votes |
private Tree createSuggestionTree() { DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Hurray! Your application is already optimized for size."); for (Category category : categoryDisplayOrder) { ImmutableList<Suggestion> suggestions = categorizedSuggestions.get(category); if (!suggestions.isEmpty()) { Map<IssueType, List<Suggestion>> suggestionMap = suggestions.stream().collect(Collectors.groupingBy(Suggestion::getIssueType)); rootNode.add(buildNodesForCategory(category, suggestionMap)); } } Tree tree = new Tree(rootNode); // Show the root if we do not have any size suggestions for the developer. tree.setRootVisible(rootNode.getChildCount() == 0); tree.addTreeSelectionListener( (TreeSelectionEvent e) -> { Object selectedNode = e.getPath().getLastPathComponent(); Object selection = ((DefaultMutableTreeNode) selectedNode).getUserObject(); descriptionAutoFixButton.setVisible(false); descriptionAutoFixStrut.setVisible(false); descriptionTitle.setVisible(false); descriptionTitleStrut.setVisible(false); description.setVisible(false); descriptionStrut.setVisible(false); descriptionMoreInfo.setVisible(false); if (selection instanceof SuggestionData || selection instanceof IssueTypeData) { splitter.setSecondComponent(descriptionPanel); descriptionTitle.setVisible(true); descriptionTitleStrut.setVisible(true); description.setVisible(true); showInformationInDescriptionPanelFor((DefaultMutableTreeNode) selectedNode); } else if (selection instanceof CategoryData) { splitter.setSecondComponent(categoryPanel); showCategoryInCategoryPanelFor((DefaultMutableTreeNode) selectedNode); } else if (selection instanceof String) { splitter.setSecondComponent(descriptionPanel); description.setVisible(true); String escapedSelection = escapeHtml4((String) selection); description.setText("<html> " + escapedSelection + "</html>"); } }); tree.setCellRenderer(new SuggestionTreeCellRenderer(tree.getCellRenderer())); return tree; }