use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.
the class EmulatorTargetChooser method chooseAvd.
@Nullable
private String chooseAvd() {
IAndroidTarget buildTarget = myFacet.getConfiguration().getAndroidTarget();
assert buildTarget != null;
AvdInfo[] avds = myFacet.getValidCompatibleAvds();
if (avds.length > 0) {
return avds[0].getName();
}
final Project project = myFacet.getModule().getProject();
AvdManager manager;
try {
manager = myFacet.getAvdManager(new AvdManagerLog() {
@Override
public void error(Throwable t, String errorFormat, Object... args) {
super.error(t, errorFormat, args);
if (errorFormat != null) {
final String msg = String.format(errorFormat, args);
LOG.error(msg);
}
}
});
} catch (final AndroidLocation.AndroidLocationException e) {
LOG.info(e);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle());
}
});
return null;
}
final AvdManager finalManager = manager;
assert finalManager != null;
return UIUtil.invokeAndWaitIfNeeded(new Computable<String>() {
@Override
public String compute() {
int result = Messages.showDialog(project, "To run using the emulator, you must have an AVD defined.", "Define AVD", new String[] { "Cancel", "Create AVD" }, 1, null);
AvdInfo createdAvd = null;
if (result == 1) {
AvdOptionsModel avdOptionsModel = new AvdOptionsModel(null);
ModelWizardDialog dialog = AvdWizardUtils.createAvdWizard(null, project, avdOptionsModel);
if (dialog.showAndGet()) {
createdAvd = avdOptionsModel.getCreatedAvd();
}
}
return createdAvd == null ? null : createdAvd.getName();
}
});
}
use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.
the class SdkUpdaterConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
myPanel.saveSources();
HtmlBuilder message = new HtmlBuilder();
message.openHtmlBody();
final List<LocalPackage> toDelete = Lists.newArrayList();
final Map<RemotePackage, UpdatablePackage> requestedPackages = Maps.newHashMap();
for (PackageNodeModel model : myPanel.getStates()) {
if (model.getState() == PackageNodeModel.SelectedState.NOT_INSTALLED) {
if (model.getPkg().hasLocal()) {
toDelete.add(model.getPkg().getLocal());
}
} else if (model.getState() == PackageNodeModel.SelectedState.INSTALLED && (model.getPkg().isUpdate() || !model.getPkg().hasLocal())) {
UpdatablePackage pkg = model.getPkg();
requestedPackages.put(pkg.getRemote(), pkg);
}
}
boolean found = false;
if (!toDelete.isEmpty()) {
found = true;
message.add("The following components will be deleted: \n");
message.beginList();
for (LocalPackage item : toDelete) {
message.listItem().add(item.getDisplayName()).add(", Revision: ").add(item.getVersion().toString());
}
message.endList();
}
if (!requestedPackages.isEmpty()) {
found = true;
message.add("The following components will be installed: \n");
message.beginList();
Multimap<RemotePackage, RemotePackage> dependencies = HashMultimap.create();
ProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
RepositoryPackages packages = getRepoManager().getPackages();
for (RemotePackage item : requestedPackages.keySet()) {
List<RemotePackage> packageDependencies = InstallerUtil.computeRequiredPackages(ImmutableList.of(item), packages, progress);
if (packageDependencies == null) {
Messages.showErrorDialog((Project) null, "Unable to resolve dependencies for " + item.getDisplayName(), "Dependency Error");
throw new ConfigurationException("Unable to resolve dependencies.");
}
for (RemotePackage dependency : packageDependencies) {
dependencies.put(dependency, item);
}
message.listItem().add(String.format("%1$s %2$s %3$s", item.getDisplayName(), item.getTypeDetails() instanceof DetailsTypes.ApiDetailsType ? "revision" : "version", item.getVersion()));
}
for (RemotePackage dependency : dependencies.keySet()) {
if (requestedPackages.containsKey(dependency)) {
continue;
}
Set<RemotePackage> requests = Sets.newHashSet(dependencies.get(dependency));
requests.remove(dependency);
if (!requests.isEmpty()) {
message.listItem().add(dependency.getDisplayName()).add(" (Required by ");
Iterator<RemotePackage> requestIterator = requests.iterator();
message.add(requestIterator.next().getDisplayName());
while (requestIterator.hasNext()) {
message.add(", ").add(requestIterator.next().getDisplayName());
}
message.add(")");
}
}
message.endList();
}
message.closeHtmlBody();
if (found) {
if (confirmChange(message)) {
if (!requestedPackages.isEmpty() || !toDelete.isEmpty()) {
ModelWizardDialog dialog = SdkQuickfixUtils.createDialogForPackages(myPanel.getComponent(), requestedPackages.values(), toDelete, true);
if (dialog != null) {
dialog.show();
for (RemotePackage remotePackage : requestedPackages.keySet()) {
PackageOperation installer = getRepoManager().getInProgressInstallOperation(remotePackage);
if (installer != null) {
PackageOperation.StatusChangeListener listener = (installer1, progress) -> myPanel.getComponent().repaint();
myListeners.add(listener);
installer.registerStateChangeListener(listener);
}
}
}
}
myPanel.refresh();
} else {
throw new ConfigurationException("Installation was canceled.");
}
} else {
// We didn't have any changes, so just reload (maybe the channel changed).
myChannelChangedCallback.run();
}
}
use of com.android.tools.idea.wizard.model.ModelWizardDialog in project android by JetBrains.
the class NewProjectWizardDemo method runWizard.
private void runWizard(ModelWizard wizard, String title) {
ModelWizardDialog dialog = new ModelWizardDialog(wizard, title, myRootPanel, new DemoWizardLayout(), null, ModelWizardDialog.CancellationPolicy.ALWAYS_CAN_CANCEL);
dialog.setSize(-1, 300);
dialog.show();
}
Aggregations