Changeset 6329 in josm for trunk


Ignore:
Timestamp:
2013-10-27T02:53:37+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #9217 - tagchecker: allow auto-fix for single test/alternative

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyKeyCommand.java

    r6009 r6329  
    1717
    1818/**
    19  * Command that replaces the key of several objects
     19 * Command that replaces the key of one or several objects
    2020 *
    2121 */
     
    3535
    3636    /**
    37      * Constructor
     37     * Constructs a new {@code ChangePropertyKeyCommand}.
     38     *
     39     * @param object the object subject to change replacement
     40     * @param key The key to replace
     41     * @param newKey the new value of the key
     42     * @since 6329
     43     */
     44    public ChangePropertyKeyCommand(OsmPrimitive object, String key, String newKey) {
     45        this(Collections.singleton(object), key, newKey);
     46    }
     47   
     48    /**
     49     * Constructs a new {@code ChangePropertyKeyCommand}.
    3850     *
    3951     * @param objects all objects subject to change replacement
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DeprecatedTags.java

    r6296 r6329  
    99
    1010import org.openstreetmap.josm.command.ChangePropertyCommand;
     11import org.openstreetmap.josm.command.ChangePropertyKeyCommand;
    1112import org.openstreetmap.josm.command.Command;
    1213import org.openstreetmap.josm.command.SequenceCommand;
     
    213214                cmds.add(new ChangePropertyCommand(p, tag.getKey(), tag.getValue()));
    214215            }
     216            if (test.size() == 1 && alternatives.size() == 1) {
     217                cmds.add(new ChangePropertyKeyCommand(p, test.get(0).getKey(), alternatives.get(0).getKey()));
     218            }
    215219            return new SequenceCommand(tr("Deprecation fix of {0}", Utils.join(", ", test)), cmds);
    216220        }
     
    237241        @Override
    238242        public boolean isFixable() {
    239             return !check.change.isEmpty();
     243            return !check.change.isEmpty() || (check.test.size() == 1 && check.alternatives.size() == 1);
    240244        }
    241245
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r6326 r6329  
    1919import java.util.Arrays;
    2020import java.util.Collection;
    21 import java.util.Collections;
    2221import java.util.HashMap;
    2322import java.util.List;
     
    671670
    672671    @Override
    673     public boolean ok()
    674     {
     672    public boolean ok() {
    675673        enabled = prefCheckKeys.isSelected() || prefCheckValues.isSelected() || prefCheckComplex.isSelected() || prefCheckFixmes.isSelected();
    676674        testBeforeUpload = prefCheckKeysBeforeUpload.isSelected() || prefCheckValuesBeforeUpload.isSelected()
     
    716714                String value = prop.getValue();
    717715                if (value == null || value.trim().length() == 0) {
    718                     commands.add(new ChangePropertyCommand(Collections.singleton(p), key, null));
     716                    commands.add(new ChangePropertyCommand(p, key, null));
    719717                } else if (value.startsWith(" ") || value.endsWith(" ")) {
    720                     commands.add(new ChangePropertyCommand(Collections.singleton(p), key, value.trim()));
     718                    commands.add(new ChangePropertyCommand(p, key, value.trim()));
    721719                } else if (key.startsWith(" ") || key.endsWith(" ")) {
    722                     commands.add(new ChangePropertyKeyCommand(Collections.singleton(p), key, key.trim()));
     720                    commands.add(new ChangePropertyKeyCommand(p, key, key.trim()));
    723721                } else {
    724722                    String evalue = entities.unescape(value);
    725723                    if (!evalue.equals(value)) {
    726                         commands.add(new ChangePropertyCommand(Collections.singleton(p), key, evalue));
     724                        commands.add(new ChangePropertyCommand(p, key, evalue));
    727725                    } else {
    728726                        String replacementKey = spellCheckKeyData.get(key);
    729727                        if (replacementKey != null) {
    730                             commands.add(new ChangePropertyKeyCommand(Collections.singleton(p),
    731                                     key, replacementKey));
     728                            commands.add(new ChangePropertyKeyCommand(p, key, replacementKey));
    732729                        }
    733730                    }
Note: See TracChangeset for help on using the changeset viewer.