1 11 package org.eclipse.pde.ui.launcher; 12 13 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 14 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 15 import org.eclipse.pde.core.plugin.IPluginModelBase; 16 import org.eclipse.pde.core.plugin.PluginRegistry; 17 18 28 public class OSGiLaunchConfigurationInitializer { 29 30 protected static final String DEFAULT = "default"; 32 38 public void initialize(ILaunchConfigurationWorkingCopy configuration) { 39 initializeFrameworkDefaults(configuration); 40 initializeBundleState(configuration); 41 initializeSourcePathProvider(configuration); 42 } 43 44 50 protected void initializeSourcePathProvider(ILaunchConfigurationWorkingCopy configuration) { 51 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, 52 PDESourcePathProvider.ID); 53 } 54 55 61 protected void initializeFrameworkDefaults(ILaunchConfigurationWorkingCopy configuration) { 62 configuration.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); 63 configuration.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); 64 } 65 66 72 protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration) { 73 StringBuffer explugins = new StringBuffer (); 74 StringBuffer wsplugins = new StringBuffer (); 75 IPluginModelBase[] models = PluginRegistry.getActiveModels(); 76 for (int i = 0; i < models.length; i++) { 77 String id = models[i].getPluginBase().getId(); 78 boolean inWorkspace = models[i].getUnderlyingResource() != null; 79 appendBundle(inWorkspace ? wsplugins : explugins, id); 80 } 81 configuration.setAttribute(IPDELauncherConstants.WORKSPACE_BUNDLES, wsplugins.toString()); 82 configuration.setAttribute(IPDELauncherConstants.TARGET_BUNDLES, explugins.toString()); 83 configuration.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true); 84 } 85 86 private void appendBundle(StringBuffer buffer, String bundleID) { 87 if (buffer.length() > 0) 88 buffer.append(","); buffer.append(bundleID); 90 buffer.append("@"); buffer.append(getStartLevel(bundleID)); 92 buffer.append(":"); buffer.append(getAutoStart(bundleID)); 94 } 95 96 103 protected String getStartLevel(String bundleID) { 104 return DEFAULT; 105 } 106 107 113 protected String getAutoStart(String bundleID) { 114 return DEFAULT; 115 } 116 117 } 118 | Popular Tags |