List of usage examples for com.intellij.openapi.actionSystem Constraints Constraints
public Constraints(Anchor anchor, @NonNls String relativeToActionId)
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 .jav a2 s. co m*/ } } }
From source file:com.android.tools.idea.startup.GradleSpecificInitializer.java
License:Apache License
private static void setUpWelcomeScreenActions() { // Force the new "flat" welcome screen. System.setProperty("ide.new.welcome.screen.force", "true"); // Update the Welcome Screen actions replaceAction("WelcomeScreen.OpenProject", new AndroidOpenFileAction("Open an existing Android Studio project")); replaceAction("WelcomeScreen.CreateNewProject", new AndroidNewProjectAction("Start a new Android Studio project")); replaceAction("WelcomeScreen.ImportProject", new AndroidImportProjectAction("Import project (Eclipse ADT, Gradle, etc.)")); replaceAction("TemplateProjectStructure", new AndroidTemplateProjectStructureAction("Default Project Structure...")); moveAction("WelcomeScreen.ImportProject", "WelcomeScreen.QuickStart.IDEA", "WelcomeScreen.QuickStart", new Constraints(AFTER, "WelcomeScreen.GetFromVcs")); ActionManager actionManager = ActionManager.getInstance(); AnAction getFromVcsAction = actionManager.getAction("WelcomeScreen.GetFromVcs"); if (getFromVcsAction != null) { getFromVcsAction.getTemplatePresentation().setText("Check out project from Version Control"); }// w w w .ja v a 2 s. c o m AnAction configureIdeaAction = actionManager.getAction("WelcomeScreen.Configure.IDEA"); if (configureIdeaAction instanceof DefaultActionGroup) { DefaultActionGroup settingsGroup = (DefaultActionGroup) configureIdeaAction; AnAction[] children = settingsGroup.getChildren(null); if (children.length == 1) { AnAction child = children[0]; if (child instanceof TemplateProjectSettingsGroup) { settingsGroup.replaceAction(child, new AndroidTemplateProjectSettingsGroup()); } } } }
From source file:com.android.tools.idea.startup.GradleSpecificInitializer.java
License:Apache License
private static void replaceProjectPopupActions() { Deque<Pair<DefaultActionGroup, AnAction>> stack = new ArrayDeque<>(); stack.add(Pair.of(null, ActionManager.getInstance().getAction("ProjectViewPopupMenu"))); while (!stack.isEmpty()) { Pair<DefaultActionGroup, AnAction> entry = stack.pop(); DefaultActionGroup parent = entry.getFirst(); AnAction action = entry.getSecond(); if (action instanceof DefaultActionGroup) { DefaultActionGroup actionGroup = (DefaultActionGroup) action; for (AnAction child : actionGroup.getChildActionsOrStubs()) { stack.push(Pair.of(actionGroup, child)); }// ww w. j a va2s . c o m } if (action instanceof MoveModuleToGroupTopLevel) { parent.remove(action); parent.add(new AndroidActionGroupRemover((ActionGroup) action, "Move Module to Group"), new Constraints(AFTER, "OpenModuleSettings")); } else if (action instanceof MarkRootGroup) { parent.remove(action); parent.add(new AndroidActionGroupRemover((ActionGroup) action, "Mark Directory As"), new Constraints(AFTER, "OpenModuleSettings")); } } }
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 ww .j a v a2 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")); }//from w ww .j a v a 2 s. 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.engine.JavaDebugProcess.java
License:Apache License
@Override public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) { Constraints beforeRunner = new Constraints(Anchor.BEFORE, "Runner.Layout"); leftToolbar.add(AnSeparator.getInstance(), beforeRunner); leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.EXPORT_THREADS), beforeRunner); leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.DUMP_THREADS), beforeRunner); leftToolbar.add(AnSeparator.getInstance(), beforeRunner); addActionToGroup(settings, XDebuggerActions.AUTO_TOOLTIP); settings.addAction(new AutoVarsSwitchAction(), Constraints.FIRST); settings.addAction(new WatchLastMethodReturnValueAction(), Constraints.FIRST); }
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 ww w . j a v 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 ww . j av a 2 s. c om } 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); }// w w w . j ava 2s . c o m 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); } }