Ignore:
Timestamp:
2015-10-25T12:59:42+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #12008 - do not create empty commands from tagging preset dialog + add robustness

Location:
trunk/src/org/openstreetmap/josm/command
Files:
2 edited

Legend:

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

    r8941 r8945  
    2828 *
    2929 * @author imi
     30 * @since 24
    3031 */
    3132public class ChangePropertyCommand extends Command {
     
    3334     * All primitives that are affected with this command.
    3435     */
    35     private final List<OsmPrimitive> objects;
     36    private final List<OsmPrimitive> objects = new LinkedList<>();
     37
    3638    /**
    3739     * Key and value pairs. If value is <code>null</code>, delete all key references with the given
     
    4850     */
    4951    public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, Map<String, String> tags) {
    50         this.objects = new LinkedList<>();
    5152        this.tags = tags;
    5253        init(objects);
     
    6162     */
    6263    public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, String key, String value) {
    63         this.objects = new LinkedList<>();
    6464        this.tags = new HashMap<>(1);
    6565        this.tags.put(key, value);
     
    108108    @Override
    109109    public boolean executeCommand() {
     110        if (objects.isEmpty())
     111            return true;
    110112        final DataSet dataSet = objects.get(0).getDataSet();
    111113        dataSet.beginUpdate();
     
    197199    }
    198200
    199     @Override public Collection<PseudoCommand> getChildren() {
     201    @Override
     202    public Collection<PseudoCommand> getChildren() {
    200203        if (objects.size() == 1)
    201204            return null;
     
    221224
    222225    /**
     226     * Returns the number of objects that will effectively be modified, before the command is executed.
     227     * @return the number of objects that will effectively be modified (can be 0)
     228     * @see Command#getParticipatingPrimitives()
     229     * @since 8945
     230     */
     231    public final int getObjectsNumber() {
     232        return objects.size();
     233    }
     234
     235    /**
    223236     * Returns the tags to set (key/value pairs).
    224237     * @return the tags to set (key/value pairs)
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r8931 r8945  
    240240    /**
    241241     * Return the primitives that take part in this command.
     242     * The collection is computed during execution.
    242243     */
    243244    @Override
Note: See TracChangeset for help on using the changeset viewer.