Example usage for com.intellij.openapi.actionSystem DefaultActionGroup addAll

List of usage examples for com.intellij.openapi.actionSystem DefaultActionGroup addAll

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem DefaultActionGroup addAll.

Prototype

public final void addAll(AnAction @NotNull... actions) 

Source Link

Usage

From source file:com.android.tools.adtui.workbench.AttachedToolWindow.java

License:Apache License

private void addGearPopupActions(@NotNull DefaultActionGroup group) {
    if (myContent != null) {
        List<AnAction> myExtraGearActions = myContent.getGearActions();
        if (!myExtraGearActions.isEmpty()) {
            group.addAll(myExtraGearActions);
            group.addSeparator();/*ww  w.  j  av  a 2  s .c om*/
        }
    }
    DefaultActionGroup attachedSide = new DefaultActionGroup("Attached Side", true);
    attachedSide.add(new TogglePropertyTypeAction(PropertyType.LEFT, "Left"));
    attachedSide.add(new ToggleOppositePropertyTypeAction(PropertyType.LEFT, "Right"));
    attachedSide.add(new SwapAction());
    group.add(attachedSide);
    ActionManager manager = ActionManager.getInstance();
    group.add(new ToggleOppositePropertyTypeAction(PropertyType.AUTO_HIDE,
            manager.getAction(InternalDecorator.TOGGLE_DOCK_MODE_ACTION_ID)));
    group.add(new TogglePropertyTypeAction(PropertyType.FLOATING,
            manager.getAction(InternalDecorator.TOGGLE_FLOATING_MODE_ACTION_ID)));
    group.add(new TogglePropertyTypeAction(PropertyType.SPLIT,
            manager.getAction(InternalDecorator.TOGGLE_SIDE_MODE_ACTION_ID)));
}

From source file:com.android.tools.idea.gradle.structure.configurables.ui.dependencies.AbstractDependenciesPanel.java

License:Apache License

@NotNull
protected final JPanel createActionsPanel() {
    JPanel actionsPanel = new JPanel(new BorderLayout());

    DefaultActionGroup actions = new DefaultActionGroup();

    AnAction addDependencyAction = new DumbAwareAction("Add Dependency", "", IconUtil.getAddIcon()) {
        @Override//from   www  . ja  v a  2 s  .c om
        public void actionPerformed(AnActionEvent e) {
            JBPopup popup = JBPopupFactory.getInstance()
                    .createListPopup(new BaseListPopupStep<AbstractPopupAction>(null, getPopupActions()) {
                        @Override
                        public Icon getIconFor(AbstractPopupAction action) {
                            return action.icon;
                        }

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

                        @Override
                        public PopupStep onChosen(AbstractPopupAction action, boolean finalChoice) {
                            return doFinalStep(action::execute);
                        }

                        @Override
                        @NotNull
                        public String getTextFor(AbstractPopupAction action) {
                            return "&" + action.index + "  " + action.text;
                        }
                    });
            popup.show(new RelativePoint(actionsPanel, new Point(0, actionsPanel.getHeight() - 1)));
        }
    };

    actions.add(addDependencyAction);
    List<AnAction> extraToolbarActions = getExtraToolbarActions();
    if (!extraToolbarActions.isEmpty()) {
        actions.addSeparator();
        actions.addAll(extraToolbarActions);
    }

    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("TOP", actions, true);
    JComponent toolbarComponent = toolbar.getComponent();
    toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
    actionsPanel.add(toolbarComponent, BorderLayout.CENTER);

    return actionsPanel;
}

From source file:com.android.tools.idea.monitor.MonitorPanel.java

License:Apache License

@NotNull
private ActionToolbarImpl setupToolbar(@NotNull ActionGroup actions, @NotNull BaseMonitorView monitor) {
    DefaultActionGroup viewActions = new DefaultActionGroup();
    viewActions.addAll(actions);
    viewActions.add(new MonitorMoveAction(this, monitor, -1));
    viewActions.add(new MonitorMoveAction(this, monitor, 1));
    viewActions.add(new MinimizeAction(this, monitor));
    ActionToolbarImpl toolbar = new ActionToolbarImpl(ActionPlaces.UNKNOWN, viewActions, true, false,
            DataManager.getInstance(), ActionManagerEx.getInstanceEx(), KeymapManagerEx.getInstanceEx());
    toolbar.setBorder(BorderFactory.createEmptyBorder());
    toolbar.setMinimumSize(new Dimension(0, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.height));
    toolbar.setPreferredSize(//from   w  ww  .j  a v  a  2s  .  c  o  m
            new Dimension(Integer.MAX_VALUE, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.height));
    toolbar.setMaximumSize(toolbar.getPreferredSize());
    return toolbar;
}

