use of com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapPluginsView method runOnPooledThread.
private synchronized void runOnPooledThread(String path, String workDir, PhoneGapConfigurable.RepositoryStore repositoryStore, final VersionCallback callback) {
final Ref<PhoneGapPackageManagementService> service = new Ref<>();
final Ref<String> error = new Ref<>();
final Ref<String> warning = new Ref<>();
final Ref<String> version = new Ref<>();
try {
PhoneGapCommandLine commandLine = checkParams(error, warning, version, path, workDir);
if (error.get() == null) {
service.set(new PhoneGapPackageManagementService(commandLine, repositoryStore));
}
} catch (Exception e) {
error.set(PhoneGapBundle.message("phonegap.plugins.executable.error"));
}
UIUtil.invokeLaterIfNeeded(() -> {
myPanel.updatePackages(service.get());
if (error.get() != null) {
packagesNotificationPanel.showError(error.get(), null, null);
}
if (warning.get() != null) {
packagesNotificationPanel.showWarning(warning.get());
}
callback.forVersion(version.get());
});
}
use of com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapPluginsView method checkParams.
private PhoneGapCommandLine checkParams(Ref<String> error, Ref<String> warning, Ref<String> version, String path, String workDir) throws ExecutionException {
boolean pathError = false;
if (!new File(workDir).exists()) {
pathError = true;
workDir = myProject.getBasePath();
}
PhoneGapCommandLine commandLine = new PhoneGapCommandLine(path, workDir);
if (!commandLine.isCorrectExecutable()) {
error.set(PhoneGapBundle.message("phonegap.plugins.executable.error"));
return commandLine;
}
version.set(commandLine.version());
if (pathError) {
error.set(PhoneGapBundle.message("phonegap.plugins.executable.work.path.error", commandLine.getPlatformName()));
return commandLine;
}
ProcessOutput output = commandLine.pluginListRaw();
if (!StringUtil.isEmpty(output.getStderr())) {
error.set(PhoneGapBundle.message("phonegap.plugins.executable.work.path.error", commandLine.getPlatformName()));
return commandLine;
}
if (commandLine.isOld()) {
warning.set(PhoneGapBundle.message("phonegap.plugins.executable.version.error"));
}
return commandLine;
}
use of com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapRunConfiguration method getCommandLine.
public PhoneGapCommandLine getCommandLine() {
PhoneGapCommandLine current = myCommandLine;
String executable = getExecutable();
String workDir = getWorkDir();
boolean passParentEnv = myPassParent;
Map<String, String> env = myEnvs;
if (current != null && StringUtil.equals(current.getPath(), executable) && StringUtil.equals(current.getWorkDir(), workDir) && passParentEnv == current.isPassParentEnv() && env.equals(current.getEnv())) {
return current;
}
assert executable != null;
assert workDir != null;
current = new PhoneGapCommandLine(executable, workDir, passParentEnv, env);
myCommandLine = current;
return current;
}
use of com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapProjectPeer method validate.
@Nullable
@Override
public ValidationInfo validate() {
String path = myExecutablePathField.getText();
boolean error;
if (myValidateCache.containsKey(path)) {
error = myValidateCache.get(path);
} else {
try {
if (StringUtil.isEmpty(path)) {
return new ValidationInfo(PhoneGapBundle.message("phonegap.incorrect.path.executable"));
}
new PhoneGapCommandLine(path, null).version();
error = false;
} catch (Exception e) {
error = true;
}
myValidateCache.put(path, error);
}
return error ? new ValidationInfo(PhoneGapBundle.message("phonegap.incorrect.path.error")) : null;
}
use of com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapProjectTemplateGenerator method generateProject.
@Override
public void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir, @NotNull final PhoneGapProjectTemplateGenerator.PhoneGapProjectSettings settings, @NotNull Module module) {
try {
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
try {
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.setText("Creating...");
File tempProject = createTemp();
PhoneGapCommandLine commandLine = new PhoneGapCommandLine(settings.getExecutable(), tempProject.getPath(), settings.getOptions());
if (!commandLine.isCorrectExecutable()) {
showErrorMessage("Incorrect path");
return;
}
commandLine.createNewProject(settings.name(), indicator);
File[] array = tempProject.listFiles();
if (array != null && array.length != 0) {
File from = ContainerUtil.getFirstItem(ContainerUtil.newArrayList(array));
assert from != null;
FileUtil.copyDir(from, new File(baseDir.getPath()));
deleteTemp(tempProject);
} else {
showErrorMessage(PhoneGapBundle.message("phonegap.project.template.create.no.files") + " " + tempProject.getAbsolutePath());
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}, PhoneGapBundle.message("phonegap.project.template.create.title"), false, project);
ApplicationManager.getApplication().runWriteAction(() -> {
PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
propertiesComponent.setValue(PhoneGapSettings.PHONEGAP_WORK_DIRECTORY, project.getBasePath());
PhoneGapSettings.State state = PhoneGapSettings.getInstance().getState();
if (!StringUtil.equals(settings.getExecutable(), state.getExecutablePath())) {
PhoneGapSettings.getInstance().loadState(new PhoneGapSettings.State(settings.executable, state.repositoriesList));
}
VfsUtil.markDirty(false, true, baseDir);
createRunConfiguration(project, settings);
baseDir.refresh(true, true, () -> {
if (PhoneGapSettings.getInstance().isExcludePlatformFolder()) {
VirtualFile platformsFolder = baseDir.findChild(PhoneGapUtil.FOLDER_PLATFORMS);
if (platformsFolder != null) {
PhoneGapStartupActivity.excludeFolder(project, platformsFolder);
}
VirtualFile ionicConfig = baseDir.findChild(PhoneGapUtil.IONIC_CONFIG);
if (ionicConfig != null) {
VirtualFile wwwFolder = baseDir.findChild(PhoneGapUtil.FOLDER_WWW);
if (wwwFolder != null) {
PhoneGapStartupActivity.excludeFolder(project, wwwFolder);
}
}
}
});
});
} catch (Exception e) {
LOG.warn(e);
showErrorMessage(e.getMessage());
}
}
Aggregations