use of com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapAddPlatformBeforeRun method executeTask.
@Override
public boolean executeTask(DataContext context, final RunConfiguration configuration, ExecutionEnvironment env, PhoneGapAddPlatformTask task) {
final PhoneGapRunConfiguration phoneGapRunConfiguration = (PhoneGapRunConfiguration) configuration;
final PhoneGapCommandLine line = phoneGapRunConfiguration.getCommandLine();
if (!line.needAddPlatform()) {
return true;
}
final Project project = configuration.getProject();
final Semaphore targetDone = new Semaphore();
final Ref<Boolean> result = new Ref<>(true);
final List<Exception> exceptions = new ArrayList<>();
ApplicationManager.getApplication().invokeAndWait(() -> {
//Save all opened documents
FileDocumentManager.getInstance().saveAllDocuments();
targetDone.down();
new Task.Backgroundable(project, PhoneGapBundle.message("phonegap.before.task.init.title"), 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, PhoneGapBundle.message("phonegap.before.task.init.title"), null, true);
result.set(false);
}
} catch (final Exception e) {
exceptions.add(e);
result.set(false);
} finally {
targetDone.up();
}
}
}.queue();
}, ModalityState.NON_MODAL);
if (!targetDone.waitFor(TimeUnit.MINUTES.toMillis(2))) {
ExecutionHelper.showErrors(project, ContainerUtil.createMaybeSingletonList(new RuntimeException("Timeout")), PhoneGapBundle.message("phonegap.before.task.init.error"), null);
} else if (!exceptions.isEmpty()) {
ExecutionHelper.showErrors(project, exceptions, PhoneGapBundle.message("phonegap.before.task.init.error"), null);
}
return result.get();
}
use of com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapRunProfileState method startProcess.
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
PhoneGapCommandLine line = phoneGapRunConfiguration.getCommandLine();
String command = phoneGapRunConfiguration.getCommand();
assert command != null;
String platform = phoneGapRunConfiguration.getPlatform();
assert platform != null;
return line.runCommand(command, platform, phoneGapRunConfiguration.hasTarget() ? phoneGapRunConfiguration.getTarget() : null, phoneGapRunConfiguration.getExtraArgs());
}
Aggregations