Search in sources :

Example 1 with SimpleTree

use of com.intellij.ui.treeStructure.SimpleTree in project intellij-community by JetBrains.

the class IntersectingLocalChangesPanel method createTree.

@NotNull
private SimpleTree createTree() {
    SimpleTree tree = new SimpleTree(TreeModelBuilder.buildFromFilePaths(myProject, true, myFiles)) {

        @Override
        protected void configureUiHelper(@NotNull TreeUIHelper helper) {
            super.configureUiHelper(helper);
            helper.installEditSourceOnDoubleClick(this);
            helper.installEditSourceOnEnterKeyHandler(this);
        }
    };
    tree.setRootVisible(false);
    tree.setShowsRootHandles(false);
    tree.setCellRenderer(new ChangesBrowserNodeRenderer(myProject, BooleanGetter.TRUE, false));
    return tree;
}
Also used : ChangesBrowserNodeRenderer(com.intellij.openapi.vcs.changes.ui.ChangesBrowserNodeRenderer) TreeUIHelper(com.intellij.ui.TreeUIHelper) SimpleTree(com.intellij.ui.treeStructure.SimpleTree) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with SimpleTree

use of com.intellij.ui.treeStructure.SimpleTree in project intellij-community by JetBrains.

the class ExternalProjectsViewImpl method initTree.

private void initTree() {
    myTree = new SimpleTree();
    myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    final ActionManager actionManager = ActionManager.getInstance();
    ActionToolbar actionToolbar = actionManager.createActionToolbar(myExternalSystemId.getReadableName() + " View Toolbar", (DefaultActionGroup) actionManager.getAction("ExternalSystemView.ActionsToolbar"), true);
    actionToolbar.setTargetComponent(myTree);
    setToolbar(actionToolbar.getComponent());
    setContent(ScrollPaneFactory.createScrollPane(myTree));
    myTree.addMouseListener(new PopupHandler() {

        public void invokePopup(final Component comp, final int x, final int y) {
            final String id = getMenuId(getSelectedNodes(ExternalSystemNode.class));
            if (id != null) {
                final ActionGroup actionGroup = (ActionGroup) actionManager.getAction(id);
                if (actionGroup != null) {
                    actionManager.createActionPopupMenu("", actionGroup).getComponent().show(comp, x, y);
                }
            }
        }

        @Nullable
        private String getMenuId(Collection<? extends ExternalSystemNode> nodes) {
            String id = null;
            for (ExternalSystemNode node : nodes) {
                String menuId = node.getMenuId();
                if (menuId == null) {
                    return null;
                }
                if (id == null) {
                    id = menuId;
                } else if (!id.equals(menuId)) {
                    return null;
                }
            }
            return id;
        }
    });
}
Also used : PopupHandler(com.intellij.ui.PopupHandler) SimpleTree(com.intellij.ui.treeStructure.SimpleTree) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with SimpleTree

use of com.intellij.ui.treeStructure.SimpleTree in project azure-tools-for-java by Microsoft.

the class AzureSdkTreePanel method initTree.

private Tree initTree() {
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Azure SDK Libraries");
    this.model = new DefaultTreeModel(root);
    final SimpleTree tree = new SimpleTree(model);
    tree.putClientProperty(RenderingUtil.ALWAYS_PAINT_SELECTION_AS_FOCUSED, true);
    tree.setCellRenderer(new NodeRenderer());
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    TreeUtil.installActions(tree);
    RelativeFont.BOLD.install(tree);
    return tree;
}
Also used : NodeRenderer(com.intellij.ide.util.treeView.NodeRenderer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) SimpleTree(com.intellij.ui.treeStructure.SimpleTree)

Example 4 with SimpleTree

use of com.intellij.ui.treeStructure.SimpleTree in project intellij-community by JetBrains.

the class MavenProjectsNavigator method initTree.

private void initTree() {
    myTree = new SimpleTree() {

        private final JLabel myLabel = new JLabel(ProjectBundle.message("maven.navigator.nothing.to.display", MavenUtil.formatHtmlImage(ADD_ICON_URL), MavenUtil.formatHtmlImage(SYNC_ICON_URL)));

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (myProjectsManager.hasProjects())
                return;
            myLabel.setFont(getFont());
            myLabel.setBackground(getBackground());
            myLabel.setForeground(getForeground());
            Rectangle bounds = getBounds();
            Dimension size = myLabel.getPreferredSize();
            myLabel.setBounds(0, 0, size.width, size.height);
            int x = (bounds.width - size.width) / 2;
            Graphics g2 = g.create(bounds.x + x, bounds.y + 20, bounds.width, bounds.height);
            try {
                myLabel.paint(g2);
            } finally {
                g2.dispose();
            }
        }
    };
    myTree.getEmptyText().clear();
    myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
}
Also used : SimpleTree(com.intellij.ui.treeStructure.SimpleTree)

Aggregations

SimpleTree (com.intellij.ui.treeStructure.SimpleTree)4 NodeRenderer (com.intellij.ide.util.treeView.NodeRenderer)1 ChangesBrowserNodeRenderer (com.intellij.openapi.vcs.changes.ui.ChangesBrowserNodeRenderer)1 PopupHandler (com.intellij.ui.PopupHandler)1 TreeUIHelper (com.intellij.ui.TreeUIHelper)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1