Search in sources :

Example 11 with ModelWizardDialog

use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.

the class DeviceSelectionPopup method initNewButton.

private void initNewButton() {
    myNewDeviceButton.addActionListener(e -> {
        ModelWizardDialog dialog = AvdWizardUtils.createAvdWizard(getContentPane(), null);
        if (dialog.showAndGet()) {
            AvdManagerConnection.getDefaultAvdManagerConnection().getAvds(true);
            initDeviceList(myConfiguration);
        }
    });
}
Also used : ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog)

Example 12 with ModelWizardDialog

use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.

the class DeployTargetPickerDialog method canLaunchDevices.

/**
   * Check the AVDs for missing system images and offer to download them.
   * @return true if the devices are able to launch, false if the user cancelled.
   */
private boolean canLaunchDevices(@NotNull List<AndroidDevice> devices) {
    Set<String> requiredPackages = Sets.newHashSet();
    for (AndroidDevice device : devices) {
        if (device instanceof LaunchableAndroidDevice) {
            LaunchableAndroidDevice avd = (LaunchableAndroidDevice) device;
            AvdInfo info = avd.getAvdInfo();
            if (AvdManagerConnection.isSystemImageDownloadProblem(info.getStatus())) {
                requiredPackages.add(AvdManagerConnection.getRequiredSystemImagePath(info));
            }
        }
    }
    if (requiredPackages.isEmpty()) {
        return true;
    }
    String title;
    StringBuilder message = new StringBuilder();
    if (requiredPackages.size() == 1) {
        title = "Download System Image";
        message.append("The system image: ").append(Iterables.getOnlyElement(requiredPackages)).append(" is missing.\n\n");
        message.append("Download it now?");
    } else {
        title = "Download System Images";
        message.append("The following system images are missing:\n");
        for (String packageName : requiredPackages) {
            message.append(packageName).append("\n");
        }
        message.append("\nDownload them now?");
    }
    int response = Messages.showOkCancelDialog(message.toString(), title, Messages.getQuestionIcon());
    if (response != Messages.OK) {
        return false;
    }
    ModelWizardDialog sdkQuickfixWizard = SdkQuickfixUtils.createDialogForPaths(myFacet.getModule().getProject(), requiredPackages);
    if (sdkQuickfixWizard == null) {
        return false;
    }
    sdkQuickfixWizard.show();
    myDevicePicker.refreshAvds(null);
    if (!sdkQuickfixWizard.isOK()) {
        return false;
    }
    AvdManagerConnection manager = AvdManagerConnection.getDefaultAvdManagerConnection();
    for (AndroidDevice device : devices) {
        if (device instanceof LaunchableAndroidDevice) {
            LaunchableAndroidDevice avd = (LaunchableAndroidDevice) device;
            AvdInfo info = avd.getAvdInfo();
            String problem;
            try {
                AvdInfo reloadedAvdInfo = manager.reloadAvd(info);
                problem = reloadedAvdInfo.getErrorMessage();
            } catch (AndroidLocation.AndroidLocationException e) {
                problem = "AVD cannot be loaded";
            }
            if (problem != null) {
                Messages.showErrorDialog(myFacet.getModule().getProject(), problem, "Emulator Launch Failed");
                return false;
            }
        }
    }
    return true;
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AvdManagerConnection(com.android.tools.idea.avdmanager.AvdManagerConnection) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) AndroidLocation(com.android.prefs.AndroidLocation)

Example 13 with ModelWizardDialog

use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.

the class DevicePicker method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == myCreateEmulatorButton) {
        AvdOptionsModel avdOptionsModel = new AvdOptionsModel(null);
        ModelWizardDialog dialog = AvdWizardUtils.createAvdWizard(myPanel, myFacet.getModule().getProject(), avdOptionsModel);
        if (dialog.showAndGet()) {
            AvdInfo createdAvd = avdOptionsModel.getCreatedAvd();
            refreshAvds(createdAvd);
        }
    }
}
Also used : AvdInfo(com.android.sdklib.internal.avd.AvdInfo) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog)

Example 14 with ModelWizardDialog

use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.

the class InstallSystemImageAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent actionEvent) {
    String path = getPackagePath();
    assert path != null;
    List<String> requested = ImmutableList.of(path);
    int response = Messages.showOkCancelDialog("The corresponding system image is missing.\n\nDownload it now?", "Download System Image", Messages.getQuestionIcon());
    if (response != Messages.OK) {
        return;
    }
    ModelWizardDialog sdkQuickfixWizard = SdkQuickfixUtils.createDialogForPaths(getProject(), requested);
    if (sdkQuickfixWizard != null) {
        sdkQuickfixWizard.show();
        refreshAvds();
    }
}
Also used : ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog)

Example 15 with ModelWizardDialog

use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.

the class IdeSdksConfigurable method createNdkDownloadLink.

private void createNdkDownloadLink() {
    myNdkDownloadHyperlinkLabel = new HyperlinkLabel();
    myNdkDownloadHyperlinkLabel.setHyperlinkText("", "Download", " Android NDK.");
    myNdkDownloadHyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            if (validateAndroidSdkPath() != null) {
                Messages.showErrorDialog(getContentPanel(), "Please select a valid SDK before downloading the NDK.");
                return;
            }
            List<String> requested = ImmutableList.of(FD_NDK);
            ModelWizardDialog dialog = createDialogForPaths(myWholePanel, requested, false);
            if (dialog != null && dialog.showAndGet()) {
                File ndk = IdeSdks.getInstance().getAndroidNdkPath();
                if (ndk != null) {
                    myNdkLocationTextField.setText(ndk.getPath());
                }
                validateState();
            }
        }
    });
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) FileChooser.chooseFile(com.intellij.openapi.fileChooser.FileChooser.chooseFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Aggregations

ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)23 Project (com.intellij.openapi.project.Project)7 AndroidVersion (com.android.sdklib.AndroidVersion)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)3 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)3 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)3 StudioSettingsController (com.android.tools.idea.sdk.StudioSettingsController)3 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)3 ImmutableList (com.google.common.collect.ImmutableList)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Nullable (org.jetbrains.annotations.Nullable)3 AndroidLocation (com.android.prefs.AndroidLocation)2 RemotePackage (com.android.repository.api.RemotePackage)2 RepoManager (com.android.repository.api.RepoManager)2 DEFAULT_EXPIRATION_PERIOD_MS (com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS)2 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)2 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)2 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)2