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