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(); } } } }
protected void selectionChanged() { TableItem[] items = fIdMapsTable.getSelection(); if (items.length > 0) { // Refresh Mappings Table fMappingsTable.removeAll(); Vector Mappings = ((IdMap) items[0].getData()).getMappings(); for (Enumeration enumeration = Mappings.elements(); enumeration.hasMoreElements(); ) { newMappingsTableItem((Mapping) enumeration.nextElement(), false); } // Refresh Ordered Table fOrderedTable.removeAll(); ArrayList Ordered = ((IdMap) items[0].getData()).getOrdered(); if (Ordered != null) { for (Iterator iter_ordered = Ordered.iterator(); iter_ordered.hasNext(); ) { newOrderedTableItem((Mapping) iter_ordered.next(), false); } } } updateEnabledState(); }