Search in sources :

Example 1 with CommonActionsManager

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

the class XFramesView method createToolbar.

private ActionToolbarImpl createToolbar() {
    final DefaultActionGroup framesGroup = new DefaultActionGroup();
    CommonActionsManager actionsManager = CommonActionsManager.getInstance();
    framesGroup.add(actionsManager.createPrevOccurenceAction(myFramesList));
    framesGroup.add(actionsManager.createNextOccurenceAction(myFramesList));
    framesGroup.addAll(ActionManager.getInstance().getAction(XDebuggerActions.FRAMES_TOP_TOOLBAR_GROUP));
    final ActionToolbarImpl toolbar = (ActionToolbarImpl) ActionManager.getInstance().createActionToolbar(ActionPlaces.DEBUGGER_TOOLBAR, framesGroup, true);
    toolbar.setReservePlaceAutoPopupIcon(false);
    toolbar.setAddSeparatorFirst(true);
    toolbar.getComponent().setBorder(new EmptyBorder(1, 0, 0, 0));
    return toolbar;
}
Also used : ActionToolbarImpl(com.intellij.openapi.actionSystem.impl.ActionToolbarImpl) CommonActionsManager(com.intellij.ide.CommonActionsManager) EmptyBorder(javax.swing.border.EmptyBorder) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 2 with CommonActionsManager

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

the class ChooseActionsDialog method createToolbarPanel.

private JPanel createToolbarPanel() {
    final JPanel panel = new JPanel(new BorderLayout());
    DefaultActionGroup group = new DefaultActionGroup();
    final JComponent toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
    final CommonActionsManager commonActionsManager = CommonActionsManager.getInstance();
    final TreeExpander treeExpander = new TreeExpander() {

        public void expandAll() {
            TreeUtil.expandAll(myActionsTree.getTree());
        }

        public boolean canExpand() {
            return true;
        }

        public void collapseAll() {
            TreeUtil.collapseAll(myActionsTree.getTree(), 0);
        }

        public boolean canCollapse() {
            return true;
        }
    };
    group.add(commonActionsManager.createExpandAllAction(treeExpander, myActionsTree.getTree()));
    group.add(commonActionsManager.createCollapseAllAction(treeExpander, myActionsTree.getTree()));
    panel.add(toolbar, BorderLayout.WEST);
    group = new DefaultActionGroup();
    ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    actionToolbar.setReservePlaceAutoPopupIcon(false);
    final JComponent searchToolbar = actionToolbar.getComponent();
    final Alarm alarm = new Alarm();
    myFilterComponent = new FilterComponent("KEYMAP_IN_QUICK_LISTS", 5) {

        public void filter() {
            alarm.cancelAllRequests();
            alarm.addRequest(() -> {
                if (!myFilterComponent.isShowing())
                    return;
                if (!myTreeExpansionMonitor.isFreeze())
                    myTreeExpansionMonitor.freeze();
                myFilteringPanel.setShortcut(null);
                final String filter = getFilter();
                myActionsTree.filter(filter, myQuicklists);
                final JTree tree = myActionsTree.getTree();
                TreeUtil.expandAll(tree);
                if (filter == null || filter.length() == 0) {
                    TreeUtil.collapseAll(tree, 0);
                    myTreeExpansionMonitor.restore();
                }
            }, 300);
        }
    };
    myFilterComponent.reset();
    panel.add(myFilterComponent, BorderLayout.CENTER);
    group.add(new AnAction(KeyMapBundle.message("filter.shortcut.action.text"), KeyMapBundle.message("filter.shortcut.action.text"), AllIcons.Actions.ShortcutFilter) {

        public void actionPerformed(AnActionEvent e) {
            myFilterComponent.reset();
            myActionsTree.reset(myKeymap, myQuicklists);
            myFilteringPanel.showPopup(searchToolbar);
        }
    });
    group.add(new AnAction(KeyMapBundle.message("filter.clear.action.text"), KeyMapBundle.message("filter.clear.action.text"), AllIcons.Actions.GC) {

        @Override
        public void update(AnActionEvent event) {
            boolean enabled = null != myFilteringPanel.getShortcut();
            Presentation presentation = event.getPresentation();
            presentation.setEnabled(enabled);
            presentation.setIcon(enabled ? AllIcons.Actions.Cancel : EmptyIcon.ICON_16);
        }

        public void actionPerformed(AnActionEvent e) {
            myFilteringPanel.setShortcut(null);
            //clear filtering
            myActionsTree.filter(null, myQuicklists);
            TreeUtil.collapseAll(myActionsTree.getTree(), 0);
            myTreeExpansionMonitor.restore();
        }
    });
    panel.add(searchToolbar, BorderLayout.EAST);
    return panel;
}
Also used : TreeExpander(com.intellij.ide.TreeExpander) FilterComponent(com.intellij.ui.FilterComponent) Alarm(com.intellij.util.Alarm) CommonActionsManager(com.intellij.ide.CommonActionsManager)

