protected static void setOrdered(IdMap idmap, ArrayList idmapOrdered) { ArrayList Ordered = new ArrayList(); for (Iterator iter_ordered = idmapOrdered.iterator(); iter_ordered.hasNext(); ) { Mapping mapping = new Mapping(); String signature = (String) iter_ordered.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)); Ordered.add(mapping); } idmap.setOrdered(Ordered); }
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(); }
private ArrayList convertPkgList(ArrayList pkgList) { ArrayList conList = new ArrayList(); Iterator it = pkgList.iterator(); while (it.hasNext()) { CallData cd = (CallData) it.next(); TestNode tn = null; if (alreadyDone.containsKey(cd)) { tn = (TestNode) alreadyDone.get(cd); } else { tn = new TestNode(); tn.setData(cd.getData()); alreadyDone.put(cd, tn); if (cd.getChildren().size() != 0) { tn.setChildren(convertPkgList(cd.getChildren())); } if (cd.getOutputs().size() != 0) { tn.setOutputs(convertPkgList(cd.getOutputs())); } } conList.add(tn); } return conList; }