1 19 20 package org.netbeans.modules.java.j2seplatform.platformdefinition; 21 22 import java.io.*; 23 import java.net.URL ; 24 import java.util.*; 25 import java.net.MalformedURLException ; 26 27 import org.openide.util.NbBundle; 28 import org.openide.util.Utilities; 29 import org.openide.ErrorManager; 30 import org.openide.filesystems.FileUtil; 31 import org.netbeans.api.java.platform.*; 32 import org.netbeans.api.java.classpath.*; 33 34 40 public class DefaultPlatformImpl extends J2SEPlatformImpl { 41 42 43 public static final String DEFAULT_PLATFORM_ANT_NAME = "default_platform"; 45 private ClassPath standardLibs; 46 47 static JavaPlatform create(Map properties, List sources, List javadoc) { 48 if (properties == null) { 49 properties = new HashMap (); 50 } 51 File javaHome = FileUtil.normalizeFile(new File(System.getProperty("jdk.home"))); List installFolders = new ArrayList (); 53 try { 54 installFolders.add (javaHome.toURI().toURL()); 55 } catch (MalformedURLException mue) { 56 ErrorManager.getDefault().notify (mue); 57 } 58 if (sources == null) { 59 sources = getSources (javaHome); 60 } 61 if (javadoc == null) { 62 javadoc = getJavadoc (javaHome); 63 } 64 return new DefaultPlatformImpl(installFolders, properties, new HashMap(System.getProperties()), sources,javadoc); 65 } 66 67 private DefaultPlatformImpl(List installFolders, Map platformProperties, Map systemProperties, List sources, List javadoc) { 68 super(null,DEFAULT_PLATFORM_ANT_NAME, 69 installFolders, platformProperties, systemProperties, sources, javadoc); 70 } 71 72 public void setAntName(String antName) { 73 throw new UnsupportedOperationException (); } 75 76 public String getDisplayName () { 77 String displayName = super.getDisplayName(); 78 if (displayName == null) { 79 displayName = NbBundle.getMessage(DefaultPlatformImpl.class,"TXT_DefaultPlatform", getSpecification().getVersion().toString()); 80 this.internalSetDisplayName (displayName); 81 } 82 return displayName; 83 } 84 85 public void setDisplayName(String name) { 86 throw new UnsupportedOperationException (); } 88 89 public ClassPath getStandardLibraries() { 90 if (standardLibs != null) 91 return standardLibs; 92 String s = System.getProperty(SYSPROP_JAVA_CLASS_PATH); if (s == null) { 94 s = ""; } 96 return standardLibs = Util.createClassPath (s); 97 } 98 99 static List getSources (File javaHome) { 100 if (javaHome != null) { 101 try { 102 File f; 103 if (Utilities.getOperatingSystem() == Utilities.OS_VMS) { 107 String srcHome = 108 System.getProperty("netbeans.openvms.j2seplatform.default.srcdir"); 109 if (srcHome != null) 110 f = new File(srcHome, "src.zip"); 111 else 112 f = new File (javaHome, "src.zip"); 113 } else { 114 f = new File (javaHome, "src.zip"); if (!f.exists()) { 117 f = new File (javaHome, "src.jar"); } 119 } 120 if (f.exists() && f.canRead()) { 121 URL url = FileUtil.getArchiveRoot(f.toURI().toURL()); 122 return Collections.singletonList (url); 123 } 124 } catch (MalformedURLException e) { 125 ErrorManager.getDefault().notify (e); 126 } 127 } 128 return null; 129 } 130 131 132 static List getJavadoc (File javaHome) { 133 if (javaHome != null ) { 134 File f = new File (javaHome,"docs"); if (f.isDirectory() && f.canRead()) { 136 try { 137 return Collections.singletonList(f.toURI().toURL()); 138 } catch (MalformedURLException mue) { 139 ErrorManager.getDefault().notify (mue); 140 } 141 } 142 } 143 return null; 144 } 145 146 } | Popular Tags |