コード例 #1
0
  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();
        }
      }
    }
  }
コード例 #2
0
 private void fillIdMaps(boolean internal) {
   HashMap IdMaps = (internal) ? fIdMapsInternal : fIdMaps;
   HashMap OrderedElements = (internal) ? fOrderedElementsInternal : fOrderedElements;
   Set IdMapKeys = IdMaps.keySet();
   for (Iterator iter_internal = IdMapKeys.iterator(); iter_internal.hasNext(); ) {
     String IdMapName = (String) iter_internal.next();
     Vector Mappings = new Vector();
     IdMap idmap = new IdMap(IdMapName, internal, Mappings);
     // create mappings of internal idmaps
     HashMap idmapHM = (HashMap) IdMaps.get(IdMapName);
     Set idmapKeys = idmapHM.keySet();
     for (Iterator iter_idmap = idmapKeys.iterator(); iter_idmap.hasNext(); ) {
       Mapping mapping = new Mapping();
       String signature = (String) iter_idmap.next();
       int end_of_signature = signature.lastIndexOf(SIGN_SEPARATOR, signature.length() - 2);
       if (end_of_signature < XMLStructureCreator.ROOT_ID.length() + 1)
         mapping.setSignature(""); // $NON-NLS-1$
       else
         mapping.setSignature(
             signature.substring(XMLStructureCreator.ROOT_ID.length() + 1, end_of_signature));
       mapping.setElement(signature.substring(end_of_signature + 1, signature.length() - 1));
       mapping.setIdAttribute((String) idmapHM.get(signature));
       Mappings.add(mapping);
     }
     // create ordered mappings
     ArrayList idmapOrdered = (ArrayList) OrderedElements.get(IdMapName);
     if (idmapOrdered != null) {
       setOrdered(idmap, idmapOrdered);
     }
     // set extension
     if (fIdExtensionToName.containsValue(IdMapName)) {
       Set keySet = fIdExtensionToName.keySet();
       String extension = new String();
       for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
         extension = (String) iter.next();
         if (((String) fIdExtensionToName.get(extension)).equals(IdMapName)) break;
       }
       idmap.setExtension(extension);
     }
     newIdMapsTableItem(idmap, false);
   }
 }
コード例 #3
0
 private void addMapping(Shell shell) {
   TableItem[] items = fIdMapsTable.getSelection();
   if (items.length > 0) {
     IdMap idmap = (IdMap) items[0].getData();
     Mapping mapping = new Mapping();
     HashMap idmapHM = (HashMap) fIdMaps.get(idmap.getName());
     XMLCompareEditMappingDialog dialog =
         new XMLCompareEditMappingDialog(shell, mapping, idmapHM, false);
     if (dialog.open() == Window.OK) {
       String idmapHMKey = mapping.getKey();
       if (idmapHM == null) idmapHM = new HashMap();
       if (!idmapHM.containsKey(idmapHMKey)) {
         idmapHM.put(idmapHMKey, mapping.getIdAttribute());
         newMappingsTableItem(mapping, true);
         Vector mappings = idmap.getMappings();
         mappings.add(mapping);
       }
     }
   }
 }
コード例 #4
0
 public void addFilter(ViewerFilter filter) {
   if (fFilters == null) fFilters = new Vector();
   fFilters.add(filter);
 }