@Override public IStatus run(IProgressMonitor monitor) { monitor = new ProgressMonitorCheckingClose(monitor); monitor.beginTask("Build Check", 2); // collect all resources which need to be checked final ProjectResourceCollector collector = new ProjectResourceCollector(); CancelingJob collectorJob = new CancelingJob("Collect") { @Override public IStatus run(IProgressMonitor monitor) { monitor.beginTask("Collect", IProgressMonitor.UNKNOWN); try { project.acceptSourceFiles(collector); } catch (CoreException e) { TinyOSPlugin.warning(e.getStatus()); } monitor.done(); return Status.OK_STATUS; } }; collectorJob.setPriority(getPriority()); collectorJob.setSystem(true); project.getModel().runJob(collectorJob, new SubProgressMonitor(monitor, 1)); if (monitor.isCanceled()) { monitor.done(); return Status.CANCEL_STATUS; } // check all resources for consistency final List<IResource> build = new ArrayList<IResource>(); final List<IResource> changed = new ArrayList<IResource>(); IProgressMonitor resourceMonitor = new SubProgressMonitor(monitor, 1); resourceMonitor.beginTask("Build Check", collector.resources.size()); for (final IResource resource : collector.resources) { CancelingJob checkJob = new CancelingJob("Check") { @Override public IStatus run(IProgressMonitor monitor) { if (project.getModel().checkChange(resource)) { changed.add(resource); } else { if (project.getModel().checkBuild(resource, monitor)) build.add(resource); } return Status.OK_STATUS; } }; checkJob.setPriority(getPriority()); checkJob.setSystem(true); project.getModel().runJob(checkJob, new SubProgressMonitor(resourceMonitor, 1)); if (monitor.isCanceled()) { monitor.done(); return Status.CANCEL_STATUS; } } // rebuild the resources which are not consistent if (build.size() > 0 || changed.size() > 0) { project.getBuilder().doAutoBuild(build, changed, autoTriggered); } resourceMonitor.done(); monitor.done(); return Status.OK_STATUS; }
public BuildCheckJob(ProjectTOS project, int autoTriggered) { super("Check consistent: '" + project.getProject().getName() + "'"); setRule(project.getProject()); this.autoTriggered = autoTriggered; this.project = project; }