Example usage for com.intellij.openapi.actionSystem Anchor AFTER

List of usage examples for com.intellij.openapi.actionSystem Anchor AFTER

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem Anchor AFTER.

Prototype

Anchor AFTER

To view the source code for com.intellij.openapi.actionSystem Anchor AFTER.

Click Source Link

Document

Anchor type that specifies the action to be placed after the relative action.

Usage

From source file:be.cegeka.intellij.plugin.configurablefilename.settings.PluginSettings.java

License:Open Source License

private void addActions() {
    if (filenames != null && !filenames.isEmpty()) {
        ActionManager am = ActionManager.getInstance();
        DefaultActionGroup newGroup = (DefaultActionGroup) am.getAction("NewGroup");
        String anchorId = "NewFile";
        for (ConfigurableFilename filename : filenames) {
            CreateFileWithConfigurableNameAction action = new CreateFileWithConfigurableNameAction(
                    filename.getType(), filename.getDefaultExtension(), filename.getTemplate());
            String actionId = "ConfigurableFileName." + filename.getType();
            am.registerAction(actionId, action);
            newGroup.addAction(action, new Constraints(Anchor.AFTER, anchorId));
            anchorId = actionId;//ww w . j  ava 2  s. c  om
        }
    }
}

From source file:com.google.cloud.tools.intellij.debugger.CloudDebugProcess.java

License:Apache License

@Override
public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar,
        @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) {
    ActionManager manager = ActionManager.getInstance();
    leftToolbar.add(new SaveAndExitAction(), new Constraints(Anchor.AFTER, IdeActions.ACTION_STOP_PROGRAM));

    leftToolbar.remove(manager.getAction(IdeActions.ACTION_RERUN));
    leftToolbar.remove(manager.getAction(IdeActions.ACTION_STOP_PROGRAM));

    // XDebugSessionTab puts this action second from end.
    AnAction[] actions = leftToolbar.getChildActionsOrStubs();
    for (AnAction action : actions) {
        String text = action.getTemplatePresentation().getText();
        if (ExecutionBundle.message("close.tab.action.name").equals(text)) {
            leftToolbar.remove(action);/*from  w  w w  .  j  a  v a  2 s.c om*/
            break;
        }
    }

    // remove help button since it points to the IntelliJ help by default and we don't have
    // a help page yet.
    // for some reason, the help button's key in leftToolbar is null, so we need to remove it
    // by class name.
    // https://github.com/GoogleCloudPlatform/gcloud-intellij/issues/149
    for (AnAction child : leftToolbar.getChildActionsOrStubs()) {
        if (child.getClass().getCanonicalName()
                .equalsIgnoreCase("com.intellij.ide.actions.ContextHelpAction")) {
            // we never want to show IDEA's help.
            leftToolbar.remove(child);

            // show our help if we have it.
            String helpUrl = GctBundle.getString("clouddebug.helpurl");
            if (!"".equals(helpUrl)) {
                leftToolbar.add(new CloudDebugHelpAction(helpUrl));
            }
            break;
        }
    }

    leftToolbar.remove(manager.getAction(XDebuggerActions.RESUME));
    leftToolbar.remove(manager.getAction(XDebuggerActions.PAUSE));
    leftToolbar.remove(manager.getAction(XDebuggerActions.MUTE_BREAKPOINTS));

    topToolbar.remove(manager.getAction(XDebuggerActions.STEP_OVER));
    topToolbar.remove(manager.getAction(XDebuggerActions.STEP_INTO));
    topToolbar.remove(manager.getAction(XDebuggerActions.FORCE_STEP_INTO));
    topToolbar.remove(manager.getAction(XDebuggerActions.STEP_OUT));
    topToolbar.remove(manager.getAction(XDebuggerActions.RUN_TO_CURSOR));
    topToolbar.remove(manager.getAction(XDebuggerActions.EVALUATE_EXPRESSION));
    topToolbar.remove(manager.getAction(DebuggerActions.POP_FRAME));
}

From source file:com.google.gct.idea.appengine.initialization.CloudPluginRegistration.java

License:Apache License

