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(); } }
public Object[] getElements(Object inputElement) { if (inputElement instanceof ITargetDefinition) { List result = new ArrayList(); // Check if there are any errors for missing features/bundles to display if (fMissing == null) { fMissing = new ArrayList(); } else { fMissing.clear(); } IResolvedBundle[] bundles = fTargetDefinition.getBundles(); for (int i = 0; i < bundles.length; i++) { if (!bundles[i].getStatus().isOK()) { fMissing.add(bundles[i]); result.add(bundles[i]); } } if (fFeaureModeButton.getSelection()) { IFeatureModel[] features = fTargetDefinition.getAllFeatures(); result.addAll(Arrays.asList(features)); // Check if we need the other category if (((TargetDefinition) fTargetDefinition).getOtherBundles().length > 0) { result.add(OTHER_CATEGORY); } } else if (fGrouping == GROUP_BY_CONTAINER) { result.addAll(Arrays.asList(fTargetDefinition.getBundleContainers())); } else if (fGrouping == GROUP_BY_NONE) { // Missing bundles are already handled by adding to fMissing, avoid adding twice IResolvedBundle[] allBundles = fTargetDefinition.getAllBundles(); for (int i = 0; i < allBundles.length; i++) { if (allBundles[i].getStatus().isOK()) { result.add(allBundles[i]); } } } else { result.addAll(Arrays.asList(getFileBundleMapping().keySet().toArray())); } return result.toArray(); } return new Object[] {inputElement}; }
public void setFiles(String[] fileNames) { int size = Arrays.asList(fileNames).size(); Vector iFileNames = new Vector(); for (int i = 0; i < size; i++) { IResource resource = workspaceRoot.findMember(fileNames[i]); if (resource instanceof IFile) iFileNames.addElement(resource); } IFile[] dummyArray = new IFile[iFileNames.size()]; this.fileNames = (IFile[]) (iFileNames.toArray(dummyArray)); }
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(); } }