Search in sources :

Example 1 with FirstRunWizardMode

use of com.android.tools.idea.welcome.config.FirstRunWizardMode in project android by JetBrains.

the class AndroidStudioWelcomeScreenProvider method createWelcomeScreen.

@Nullable
@Override
public WelcomeScreen createWelcomeScreen(JRootPane rootPane) {
    checkInternetConnection();
    FirstRunWizardMode wizardMode = getWizardMode();
    // This means isAvailable was false! Why are we even called?
    assert wizardMode != null;
    //noinspection AssignmentToStaticFieldFromInstanceMethod
    ourWasShown = true;
    return new FirstRunWizardHost(wizardMode);
}
Also used : FirstRunWizardMode(com.android.tools.idea.welcome.config.FirstRunWizardMode) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with FirstRunWizardMode

use of com.android.tools.idea.welcome.config.FirstRunWizardMode in project android by JetBrains.

the class GradleSpecificInitializer method setupSdks.

private static void setupSdks() {
    IdeSdks ideSdks = IdeSdks.getInstance();
    File androidHome = ideSdks.getAndroidSdkPath();
    if (androidHome != null) {
        String androidHomePath = androidHome.getAbsolutePath();
        ValidationResult result = validateLocation(androidHomePath, "Android SDK location", false, WritableCheckMode.DO_NOT_CHECK);
        if (result.isError()) {
            notifyInvalidSdk();
        }
        // Do not prompt user to select SDK path (we have one already.) Instead, check SDK compatibility when a project is opened.
        return;
    }
    // If running in a GUI test we don't want the "Select SDK" dialog to show up when running GUI tests.
    if (AndroidPlugin.isGuiTestingMode()) {
        // This is good enough. Later on in the GUI test we'll validate the given SDK path.
        return;
    }
    Sdk sdk = findFirstCompatibleAndroidSdk();
    if (sdk != null) {
        String sdkHomePath = sdk.getHomePath();
        assert sdkHomePath != null;
        ideSdks.createAndroidSdkPerAndroidTarget(new File(toSystemDependentName(sdkHomePath)));
        return;
    }
    // Called in a 'invokeLater' block, otherwise file chooser will hang forever.
    ApplicationManager.getApplication().invokeLater(() -> {
        File androidSdkPath = getAndroidSdkPath();
        if (androidSdkPath == null) {
            return;
        }
        FirstRunWizardMode wizardMode = AndroidStudioWelcomeScreenProvider.getWizardMode();
        // Only show "Select SDK" dialog if the "First Run" wizard is not displayed.
        boolean promptSdkSelection = wizardMode == null;
        Sdk sdk1 = createNewAndroidPlatform(androidSdkPath.getPath(), promptSdkSelection);
        if (sdk1 != null) {
            // Rename the SDK to fit our default naming convention.
            String sdkNamePrefix = AndroidSdks.SDK_NAME_PREFIX;
            if (sdk1.getName().startsWith(sdkNamePrefix)) {
                SdkModificator sdkModificator = sdk1.getSdkModificator();
                sdkModificator.setName(sdkNamePrefix + sdk1.getName().substring(sdkNamePrefix.length()));
                sdkModificator.commitChanges();
                // Rename the JDK that goes along with this SDK.
                AndroidSdkAdditionalData additionalData = AndroidSdks.getInstance().getAndroidSdkAdditionalData(sdk1);
                if (additionalData != null) {
                    Sdk jdk = additionalData.getJavaSdk();
                    if (jdk != null) {
                        sdkModificator = jdk.getSdkModificator();
                        sdkModificator.setName(DEFAULT_JDK_NAME);
                        sdkModificator.commitChanges();
                    }
                }
                // Fill out any missing build APIs for this new SDK.
                ideSdks.createAndroidSdkPerAndroidTarget(androidSdkPath);
            }
        }
    });
}
Also used : IdeSdks(com.android.tools.idea.sdk.IdeSdks) AndroidSdkAdditionalData(org.jetbrains.android.sdk.AndroidSdkAdditionalData) FirstRunWizardMode(com.android.tools.idea.welcome.config.FirstRunWizardMode) Sdk(com.intellij.openapi.projectRoots.Sdk) ValidationResult(com.android.tools.idea.npw.WizardUtils.ValidationResult) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 3 with FirstRunWizardMode

