private void removeOrdered(Shell shell) { TableItem[] itemsIdMaps = fIdMapsTable.getSelection(); TableItem[] itemsOrdered = fOrderedTable.getSelection(); if (itemsOrdered.length > 0 && itemsIdMaps.length > 0) { Mapping mapping = (Mapping) itemsOrdered[0].getData(); IdMap idmap = (IdMap) itemsIdMaps[0].getData(); ArrayList idmapAL = (ArrayList) fOrderedElements.get(idmap.getName()); idmapAL.remove(mapping.getKey()); if (idmapAL.size() <= 0) fOrderedElements.remove(idmap.getName()); ArrayList ordered = idmap.getOrdered(); ordered.remove(mapping); if (ordered.size() <= 0) idmap.setOrdered(null); itemsOrdered[0].dispose(); // Table is single selection } }
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 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(); }
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 ISiteFeature[] getFeaturesFromSelection(IStructuredSelection sel) { if (sel.isEmpty()) return new ISiteFeature[0]; if (cachedSelection == sel) return cachedFeatures; cachedSelection = sel; ArrayList<ISiteFeature> features = new ArrayList<ISiteFeature>(sel.size()); Iterator<?> iterator = sel.iterator(); while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof SiteFeatureAdapter) { if ((((SiteFeatureAdapter) next).feature) != null) { features.add(((SiteFeatureAdapter) next).feature); } } } cachedFeatures = features.toArray(new ISiteFeature[features.size()]); return cachedFeatures; }
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 editIdMap(Shell shell) { TableItem[] items = fIdMapsTable.getSelection(); if (items.length > 0) { IdMap idmap = (IdMap) items[0].getData(); XMLCompareEditCopyIdMapDialog dialog = new XMLCompareEditCopyIdMapDialog(shell, idmap, fIdMaps, fIdMapsInternal); if (dialog.open() == Window.OK) { String new_idmapName = dialog.getResult(); if (!fIdMaps.containsKey(new_idmapName)) { // copy over id mappings Vector newMappings = new Vector(); IdMap newIdMap = new IdMap(new_idmapName, false, newMappings); HashMap newIdmapHM = new HashMap(); fIdMaps.put(newIdMap.getName(), newIdmapHM); Vector Mappings = idmap.getMappings(); for (Enumeration enumeration = Mappings.elements(); enumeration.hasMoreElements(); ) { Mapping mapping = (Mapping) enumeration.nextElement(); Mapping newMapping = new Mapping(mapping.getElement(), mapping.getSignature(), mapping.getIdAttribute()); newMappings.add(newMapping); newIdmapHM.put(newMapping.getKey(), newMapping.getIdAttribute()); } // copy over ordered entries ArrayList orderedAL = idmap.getOrdered(); if (orderedAL != null && orderedAL.size() > 0) { ArrayList newOrderedAL = new ArrayList(); newIdMap.setOrdered(newOrderedAL); ArrayList idmapOrdered = new ArrayList(); fOrderedElements.put(newIdMap.getName(), idmapOrdered); for (Iterator iter = orderedAL.iterator(); iter.hasNext(); ) { Mapping ordered = (Mapping) iter.next(); Mapping newOrdered = new Mapping(ordered.getElement(), ordered.getSignature()); newOrderedAL.add(newOrdered); idmapOrdered.add(newOrdered.getKey()); } } newIdMapsTableItem(newIdMap, true); selectionChanged(); } } } }
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()])); } }