Changeset 6699 in josm
- Timestamp:
- 2014-01-16T02:42:49+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java
r6084 r6699 19 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 20 import org.openstreetmap.josm.data.osm.Relation; 21 import org.openstreetmap.josm.data.osm.Tag; 21 22 22 23 /** … … 76 77 Map<String, String> newKeys = new HashMap<String, String>(keys); 77 78 for (Entry<String, String> e : keys.entrySet()) { 78 String v = e.getValue() .trim();79 String k = e.getKey() .trim();79 String v = Tag.removeWhiteSpaces(e.getValue()); 80 String k = Tag.removeWhiteSpaces(e.getKey()); 80 81 if(!e.getKey().equals(k)) { 81 82 boolean drop = k.isEmpty() || v.isEmpty(); -
trunk/src/org/openstreetmap/josm/data/osm/Tag.java
r6513 r6699 3 3 4 4 import org.openstreetmap.josm.tools.CheckParameterUtil; 5 import org.openstreetmap.josm.tools.Utils; 5 6 6 7 /** … … 17 18 * Create an empty tag whose key and value are empty. 18 19 */ 19 public Tag(){ 20 public Tag() { 20 21 this("", ""); 21 22 } … … 119 120 return key + "=" + value; 120 121 } 122 123 /** 124 * Removes leading, trailing, and multiple inner whitespaces from the given string, to be used as a key or value. 125 * @param s The string 126 * @return The string without leading, trailing or multiple inner whitespaces 127 * @since 6699 128 */ 129 public static String removeWhiteSpaces(String s) { 130 if (s == null || s.isEmpty()) { 131 return s; 132 } 133 return Utils.strip(s).replaceAll("\\s+", " "); 134 } 121 135 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r6681 r6699 142 142 CheckParameterUtil.ensureThat(val.contains("=>"), "Separate old from new key by '=>'!"); 143 143 final String[] x = val.split("=>", 2); 144 check.keyChange.put( x[0].trim(), x[1].trim());144 check.keyChange.put(Tag.removeWhiteSpaces(x[0]), Tag.removeWhiteSpaces(x[1])); 145 145 } else if ("suggestAlternative".equals(ai.key) && val != null) { 146 146 check.alternatives.add(val); -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r6650 r6699 36 36 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 37 37 import org.openstreetmap.josm.data.osm.OsmUtils; 38 import org.openstreetmap.josm.data.osm.Tag; 38 39 import org.openstreetmap.josm.data.validation.Severity; 39 40 import org.openstreetmap.josm.data.validation.Test; … … 563 564 commands.add(new ChangePropertyCommand(p, key, null)); 564 565 } else if (value.startsWith(" ") || value.endsWith(" ")) { 565 commands.add(new ChangePropertyCommand(p, key, value.trim()));566 commands.add(new ChangePropertyCommand(p, key, Tag.removeWhiteSpaces(value))); 566 567 } else if (key.startsWith(" ") || key.endsWith(" ")) { 567 commands.add(new ChangePropertyKeyCommand(p, key, key.trim()));568 commands.add(new ChangePropertyKeyCommand(p, key, Tag.removeWhiteSpaces(key))); 568 569 } else { 569 570 String evalue = entities.unescape(value); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java
r6616 r6699 32 32 import org.openstreetmap.josm.command.Command; 33 33 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 import org.openstreetmap.josm.data.osm.Tag; 34 35 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 35 36 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; … … 189 190 if (primitives == null || primitives.isEmpty()) 190 191 return null; 191 return new ChangePropertyCommand(primitives, tfKey.getText() ,tfValue.getText());192 return new ChangePropertyCommand(primitives, Tag.removeWhiteSpaces(tfKey.getText()), Tag.removeWhiteSpaces(tfValue.getText())); 192 193 } 193 194 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r6546 r6699 331 331 */ 332 332 private void performTagEdit() { 333 String value = values.getEditor().getItem().toString() .trim();333 String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString()); 334 334 // is not Java 1.5 335 335 //value = java.text.Normalizer.normalize(value, java.text.Normalizer.Form.NFC); … … 337 337 value = null; // delete the key 338 338 } 339 String newkey = keys.getEditor().getItem().toString() .trim();339 String newkey = Tag.removeWhiteSpaces(keys.getEditor().getItem().toString()); 340 340 //newkey = java.text.Normalizer.normalize(newkey, java.text.Normalizer.Form.NFC); 341 341 if (newkey.isEmpty()) { … … 732 732 */ 733 733 public void performTagAdding() { 734 String key = keys.getEditor().getItem().toString() .trim();735 String value = values.getEditor().getItem().toString() .trim();734 String key = Tag.removeWhiteSpaces(keys.getEditor().getItem().toString()); 735 String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString()); 736 736 if (key.isEmpty() || value.isEmpty()) return; 737 737 lastAddKey = key; … … 743 743 } 744 744 745 746 745 public void undoAllTagsAdding() { 747 746 Main.main.undoRedo.undo(commandCount); 748 747 } 749 750 748 751 749 private void disableTagIfNeeded(final Tag t, final JosmAction action) { -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r6572 r6699 714 714 } 715 715 716 v = v.trim();716 v = Tag.removeWhiteSpaces(v); 717 717 718 718 if (!"false".equals(use_last_as_default) || auto_increment != null) { … … 1076 1076 value = ""; 1077 1077 } 1078 value = value.trim();1078 value = Tag.removeWhiteSpaces(value); 1079 1079 1080 1080 // no change if same as before
Note:
See TracChangeset
for help on using the changeset viewer.