Changeset 4302 in josm


Ignore:
Timestamp:
Aug 8, 2011 12:39:06 AM (22 months ago)
Author:
stoecker
Message:

fix #6364 - patch by simon04 - can't remove tag with preset (hopefully don't break anything with this patch)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r3910 r4302  
    66 
    77import java.util.ArrayList; 
     8import java.util.Arrays; 
    89import java.util.Collection; 
    910import java.util.Collections; 
     
    4546        this.objects = new LinkedList<OsmPrimitive>(); 
    4647        this.key = key; 
    47         this.value = value; 
    48         if (value == null) { 
     48        this.value = (value == null || value.isEmpty()) ? null : value; 
     49        if (this.value == null) { 
    4950            for (OsmPrimitive osm : objects) { 
    5051                if(osm.get(key) != null) { 
     
    5556            for (OsmPrimitive osm : objects) { 
    5657                String val = osm.get(key); 
    57                 if (val == null || !value.equals(val)) { 
     58                if (val == null || !this.value.equals(val)) { 
    5859                    this.objects.add(osm); 
    5960                } 
     
    6364 
    6465    public ChangePropertyCommand(OsmPrimitive object, String key, String value) { 
    65         this.objects = new LinkedList<OsmPrimitive>(); 
    66         this.key = key; 
    67         this.value = value; 
    68         String val = object.get(key); 
    69         if ((value == null && val != null) 
    70                 || (value != null && (val == null || !value.equals(val)))) { 
    71             this.objects.add(object); 
    72         } 
     66        this(Arrays.asList(object), key, value); 
    7367    } 
    7468 
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r4221 r4302  
    14951495        List<Command> cmds = new ArrayList<Command>(); 
    14961496        for (Tag tag: changedTags) { 
    1497             if (!tag.getValue().isEmpty()) { 
    1498                 cmds.add(new ChangePropertyCommand(sel, tag.getKey(), tag.getValue())); 
    1499             } 
     1497            cmds.add(new ChangePropertyCommand(sel, tag.getKey(), tag.getValue())); 
    15001498        } 
    15011499 
Note: See TracChangeset for help on using the changeset viewer.