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 handleSetImportSelection(ArrayList<Object> newSelectionList) { if (newSelectionList.size() == 0) { handleRemoveAll(); pageChanged(); return; } TableItem[] items = fImportListViewer.getTable().getItems(); Object[] oldSelection = new Object[items.length]; for (int i = 0; i < items.length; i++) { oldSelection[i] = items[i].getData(); } // remove items that were in the old selection, but are not in the new one List<Object> itemsToRemove = new ArrayList<>(); for (int i = 0; i < oldSelection.length; i++) { if (newSelectionList.contains(oldSelection[i])) { newSelectionList.remove(oldSelection[i]); } else { itemsToRemove.add(oldSelection[i]); } } doRemove(itemsToRemove); // add items that were not in the old selection and are in the new one doAdd(newSelectionList); pageChanged(); }
private void handleExistingProjects() { ArrayList<Object> result = new ArrayList<>(); for (int i = 0; i < fModels.length; i++) { String id = fModels[i].getPluginBase().getId(); IProject project = (IProject) PDEPlugin.getWorkspace().getRoot().findMember(id); if (project != null && project.isOpen() && WorkspaceModelManager.isPluginProject(project)) { result.add(fModels[i]); } } handleSetImportSelection(result); }
private void handleRemoveAll() { TableItem[] items = fImportListViewer.getTable().getItems(); ArrayList<Object> data = new ArrayList<>(); for (int i = 0; i < items.length; i++) { data.add(items[i].getData()); } if (data.size() > 0) { doRemove(data); pageChanged(false, true); } }
private void handleAddAll() { TableItem[] items = fAvailableListViewer.getTable().getItems(); ArrayList<Object> data = new ArrayList<>(); for (int i = 0; i < items.length; i++) { data.add(items[i].getData()); } if (data.size() > 0) { doAdd(data); pageChanged(true, false); } }
private void computeUnmigrated() { IPluginModelBase[] models = PluginRegistry.getWorkspaceModels(); ArrayList<IPluginModelBase> modelArray = new ArrayList<IPluginModelBase>(); try { for (int i = 0; i < models.length; i++) { if (models[i].getUnderlyingResource().getProject().hasNature(JavaCore.NATURE_ID)) modelArray.add(models[i]); } } catch (CoreException e) { PDEPlugin.logException(e); } fUnmigrated = modelArray.toArray(new IPluginModelBase[modelArray.size()]); }
private void handleAddRequiredPlugins() { TableItem[] items = fImportListViewer.getTable().getItems(); if (items.length == 0) return; if (items.length == 1) { IPluginModelBase model = (IPluginModelBase) items[0].getData(); if (model.getPluginBase().getId().equals("org.eclipse.core.boot")) { // $NON-NLS-1$ return; } } ArrayList<IPluginModelBase> result = new ArrayList<>(); for (int i = 0; i < items.length; i++) { addPluginAndDependencies( (IPluginModelBase) items[i].getData(), result, fAddFragmentsButton.getSelection()); } ArrayList<Object> resultObject = new ArrayList<>(result.size()); resultObject.addAll(result); handleSetImportSelection(resultObject); }
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); }
private void handleSwap() { TableItem[] aItems = fAvailableListViewer.getTable().getItems(); TableItem[] iItems = fImportListViewer.getTable().getItems(); ArrayList<Object> data = new ArrayList<>(); for (int i = 0; i < iItems.length; i++) { data.add(iItems[i].getData()); } if (data.size() > 0) { doRemove(data); } data.clear(); for (int i = 0; i < aItems.length; i++) { data.add(aItems[i].getData()); } if (data.size() > 0) { doAdd(data); } pageChanged(); }