@Override
public void initComponent() {
    if (Boolean.getBoolean(SHOW_DEPLOY)) {
        ActionManager am = ActionManager.getInstance();

        AppEngineUpdateAction action = new AppEngineUpdateAction();
        action.getTemplatePresentation().setText("Deploy Module to App Engine...");

        am.registerAction("GoogleCloudTools.AppEngineUpdate", action);
        DefaultActionGroup buildMenu = (DefaultActionGroup) am.getAction("BuildMenu");

        DefaultActionGroup appEngineUpdateGroup = new DefaultActionGroup();
        appEngineUpdateGroup.addSeparator();
        appEngineUpdateGroup.add(action);
        buildMenu.add(appEngineUpdateGroup, new Constraints(Anchor.AFTER, "Compile"));
    }/*w ww.j a v a 2s .c o  m*/
}

From source file:com.google.gct.idea.debugger.CloudDebugProcess.java

License:Apache License

@Override
public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar,
        @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) {
    ActionManager manager = ActionManager.getInstance();
    leftToolbar.add(new SaveAndExitAction(), new Constraints(Anchor.AFTER, IdeActions.ACTION_STOP_PROGRAM));

    leftToolbar.remove(manager.getAction(IdeActions.ACTION_RERUN));
    leftToolbar.remove(manager.getAction(IdeActions.ACTION_STOP_PROGRAM));
    leftToolbar.remove(manager.getAction(XDebuggerActions.RESUME));
    leftToolbar.remove(manager.getAction(XDebuggerActions.PAUSE));
    leftToolbar.remove(manager.getAction(XDebuggerActions.MUTE_BREAKPOINTS));

    topToolbar.remove(manager.getAction(XDebuggerActions.STEP_OVER));
    topToolbar.remove(manager.getAction(XDebuggerActions.STEP_INTO));
    topToolbar.remove(manager.getAction(XDebuggerActions.FORCE_STEP_INTO));
    topToolbar.remove(manager.getAction(XDebuggerActions.STEP_OUT));
    topToolbar.remove(manager.getAction(XDebuggerActions.RUN_TO_CURSOR));
    topToolbar.remove(manager.getAction(XDebuggerActions.EVALUATE_EXPRESSION));
}

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;/* w ww .  j  av  a2 s  .co 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  w  w .  ja  v  a 2 s.  com
    }

    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.xdebugger.impl.ui.XDebugSessionTab.java

License:Apache License

private void attachToSession(@NotNull XDebugSessionImpl session) {
    for (XDebugView view : myViews) {
        session.addSessionListener(new XDebugViewSessionListener(view), myRunContentDescriptor);
    }/*from  w ww.  java 2 s .com*/

    XDebugTabLayouter layouter = session.getDebugProcess().createTabLayouter();
    Content consoleContent = layouter.registerConsoleContent(myUi, myConsole);
    attachNotificationTo(consoleContent);

    layouter.registerAdditionalContent(myUi);
    RunContentBuilder.addAdditionalConsoleEditorActions(myConsole, consoleContent);

    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;
    }

    DefaultActionGroup leftToolbar = new DefaultActionGroup();
    final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    if (myEnvironment != null) {
        leftToolbar.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN));
        List<AnAction> additionalRestartActions = session.getRestartActions();
        if (!additionalRestartActions.isEmpty()) {
            leftToolbar.addAll(additionalRestartActions);
            leftToolbar.addSeparator();
        }
        leftToolbar.addAll(session.getExtraActions());
    }
    leftToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));

    for (AnAction action : session.getExtraStopActions()) {
        leftToolbar.add(action, new Constraints(Anchor.AFTER, IdeActions.ACTION_STOP_PROGRAM));
    }

    //group.addSeparator();
    //addAction(group, DebuggerActions.EXPORT_THREADS);
    leftToolbar.addSeparator();

    leftToolbar.add(myUi.getOptions().getLayoutActions());
    final AnAction[] commonSettings = myUi.getOptions().getSettingsActionsList();
    DefaultActionGroup settings = new DefaultActionGroup(ActionsBundle.message("group.XDebugger.settings.text"),
            true);
    settings.getTemplatePresentation()
            .setIcon(myUi.getOptions().getSettingsActions().getTemplatePresentation().getIcon());
    if (commonSettings.length > 0) {
        for (AnAction each : commonSettings) {
            settings.add(each);
        }
        settings.addSeparator();
    }
    if (!session.getDebugProcess().isValuesCustomSorted()) {
        settings.add(new ToggleSortValuesAction(commonSettings.length == 0));
    }

    leftToolbar.add(settings);

    leftToolbar.addSeparator();

    leftToolbar.add(PinToolwindowTabAction.getPinAction());
    leftToolbar.add(new CloseAction(myEnvironment != null ? myEnvironment.getExecutor() : debugExecutor,
            myRunContentDescriptor, myProject));
    leftToolbar.add(new ContextHelpAction(debugExecutor.getHelpId()));

    DefaultActionGroup topToolbar = new DefaultActionGroup();
    topToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));

    session.getDebugProcess().registerAdditionalActions(leftToolbar, topToolbar, settings);
    myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
    myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);

    if (myEnvironment != null) {
        initLogConsoles(myEnvironment.getRunProfile(), myRunContentDescriptor, myConsole);
    }
}

