1 11 package org.eclipse.pde.internal.builders; 12 13 import java.util.*; 14 15 import org.eclipse.core.resources.*; 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.osgi.util.NLS; 18 import org.eclipse.pde.internal.*; 19 20 public class UpdateSiteBuilder extends IncrementalProjectBuilder { 21 class DeltaVisitor implements IResourceDeltaVisitor { 22 private IProgressMonitor monitor; 23 public DeltaVisitor(IProgressMonitor monitor) { 24 this.monitor = monitor; 25 } 26 public boolean visit(IResourceDelta delta) { 27 IResource resource = delta.getResource(); 28 29 if (resource instanceof IProject) { 30 IProject project = (IProject) resource; 32 try { 33 return (project.hasNature(PDE.SITE_NATURE)); 34 } catch (CoreException e) { 35 PDE.logException(e); 36 return false; 37 } 38 } 39 if (resource instanceof IFile) { 40 IFile candidate = (IFile) resource; 42 if (candidate.getName().equals("site.xml")) { if (delta.getKind() != IResourceDelta.REMOVED) { 45 checkFile(candidate, monitor); 46 return true; 47 } 48 } 49 } 50 return true; 51 } 52 } 53 54 protected IProject[] build(int kind, Map args, IProgressMonitor monitor) 55 throws CoreException { 56 57 IResourceDelta delta = null; 58 if (kind != FULL_BUILD) 59 delta = getDelta(getProject()); 60 61 if (delta == null || kind == FULL_BUILD) { 62 IProject project = getProject(); 64 IFile file = project.getFile("site.xml"); if (file.exists()) { 66 checkFile(file, monitor); 67 } 68 } else { 69 delta.accept(new DeltaVisitor(monitor)); 70 } 71 return null; 72 } 73 74 private void checkFile(IFile file, IProgressMonitor monitor) { 75 String message = 76 NLS.bind(PDEMessages.Builders_verifying, file.getFullPath().toString()); 77 monitor.subTask(message); 78 UpdateSiteErrorReporter reporter = new UpdateSiteErrorReporter(file); 79 ValidatingSAXParser.parse(file, reporter); 80 if (reporter.getErrorCount() == 0) { 81 reporter.validateContent(monitor); 82 } 83 monitor.subTask(PDEMessages.Builders_updating); 84 monitor.done(); 85 } 86 87 } 88 | Popular Tags |