Java Code Examples for com.intellij.ui.treeStructure.Tree#addTreeSelectionListener()
The following examples show how to use
com.intellij.ui.treeStructure.Tree#addTreeSelectionListener() .
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: 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 2
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 3
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 4
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 5
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 6
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; }
Example 7
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); }