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

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

Introduction

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

Prototype

public boolean replaceAction(@NotNull AnAction oldAction, @NotNull AnAction newAction) 

Source Link

Document

Replaces specified action with the a one.

Usage

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");
    }/*from   w  w w.  j a  v a  2 s. c om*/

    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());
            }
        }
    }
}