Changeset 4387 in josm for trunk/src/org


Ignore:
Timestamp:
2011-08-31T17:15:24+02:00 (13 years ago)
Author:
bastiK
Message:

fixed #6746 - paste properties in new layer results in nullpointer exception

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java

    r3995 r4387  
    109109        protected Map<OsmPrimitiveType, Integer> getSourceStatistics() {
    110110            HashMap<OsmPrimitiveType, Integer> ret = new HashMap<OsmPrimitiveType, Integer>();
    111             for (OsmPrimitiveType type: OsmPrimitiveType.values()) {
     111            for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    112112                if (!getSourceTagsByType(type).isEmpty()) {
    113113                    ret.put(type, getSourcePrimitivesByType(type).size());
     
    119119        protected Map<OsmPrimitiveType, Integer> getTargetStatistics() {
    120120            HashMap<OsmPrimitiveType, Integer> ret = new HashMap<OsmPrimitiveType, Integer>();
    121             for (OsmPrimitiveType type: OsmPrimitiveType.values()) {
     121            for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    122122                int count = OsmPrimitive.getFilteredList(target, type.getOsmClass()).size();
    123123                if (count > 0) {
     
    139139        protected void pasteFromHomogeneousSource() {
    140140            TagCollection tc = null;
    141             for (OsmPrimitiveType type : OsmPrimitiveType.values()) {
     141            for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
    142142                TagCollection tc1 = getSourceTagsByType(type);
    143143                if (!tc1.isEmpty()) {
     
    185185         */
    186186        protected boolean canPasteFromHeterogeneousSourceWithoutConflict(Collection<OsmPrimitive> targets) {
    187             for (OsmPrimitiveType type:OsmPrimitiveType.values()) {
     187            for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
    188188                if (hasTargetPrimitives(type.getOsmClass())) {
    189189                    TagCollection tc = TagCollection.unionOfAllPrimitives(getSourcePrimitivesByType(type));
     
    203203        protected void pasteFromHeterogeneousSource() {
    204204            if (canPasteFromHeterogeneousSourceWithoutConflict(target)) {
    205                 for (OsmPrimitiveType type:OsmPrimitiveType.values()) {
     205                for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
    206206                    if (hasSourceTagsByType(type) && hasTargetPrimitives(type.getOsmClass())) {
    207207                        buildChangeCommand(target, getSourceTagsByType(type));
     
    220220                if (dialog.isCanceled())
    221221                    return;
    222                 for (OsmPrimitiveType type:OsmPrimitiveType.values()) {
     222                for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
    223223                    if (hasSourceTagsByType(type) && hasTargetPrimitives(type.getOsmClass())) {
    224224                        buildChangeCommand(OsmPrimitive.getFilteredList(target, type.getOsmClass()), dialog.getResolution(type));
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java

    r4172 r4387  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
    34import static org.openstreetmap.josm.tools.I18n.marktr;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
    67import java.text.MessageFormat;
     8import java.util.Arrays;
     9import java.util.Collection;
    710
    811public enum OsmPrimitiveType {
     
    1518    CLOSEDWAY  (marktr(/* ICON(data/) */"closedway"), null, WayData.class),
    1619    MULTIPOLYGON (marktr(/* ICON(data/) */"multipolygon"), null, RelationData.class);
     20
     21    private final static Collection<OsmPrimitiveType> DATA_VALUES = Arrays.asList(NODE, WAY, RELATION);
    1722
    1823    private final String apiTypeName;
     
    6166    }
    6267
     68    public static Collection<OsmPrimitiveType> dataValues() {
     69        return DATA_VALUES;
     70    }
     71
    6372    public OsmPrimitive newInstance(long uniqueId, boolean allowNegative) {
    6473        switch (this) {
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java

    r4191 r4387  
    7878        allPrimitivesResolver = new TagConflictResolver();
    7979        resolvers = new HashMap<OsmPrimitiveType, TagConflictResolver>();
    80         for (OsmPrimitiveType type: OsmPrimitiveType.values()) {
     80        for (OsmPrimitiveType type: OsmPrimitiveType.dataValues()) {
    8181            resolvers.put(type, new TagConflictResolver());
    8282            resolvers.get(type).getModel().addPropertyChangeListener(this);
Note: See TracChangeset for help on using the changeset viewer.