Changeset 8945 in josm
- Timestamp:
- 2015-10-25T12:59:42+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r8941 r8945 28 28 * 29 29 * @author imi 30 * @since 24 30 31 */ 31 32 public class ChangePropertyCommand extends Command { … … 33 34 * All primitives that are affected with this command. 34 35 */ 35 private final List<OsmPrimitive> objects; 36 private final List<OsmPrimitive> objects = new LinkedList<>(); 37 36 38 /** 37 39 * Key and value pairs. If value is <code>null</code>, delete all key references with the given … … 48 50 */ 49 51 public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, Map<String, String> tags) { 50 this.objects = new LinkedList<>();51 52 this.tags = tags; 52 53 init(objects); … … 61 62 */ 62 63 public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, String key, String value) { 63 this.objects = new LinkedList<>();64 64 this.tags = new HashMap<>(1); 65 65 this.tags.put(key, value); … … 108 108 @Override 109 109 public boolean executeCommand() { 110 if (objects.isEmpty()) 111 return true; 110 112 final DataSet dataSet = objects.get(0).getDataSet(); 111 113 dataSet.beginUpdate(); … … 197 199 } 198 200 199 @Override public Collection<PseudoCommand> getChildren() { 201 @Override 202 public Collection<PseudoCommand> getChildren() { 200 203 if (objects.size() == 1) 201 204 return null; … … 221 224 222 225 /** 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 /** 223 236 * Returns the tags to set (key/value pairs). 224 237 * @return the tags to set (key/value pairs) -
trunk/src/org/openstreetmap/josm/command/Command.java
r8931 r8945 240 240 /** 241 241 * Return the primitives that take part in this command. 242 * The collection is computed during execution. 242 243 */ 243 244 @Override -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r8937 r8945 453 453 List<Command> cmds = new ArrayList<>(); 454 454 for (Tag tag: changedTags) { 455 cmds.add(new ChangePropertyCommand(sel, tag.getKey(), tag.getValue())); 455 ChangePropertyCommand cmd = new ChangePropertyCommand(sel, tag.getKey(), tag.getValue()); 456 if (cmd.getObjectsNumber() > 0) { 457 cmds.add(cmd); 458 } 456 459 } 457 460
Note:
See TracChangeset
for help on using the changeset viewer.