Search in sources :

Example 1 with Diagnostician

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);
            }
        }
    });
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Diagnostician(org.eclipse.n4js.npmexporter.validation.Diagnostician) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) ArchiveException(org.apache.commons.compress.archivers.ArchiveException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CompressorException(org.apache.commons.compress.compressors.CompressorException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ArchiveException (org.apache.commons.compress.archivers.ArchiveException)1 CompressorException (org.apache.commons.compress.compressors.CompressorException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 Diagnostician (org.eclipse.n4js.npmexporter.validation.Diagnostician)1 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)1