- Timestamp:
- 2024-11-25T23:08:52+01:00 (2 weeks ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java
r18801 r19261 14 14 import java.util.Collections; 15 15 import java.util.List; 16 import java.util.regex.Pattern; 16 17 17 18 import javax.swing.AbstractButton; … … 48 49 */ 49 50 public class Text extends KeyedItem { 51 private static final Pattern MULTILINE_WHITESPACE_PATTERN = Pattern.compile("[\\s&&[^\n]]+"); 50 52 51 53 private static int auto_increment_selected; // NOSONAR … … 241 243 } 242 244 243 v = Utils.removeWhiteSpaces(v); 245 if (this.normalize) { 246 if (this.multiline) { 247 v = Utils.removeWhiteSpaces(MULTILINE_WHITESPACE_PATTERN, v); 248 } else { 249 v = Utils.removeWhiteSpaces(v); 250 } 251 } 244 252 245 253 if (!"false".equals(use_last_as_default) || auto_increment != null) { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/TextItem.java
r17608 r19261 23 23 /** The context used for translating {@link #text} */ 24 24 public String text_context; // NOSONAR 25 26 /** {@code true} if the value is a multiline value */ 27 public boolean multiline; // NOSONAR 28 /** {@code true} if the value should be normalized */ 29 public boolean normalize = true; // NOSONAR 25 30 26 31 /** The localized version of {@link #text} */ -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r19133 r19261 821 821 */ 822 822 public static String removeWhiteSpaces(String s) { 823 return removeWhiteSpaces(WHITE_SPACES_PATTERN, s); 824 } 825 826 /** 827 * Removes leading, trailing, and multiple inner whitespaces from the given string, to be used as a key or value. 828 * @param s The string 829 * @param whitespaces The regex for whitespaces to remove outside the leading and trailing whitespaces (see {@link #strip(String)}) 830 * @return The string without leading, trailing or multiple inner whitespaces 831 * @since 19261 832 */ 833 public static String removeWhiteSpaces(Pattern whitespaces, String s) { 823 834 if (isEmpty(s)) { 824 835 return s; 825 836 } 826 return strip(s).replaceAll("\\s+"," ");837 return whitespaces.matcher(strip(s)).replaceAll(" "); 827 838 } 828 839
Note:
See TracChangeset
for help on using the changeset viewer.