Search in sources :

Example 1 with DynamicWizardHost

use of com.android.tools.idea.wizard.dynamic.DynamicWizardHost in project android by JetBrains.

the class SdkUpdaterConfigPanel method setUpSingleSdkChooser.

private void setUpSingleSdkChooser() {
    myEditSdkLink.setHyperlinkText("Edit");
    myEditSdkLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final DynamicWizardHost host = new DialogWrapperHost(null);
            DynamicWizard wizard = new DynamicWizard(null, null, "SDK Setup", host) {

                @Override
                public void init() {
                    DownloadingComponentsStep progressStep = new DownloadingComponentsStep(myHost.getDisposable(), myHost);
                    String sdkPath = mySdkLocationTextField.getText();
                    File location;
                    if (StringUtil.isEmpty(sdkPath)) {
                        location = FirstRunWizardDefaults.getInitialSdkLocation(FirstRunWizardMode.MISSING_SDK);
                    } else {
                        location = new File(sdkPath);
                    }
                    InstallComponentsPath path = new InstallComponentsPath(FirstRunWizardMode.MISSING_SDK, location, progressStep, false);
                    progressStep.setInstallComponentsPath(path);
                    addPath(path);
                    addPath(new SingleStepPath(progressStep));
                    super.init();
                }

                @Override
                public void performFinishingActions() {
                    File sdkLocation = IdeSdks.getInstance().getAndroidSdkPath();
                    if (sdkLocation == null) {
                        return;
                    }
                    String stateSdkLocationPath = myState.get(WizardConstants.KEY_SDK_INSTALL_LOCATION);
                    assert stateSdkLocationPath != null;
                    File stateSdkLocation = new File(stateSdkLocationPath);
                    if (!FileUtil.filesEqual(sdkLocation, stateSdkLocation)) {
                        setAndroidSdkLocation(stateSdkLocation);
                        sdkLocation = stateSdkLocation;
                    }
                    mySelectedSdkLocation.setValue(sdkLocation);
                }

                @NotNull
                @Override
                protected String getProgressTitle() {
                    return "Setting up SDK...";
                }

                @Override
                protected String getWizardActionDescription() {
                    return "Setting up SDK...";
                }
            };
            wizard.init();
            wizard.show();
        }
    });
    mySdkLocationTextField.setEditable(false);
}
Also used : DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) SingleStepPath(com.android.tools.idea.wizard.dynamic.SingleStepPath) HyperlinkEvent(javax.swing.event.HyperlinkEvent) InstallComponentsPath(com.android.tools.idea.welcome.wizard.InstallComponentsPath) DialogWrapperHost(com.android.tools.idea.wizard.dynamic.DialogWrapperHost) DynamicWizardHost(com.android.tools.idea.wizard.dynamic.DynamicWizardHost) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Aggregations

InstallComponentsPath (com.android.tools.idea.welcome.wizard.InstallComponentsPath)1 DialogWrapperHost (com.android.tools.idea.wizard.dynamic.DialogWrapperHost)1 DynamicWizard (com.android.tools.idea.wizard.dynamic.DynamicWizard)1 DynamicWizardHost (com.android.tools.idea.wizard.dynamic.DynamicWizardHost)1 SingleStepPath (com.android.tools.idea.wizard.dynamic.SingleStepPath)1 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)1 File (java.io.File)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 NotNull (org.jetbrains.annotations.NotNull)1