1 19 20 package org.netbeans.bluej.classpath; 21 22 import java.io.File ; 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 import java.util.List ; 26 import java.util.StringTokenizer ; 27 import org.netbeans.api.java.classpath.ClassPath; 28 import org.netbeans.api.java.platform.JavaPlatformManager; 29 import org.netbeans.bluej.BluejProject; 30 import org.netbeans.bluej.options.BlueJSettings; 31 import org.netbeans.spi.java.classpath.ClassPathFactory; 32 import org.netbeans.spi.java.classpath.ClassPathImplementation; 33 import org.netbeans.spi.java.classpath.ClassPathProvider; 34 import org.netbeans.spi.java.classpath.support.ClassPathSupport; 35 import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport; 36 import org.openide.filesystems.FileObject; 37 import org.openide.filesystems.FileUtil; 38 39 43 public class ClassPathProviderImpl implements ClassPathProvider { 44 45 private BluejProject project; 46 47 private ClassPath boot; 48 private ClassPath source; 49 private ClassPath compile; 50 private ClassPath[] boots; 51 private ClassPath[] sources; 52 private ClassPath[] compiles; 53 54 private CPImpl cpimpl; 55 56 57 58 public ClassPathProviderImpl(BluejProject prj) { 59 project = prj; 60 } 61 62 public CPImpl getBluejCPImpl() { 63 return cpimpl; 64 } 65 66 public ClassPath findClassPath(FileObject file, String type) { 67 if (type.equals(ClassPath.COMPILE)) { 68 return getCompileTimeClasspath(file); 69 } else if (type.equals(ClassPath.EXECUTE)) { 70 return getRunTimeClasspath(file); 71 } else if (type.equals(ClassPath.SOURCE)) { 72 return getSourcepath(file); 73 } else if (type.equals(ClassPath.BOOT)) { 74 return getBootClassPath(); 75 } else { 76 return null; 77 } 78 } 79 80 private ClassPath getBootClassPath() { 81 if (boot == null) { 82 boot = JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(); 83 } 84 return boot; 85 } 86 87 private ClassPath getSourcepath(FileObject file) { if (source == null) { 89 source = ClassPathSupport.createClassPath(new FileObject[] { project.getProjectDirectory() }); 90 } 91 return source; 92 } 93 94 private ClassPath getRunTimeClasspath(FileObject file) { return null; 96 } 97 98 private ClassPath getCompileTimeClasspath(FileObject file) { if (compile == null) { 100 ClassPath antcp = ClassPathFactory.createClassPath( 102 ProjectClassPathSupport.createPropertyBasedClassPathImplementation( 103 FileUtil.toFile(project.getProjectDirectory()), project.getAntProjectHelper().getStandardPropertyEvaluator(), 104 new String [] {"javac.classpath"})); cpimpl = new CPImpl(project); 106 ClassPath bluejcp = ClassPathFactory.createClassPath(cpimpl); 107 compile = ClassPathSupport.createProxyClassPath( new ClassPath[] {antcp, bluejcp} ); 108 } 109 return compile; 110 } 111 112 public ClassPath[] getCompileTimeClasspath() { 113 if (compiles == null) { 114 compiles = new ClassPath[] { getCompileTimeClasspath(project.getProjectDirectory()), 115 ClassPathSupport.createClassPath(new FileObject[] { project.getProjectDirectory() })}; 117 } 118 return compiles; 119 } 120 121 public ClassPath[] getSourcePath() { 122 if (sources == null) { 123 sources = new ClassPath[] { getSourcepath(project.getProjectDirectory()) }; 124 } 125 return sources; 126 } 127 128 public ClassPath[] getBootPath() { 129 if (boots == null) { 130 boots = new ClassPath[] { getBootClassPath() }; 131 } 132 return boots; 133 } 134 135 } 136 | Popular Tags |