private BundleDescription[] getBundles() { TreeMap<String, BundleDescription> map = new TreeMap<String, BundleDescription>(); IProduct product = getProduct(); BundleDescription[] bundles = TargetPlatformHelper.getState().getBundles(); for (int i = 0; i < bundles.length; i++) { String id = bundles[i].getSymbolicName(); if (!product.containsPlugin(id)) { map.put(id, bundles[i]); } } return map.values().toArray(new BundleDescription[map.size()]); }
public static void handleAddRequired(IProductPlugin[] plugins, boolean includeOptional) { if (plugins.length == 0) return; ArrayList<BundleDescription> list = new ArrayList<BundleDescription>(plugins.length); for (int i = 0; i < plugins.length; i++) { list.add(TargetPlatformHelper.getState().getBundle(plugins[i].getId(), null)); } DependencyCalculator calculator = new DependencyCalculator(includeOptional); calculator.findDependencies(list.toArray()); BundleDescription[] bundles = TargetPlatformHelper.getState().getBundles(); for (int i = 0; i < bundles.length; i++) { HostSpecification host = bundles[i].getHost(); if (host != null && !("org.eclipse.ui.workbench.compatibility" .equals(bundles[i].getSymbolicName())) // $NON-NLS-1$ && calculator.containsPluginId(host.getName())) { calculator.findDependency(bundles[i]); } } Collection<?> dependencies = calculator.getBundleIDs(); IProduct product = plugins[0].getProduct(); IProductModelFactory factory = product.getModel().getFactory(); IProductPlugin[] requiredPlugins = new IProductPlugin[dependencies.size()]; int i = 0; Iterator<?> iter = dependencies.iterator(); while (iter.hasNext()) { String id = iter.next().toString(); IProductPlugin plugin = factory.createPlugin(); plugin.setId(id); requiredPlugins[i++] = plugin; } product.addPlugins(requiredPlugins); }