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