1 17 package org.eclipse.emf.codegen.jet; 18 19 20 import java.util.Map ; 21 22 import org.eclipse.core.resources.IProject; 23 import org.eclipse.core.resources.IResourceDelta; 24 import org.eclipse.core.resources.IncrementalProjectBuilder; 25 import org.eclipse.core.runtime.CoreException; 26 import org.eclipse.core.runtime.IProgressMonitor; 27 import org.eclipse.core.runtime.OperationCanceledException; 28 29 30 public class JETBuilder extends IncrementalProjectBuilder 31 { 32 35 public JETBuilder() 36 { 37 super(); 38 } 39 40 protected IProject[] build(int kind, Map arguments, IProgressMonitor monitor) throws CoreException 41 { 42 if (!getProject().exists()) 43 { 44 return new IProject[0]; 45 } 46 else 47 { 48 try 49 { 50 if (kind == FULL_BUILD) 51 { 52 fullBuild(monitor); 53 } 54 else 55 { 56 IResourceDelta delta = getDelta(getProject()); 57 if (delta == null) 58 { 59 fullBuild(monitor); 60 } 61 else 62 { 63 incrementalBuild(delta, monitor); 64 } 65 } 66 } 67 catch (OperationCanceledException e) 68 { 69 } 72 73 return null; 74 } 75 } 76 77 80 protected void fullBuild(IProgressMonitor monitor) throws CoreException 81 { 82 JETNature nature = JETNature.getRuntime(getProject()); 83 if (nature != null) 84 { 85 JETCompileTemplateOperation compileTemplateOperation = 86 new JETCompileTemplateOperation(getProject(), nature.getTemplateContainers()); 87 compileTemplateOperation.setInBuild(true); 88 if (compileTemplateOperation.shouldCompile()) 89 { 90 compileTemplateOperation.run(monitor); 91 } 92 } 93 } 94 95 98 protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException 99 { 100 JETNature nature = JETNature.getRuntime(getProject()); 101 if (nature != null) 102 { 103 if (delta.getKind() == IResourceDelta.ADDED || 104 delta.getKind() == IResourceDelta.CHANGED || 105 delta.getKind() == IResourceDelta.CONTENT || 106 delta.getKind() == IResourceDelta.OPEN) 107 { 108 JETCompileTemplateOperation compileTemplateOperation = 109 new JETCompileTemplateOperation(getProject(), nature.getTemplateContainers()); 110 compileTemplateOperation.setInBuild(true); 111 if (compileTemplateOperation.shouldCompile()) 112 { 113 compileTemplateOperation.run(monitor); 114 } 115 } 116 } 117 } 118 } 119 | Popular Tags |