From source file:com.android.tools.idea.run.ExternalToolRunner.java

License:Apache License

protected ConsoleView initConsoleUi() {
    ConsoleView consoleView = createConsoleView();
    consoleView.print(myCommandLine.getCommandLineString() + '\n', ConsoleViewContentType.USER_INPUT);
    consoleView.attachToProcess(myProcessHandler);

    JPanel panel = new JPanel(new BorderLayout());

    DefaultActionGroup toolbarActions = new DefaultActionGroup();
    ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN,
            toolbarActions, false);/*from   w  w  w.j a  va  2  s .c  o  m*/
    panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
    panel.add(consoleView.getComponent(), BorderLayout.CENTER);
    actionToolbar.setTargetComponent(panel);

    toolbarActions.addAll(consoleView.createConsoleActions());
    fillToolBarActions(toolbarActions);
    panel.updateUI();

    Executor defaultExecutor = DefaultRunExecutor.getRunExecutorInstance();
    final RunContentDescriptor contentDescriptor = new RunContentDescriptor(consoleView, myProcessHandler,
            panel, myTitle);
    showConsole(defaultExecutor, contentDescriptor);

    myProcessHandler.addProcessListener(new ConsoleListener(myProject, defaultExecutor, myProcessHandler));
    myProcessHandler.startNotify();
    return consoleView;
}

From source file:com.atlassian.theplugin.idea.bamboo.BambooToolWindowPanel.java

License:Apache License

public void launchContextMenu(MouseEvent e) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    final ActionGroup configActionGroup = (ActionGroup) ActionManager.getInstance()
            .getAction("ThePlugin.Bamboo.BuildPopupMenuNew");
    actionGroup.addAll(configActionGroup);

    final ActionPopupMenu popup = ActionManager.getInstance().createActionPopupMenu(getActionPlaceName(),
            actionGroup);//from  ww  w.  j av  a2  s. c  o  m

    final JPopupMenu jPopupMenu = popup.getComponent();
    jPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}

From source file:com.atlassian.theplugin.idea.bamboo.BambooToolWindowPanel.java

License:Apache License

public void launchContextMenuGorGroup(MouseEvent e) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    final ActionGroup configActionGroup = (ActionGroup) ActionManager.getInstance()
            .getAction("ThePlugin.Bamboo.BuildPopupMenuNewGroup");
    actionGroup.addAll(configActionGroup);

    final ActionPopupMenu popup = ActionManager.getInstance().createActionPopupMenu(getActionPlaceName(),
            actionGroup);/*ww w  .ja va 2  s  .c  o m*/

    final JPopupMenu jPopupMenu = popup.getComponent();
    jPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}

From source file:com.intellij.debugger.ui.DebuggerSessionTab.java

License:Apache License