From source file:com.mediaworx.intellij.opencmsplugin.OpenCmsPlugin.java

License:Open Source License

/**
 * Creates and registers the OpenCms menu for the project popup as an action group
 *//*from  www.j  a  va2 s.c  om*/
private void registerProjectPopupMenu() {
    OpenCmsProjectPopupMenu openCmsProjectPopupMenu = (OpenCmsProjectPopupMenu) actionManager
            .getAction(PROJECT_POPUP_MENU_ID);
    if (openCmsProjectPopupMenu == null) {
        DefaultActionGroup projectPopup = (DefaultActionGroup) actionManager
                .getAction(IdeActions.GROUP_PROJECT_VIEW_POPUP);
        openCmsProjectPopupMenu = new OpenCmsProjectPopupMenu(this);
        addAction(projectPopup, PROJECT_POPUP_MENU_ID, openCmsProjectPopupMenu, "_OpenCms", MENU_ICON,
                new Constraints(Anchor.BEFORE, "RevealIn"));
        projectPopup.add(Separator.getInstance(), new Constraints(Anchor.AFTER, PROJECT_POPUP_MENU_ID));
    }
}

From source file:com.mediaworx.intellij.opencmsplugin.OpenCmsPlugin.java

License:Open Source License

/**
 * Creates and registers the OpenCms menu for the editor popup as an action group
 *//* ww  w .  j a  va2 s . c om*/
private void registerEditorPopupMenu() {
    OpenCmsEditorPopupMenu openCmsEditorPopupMenu = (OpenCmsEditorPopupMenu) actionManager
            .getAction(EDITOR_POPUP_MENU_ID);
    if (openCmsEditorPopupMenu == null) {
        DefaultActionGroup editorPopup = (DefaultActionGroup) actionManager
                .getAction(IdeActions.GROUP_EDITOR_POPUP);
        openCmsEditorPopupMenu = new OpenCmsEditorPopupMenu(this);
        addAction(editorPopup, EDITOR_POPUP_MENU_ID, openCmsEditorPopupMenu, "_OpenCms", MENU_ICON,
                new Constraints(Anchor.AFTER, "ChangeFileEncodingAction"));
        editorPopup.addAction(Separator.getInstance(), new Constraints(Anchor.BEFORE, EDITOR_POPUP_MENU_ID));
    }
}

From source file:com.mediaworx.intellij.opencmsplugin.OpenCmsPlugin.java

License:Open Source License

/**
 * Creates and registers the OpenCms menu for the editor tab popup as an action group
 *///  www  .  j a  va2 s. com
private void registerEditorTabPopupMenu() {
    OpenCmsEditorTabPopupMenu openCmsEditorTabPopupMenu = (OpenCmsEditorTabPopupMenu) actionManager
            .getAction(TAB_POPUP_MENU_ID);
    if (openCmsEditorTabPopupMenu == null) {
        // DefaultActionGroup editorTabPopup = (DefaultActionGroup)actionManager.getAction(IdeActions.GROUP_EDITOR_TAB_POPUP);
        DefaultActionGroup editorTabPopup = (DefaultActionGroup) actionManager
                .getAction("EditorTabPopupMenuEx");
        openCmsEditorTabPopupMenu = new OpenCmsEditorTabPopupMenu(this);
        editorTabPopup.addAction(Separator.getInstance());
        // addAction(editorTabPopup, TAB_POPUP_MENU_ID, openCmsEditorTabPopupMenu, "_OpenCms", MENU_ICON, new Constraints(Anchor.AFTER, "UnsplitAll"));
        addAction(editorTabPopup, TAB_POPUP_MENU_ID, openCmsEditorTabPopupMenu, "_OpenCms", MENU_ICON,
                new Constraints(Anchor.BEFORE, "RunContextPopupGroup"));
        // editorTabPopup.addAction(Separator.getInstance(), new Constraints(Anchor.BEFORE, TAB_POPUP_MENU_ID));
        editorTabPopup.addAction(Separator.getInstance(), new Constraints(Anchor.AFTER, TAB_POPUP_MENU_ID));
    }
}