Example 3 with CommonActionsManager

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

the class KeymapPanel method createToolbarPanel.

private JPanel createToolbarPanel() {
    final JPanel panel = new JPanel(new GridBagLayout());
    DefaultActionGroup group = new DefaultActionGroup();
    final JComponent toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
    final CommonActionsManager commonActionsManager = CommonActionsManager.getInstance();
    final TreeExpander treeExpander = new TreeExpander() {

        @Override
        public void expandAll() {
            TreeUtil.expandAll(myActionsTree.getTree());
        }

        @Override
        public boolean canExpand() {
            return true;
        }

        @Override
        public void collapseAll() {
            TreeUtil.collapseAll(myActionsTree.getTree(), 0);
        }

        @Override
        public boolean canCollapse() {
            return true;
        }
    };
    group.add(commonActionsManager.createExpandAllAction(treeExpander, myActionsTree.getTree()));
    group.add(commonActionsManager.createCollapseAllAction(treeExpander, myActionsTree.getTree()));
    group.add(new AnAction("Edit Shortcut", "Edit Shortcut", AllIcons.ToolbarDecorator.Edit) {

        {
            registerCustomShortcutSet(CommonShortcuts.ENTER, myActionsTree.getTree());
        }

        @Override
        public void update(@NotNull AnActionEvent e) {
            final String actionId = myActionsTree.getSelectedActionId();
            e.getPresentation().setEnabled(actionId != null);
        }

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            editSelection(e.getInputEvent(), false);
        }
    });
    panel.add(toolbar, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 0, 0, 0), 0, 0));
    group = new DefaultActionGroup();
    ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    actionToolbar.setReservePlaceAutoPopupIcon(false);
    final JComponent searchToolbar = actionToolbar.getComponent();
    final Alarm alarm = new Alarm();
    myFilterComponent = new FilterComponent("KEYMAP", 5) {

        @Override
        public void filter() {
            alarm.cancelAllRequests();
            alarm.addRequest(() -> {
                if (!myFilterComponent.isShowing())
                    return;
                myTreeExpansionMonitor.freeze();
                myFilteringPanel.setShortcut(null);
                final String filter = getFilter();
                myActionsTree.filter(filter, myQuickLists);
                final JTree tree = myActionsTree.getTree();
                TreeUtil.expandAll(tree);
                if (filter == null || filter.length() == 0) {
                    TreeUtil.collapseAll(tree, 0);
                    myTreeExpansionMonitor.restore();
                } else {
                    myTreeExpansionMonitor.unfreeze();
                }
            }, 300);
        }
    };
    myFilterComponent.reset();
    panel.add(myFilterComponent, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(8, 0, 0, 0), 0, 0));
    group.add(new DumbAwareAction(KeyMapBundle.message("filter.shortcut.action.text"), KeyMapBundle.message("filter.shortcut.action.text"), AllIcons.Actions.ShortcutFilter) {

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            myFilterComponent.reset();
            //noinspection ConstantConditions
            myActionsTree.reset(myEditor.getModel().getSelected(), myQuickLists);
            myFilteringPanel.showPopup(searchToolbar);
        }
    });
    group.add(new DumbAwareAction(KeyMapBundle.message("filter.clear.action.text"), KeyMapBundle.message("filter.clear.action.text"), AllIcons.Actions.GC) {

        @Override
        public void update(AnActionEvent event) {
            boolean enabled = null != myFilteringPanel.getShortcut();
            Presentation presentation = event.getPresentation();
            presentation.setEnabled(enabled);
            presentation.setIcon(enabled ? AllIcons.Actions.Cancel : EmptyIcon.ICON_16);
        }

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            myTreeExpansionMonitor.freeze();
            myFilteringPanel.setShortcut(null);
            //clear filtering
            myActionsTree.filter(null, myQuickLists);
            TreeUtil.collapseAll(myActionsTree.getTree(), 0);
            myTreeExpansionMonitor.restore();
        }
    });
    panel.add(searchToolbar, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(8, 0, 0, 0), 0, 0));
    return panel;
}
Also used : TreeExpander(com.intellij.ide.TreeExpander) FilterComponent(com.intellij.ui.FilterComponent) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) Alarm(com.intellij.util.Alarm) CommonActionsManager(com.intellij.ide.CommonActionsManager)

