use of org.eclipse.n4js.npmexporter.validation.Diagnostician in project n4js by eclipse.
the class NpmExportWizard method updateProjectsToExportSelection.
/**
* @param checked
* list of selected projects to export
* @throws InterruptedException
* @throws InvocationTargetException
*/
public void updateProjectsToExportSelection(Object[] checked) throws InvocationTargetException, InterruptedException {
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
List<IProject> checkedProjects = newArrayList();
for (Object o : checked) checkedProjects.add((IProject) o);
List<? extends IN4JSProject> checkedIN4JSProjects = mapToIN4JSProjects(checkedProjects);
// validate:
final Diagnostician diag = new Diagnostician();
List<IN4JSProject> _requiresMerge1 = newArrayList();
for (IN4JSProject p : checkedIN4JSProjects) {
diag.setActiveProject(p);
npmExporter.validate(p, diag);
if (npmExporter.requiresJsonMerge(p)) {
_requiresMerge1.add(p);
}
}
setRequireJsonMerge(_requiresMerge1);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (diag.isIssueFree()) {
exportPage.setErrorMessage(null);
exportPage.setErrorText("");
} else {
exportPage.setPageComplete(false);
exportPage.setErrorMessage("Validation errors for projects: " + Joiner.on(", ").join(diag.projectsWithEntries().stream().map(p -> p.getProjectId()).iterator()));
String text = diag.asErrorText();
exportPage.setErrorText(text);
}
}
});
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
});
}
Aggregations