- Timestamp:
- 2010-03-15T14:18:45+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
r3083 r3137 11 11 import java.util.Iterator; 12 12 import java.util.List; 13 import java.util.Map; 13 14 import java.util.Set; 14 15 import java.util.Map.Entry; … … 54 55 55 56 /** 57 * Creates a tag collection from a map of key/value-pairs. Replies 58 * an empty tag collection if {@code tags} is null. 59 * 60 * @param tags the key/value-pairs 61 * @return the tag collection 62 */ 63 public static TagCollection from(Map<String,String> tags) { 64 TagCollection ret = new TagCollection(); 65 if (tags == null) return ret; 66 for (Entry<String,String> entry: tags.entrySet()) { 67 String key = entry.getKey() == null? "" : entry.getKey(); 68 String value = entry.getValue() == null ? "" : entry.getValue(); 69 ret.add(new Tag(key,value)); 70 } 71 return ret; 72 } 73 74 /** 56 75 * Creates a tag collection from the union of the tags managed by 57 76 * a collection of primitives. Replies an empty tag collection, -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r3083 r3137 22 22 import org.openstreetmap.josm.command.SequenceCommand; 23 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 import org.openstreetmap.josm.data.osm.TagCollection; 24 25 import org.openstreetmap.josm.data.osm.Tagged; 25 26 … … 331 332 332 333 /** 334 * Initializes the model with the tags in a tag collection. Removes 335 * all tags if {@code tags} is null. 336 * 337 * @param tags the tags 338 */ 339 public void initFromTags(TagCollection tags) { 340 clear(); 341 if (tags == null){ 342 setDirty(false); 343 return; 344 } 345 for (String key : tags.getKeys()) { 346 String value = tags.getJoinedValues(key); 347 add(key,value); 348 } 349 sort(); 350 // add an empty row 351 TagModel tag = new TagModel(); 352 this.tags.add(tag); 353 setDirty(false); 354 } 355 356 /** 333 357 * applies the current state of the tag editor model to a primitive 334 358 * … … 370 394 applyToTags(tags); 371 395 return tags; 396 } 397 398 /** 399 * Replies the the tags in this tag editor model as {@see TagCollection}. 400 * 401 * @return the the tags in this tag editor model as {@see TagCollection} 402 */ 403 public TagCollection getTagCollection() { 404 return TagCollection.from(getTags()); 372 405 } 373 406
Note:
See TracChangeset
for help on using the changeset viewer.