if (!line.needAddPlatform()) {
return true;
}
final Project project = configuration.getProject();
final Semaphore targetDone = new Semaphore();
final Ref<Boolean> result = new Ref<Boolean>(true);
final List<Exception> exceptions = new ArrayList<Exception>();
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
public void run() {
//Save all opened documents
FileDocumentManager.getInstance().saveAllDocuments();
targetDone.down();
new Task.Backgroundable(project, "Init PhoneGap/Cordova platform", true) {
public boolean shouldStartInBackground() {
return true;
}
public void run(@NotNull final ProgressIndicator indicator) {
try {
String platform = phoneGapRunConfiguration.getPlatform();
assert platform != null;
ProcessOutput output = line.platformAdd(platform);
if (output.getExitCode() != 0) {
ExecutionHelper.showOutput(project, output, "Init PhoneGap/Cordova platform", null, true);
result.set(false);
targetDone.up();
return;
}
targetDone.up();
}
catch (final ExecutionException e) {
exceptions.add(e);
result.set(false);
targetDone.up();
}
}
}.queue();
}
}, ModalityState.NON_MODAL);
targetDone.waitFor();
if (!exceptions.isEmpty()) {
ExecutionHelper.showErrors(project, exceptions, "Cannot Init Platform", null);
}