Changeset 10663 in josm for trunk/src/org/openstreetmap/josm/command
- Timestamp:
- 2016-07-28T01:24:39+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/command
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/ChangeNodesCommand.java
r9371 r10663 38 38 this.way = way; 39 39 this.newNodes = newNodes; 40 if (newNodes.isEmpty()) { 41 throw new IllegalArgumentException("Cannot set nodes to be an empty list."); 42 } 40 43 } 41 44 … … 55 58 @Override 56 59 public String getDescriptionText() { 57 return tr("Change dnodes of {0}", way.getDisplayName(DefaultNameFormatter.getInstance()));60 return tr("Change nodes of {0}", way.getDisplayName(DefaultNameFormatter.getInstance())); 58 61 } 59 62 -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r10308 r10663 156 156 String msg; 157 157 Map.Entry<String, String> entry = tags.entrySet().iterator().next(); 158 if (entry.getValue() == null) { 158 if (entry.getValue() == null || entry.getValue().isEmpty()) { 159 159 switch(OsmPrimitiveType.from(primitive)) { 160 160 case NODE: msg = marktr("Remove \"{0}\" for node ''{1}''"); break; … … 175 175 } else if (objects.size() > 1 && tags.size() == 1) { 176 176 Map.Entry<String, String> entry = tags.entrySet().iterator().next(); 177 if (entry.getValue() == null) { 177 if (entry.getValue() == null || entry.getValue().isEmpty()) { 178 178 /* I18n: plural form for objects, but value < 2 not possible! */ 179 179 text = trn("Remove \"{0}\" for {1} object", "Remove \"{0}\" for {1} objects", objects.size(), entry.getKey(), objects.size()); … … 186 186 boolean allnull = true; 187 187 for (Map.Entry<String, String> tag : this.tags.entrySet()) { 188 if (tag.getValue() != null) { 188 if (tag.getValue() != null && !tag.getValue().isEmpty()) { 189 189 allnull = false; 190 190 break; … … 226 226 return Collections.singleton(osm); 227 227 } 228 229 228 }); 230 229 } -
trunk/src/org/openstreetmap/josm/command/ChangePropertyKeyCommand.java
r9371 r10663 66 66 return false; // save old 67 67 for (OsmPrimitive osm : objects) { 68 if (osm.hasKey s()) {68 if (osm.hasKey(key) || osm.hasKey(newKey)) { 69 69 osm.setModified(true); 70 70 String oldValue = osm.get(key); … … 87 87 NameVisitor v = new NameVisitor(); 88 88 objects.get(0).accept(v); 89 text += ' '+tr(v.className)+' '+v.name;89 text += " "+tr(v.className)+" "+v.name; 90 90 } else { 91 text += ' '+objects.size()+' '+trn("object", "objects", objects.size());91 text += " "+objects.size()+" "+trn("object", "objects", objects.size()); 92 92 } 93 93 return text; … … 108 108 for (final OsmPrimitive osm : objects) { 109 109 osm.accept(v); 110 final String name = v.name; 111 final Icon icon = v.icon; 110 112 children.add(new PseudoCommand() { 111 113 @Override 112 114 public String getDescriptionText() { 113 return v.name;115 return name; 114 116 } 115 117 116 118 @Override 117 119 public Icon getDescriptionIcon() { 118 return v.icon;120 return icon; 119 121 } 120 122 -
trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java
r10250 r10663 49 49 public boolean executeCommand() { 50 50 if (position < 0 || position >= relation.getMembersCount()) 51 return false;51 return true; 52 52 53 53 oldRole = relation.getMember(position).getRole(); … … 62 62 @Override 63 63 public void undoCommand() { 64 relation.setMember(position, new RelationMember(oldRole, relation.getMember(position).getMember())); 65 if (oldModified != null) { 66 relation.setModified(oldModified); 64 if (position >= 0 && position < relation.getMembersCount()) { 65 relation.setMember(position, new RelationMember(oldRole, relation.getMember(position).getMember())); 66 if (oldModified != null) { 67 relation.setModified(oldModified); 68 } 67 69 } 68 70 } -
trunk/src/org/openstreetmap/josm/command/Command.java
r10599 r10663 188 188 * the removed layer) 189 189 * 190 * @param oldLayer the old layer 191 * @return true if this command 190 * @param oldLayer the old layer that was removed 191 * @return true if this command is invalid after that layer is removed. 192 192 */ 193 193 public boolean invalidBecauselayerRemoved(Layer oldLayer) { 194 if (!(oldLayer instanceof OsmDataLayer))195 return false;196 194 return layer == oldLayer; 197 195 } -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r10216 r10663 51 51 */ 52 52 public class DeleteCommand extends Command { 53 private static final class DeleteChildCommand implements PseudoCommand { 54 private final OsmPrimitive osm; 55 56 private DeleteChildCommand(OsmPrimitive osm) { 57 this.osm = osm; 58 } 59 60 @Override 61 public String getDescriptionText() { 62 return tr("Deleted ''{0}''", osm.getDisplayName(DefaultNameFormatter.getInstance())); 63 } 64 65 @Override 66 public Icon getDescriptionIcon() { 67 return ImageProvider.get(osm.getDisplayType()); 68 } 69 70 @Override 71 public Collection<? extends OsmPrimitive> getParticipatingPrimitives() { 72 return Collections.singleton(osm); 73 } 74 75 @Override 76 public String toString() { 77 return "DeleteChildCommand [osm=" + osm + "]"; 78 } 79 } 80 53 81 /** 54 82 * The primitives that get deleted. … … 65 93 public DeleteCommand(Collection<? extends OsmPrimitive> data) { 66 94 CheckParameterUtil.ensureParameterNotNull(data, "data"); 67 if (data.isEmpty())68 throw new IllegalArgumentException(tr("At least one object to delete required, got empty collection"));69 95 this.toDelete = data; 70 96 checkConsistency(); … … 106 132 super(layer); 107 133 CheckParameterUtil.ensureParameterNotNull(data, "data"); 108 if (data.isEmpty())109 throw new IllegalArgumentException(tr("At least one object to delete required, got empty collection"));110 134 this.toDelete = data; 111 135 checkConsistency(); … … 113 137 114 138 private void checkConsistency() { 139 if (toDelete.isEmpty()) { 140 throw new IllegalArgumentException(tr("At least one object to delete required, got empty collection")); 141 } 115 142 for (OsmPrimitive p : toDelete) { 116 143 if (p == null) { … … 216 243 List<PseudoCommand> children = new ArrayList<>(toDelete.size()); 217 244 for (final OsmPrimitive osm : toDelete) { 218 children.add(new PseudoCommand() { 219 220 @Override public String getDescriptionText() { 221 return tr("Deleted ''{0}''", osm.getDisplayName(DefaultNameFormatter.getInstance())); 222 } 223 224 @Override public Icon getDescriptionIcon() { 225 return ImageProvider.get(osm.getDisplayType()); 226 } 227 228 @Override public Collection<? extends OsmPrimitive> getParticipatingPrimitives() { 229 return Collections.singleton(osm); 230 } 231 232 }); 245 children.add(new DeleteChildCommand(osm)); 233 246 } 234 247 return children; … … 441 454 } 442 455 456 /** 457 * Create a command that deletes a single way segment. The way may be split by this. 458 * @param layer The layer the segment is in. 459 * @param ws The way segment that should be deleted 460 * @return A matching command to safely delete that segment. 461 */ 443 462 public static Command deleteWaySegment(OsmDataLayer layer, WaySegment ws) { 444 463 if (ws.way.getNodesCount() < 3) -
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r10378 r10663 243 243 public Collection<Node> getParticipatingPrimitives() { 244 244 return nodes; 245 } 246 247 /** 248 * Gets the offset. 249 * @return The current offset. 250 */ 251 protected EastNorth getOffset() { 252 return new EastNorth(x, y); 245 253 } 246 254 -
trunk/src/org/openstreetmap/josm/command/RotateCommand.java
r10378 r10663 39 39 * @param currentEN cuurent eats/north 40 40 */ 41 public RotateCommand(Collection<OsmPrimitive> objects, EastNorth currentEN) { 41 public RotateCommand(Collection<? extends OsmPrimitive> objects, EastNorth currentEN) { 42 42 super(objects); 43 43 … … 71 71 72 72 /** 73 * Set the rotation angle. 74 * @param rotationAngle The rotate angle 75 */ 76 protected void setRotationAngle(double rotationAngle) { 77 this.rotationAngle = rotationAngle; 78 } 79 80 /** 73 81 * Rotate nodes. 74 82 */ 75 83 @Override 76 84 protected void transformNodes() { 85 double cosPhi = Math.cos(rotationAngle); 86 double sinPhi = Math.sin(rotationAngle); 77 87 for (Node n : nodes) { 78 double cosPhi = Math.cos(rotationAngle);79 double sinPhi = Math.sin(rotationAngle);80 88 EastNorth oldEastNorth = oldStates.get(n).getEastNorth(); 81 89 double x = oldEastNorth.east() - pivot.east(); -
trunk/src/org/openstreetmap/josm/command/ScaleCommand.java
r10378 r10663 35 35 * @param currentEN cuurent eats/north 36 36 */ 37 public ScaleCommand(Collection<OsmPrimitive> objects, EastNorth currentEN) { 37 public ScaleCommand(Collection<? extends OsmPrimitive> objects, EastNorth currentEN) { 38 38 super(objects); 39 39 … … 58 58 double startDistance = pivot.distance(startEN); 59 59 double currentDistance = pivot.distance(currentEN); 60 scalingFactor =Math.cos(startAngle-endAngle) * currentDistance / startDistance;60 setScalingFactor(Math.cos(startAngle-endAngle) * currentDistance / startDistance); 61 61 transformNodes(); 62 } 63 64 /** 65 * Set the scaling factor 66 * @param scalingFactor The scaling factor. 67 */ 68 protected void setScalingFactor(double scalingFactor) { 69 this.scalingFactor = scalingFactor; 62 70 } 63 71 -
trunk/src/org/openstreetmap/josm/command/SelectCommand.java
r10364 r10663 5 5 6 6 import java.util.Collection; 7 import java.util.Collections; 8 import java.util.HashSet; 7 9 import java.util.Objects; 8 10 … … 28 30 */ 29 31 public SelectCommand(Collection<OsmPrimitive> newSelection) { 30 this.newSelection = newSelection; 32 if (newSelection == null || newSelection.isEmpty()) { 33 this.newSelection = Collections.emptySet(); 34 } else { 35 this.newSelection = new HashSet<>(newSelection); 36 } 31 37 } 32 38 -
trunk/src/org/openstreetmap/josm/command/TransformNodesCommand.java
r10248 r10663 49 49 * @param objects objects to fetch nodes from 50 50 */ 51 public TransformNodesCommand(Collection<OsmPrimitive> objects) { 51 public TransformNodesCommand(Collection<? extends OsmPrimitive> objects) { 52 52 this.nodes = AllNodesVisitor.getAllNodes(objects); 53 53 storeOldState();
Note:
See TracChangeset
for help on using the changeset viewer.