Changeset 16832 in josm
- Timestamp:
- 2020-08-03T19:46:04+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r16244 r16832 12 12 import java.util.Objects; 13 13 14 import javax.swing.JCheckBox; 15 import javax.swing.JPanel; 16 14 17 import ch.poole.openinghoursparser.OpeningHoursParser; 15 18 import ch.poole.openinghoursparser.ParseException; … … 18 21 import org.openstreetmap.josm.command.ChangePropertyCommand; 19 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 import org.openstreetmap.josm.data.preferences.BooleanProperty; 24 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; 20 25 import org.openstreetmap.josm.data.validation.Severity; 21 26 import org.openstreetmap.josm.data.validation.Test.TagTest; 22 27 import org.openstreetmap.josm.data.validation.TestError; 28 import org.openstreetmap.josm.tools.GBC; 23 29 24 30 /** … … 32 38 33 39 private static final Collection<String> KEYS_TO_CHECK = Arrays.asList("opening_hours", "collection_times", "service_times"); 40 private static final BooleanProperty PREF_STRICT_MODE = 41 new BooleanProperty(ValidatorPrefHelper.PREFIX + "." + OpeningHourTest.class.getSimpleName() + "." + "strict", false); 42 private final JCheckBox checkboxStrictMode = new JCheckBox(tr("Enable strict mode.")); 34 43 35 44 /** … … 90 99 String prettifiedValue = null; 91 100 try { 92 final List<Rule> rules = new OpeningHoursParser(new StringReader(value)).rules(false); 101 final boolean strict = PREF_STRICT_MODE.get(); 102 final List<Rule> rules = new OpeningHoursParser(new StringReader(value)).rules(strict); 93 103 prettifiedValue = Util.rulesToOpeningHoursString(rules); 94 if (!Objects.equals(value, prettifiedValue) ) {104 if (!Objects.equals(value, prettifiedValue) && !strict) { 95 105 // parse again in strict mode for detailed message 96 106 new OpeningHoursParser(new StringReader(value)).rules(true); … … 121 131 } 122 132 } 133 134 @Override 135 public void addGui(JPanel testPanel) { 136 super.addGui(testPanel); 137 checkboxStrictMode.setSelected(PREF_STRICT_MODE.get()); 138 testPanel.add(checkboxStrictMode, GBC.eol().insets(20, 0, 0, 0)); 139 } 140 141 @Override 142 public boolean ok() { 143 super.ok(); 144 PREF_STRICT_MODE.put(checkboxStrictMode.isSelected()); 145 return false; 146 } 123 147 }
Note:
See TracChangeset
for help on using the changeset viewer.