protected TableItem newOrderedTableItem(Mapping mapping, boolean selected) { TableItem[] items = fOrderedTable.getItems(); int i = 0; while (i < items.length && mapping.getElement().compareToIgnoreCase(items[i].getText(0)) > 0) i++; TableItem item = new TableItem(fOrderedTable, SWT.NULL, i); String[] values = new String[] {mapping.getElement(), mapping.getSignature()}; item.setText(values); item.setData(mapping); if (selected) fOrderedTable.setSelection(i); return item; }
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 TableItem newMappingsTableItem(Mapping mapping, boolean selected) { TableItem[] items = fMappingsTable.getItems(); int i = 0; while (i < items.length && mapping.getElement().compareToIgnoreCase(items[i].getText(0)) > 0) i++; TableItem item = new TableItem(fMappingsTable, SWT.NULL, i); String idtext = mapping.getIdAttribute(); String idtype; if (idtext.charAt(0) == XMLStructureCreator.ID_TYPE_BODY) { idtext = idtext.substring(1, idtext.length()); idtype = IDTYPE_CHILDBODY; } else idtype = IDTYPE_ATTRIBUTE; String[] values = new String[] {mapping.getElement(), mapping.getSignature(), idtext, idtype}; item.setText(values); item.setData(mapping); if (selected) fMappingsTable.setSelection(i); return item; }