public DebuggerSessionTab(final Project project, final String sessionName,
        @NotNull final DebugUIEnvironment environment, @NotNull DebuggerSession debuggerSession) {
    super(project, "JavaDebugger", sessionName, debuggerSession.getSearchScope());

    myDebuggerSession = debuggerSession;
    myDebugUIEnvironment = environment;//from w  w  w.j  a  va  2 s. c  o  m

    final DefaultActionGroup focus = new DefaultActionGroup();
    focus.add(ActionManager.getInstance().getAction("Debugger.FocusOnBreakpoint"));
    myUi.getOptions().setAdditionalFocusActions(focus);

    final DebuggerSettings debuggerSettings = DebuggerSettings.getInstance();
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
        getContextManager().addListener(new DebuggerContextListener() {
            @Override
            public void changeEvent(DebuggerContextImpl newContext, int event) {
                switch (event) {
                case DebuggerSession.EVENT_DETACHED:
                    myUi.updateActionsNow();

                    if (XDebuggerSettingsManager.getInstanceImpl().getGeneralSettings()
                            .isHideDebuggerOnProcessTermination()) {
                        try {
                            ExecutionManager.getInstance(project).getContentManager().hideRunContent(
                                    DefaultDebugExecutor.getDebugExecutorInstance(), myRunContentDescriptor);
                        } catch (NullPointerException e) {
                            //if we can get closeProcess after the project have been closed
                            LOG.debug(e);
                        }
                    }
                    break;
                }
            }
        });
    }

    DefaultActionGroup topToolbar = new DefaultActionGroup();
    ActionManager actionManager = ActionManager.getInstance();
    topToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));
    topToolbar.add(actionManager.getAction(DebuggerActions.POP_FRAME),
            new Constraints(Anchor.AFTER, XDebuggerActions.STEP_OUT));
    topToolbar.add(AnSeparator.getInstance(), new Constraints(Anchor.BEFORE, DebuggerActions.POP_FRAME));
    topToolbar.add(AnSeparator.getInstance(), new Constraints(Anchor.AFTER, DebuggerActions.POP_FRAME));
    myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);

    myWatchPanel = new MainWatchPanel(project, getContextManager());
    myFramesPanel = new FramesPanel(project, getContextManager());

    final AlertIcon breakpointAlert = new AlertIcon(AllIcons.Debugger.BreakpointAlert);

    // watches
    Content watches = myUi.createContent(DebuggerContentInfo.WATCHES_CONTENT, myWatchPanel,
            XDebuggerBundle.message("debugger.session.tab" + ".watches.title"), AllIcons.Debugger.Watches,
            null);
    watches.setCloseable(false);
    watches.setAlertIcon(breakpointAlert);
    myUi.addContent(watches, 0, PlaceInGrid.right, false);

    // frames
    Content framesContent = myUi.createContent(DebuggerContentInfo.FRAME_CONTENT, myFramesPanel,
            XDebuggerBundle.message("debugger.session.tab" + ".frames.title"), AllIcons.Debugger.Frame,
            myFramesPanel.getFramesList());
    framesContent.setCloseable(false);
    framesContent.setAlertIcon(breakpointAlert);

    myUi.addContent(framesContent, 0, PlaceInGrid.left, false);

    // variables
    myVariablesPanel = new VariablesPanel(project, myStateManager, this);
    myVariablesPanel.getFrameTree().setAutoVariablesMode(debuggerSettings.AUTO_VARIABLES_MODE);
    Content vars = myUi.createContent(DebuggerContentInfo.VARIABLES_CONTENT, myVariablesPanel,
            XDebuggerBundle.message("debugger.session.tab" + ".variables.title"), AllIcons.Debugger.Value,
            null);
    vars.setCloseable(false);
    vars.setAlertIcon(breakpointAlert);
    myUi.addContent(vars, 0, PlaceInGrid.center, false);

    // threads
    myThreadsPanel = new ThreadsPanel(project, getContextManager());
    Content threadsContent = myUi.createContent(DebuggerContentInfo.THREADS_CONTENT, myThreadsPanel,
            XDebuggerBundle.message("debugger.session" + ".tab.threads.title"), AllIcons.Debugger.Threads,
            null);
    threadsContent.setCloseable(false);
    //threadsContent.setAlertIcon(breakpointAlert);

    //final DefaultActionGroup threadsGroup = new DefaultActionGroup();
    //threadsContent.setActions(threadsGroup, ActionPlaces.DEBUGGER_TOOLBAR, threadsPanel.getThreadsTree());

    myUi.addContent(threadsContent, 0, PlaceInGrid.left, true);

    for (Content each : myUi.getContents()) {
        updateStatus(each);
    }

    myUi.addListener(new ContentManagerAdapter() {
        @Override
        public void selectionChanged(ContentManagerEvent event) {
            updateStatus(event.getContent());
        }
    }, this);

    debuggerSession.getContextManager().addListener(new DebuggerContextListener() {
        @Override
        public void changeEvent(DebuggerContextImpl newContext, int event) {
            if (!myUi.isDisposed()) {
                attractFramesOnPause(event);
                myStateManager.fireStateChanged(newContext, event);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (!myUi.isDisposed()) {
                            myUi.updateActionsNow();
                        }
                    }
                });
            }
        }
    });

    //    ExecutionResult executionResult = debuggerSession.getProcess().getExecutionResult();
    //    myConsole = executionResult.getExecutionConsole();
    //    myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(),
    // getSessionName(),
    //                                                      environment.getIcon());
    //    initUI(executionResult);
}

From source file:com.intellij.debugger.ui.DebuggerSessionTab.java

License:Apache License

