Changeset 6636 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-01-05T19:32:00+01:00 (11 years ago)
Author:
simon04
Message:

see #9414 - MapCSS validator: skip tests with informational severity if that isn't enabled

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java

    r6529 r6636  
    6060            test.visit(selection);
    6161            test.endTest();
    62             if (Main.pref.getBoolean(ValidatorPreference.PREF_OTHER, false) &&
     62            if (ValidatorPreference.PREF_OTHER.get() &&
    6363                Main.pref.getBoolean(ValidatorPreference.PREF_OTHER_UPLOAD, false)) {
    6464                errors.addAll(test.getErrors());
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r6612 r6636  
    4040import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser;
    4141import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
     42import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
    4243import org.openstreetmap.josm.gui.widgets.EditableList;
    4344import org.openstreetmap.josm.io.MirroredInputStream;
     
    284285         */
    285286        String getMessage() {
    286             return errors.keySet().iterator().next();
     287            return errors.isEmpty() ? null : errors.keySet().iterator().next();
    287288        }
    288289
     
    313314
    314315        Severity getSeverity() {
    315             return errors.values().iterator().next();
     316            return errors.isEmpty() ? null : errors.values().iterator().next();
    316317        }
    317318
     
    364365     * Obtains all {@link TestError}s for the {@link OsmPrimitive} {@code p}.
    365366     */
    366     public Collection<TestError> getErrorsForPrimitive(OsmPrimitive p) {
     367    public Collection<TestError> getErrorsForPrimitive(OsmPrimitive p, boolean includeOtherSeverity) {
    367368        final ArrayList<TestError> r = new ArrayList<TestError>();
    368369        final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    369370        for (TagCheck check : checks) {
     371            if (Severity.OTHER.equals(check.getSeverity()) && !includeOtherSeverity) {
     372                continue;
     373            }
    370374            final Selector selector = check.whichSelectorMatchesEnvironment(env);
    371375            if (selector != null) {
     
    388392    @Override
    389393    public void check(OsmPrimitive p) {
    390         errors.addAll(getErrorsForPrimitive(p));
     394        errors.addAll(getErrorsForPrimitive(p, ValidatorPreference.PREF_OTHER.get()));
    391395    }
    392396
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r6529 r6636  
    161161        }
    162162
    163         boolean other = Main.pref.getBoolean(ValidatorPreference.PREF_OTHER, false);
     163        final Boolean other = ValidatorPreference.PREF_OTHER.get();
    164164        for (TestError e : errors) {
    165165            if (e.getIgnored()) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreference.java

    r6593 r6636  
    1616
    1717import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1819import org.openstreetmap.josm.data.validation.OsmValidator;
    1920import org.openstreetmap.josm.data.validation.Test;
     
    6465    public static final String PREF_OTHER_UPLOAD = PREFIX + ".otherUpload";
    6566
    66     /** The preferences key for ignored severity other */
    67     public static final String PREF_OTHER = PREFIX + ".other";
     67    /** The preferences for ignored severity other */
     68    public static final BooleanProperty PREF_OTHER = new BooleanProperty(PREFIX + ".other", false);
    6869
    6970    /**
     
    9596        testPanel.add(prefUseLayer, GBC.eol());
    9697
    97         prefOther = new JCheckBox(tr("Show informational level."), Main.pref.getBoolean(PREF_OTHER, false));
     98        prefOther = new JCheckBox(tr("Show informational level."), PREF_OTHER.get());
    9899        prefOther.setToolTipText(tr("Show the informational tests."));
    99100        testPanel.add(prefOther, GBC.eol());
     
    143144        Main.pref.putCollection(PREF_SKIP_TESTS_BEFORE_UPLOAD, testsBeforeUpload);
    144145        Main.pref.put(PREF_USE_IGNORE, prefUseIgnore.isSelected());
    145         Main.pref.put(PREF_OTHER, prefOther.isSelected());
     146        PREF_OTHER.put(prefOther.isSelected());
    146147        Main.pref.put(PREF_OTHER_UPLOAD, prefOtherUpload.isSelected());
    147148        Main.pref.put(PREF_LAYER, prefUseLayer.isSelected());
Note: See TracChangeset for help on using the changeset viewer.