1 11 package org.eclipse.pde.internal.ui.wizards.product; 12 13 import org.eclipse.core.resources.IContainer; 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.Path; 17 import org.eclipse.debug.core.ILaunchConfiguration; 18 import org.eclipse.pde.core.plugin.TargetPlatform; 19 import org.eclipse.pde.internal.core.iproduct.IConfigurationFileInfo; 20 import org.eclipse.pde.internal.core.iproduct.IProduct; 21 import org.eclipse.pde.internal.core.iproduct.IProductModelFactory; 22 import org.eclipse.pde.internal.ui.PDEPlugin; 23 import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator; 24 import org.eclipse.pde.ui.launcher.IPDELauncherConstants; 25 26 27 public class ProductFromConfigOperation extends BaseProductCreationOperation { 28 29 private ILaunchConfiguration fLaunchConfiguration; 30 31 public ProductFromConfigOperation(IFile file, ILaunchConfiguration config) { 32 super(file); 33 fLaunchConfiguration = config; 34 } 35 36 39 protected void initializeProduct(IProduct product) { 40 if (fLaunchConfiguration == null) 41 return; 42 try { 43 IProductModelFactory factory = product.getModel().getFactory(); 44 boolean useProduct = fLaunchConfiguration.getAttribute(IPDELauncherConstants.USE_PRODUCT, false); 45 if (useProduct) { 46 String id = fLaunchConfiguration.getAttribute(IPDELauncherConstants.PRODUCT, (String )null); 47 if (id != null) { 48 initializeProductInfo(factory, product, id); 49 } 50 } else { 51 String appName = fLaunchConfiguration.getAttribute(IPDELauncherConstants.APPLICATION, TargetPlatform.getDefaultApplication()); 52 product.setApplication(appName); 53 } 54 addPlugins(factory, product, LaunchPluginValidator.getPluginList(fLaunchConfiguration)); 55 if (fLaunchConfiguration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) { 56 super.initializeProduct(product); 57 } else { 58 String path = fLaunchConfiguration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, "/"); IContainer container = PDEPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(path)); 60 if (container != null) { 61 IConfigurationFileInfo info = factory.createConfigFileInfo(); 62 info.setUse("custom"); info.setPath(container.getFullPath().toString()); 64 product.setConfigurationFileInfo(info); 65 } else { 66 super.initializeProduct(product); 67 } 68 } 69 } catch (CoreException e) { 70 } 71 } 72 73 } 74 | Popular Tags |