Changeset 17643 in josm


Ignore:
Timestamp:
2021-03-23T00:47:37+01:00 (3 years ago)
Author:
simon04
Message:

see #19078 - Presets: validate user input (using MapCSSTagChecker, OpeningHourTest)

This feature is disabled by default and can be activated by setting the advanced preference taggingpreset.validator to true.

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r17591 r17643  
    125125    @Override
    126126    public void check(final OsmPrimitive p) {
     127        addErrorsForPrimitive(p, this.errors);
     128    }
     129
     130    /**
     131     * Checks the tags of the given primitive and adds validation errors to the given list.
     132     * @param p The primitive to test
     133     * @param errors The list to add validation errors to
     134     * @since 17643
     135     */
     136    public void addErrorsForPrimitive(OsmPrimitive p, Collection<TestError> errors) {
    127137        if (p.isTagged()) {
    128138            for (String key : KEYS_TO_CHECK) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r17610 r17643  
    317317            pp.add(label);
    318318        }
     319        JLabel validationLabel = new JLabel(ImageProvider.get("warning-small", ImageProvider.ImageSizes.LARGEICON));
     320        validationLabel.setVisible(false);
     321        pp.add(validationLabel);
     322
    319323        final int count = pp.getComponentCount();
    320324        if (preset_name_label) {
     
    353357        if (selected.isEmpty() && !supportsRelation()) {
    354358            GuiHelper.setEnabledRec(items, false);
     359        }
     360
     361        if (selected.size() == 1 && Config.getPref().getBoolean("taggingpreset.validator", false)) {
     362            itemGuiSupport.addListener((source, key, newValue) ->
     363                    TaggingPresetValidation.validateAsync(selected.iterator().next(), validationLabel, getChangedTags()));
    355364        }
    356365
Note: See TracChangeset for help on using the changeset viewer.