1 11 package org.eclipse.jdt.apt.core.internal; 12 13 import org.eclipse.core.resources.IFolder; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager; 17 import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager; 18 import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil; 19 import org.eclipse.jdt.apt.core.util.AptPreferenceConstants; 20 import org.eclipse.jdt.core.IJavaProject; 21 22 27 public class AptProject { 28 29 private final IJavaProject _javaProject; 30 31 private final GeneratedFileManager _gfm; 32 33 private final GeneratedSourceFolderManager _gsfm; 34 35 public AptProject(final IJavaProject javaProject) { 36 _javaProject = javaProject; 37 _gsfm = new GeneratedSourceFolderManager(this); 38 _gfm = new GeneratedFileManager(this, _gsfm); 39 } 40 41 public IJavaProject getJavaProject() { 42 return _javaProject; 43 } 44 45 public GeneratedFileManager getGeneratedFileManager() { 46 return _gfm; 47 } 48 49 public GeneratedSourceFolderManager getGeneratedSourceFolderManager() { 50 return _gsfm; 51 } 52 53 57 public void compilationStarted() { 58 _gfm.compilationStarted(); 59 } 60 61 69 public void preferenceChanged(String key) { 70 if (AptPreferenceConstants.APT_GENSRCDIR.equals(key)) { 71 _gsfm.folderNamePreferenceChanged(); 72 } 73 else if(AptPreferenceConstants.APT_ENABLED.equals(key) ){ 74 _gsfm.enabledPreferenceChanged(); 75 } 76 } 77 78 86 87 public void projectClean( boolean deleteFiles ) 88 { 89 _gfm.projectCleaned(); 90 91 if ( deleteFiles ) 95 { 96 IFolder f = _gsfm.getFolder(); 97 if ( f != null && f.exists() ) 98 { 99 try 100 { 101 IResource[] members = f.members(); 102 for ( int i = 0; i<members.length; i++ ){ 103 FileSystemUtil.deleteDerivedResources(members[i]); 104 } 105 } 106 catch ( CoreException ce ) 107 { 108 AptPlugin.log(ce, "Could not delete generated files"); } 110 } 111 } 112 } 113 114 117 public void projectClosed() 118 { 119 _gfm.projectClosed(); 120 } 121 122 129 public void projectDeleted() 130 { 131 if (AptPlugin.DEBUG) 132 AptPlugin.trace("AptProject.projectDeleted cleaning state for project " + _javaProject.getElementName()); _gfm.projectDeleted(); 134 } 135 136 } 137 | Popular Tags |