/** * Gets a list of all the bundles that can be added as implicit dependencies * * @return list of possible dependencies */ protected BundleInfo[] getValidBundles() throws CoreException { NameVersionDescriptor[] current = getTargetDefinition().getImplicitDependencies(); Set<String> currentBundles = new HashSet<String>(); if (current != null) { for (int i = 0; i < current.length; i++) { if (!currentBundles.contains(current[i].getId())) { currentBundles.add(current[i].getId()); } } } List<BundleInfo> targetBundles = new ArrayList<BundleInfo>(); TargetBundle[] allTargetBundles = getTargetDefinition().getAllBundles(); if (allTargetBundles == null || allTargetBundles.length == 0) { throw new CoreException( new Status( IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0)); } for (int i = 0; i < allTargetBundles.length; i++) { BundleInfo bundleInfo = allTargetBundles[i].getBundleInfo(); if (!currentBundles.contains(bundleInfo.getSymbolicName())) { currentBundles.add(bundleInfo.getSymbolicName()); // to avoid duplicate entries targetBundles.add(bundleInfo); } } return targetBundles.toArray(new BundleInfo[targetBundles.size()]); }
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 computeSelected(Collection<?> initialSelection) { if (initialSelection == null || initialSelection.size() == 0) return; Set<IPluginModelBase> selected = new HashSet<IPluginModelBase>(); Iterator<?> iter = initialSelection.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof IProject) { IPluginModelBase model = PluginRegistry.findModel((IProject) obj); if (model != null) { selected.add(model); } } } fSelected = selected.toArray(new IPluginModelBase[selected.size()]); }
@Override protected void refreshPage() { fAvailableListViewer.addFilter(fSourceFilter); fImportListViewer.getTable().removeAll(); fSelected.clear(); fAvailableFilter.setPattern("*"); // $NON-NLS-1$ fSourceFilter.setState(fPage1.getState()); fVersionFilter.setModel(fModels); fAvailableListViewer.refresh(); pageChanged(); }
private void doRemove(List<Object> items) { fSelected.removeAll(items); fImportListViewer.remove(items.toArray()); fAvailableListViewer.add(items.toArray()); }
/** * Delimits a comma separated preference and add the items to the given set * * @param set * @param preference */ private void addExtraChoices(Set<String> set, String preference) { StringTokenizer tokenizer = new StringTokenizer(preference, ","); // $NON-NLS-1$ while (tokenizer.hasMoreTokens()) { set.add(tokenizer.nextToken().trim()); } }