Example 4 with CommonActionsManager

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

the class SourceItemsTree method createPopupGroup.

private ActionGroup createPopupGroup() {
    final DefaultActionGroup group = new DefaultActionGroup();
    group.add(new PutSourceItemIntoDefaultLocationAction(this, myArtifactsEditor));
    group.add(new PackAndPutIntoDefaultLocationAction(this, myArtifactsEditor));
    group.add(new PutSourceItemIntoParentAndLinkViaManifestAction(this, myArtifactsEditor));
    group.add(new ExtractIntoDefaultLocationAction(this, myArtifactsEditor));
    group.add(Separator.getInstance());
    group.add(new SourceItemNavigateAction(this));
    group.add(new SourceItemFindUsagesAction(this, myArtifactsEditor.getContext().getProject(), myArtifactsEditor.getContext().getParent()));
    DefaultTreeExpander expander = new DefaultTreeExpander(this);
    final CommonActionsManager commonActionsManager = CommonActionsManager.getInstance();
    group.add(Separator.getInstance());
    group.addAction(commonActionsManager.createExpandAllAction(expander, this));
    group.addAction(commonActionsManager.createCollapseAllAction(expander, this));
    return group;
}
Also used : CommonActionsManager(com.intellij.ide.CommonActionsManager) DefaultTreeExpander(com.intellij.ide.DefaultTreeExpander)

Example 5 with CommonActionsManager

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

the class ModulesDependenciesPanel method installTreeActions.

private static void installTreeActions(Tree tree, boolean enableExpandAll) {
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(NODE_RENDERER);
    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);
    DefaultActionGroup group = new DefaultActionGroup();
    CommonActionsManager commonActionManager = CommonActionsManager.getInstance();
    ActionManager globalActionManager = ActionManager.getInstance();
    TreeExpander treeExpander = new MyTreeExpander(tree, enableExpandAll);
    group.add(commonActionManager.createExpandAllAction(treeExpander, tree));
    group.add(commonActionManager.createCollapseAllAction(treeExpander, tree));
    group.add(globalActionManager.getAction(IdeActions.ACTION_EDIT_SOURCE));
    group.add(Separator.getInstance());
    group.add(globalActionManager.getAction(IdeActions.ACTION_ANALYZE_DEPENDENCIES));
    group.add(globalActionManager.getAction(IdeActions.ACTION_ANALYZE_BACK_DEPENDENCIES));
    group.add(globalActionManager.getAction(IdeActions.ACTION_ANALYZE_CYCLIC_DEPENDENCIES));
    group.add(globalActionManager.getAction(IdeActions.ACTION_ANALYZE_MODULE_DEPENDENCIES));
    PopupHandler.installUnknownPopupHandler(tree, group, ActionManager.getInstance());
}
Also used : TreePath(javax.swing.tree.TreePath) TreeExpander(com.intellij.ide.TreeExpander) CommonActionsManager(com.intellij.ide.CommonActionsManager)

Aggregations

CommonActionsManager (com.intellij.ide.CommonActionsManager)15 TreeExpander (com.intellij.ide.TreeExpander)7 DefaultTreeExpander (com.intellij.ide.DefaultTreeExpander)6 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)6 NotNull (org.jetbrains.annotations.NotNull)3 AnAction (com.intellij.openapi.actionSystem.AnAction)2 ActionToolbarImpl (com.intellij.openapi.actionSystem.impl.ActionToolbarImpl)2 FilterComponent (com.intellij.ui.FilterComponent)2 Alarm (com.intellij.util.Alarm)2 TreePath (javax.swing.tree.TreePath)2 ConsoleActionsPostProcessor (com.intellij.execution.actions.ConsoleActionsPostProcessor)1 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)1 OccurenceNavigator (com.intellij.ide.OccurenceNavigator)1 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)1 ScrollToTheEndToolbarAction (com.intellij.openapi.editor.actions.ScrollToTheEndToolbarAction)1 ToggleUseSoftWrapsToolbarAction (com.intellij.openapi.editor.actions.ToggleUseSoftWrapsToolbarAction)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 Content (com.intellij.ui.content.Content)1 ArrayList (java.util.ArrayList)1