private void initUI(ExecutionResult executionResult) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;/*from w ww  .  ja va2  s  . c o  m*/
    }

    myUi.removeContent(myUi.findContent(DebuggerContentInfo.CONSOLE_CONTENT), true);

    Content console = null;
    if (myConsole instanceof ExecutionConsoleEx) {
        ((ExecutionConsoleEx) myConsole).buildUi(myUi);
        console = myUi.findContent(DebuggerContentInfo.CONSOLE_CONTENT);
        if (console == null) {
            LOG.debug("Reuse console created with non-debug runner");
        }
    }
    if (console == null) {
        console = myUi.createContent(DebuggerContentInfo.CONSOLE_CONTENT, myConsole.getComponent(),
                XDebuggerBundle.message("debugger.session" + ".tab.console.content.name"),
                AllIcons.Debugger.Console, myConsole.getPreferredFocusableComponent());

        console.setCloseable(false);
        myUi.addContent(console, 1, PlaceInGrid.bottom, false);
    }
    attachNotificationTo(console);

    if (myConsole != null) {
        Disposer.register(this, myConsole);
    }

    final DefaultActionGroup consoleActions = new DefaultActionGroup();
    if (myConsole instanceof ConsoleView) {
        AnAction[] actions = ((ConsoleView) myConsole).createConsoleActions();
        for (AnAction goAction : actions) {
            consoleActions.add(goAction);
        }
    }
    console.setActions(consoleActions, ActionPlaces.DEBUGGER_TOOLBAR,
            myConsole.getPreferredFocusableComponent());

    //    myDebugUIEnvironment.initLogs(myRunContentDescriptor, myManager);

    DefaultActionGroup leftToolbar = new DefaultActionGroup();

    if (executionResult instanceof DefaultExecutionResult) {
        final AnAction[] actions = ((DefaultExecutionResult) executionResult).getRestartActions();
        if (actions != null) {
            leftToolbar.addAll(actions);
            if (actions.length > 0) {
                leftToolbar.addSeparator();
            }
        }
    }
    final AnAction[] profileActions = executionResult.getActions();
    leftToolbar.addAll(profileActions);

    leftToolbar.add(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
    if (executionResult instanceof DefaultExecutionResult) {
        AnAction[] actions = ((DefaultExecutionResult) executionResult).getAdditionalStopActions();
        for (AnAction action : actions) {
            leftToolbar.add(action, new Constraints(Anchor.AFTER, IdeActions.ACTION_STOP_PROGRAM));
        }
    }

    leftToolbar.addSeparator();
    addAction(leftToolbar, DebuggerActions.EXPORT_THREADS);
    addAction(leftToolbar, DebuggerActions.DUMP_THREADS);
    leftToolbar.addSeparator();

    leftToolbar.add(myUi.getOptions().getLayoutActions());

    final AnAction[] commonSettings = myUi.getOptions().getSettingsActionsList();
    final AnAction commonSettingsList = myUi.getOptions().getSettingsActions();

    final DefaultActionGroup settings = new DefaultActionGroup("DebuggerSettings", true) {
        @Override
        public void update(AnActionEvent e) {
            e.getPresentation().setText(ActionsBundle.message("group.XDebugger.settings.text"));
            e.getPresentation().setIcon(commonSettingsList.getTemplatePresentation().getIcon());
        }

        @Override
        public boolean isDumbAware() {
            return true;
        }
    };
    for (AnAction each : commonSettings) {
        settings.add(each);
    }
    if (commonSettings.length > 0) {
        settings.addSeparator();
    }
    settings.add(new WatchLastMethodReturnValueAction());
    settings.add(new AutoVarsSwitchAction());
    settings.addSeparator();
    addActionToGroup(settings, XDebuggerActions.AUTO_TOOLTIP);

    leftToolbar.add(settings);

    leftToolbar.addSeparator();

    addActionToGroup(leftToolbar, PinToolwindowTabAction.ACTION_NAME);

    myDebugUIEnvironment.initActions(myRunContentDescriptor, leftToolbar);

    myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
}

From source file:com.intellij.diff.util.DiffUtil.java

License:Apache License

public static void addActionBlock(@NotNull DefaultActionGroup group,
        @Nullable List<? extends AnAction> actions) {
    if (actions == null || actions.isEmpty())
        return;/* w  w  w  .j  a  v a2s. c  o m*/
    if (group.getChildrenCount() != 0)
        group.addSeparator();
    group.addAll(actions);
}

From source file:com.intellij.execution.runners.AbstractConsoleRunnerWithHistory.java

License:Apache License

protected List<AnAction> fillToolBarActions(final DefaultActionGroup toolbarActions,
        final Executor defaultExecutor, final RunContentDescriptor contentDescriptor) {

    List<AnAction> actionList = ContainerUtil.newArrayList();

    //stop/*from www  .  j  a v a 2s  . co m*/
    actionList.add(createStopAction());

    //close
    actionList.add(createCloseAction(defaultExecutor, contentDescriptor));

    // run action
    actionList.add(createConsoleExecAction(myConsoleExecuteActionHandler));

    // Help
    actionList.add(CommonActionsManager.getInstance().createHelpAction("interactive_console"));

    toolbarActions.addAll(actionList);

    return actionList;
}