private void addBundleToProduct( final WARProductModelFactory factory, final String id, final IWARProduct product) { IProductPlugin bundle = factory.createPlugin(); bundle.setId(id); bundle.setVersion("0.0.0"); product.addPlugins(new IProductPlugin[] {bundle}); }
private void addPlugin(String id, String version) { IProduct product = getProduct(); IProductModelFactory factory = product.getModel().getFactory(); IProductPlugin plugin = factory.createPlugin(); plugin.setId(id); plugin.setVersion(version); product.addPlugins(new IProductPlugin[] {plugin}); fPluginTable.setSelection(new StructuredSelection(plugin)); }
private void addDependenciesAndPlugins() { IProduct product = getProduct(); if (!product.useFeatures()) { IProductModelFactory factory = product.getModel().getFactory(); IProductPlugin plugin = factory.createPlugin(); plugin.setId(INTRO_PLUGIN_ID); product.addPlugins(new IProductPlugin[] {plugin}); boolean includeOptional = false; IFormPage page = getPage().getEditor().findPage(DependenciesPage.PLUGIN_ID); if (page != null) includeOptional = ((DependenciesPage) page).includeOptionalDependencies(); PluginSection.handleAddRequired(new IProductPlugin[] {plugin}, includeOptional); } if (fManifest == null) loadManifestAndIntroIds(true); if (fManifest != null) addRequiredBundle(); }
private void checkForBannedBundle(final String id) throws Exception { IWARProduct product = createBasicProductWithLibraries(); IProductPlugin plugin = new ProductPlugin(product.getModel()); plugin.setId(id); IProductPlugin[] plugins = new IProductPlugin[] {plugin}; product.addPlugins(plugins); Validator validator = new Validator(product); Validation validation = validator.validate(); assertFalse(validation.isValid()); ValidationError[] errors = validation.getErrors(); boolean foundBannedBundle = false; for (int i = 0; i < errors.length && !foundBannedBundle; i++) { ValidationError error = errors[i]; if (error.getType() == ValidationError.BUNDLE_BANNED) { IProductPlugin bannedPlugin = (IProductPlugin) error.getCausingObject(); String message = error.getMessage(); if (bannedPlugin.getId().equals(id) && message.indexOf(id) != -1) { foundBannedBundle = true; } } } assertTrue(foundBannedBundle); }
private void handleAddWorkingSet() { IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), true); if (dialog.open() == Window.OK) { IWorkingSet[] workingSets = dialog.getSelection(); IProduct product = getProduct(); IProductModelFactory factory = product.getModel().getFactory(); ArrayList<IProductPlugin> pluginList = new ArrayList<IProductPlugin>(); for (int i = 0; i < workingSets.length; i++) { IAdaptable[] elements = workingSets[i].getElements(); for (int j = 0; j < elements.length; j++) { IPluginModelBase model = findModel(elements[j]); if (model != null) { IProductPlugin plugin = factory.createPlugin(); IPluginBase base = model.getPluginBase(); plugin.setId(base.getId()); pluginList.add(plugin); } } } product.addPlugins(pluginList.toArray(new IProductPlugin[pluginList.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); }