1 19 package org.netbeans.modules.java.platform; 20 21 import java.io.File ; 22 import java.util.prefs.Preferences ; 23 import org.openide.util.NbBundle; 24 import org.openide.util.NbPreferences; 25 import org.openide.util.Utilities; 26 27 28 29 33 public class PlatformSettings { 34 private static final PlatformSettings INSTANCE = new PlatformSettings(); 35 private static final String PROP_PLATFORMS_FOLDER = "platformsFolder"; private static final String APPLE_JAVAVM_FRAMEWORK_PATH = "/System/Library/Frameworks/JavaVM.framework/Versions/"; 38 public PlatformSettings () { 39 40 } 41 42 public String displayName() { 43 return NbBundle.getMessage(PlatformSettings.class,"TXT_PlatformSettings"); 44 } 45 46 private static Preferences getPreferences() { 47 return NbPreferences.forModule(PlatformSettings.class); 48 } 49 50 public File getPlatformsFolder () { 51 String folderName = getPreferences().get(PROP_PLATFORMS_FOLDER, null); 52 if (folderName == null) { 53 File f; 54 if (Utilities.isMac()) { 55 f = new File (APPLE_JAVAVM_FRAMEWORK_PATH); 56 } 57 else { 58 f = new File (System.getProperty("user.home")); File tmp; 60 while ((tmp = f.getParentFile())!=null) { 61 f = tmp; 62 } 63 } 64 return f; 65 } 66 else { 67 return new File (folderName); 68 } 69 } 70 71 public void setPlatformsFolder (File file) { 72 getPreferences().put(PROP_PLATFORMS_FOLDER, file.getAbsolutePath()); 73 } 74 75 76 public synchronized static PlatformSettings getDefault () { 77 return INSTANCE; 78 } 79 } 80 | Popular Tags |