protected void handleAdd() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new StyledBundleLabelProvider(false, false)); try { dialog.setElements(getValidBundles()); } catch (CoreException e) { dialog.setMessage(e.getMessage()); } dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); dialog.setMultipleSelection(true); if (dialog.open() == Window.OK) { Object[] models = dialog.getResult(); ArrayList<NameVersionDescriptor> pluginsToAdd = new ArrayList<NameVersionDescriptor>(); for (int i = 0; i < models.length; i++) { BundleInfo desc = ((BundleInfo) models[i]); pluginsToAdd.add(new NameVersionDescriptor(desc.getSymbolicName(), null)); } Set<NameVersionDescriptor> allDependencies = new HashSet<NameVersionDescriptor>(); allDependencies.addAll(pluginsToAdd); NameVersionDescriptor[] currentBundles = getTargetDefinition().getImplicitDependencies(); if (currentBundles != null) { allDependencies.addAll(Arrays.asList(currentBundles)); } getTargetDefinition() .setImplicitDependencies( allDependencies.toArray(new NameVersionDescriptor[allDependencies.size()])); fElementViewer.refresh(); updateImpButtons(); } }
private void handleRemove() { LinkedList<NameVersionDescriptor> bundles = new LinkedList<NameVersionDescriptor>(); bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies())); Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray(); if (removeBundles.length > 0) { for (int i = 0; i < removeBundles.length; i++) { if (removeBundles[i] instanceof NameVersionDescriptor) { bundles.remove(removeBundles[i]); } } getTargetDefinition() .setImplicitDependencies(bundles.toArray((new NameVersionDescriptor[bundles.size()]))); fElementViewer.refresh(); updateImpButtons(); } }