Search in sources :

Example 6 with DefaultTreeExpander

use of com.intellij.ide.DefaultTreeExpander in project intellij-community by JetBrains.

the class IntentionSettingsTree method initTree.

private void initTree() {
    myTree = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer(true) {

        @Override
        public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            if (!(value instanceof CheckedTreeNode))
                return;
            CheckedTreeNode node = (CheckedTreeNode) value;
            SimpleTextAttributes attributes = node.getUserObject() instanceof IntentionActionMetaData ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
            final String text = getNodeText(node);
            final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
            UIUtil.changeBackGround(this, background);
            if (text != null) {
                SearchUtil.appendFragments(myFilter != null ? myFilter.getFilter() : null, text, attributes.getStyle(), attributes.getFgColor(), background, getTextRenderer());
            }
        }
    }, new CheckedTreeNode(null));
    myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = e.getPath();
            Object userObject = ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
            selectionChanged(userObject);
        }
    });
    myFilter = new MyFilterComponent();
    myComponent = new JPanel(new BorderLayout());
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    myNorthPanel = new JPanel(new BorderLayout());
    myNorthPanel.add(myFilter, BorderLayout.CENTER);
    final DefaultActionGroup group = new DefaultActionGroup();
    final CommonActionsManager actionManager = CommonActionsManager.getInstance();
    final DefaultTreeExpander treeExpander = new DefaultTreeExpander(myTree);
    group.add(actionManager.createExpandAllAction(treeExpander, myTree));
    group.add(actionManager.createCollapseAllAction(treeExpander, myTree));
    myNorthPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.WEST);
    myComponent.add(myNorthPanel, BorderLayout.NORTH);
    myComponent.add(scrollPane, BorderLayout.CENTER);
    myFilter.reset();
}
Also used : TreeSelectionListener(javax.swing.event.TreeSelectionListener) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) TreePath(javax.swing.tree.TreePath) CommonActionsManager(com.intellij.ide.CommonActionsManager) DefaultTreeExpander(com.intellij.ide.DefaultTreeExpander) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 7 with DefaultTreeExpander

use of com.intellij.ide.DefaultTreeExpander in project intellij-community by JetBrains.

the class ArtifactEditorImpl method createPopupActionGroup.

private DefaultActionGroup createPopupActionGroup() {
    final LayoutTree tree = myLayoutTreeComponent.getLayoutTree();
    DefaultActionGroup popupActionGroup = new DefaultActionGroup();
    final List<AnAction> createActions = new ArrayList<>();
    AddCompositeElementAction.addCompositeCreateActions(createActions, this);
    for (AnAction createAction : createActions) {
        popupActionGroup.add(createAction);
    }
    popupActionGroup.add(createAddNonCompositeElementGroup());
    final RemovePackagingElementAction removeAction = new RemovePackagingElementAction(this);
    removeAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), tree);
    popupActionGroup.add(removeAction);
    popupActionGroup.add(new ExtractArtifactAction(this));
    popupActionGroup.add(new InlineArtifactAction(this));
    popupActionGroup.add(new RenamePackagingElementAction(this));
    popupActionGroup.add(new SurroundElementWithAction(this));
    popupActionGroup.add(Separator.getInstance());
    popupActionGroup.add(new HideContentAction(this));
    popupActionGroup.add(new LayoutTreeNavigateAction(myLayoutTreeComponent));
    popupActionGroup.add(new LayoutTreeFindUsagesAction(myLayoutTreeComponent, myProject, myContext.getParent()));
    popupActionGroup.add(Separator.getInstance());
    CommonActionsManager actionsManager = CommonActionsManager.getInstance();
    DefaultTreeExpander treeExpander = new DefaultTreeExpander(tree);
    popupActionGroup.add(actionsManager.createExpandAllAction(treeExpander, tree));
    popupActionGroup.add(actionsManager.createCollapseAllAction(treeExpander, tree));
    return popupActionGroup;
}
Also used : ArrayList(java.util.ArrayList) CommonActionsManager(com.intellij.ide.CommonActionsManager) DefaultTreeExpander(com.intellij.ide.DefaultTreeExpander)

Example 8 with DefaultTreeExpander

use of com.intellij.ide.DefaultTreeExpander in project azure-tools-for-java by Microsoft.

the class AzureSdkTreePanel method initToolbar.

private ActionToolbarImpl initToolbar() {
    final DefaultTreeExpander expander = new DefaultTreeExpander(this.tree);
    final DefaultActionGroup group = new DefaultActionGroup();
    final CommonActionsManager manager = CommonActionsManager.getInstance();
    group.add(new RefreshAction());
    group.addSeparator();
    group.add(manager.createExpandAllAction(expander, this.tree));
    group.add(manager.createCollapseAllAction(expander, this.tree));
    return new ActionToolbarImpl(ActionPlaces.TOOLBAR, group, true);
}
Also used : ActionToolbarImpl(com.intellij.openapi.actionSystem.impl.ActionToolbarImpl) CommonActionsManager(com.intellij.ide.CommonActionsManager) DefaultTreeExpander(com.intellij.ide.DefaultTreeExpander) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Aggregations

DefaultTreeExpander (com.intellij.ide.DefaultTreeExpander)8 CommonActionsManager (com.intellij.ide.CommonActionsManager)7 TreeExpander (com.intellij.ide.TreeExpander)3 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 NotNull (org.jetbrains.annotations.NotNull)2 ExecutionBundle (com.intellij.execution.ExecutionBundle)1 DashboardGrouper (com.intellij.execution.dashboard.tree.DashboardGrouper)1 RunDashboardTreeStructure (com.intellij.execution.dashboard.tree.RunDashboardTreeStructure)1 DataManager (com.intellij.ide.DataManager)1 com.intellij.ide.util.treeView (com.intellij.ide.util.treeView)1 ActionPresentation (com.intellij.ide.util.treeView.smartTree.ActionPresentation)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 ActionToolbarImpl (com.intellij.openapi.actionSystem.impl.ActionToolbarImpl)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 DumbAware (com.intellij.openapi.project.DumbAware)1 Project (com.intellij.openapi.project.Project)1 Splitter (com.intellij.openapi.ui.Splitter)1