Ignore:
Timestamp:
2010-03-15T14:18:45+01:00 (14 years ago)
Author:
Gubaer
Message:

added a few utility methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java

    r3083 r3137  
    2222import org.openstreetmap.josm.command.SequenceCommand;
    2323import org.openstreetmap.josm.data.osm.OsmPrimitive;
     24import org.openstreetmap.josm.data.osm.TagCollection;
    2425import org.openstreetmap.josm.data.osm.Tagged;
    2526
     
    331332
    332333    /**
     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    /**
    333357     * applies the current state of the tag editor model to a primitive
    334358     *
     
    370394        applyToTags(tags);
    371395        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());
    372405    }
    373406
Note: See TracChangeset for help on using the changeset viewer.