public void setFiles(String[] fileNames) { int size = Arrays.asList(fileNames).size(); Vector iFileNames = new Vector(); for (int i = 0; i < size; i++) { IResource resource = workspaceRoot.findMember(fileNames[i]); if (resource instanceof IFile) iFileNames.addElement(resource); } IFile[] dummyArray = new IFile[iFileNames.size()]; this.fileNames = (IFile[]) (iFileNames.toArray(dummyArray)); }
private void removeMapping(Shell shell) { TableItem[] itemsIdMaps = fIdMapsTable.getSelection(); TableItem[] itemsMappings = fMappingsTable.getSelection(); if (itemsMappings.length > 0 && itemsIdMaps.length > 0) { Mapping mapping = (Mapping) itemsMappings[0].getData(); IdMap idmap = (IdMap) itemsIdMaps[0].getData(); HashMap idmapHS = (HashMap) fIdMaps.get(idmap.getName()); idmapHS.remove(mapping.getKey()); Vector mappings = idmap.getMappings(); mappings.remove(mapping); itemsMappings[0].dispose(); // Table is single selection } }
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(); } } } }
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); } }
public void setVisible(boolean visible) { if (visible == true) { if (fFilters != null) { sourceFileViewer.resetFilters(); for (Iterator i = fFilters.iterator(); i.hasNext(); ) sourceFileViewer.addFilter((ViewerFilter) i.next()); } sourceFileViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); } super.setVisible(visible); }
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 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); } } } }
public void addFilter(ViewerFilter filter) { if (fFilters == null) fFilters = new Vector(); fFilters.add(filter); }