use of com.android.tools.idea.welcome.config.FirstRunWizardMode in project android by JetBrains.

the class AndroidSdkInitializer method setUpSdks.

private static void setUpSdks() {
    Sdk sdk = findFirstCompatibleAndroidSdk();
    if (sdk != null) {
        String sdkHomePath = sdk.getHomePath();
        assert sdkHomePath != null;
        IdeSdks.getInstance().createAndroidSdkPerAndroidTarget(new File(toSystemDependentName(sdkHomePath)));
        return;
    }
    // Called in a 'invokeLater' block, otherwise file chooser will hang forever.
    ApplicationManager.getApplication().invokeLater(() -> {
        File androidSdkPath = findOrGetAndroidSdkPath();
        if (androidSdkPath == null) {
            return;
        }
        FirstRunWizardMode wizardMode = AndroidStudioWelcomeScreenProvider.getWizardMode();
        // Only show "Select SDK" dialog if the "First Run" wizard is not displayed.
        boolean promptSdkSelection = wizardMode == null;
        Sdk newSdk = createNewAndroidPlatform(androidSdkPath.getPath(), promptSdkSelection);
        if (newSdk != null) {
            // Rename the SDK to fit our default naming convention.
            String sdkNamePrefix = AndroidSdks.SDK_NAME_PREFIX;
            if (newSdk.getName().startsWith(sdkNamePrefix)) {
                SdkModificator sdkModificator = newSdk.getSdkModificator();
                sdkModificator.setName(sdkNamePrefix + newSdk.getName().substring(sdkNamePrefix.length()));
                sdkModificator.commitChanges();
                // Rename the JDK that goes along with this SDK.
                AndroidSdkAdditionalData additionalData = AndroidSdks.getInstance().getAndroidSdkAdditionalData(newSdk);
                if (additionalData != null) {
                    Sdk jdk = additionalData.getJavaSdk();
                    if (jdk != null) {
                        sdkModificator = jdk.getSdkModificator();
                        sdkModificator.setName(DEFAULT_JDK_NAME);
                        sdkModificator.commitChanges();
                    }
                }
                // Fill out any missing build APIs for this new SDK.
                IdeSdks.getInstance().createAndroidSdkPerAndroidTarget(androidSdkPath);
            }
        }
    });
}
Also used : AndroidSdkAdditionalData(org.jetbrains.android.sdk.AndroidSdkAdditionalData) FirstRunWizardMode(com.android.tools.idea.welcome.config.FirstRunWizardMode) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) File(java.io.File)

Example 4 with FirstRunWizardMode

use of com.android.tools.idea.welcome.config.FirstRunWizardMode in project android by JetBrains.

the class FirstRunWizardTest method assertPagesVisible.

private void assertPagesVisible(@Nullable InstallerData data, boolean isComponentsStepVisible, boolean hasAndroidSdkPath) {
    InstallerData.set(data);
    FirstRunWizardMode mode = data == null ? FirstRunWizardMode.NEW_INSTALL : FirstRunWizardMode.INSTALL_HANDOFF;
    assertVisible(new SdkComponentsStep(new ComponentCategory("test", "test"), KEY_TRUE, createKey(String.class), mode), data, isComponentsStepVisible);
    if (data != null) {
        assertEquals(String.valueOf(data.toString()), hasAndroidSdkPath, data.hasValidSdkLocation());
    }
}
Also used : FirstRunWizardMode(com.android.tools.idea.welcome.config.FirstRunWizardMode) ComponentCategory(com.android.tools.idea.welcome.install.ComponentCategory)

Aggregations

FirstRunWizardMode (com.android.tools.idea.welcome.config.FirstRunWizardMode)4 Sdk (com.intellij.openapi.projectRoots.Sdk)2 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)2 File (java.io.File)2 AndroidSdkAdditionalData (org.jetbrains.android.sdk.AndroidSdkAdditionalData)2 ValidationResult (com.android.tools.idea.npw.WizardUtils.ValidationResult)1 IdeSdks (com.android.tools.idea.sdk.IdeSdks)1 ComponentCategory (com.android.tools.idea.welcome.install.ComponentCategory)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Nullable (org.jetbrains.annotations.Nullable)1