Changeset 702 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2008-07-11T20:49:51+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java
r700 r702 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.data.osm; 3 4 import java.util.ArrayList; 5 import java.util.Arrays; 6 import java.util.Locale; 7 8 public class OsmUtils { 9 10 static ArrayList<String> TRUE_VALUES = new ArrayList<String>(Arrays 11 .asList(new String[] { "true", "yes", "1", "on" })); 12 static ArrayList<String> FALSE_VALUES = new ArrayList<String>(Arrays 13 .asList(new String[] { "false", "no", "0", "off" })); 14 15 public static final String trueval = "yes"; 16 public static final String falseval = "no"; 17 18 public static Boolean getOsmBoolean(String value) { 19 if(value == null) return null; 20 String lowerValue = value.toLowerCase(Locale.ENGLISH); 21 if (TRUE_VALUES.contains(lowerValue)) return Boolean.TRUE; 22 if (FALSE_VALUES.contains(lowerValue)) return Boolean.FALSE; 23 return null; 24 } 25 public static String getNamedOsmBoolean(String value) { 26 Boolean res = getOsmBoolean(value); 27 return res == null ? value : (res ? trueval : falseval); 28 } 29 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r700 r702 39 39 import org.openstreetmap.josm.command.SequenceCommand; 40 40 import org.openstreetmap.josm.data.osm.OsmPrimitive; 41 import org.openstreetmap.josm.data.osm.OsmUtils; 41 42 import org.openstreetmap.josm.gui.QuadStateCheckBox; 42 43 import org.openstreetmap.josm.tools.GBC; … … 82 83 returnValue.values = new HashSet<String>(); 83 84 for (OsmPrimitive s : sel) { 84 String v = s.get(key); 85 if ("true".equalsIgnoreCase(v)) v = "true"; 86 else if ("yes".equalsIgnoreCase(v)) v = "true"; 87 else if ("1".equals(v)) v = "true"; 88 else if ("false".equalsIgnoreCase(v)) v = "false"; 89 else if ("no".equalsIgnoreCase(v)) v = "false"; 90 else if ("0".equals(v)) v = "false"; 91 returnValue.values.add(v); 85 returnValue.values.add(OsmUtils.getNamedOsmBoolean(s.get(key))); 92 86 } 93 87 return returnValue; … … 173 167 String oneValue = null; 174 168 for (String s : usage.values) oneValue = s; 175 if (usage.values.size() < 2 && (oneValue == null || "true".equals(oneValue) || "false".equals(oneValue))) {169 if (usage.values.size() < 2 && (oneValue == null || OsmUtils.trueval.equals(oneValue) || OsmUtils.falseval.equals(oneValue))) { 176 170 // all selected objects share the same value which is either true or false or unset, 177 171 // we can display a standard check box. 178 initialState = "true".equals(oneValue) ?172 initialState = OsmUtils.trueval.equals(oneValue) ? 179 173 QuadStateCheckBox.State.SELECTED : 180 "false".equals(oneValue) ?174 OsmUtils.falseval.equals(oneValue) ? 181 175 QuadStateCheckBox.State.NOT_SELECTED : 182 176 QuadStateCheckBox.State.UNSET; … … 207 201 // otherwise change things according to the selected value. 208 202 cmds.add(new ChangePropertyCommand(sel, key, 209 check.getState() == QuadStateCheckBox.State.SELECTED ? "true":210 check.getState() == QuadStateCheckBox.State.NOT_SELECTED ? "false":203 check.getState() == QuadStateCheckBox.State.SELECTED ? OsmUtils.trueval : 204 check.getState() == QuadStateCheckBox.State.NOT_SELECTED ? OsmUtils.falseval : 211 205 null)); 212 206 } … … 355 349 public void setDisplayName(String name) { 356 350 putValue(Action.NAME, tr(name)); 351 String tooltip = tr("Use presets ''{0}''", tr(name)); 352 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+"</html>"); 357 353 } 358 354
Note:
See TracChangeset
for help on using the changeset viewer.