1 11 package org.eclipse.pde.core.plugin; 12 13 import java.io.File ; 14 import java.net.URL ; 15 import java.util.Properties ; 16 import java.util.Set ; 17 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IPath; 20 import org.eclipse.core.runtime.Path; 21 import org.eclipse.core.runtime.Platform; 22 import org.eclipse.core.runtime.Preferences; 23 import org.eclipse.pde.internal.core.ICoreConstants; 24 import org.eclipse.pde.internal.core.PDECore; 25 import org.eclipse.pde.internal.core.TargetPlatformHelper; 26 import org.eclipse.pde.internal.core.UpdateManagerHelper; 27 28 41 public class TargetPlatform { 42 43 private static String PRODUCT_PROPERTY = "eclipse.product"; private static String APPLICATION_PROPERTY = "eclipse.application"; 46 private static String SDK_PRODUCT = "org.eclipse.sdk.ide"; private static String PLATFORM_PRODUCT = "org.eclipse.platform.ide"; 49 private static String IDE_APPLICATION = "org.eclipse.ui.ide.workbench"; 51 57 public static String getLocation() { 58 Preferences preferences = PDECore.getDefault().getPluginPreferences(); 59 return preferences.getString(ICoreConstants.PLATFORM_PATH); 60 } 61 62 68 public static String getDefaultLocation() { 69 URL installURL = Platform.getInstallLocation().getURL(); 70 IPath path = new Path(installURL.getFile()).removeTrailingSeparator(); 71 return path.toOSString(); 72 73 } 74 75 81 public static String getOS() { 82 return getProperty(ICoreConstants.OS, Platform.getOS()); 83 } 84 85 91 public static String getWS() { 92 return getProperty(ICoreConstants.WS, Platform.getWS()); 93 } 94 95 101 public static String getNL() { 102 return getProperty(ICoreConstants.NL, Platform.getNL()); 103 } 104 105 111 public static String getOSArch() { 112 return getProperty(ICoreConstants.ARCH, Platform.getOSArch()); 113 } 114 115 private static String getProperty(String key, String defaultValue) { 116 Preferences preferences = PDECore.getDefault().getPluginPreferences(); 117 String value = preferences.getString(key); 118 return value.equals("") ? defaultValue : value; } 120 121 132 public static String [] getApplications() { 133 return TargetPlatformHelper.getApplicationNames(); 134 } 135 136 147 public static String [] getProducts() { 148 return TargetPlatformHelper.getProductNames(); 149 } 150 151 160 public static String getDefaultProduct() { 161 Properties config = TargetPlatformHelper.getConfigIniProperties(); 162 Set set = TargetPlatformHelper.getProductNameSet(); 163 if (config != null) { 164 String product = (String ) config.get(PRODUCT_PROPERTY); 165 if (product != null && set.contains(product)) 166 return product; 167 } 168 169 if (set.contains(SDK_PRODUCT)) 170 return SDK_PRODUCT; 171 172 return set.contains(PLATFORM_PRODUCT) ? PLATFORM_PRODUCT : null; 173 } 174 175 185 public static String getDefaultApplication() { 186 Properties config = TargetPlatformHelper.getConfigIniProperties(); 187 Set set = TargetPlatformHelper.getApplicationNameSet(); 188 if (config != null) { 189 String application = (String ) config.get(APPLICATION_PROPERTY); 190 if (application != null && set.contains(application)) 191 return application; 192 } 193 return IDE_APPLICATION; 194 } 195 196 208 public static void createPlatformConfiguration( 209 File location, IPluginModelBase[] plugins, IPluginModelBase brandingPlugin) 210 throws CoreException { 211 UpdateManagerHelper.createPlatformConfiguration(location, plugins, brandingPlugin); 212 } 213 214 231 public static String getBundleList() { 232 return TargetPlatformHelper.getBundleList(); 233 } 234 235 } 236 | Popular Tags |