Ticket #6364: remove_tag_with_preset.patch
File remove_tag_with_preset.patch, 2.5 KB (added by , 13 years ago) |
---|
-
src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
1494 1494 public static Command createCommand(Collection<OsmPrimitive> sel, List<Tag> changedTags) { 1495 1495 List<Command> cmds = new ArrayList<Command>(); 1496 1496 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())); 1500 1498 } 1501 1499 1502 1500 if (cmds.size() == 0) -
src/org/openstreetmap/josm/command/ChangePropertyCommand.java
5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 7 import java.util.ArrayList; 8 import java.util.Arrays; 8 9 import java.util.Collection; 9 10 import java.util.Collections; 10 11 import java.util.LinkedList; … … 44 45 super(); 45 46 this.objects = new LinkedList<OsmPrimitive>(); 46 47 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) { 49 50 for (OsmPrimitive osm : objects) { 50 51 if(osm.get(key) != null) { 51 52 this.objects.add(osm); … … 54 55 } else { 55 56 for (OsmPrimitive osm : objects) { 56 57 String val = osm.get(key); 57 if (val == null || ! value.equals(val)) {58 if (val == null || !this.value.equals(val)) { 58 59 this.objects.add(osm); 59 60 } 60 61 } … … 62 63 } 63 64 64 65 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); 73 67 } 74 68 75 69 @Override public boolean executeCommand() {