コード例 #1
0
  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();
  }
コード例 #2
0
 private void addOrdered(Shell shell) {
   TableItem[] items = fIdMapsTable.getSelection();
   if (items.length > 0) {
     //			Set orderedSet= fOrderedElements.keySet();
     //			for (Iterator iter= orderedSet.iterator(); iter.hasNext(); ) {
     //				String IdMapName= (String) iter.next();
     //				ArrayList ordered= (ArrayList) fOrderedElements.get(IdMapName);
     //				for (Iterator iter2= ordered.iterator(); iter2.hasNext(); ) {
     //					System.out.println(IdMapName + ": " + iter2.next()); //$NON-NLS-1$
     //				}
     //			}
     IdMap idmap = (IdMap) items[0].getData();
     Mapping mapping = new Mapping();
     ArrayList idmapAL = (ArrayList) fOrderedElements.get(idmap.getName());
     if (idmapAL == null) idmapAL = new ArrayList();
     XMLCompareEditOrderedDialog dialog =
         new XMLCompareEditOrderedDialog(shell, mapping, idmapAL, false);
     if (dialog.open() == Window.OK) {
       String idmapALKey = mapping.getKey();
       if (!idmapAL.contains(idmapALKey)) {
         idmapAL.add(idmapALKey);
         newOrderedTableItem(mapping, true);
         ArrayList ordered = idmap.getOrdered();
         if (ordered == null) {
           ordered = new ArrayList();
           ordered.add(mapping);
           idmap.setOrdered(ordered);
         } else {
           ordered.add(mapping);
         }
         if (!fOrderedElements.containsKey(idmap.getName()))
           fOrderedElements.put(idmap.getName(), idmapAL);
       }
     }
   }
 }