1 19 20 package org.netbeans.modules.j2ee.earproject; 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeSupport ; 24 import java.util.Collection ; 25 import java.util.Collections ; 26 import java.util.List ; 27 import java.util.Map ; 28 import org.netbeans.api.java.classpath.ClassPath; 29 import org.netbeans.api.java.platform.JavaPlatform; 30 import org.netbeans.api.java.platform.Specification; 31 import org.netbeans.modules.java.platform.JavaPlatformProvider; 32 import org.openide.filesystems.FileObject; 33 import org.openide.modules.SpecificationVersion; 34 35 38 public final class TestPlatformProvider implements JavaPlatformProvider { 39 40 private JavaPlatform defaultPlatform; 41 private JavaPlatform explicitPlatform; 42 private PropertyChangeSupport support; 43 private boolean hideExplicitPlatform; 44 45 public TestPlatformProvider (ClassPath defaultPlatformBootClassPath, ClassPath explicitPlatformBootClassPath) { 46 this.support = new PropertyChangeSupport (this); 47 this.defaultPlatform = new TestPlatform("default_platform", defaultPlatformBootClassPath); 48 this.explicitPlatform = new TestPlatform("ExplicitPlatform", explicitPlatformBootClassPath); 49 } 50 51 public void removePropertyChangeListener(PropertyChangeListener listener) { 52 this.support.removePropertyChangeListener (listener); 53 } 54 55 public void addPropertyChangeListener(PropertyChangeListener listener) { 56 this.support.addPropertyChangeListener(listener); 57 } 58 59 public JavaPlatform[] getInstalledPlatforms() { 60 if (this.hideExplicitPlatform) { 61 return new JavaPlatform[] { 62 this.defaultPlatform, 63 }; 64 } 65 else { 66 return new JavaPlatform[] { 67 this.defaultPlatform, 68 this.explicitPlatform, 69 }; 70 } 71 } 72 73 public JavaPlatform getDefaultPlatform () { 74 return this.defaultPlatform; 75 } 76 77 public void setExplicitPlatformVisible (boolean value) { 78 this.hideExplicitPlatform = !value; 79 this.support.firePropertyChange(PROP_INSTALLED_PLATFORMS,null,null); 80 } 81 82 private static class TestPlatform extends JavaPlatform { 83 84 private final String systemName; 85 private final Map properties; 86 private final ClassPath bootClassPath; 87 88 public TestPlatform (String systemName, ClassPath bootCP) { 89 this.systemName = systemName; 90 this.bootClassPath = bootCP; 91 this.properties = Collections.singletonMap("platform.ant.name",this.systemName); 92 } 93 94 public FileObject findTool(String toolName) { 95 return null; 96 } 97 98 public String getVendor() { 99 return "me"; 100 } 101 102 public ClassPath getStandardLibraries() { 103 return null; 104 } 105 106 public Specification getSpecification() { 107 return new Specification ("j2se", new SpecificationVersion ("1.5")); 108 } 109 110 public ClassPath getSourceFolders() { 111 return null; 112 } 113 114 public Map getProperties() { 115 return this.properties; 116 } 117 118 public List getJavadocFolders() { 119 return null; 120 } 121 122 public Collection getInstallFolders() { 123 return null; 124 } 125 126 public String getDisplayName() { 127 return this.systemName; 128 } 129 130 public ClassPath getBootstrapLibraries() { 131 return this.bootClassPath; 132 } 133 } 134 } 135 | Popular Tags |