- Timestamp:
- 2014-01-01T23:07:33+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r6580 r6593 1490 1490 @Override 1491 1491 public void visit(ListSetting setting) { 1492 /* don't save default values */ 1493 if (setting.equals(defaultsMap.get(key))) 1494 return; 1492 1495 b.append(" <list key='").append(XmlWriter.encode(key)).append("'>\n"); 1493 1496 for (String s : setting.getValue()) { … … 1499 1502 @Override 1500 1503 public void visit(ListListSetting setting) { 1504 /* don't save default values */ 1505 if (setting.equals(defaultsMap.get(key))) 1506 return; 1501 1507 b.append(" <lists key='").append(XmlWriter.encode(key)).append("'>\n"); 1502 1508 for (List<String> list : setting.getValue()) { … … 1558 1564 "gpxLayer.downloadAlongTrack.area", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.area 1559 1565 "gpxLayer.downloadAlongTrack.near", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.near 1566 "validator.tests", // 01/2014 - can be removed mid-2014. Replaced by validator.skip 1567 "validator.testsBeforeUpload", // 01/2014 - can be removed mid-2014. Replaced by validator.skipBeforeUpload 1568 "validator.TagChecker.sources", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source 1569 "validator.TagChecker.usedatafile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source 1570 "validator.TagChecker.useignorefile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source 1571 "validator.TagChecker.usespellfile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source 1560 1572 }; 1561 1573 for (String key : obsolete) { -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r6592 r6593 85 85 @SuppressWarnings("unchecked") 86 86 private static final Class<Test>[] allAvailableTests = new Class[] { 87 /* FIXME - unique error numbers for tests aren't properly unique - ignoring will not work as expected */ 87 88 DuplicateNode.class, // ID 1 .. 99 88 89 OverlappingWays.class, // ID 101 .. 199 … … 231 232 232 233 private static void applyPrefs(Map<String, Test> tests, boolean beforeUpload) { 233 Pattern regexp = Pattern.compile("(\\w+)=(true|false),?"); 234 Matcher m = regexp.matcher(Main.pref.get(beforeUpload ? ValidatorPreference.PREF_TESTS_BEFORE_UPLOAD 235 : ValidatorPreference.PREF_TESTS)); 236 int pos = 0; 237 while (m.find(pos)) { 238 String testName = m.group(1); 234 for(String testName : Main.pref.getCollection(beforeUpload 235 ? ValidatorPreference.PREF_SKIP_TESTS_BEFORE_UPLOAD : ValidatorPreference.PREF_SKIP_TESTS)) { 239 236 Test test = tests.get(testName); 240 237 if (test != null) { 241 boolean enabled = Boolean.valueOf(m.group(2));242 238 if (beforeUpload) { 243 test.testBeforeUpload = enabled;239 test.testBeforeUpload = false; 244 240 } else { 245 test.enabled = enabled;241 test.enabled = false; 246 242 } 247 243 } 248 pos = m.end();249 244 } 250 245 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r6591 r6593 94 94 public static final String PREF_CHECK_FIXMES = PREFIX + ".checkFixmes"; 95 95 96 public static final String PREF_SOURCES = PREFIX + ".sources"; 97 public static final String PREF_USE_DATA_FILE = PREFIX + ".usedatafile"; 98 public static final String PREF_USE_IGNORE_FILE = PREFIX + ".useignorefile"; 99 public static final String PREF_USE_SPELL_FILE = PREFIX + ".usespellfile"; 96 public static final String PREF_SOURCES = PREFIX + ".source"; 100 97 101 98 public static final String PREF_CHECK_KEYS_BEFORE_UPLOAD = PREF_CHECK_KEYS + "BeforeUpload"; … … 120 117 protected JCheckBox prefCheckFixmesBeforeUpload; 121 118 protected JCheckBox prefCheckPaintBeforeUpload; 122 123 protected JCheckBox prefUseDataFile;124 protected JCheckBox prefUseIgnoreFile;125 protected JCheckBox prefUseSpellFile;126 119 127 120 protected static final int EMPTY_VALUES = 1200; … … 172 165 173 166 spellCheckKeyData = new HashMap<String, String>(); 174 String sources = Main.pref.get( PREF_SOURCES, ""); 175 if (Main.pref.getBoolean(PREF_USE_DATA_FILE, true)) { 176 if (sources == null || sources.length() == 0) { 177 sources = DATA_FILE; 178 } else { 179 sources = DATA_FILE + ";" + sources; 180 } 181 } 182 if (Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true)) { 183 if (sources == null || sources.length() == 0) { 184 sources = IGNORE_FILE; 185 } else { 186 sources = IGNORE_FILE + ";" + sources; 187 } 188 } 189 if (Main.pref.getBoolean(PREF_USE_SPELL_FILE, true)) { 190 if( sources == null || sources.length() == 0) { 191 sources = SPELL_FILE; 192 } else { 193 sources = SPELL_FILE + ";" + sources; 194 } 195 } 196 167 197 168 String errorSources = ""; 198 if (sources.length() == 0) 199 return; 200 for (String source : sources.split(";")) { 169 for (String source : Main.pref.getCollection(PREF_SOURCES, Arrays.asList(DATA_FILE, IGNORE_FILE, SPELL_FILE))) { 201 170 BufferedReader reader = null; 202 171 try { … … 511 480 testPanel.add(prefCheckComplexBeforeUpload, a); 512 481 513 final String sources = Main.pref.get(PREF_SOURCES);482 final Collection<String> sources = Main.pref.getCollection(PREF_SOURCES, Arrays.asList(DATA_FILE, IGNORE_FILE, SPELL_FILE)); 514 483 sourcesList = new EditableList(tr("TagChecker source")); 515 sourcesList.setItems(sources != null ? Arrays.asList(sources.split(";")) : Collections.<String>emptyList());484 sourcesList.setItems(sources); 516 485 testPanel.add(new JLabel(tr("Data sources ({0})", "*.cfg")), GBC.eol().insets(23, 0, 0, 0)); 517 486 testPanel.add(sourcesList, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(23, 0, 0, 0)); … … 545 514 prefCheckFixmesBeforeUpload.setSelected(Main.pref.getBoolean(PREF_CHECK_FIXMES_BEFORE_UPLOAD, true)); 546 515 testPanel.add(prefCheckFixmesBeforeUpload, a); 547 548 prefUseDataFile = new JCheckBox(tr("Use default data file."), Main.pref.getBoolean(PREF_USE_DATA_FILE, true));549 prefUseDataFile.setToolTipText(tr("Use the default data file (recommended)."));550 testPanel.add(prefUseDataFile, GBC.eol().insets(20,0,0,0));551 552 prefUseIgnoreFile = new JCheckBox(tr("Use default tag ignore file."), Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true));553 prefUseIgnoreFile.setToolTipText(tr("Use the default tag ignore file (recommended)."));554 testPanel.add(prefUseIgnoreFile, GBC.eol().insets(20,0,0,0));555 556 prefUseSpellFile = new JCheckBox(tr("Use default spellcheck file."), Main.pref.getBoolean(PREF_USE_SPELL_FILE, true));557 prefUseSpellFile.setToolTipText(tr("Use the default spellcheck file (recommended)."));558 testPanel.add(prefUseSpellFile, GBC.eol().insets(20,0,0,0));559 516 } 560 517 … … 579 536 Main.pref.put(PREF_CHECK_KEYS_BEFORE_UPLOAD, prefCheckKeysBeforeUpload.isSelected()); 580 537 Main.pref.put(PREF_CHECK_FIXMES_BEFORE_UPLOAD, prefCheckFixmesBeforeUpload.isSelected()); 581 Main.pref.put(PREF_USE_DATA_FILE, prefUseDataFile.isSelected()); 582 Main.pref.put(PREF_USE_IGNORE_FILE, prefUseIgnoreFile.isSelected()); 583 Main.pref.put(PREF_USE_SPELL_FILE, prefUseSpellFile.isSelected()); 584 final List<String> sources = sourcesList.getItems(); 585 return Main.pref.put(PREF_SOURCES, sources.isEmpty() ? null : Utils.join(";", sources)); 538 return Main.pref.putCollection(PREF_SOURCES, sourcesList.getItems()); 586 539 } 587 540 588 541 @Override 589 542 public Command fixError(TestError testError) { 590 591 543 List<Command> commands = new ArrayList<Command>(50); 592 544 … … 631 583 @Override 632 584 public boolean isFixable(TestError testError) { 633 634 585 if (testError.getTester() instanceof TagChecker) { 635 586 int code = testError.getCode(); -
trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreference.java
r6529 r6593 8 8 import java.awt.event.ActionListener; 9 9 import java.util.Collection; 10 import java.util.LinkedList; 10 11 11 12 import javax.swing.BorderFactory; … … 52 53 53 54 /** The preferences key for enabled tests */ 54 public static final String PREF_ TESTS = PREFIX + ".tests";55 public static final String PREF_SKIP_TESTS = PREFIX + ".skip"; 55 56 56 57 /** The preferences key for enabled tests */ … … 58 59 59 60 /** The preferences key for enabled tests before upload*/ 60 public static final String PREF_ TESTS_BEFORE_UPLOAD = PREFIX + ".testsBeforeUpload";61 public static final String PREF_SKIP_TESTS_BEFORE_UPLOAD = PREFIX + ".skipBeforeUpload"; 61 62 62 63 /** The preferences key for ignored severity other on upload */ … … 126 127 @Override 127 128 public boolean ok() { 128 StringBuilder tests = new StringBuilder();129 StringBuilder testsBeforeUpload = new StringBuilder();129 Collection<String> tests = new LinkedList<String>(); 130 Collection<String> testsBeforeUpload = new LinkedList<String>(); 130 131 131 132 for (Test test : allTests) { 132 133 test.ok(); 133 134 String name = test.getClass().getSimpleName(); 134 tests.append(',').append(name).append('=').append(test.enabled); 135 testsBeforeUpload.append(',').append(name).append('=').append(test.testBeforeUpload); 135 if(!test.enabled) 136 tests.add(name); 137 if(!test.testBeforeUpload) 138 testsBeforeUpload.add(name); 136 139 } 137 138 if (tests.length() > 0) {139 tests = tests.deleteCharAt(0);140 }141 if (testsBeforeUpload.length() > 0) {142 testsBeforeUpload = testsBeforeUpload.deleteCharAt(0);143 }144 145 140 OsmValidator.initializeTests(allTests); 146 141 147 Main.pref.put (PREF_TESTS, tests.toString());148 Main.pref.put (PREF_TESTS_BEFORE_UPLOAD, testsBeforeUpload.toString());142 Main.pref.putCollection(PREF_SKIP_TESTS, tests); 143 Main.pref.putCollection(PREF_SKIP_TESTS_BEFORE_UPLOAD, testsBeforeUpload); 149 144 Main.pref.put(PREF_USE_IGNORE, prefUseIgnore.isSelected()); 150 145 Main.pref.put(PREF_OTHER, prefOther.isSelected());
Note:
See TracChangeset
for help on using the changeset viewer.