1 11 package org.eclipse.pde.internal.ui.wizards.product; 12 13 import java.util.Set ; 14 15 import org.eclipse.core.resources.IFile; 16 import org.eclipse.pde.core.plugin.IPluginAttribute; 17 import org.eclipse.pde.core.plugin.IPluginElement; 18 import org.eclipse.pde.core.plugin.IPluginModelBase; 19 import org.eclipse.pde.core.plugin.PluginRegistry; 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.search.dependencies.DependencyCalculator; 23 24 25 public class ProductFromExtensionOperation extends BaseProductCreationOperation { 26 27 private String fId; 28 29 public ProductFromExtensionOperation(IFile file, String productId) { 30 super(file); 31 fId = productId; 32 } 33 34 37 protected void initializeProduct(IProduct product) { 38 if (fId == null) 39 return; 40 IProductModelFactory factory = product.getModel().getFactory(); 41 initializeProductInfo(factory, product, fId); 42 addPlugins(factory, product, getPlugins()); 43 super.initializeProduct(product); 44 } 45 46 private String [] getPlugins() { 47 int lastDot = fId.lastIndexOf('.'); 48 if (lastDot == -1) 49 return new String [0]; 50 51 DependencyCalculator calculator = new DependencyCalculator(false); 52 IPluginModelBase model = PluginRegistry.findModel(fId.substring(0, lastDot)); 54 if (model != null) 55 calculator.findDependency(model); 56 57 IPluginElement element = getProductExtension(fId); 59 if (element != null) { 60 IPluginAttribute attr = element.getAttribute("application"); if (attr != null) { 62 String appId = attr.getValue(); 63 lastDot = appId.lastIndexOf('.'); 64 if (lastDot != -1) { 65 model = PluginRegistry.findModel(appId.substring(0, lastDot)); 66 if (model != null) { 67 calculator.findDependency(model); 68 } 69 } 70 } 71 } 72 Set ids = calculator.getBundleIDs(); 73 return (String [])ids.toArray(new String [ids.size()]); 74 } 75 76 } 77 | Popular Tags |