Changeset 12053 in josm
- Timestamp:
- 2017-05-03T18:12:48+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r12052 r12053 137 137 138 138 ds.beginUpdate(); 139 if (c instanceof MoveCommand && ds.equals( ((MoveCommand) c).getAffectedDataSet())139 if (c instanceof MoveCommand && ds.equals(c.getAffectedDataSet()) 140 140 && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 141 141 ((MoveCommand) c).moveAgain(distx, disty); -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r12048 r12053 711 711 return false; 712 712 } 713 Command c = getLastCommand ();713 Command c = getLastCommandInDataset(ds); 714 714 if (mode == Mode.MOVE) { 715 715 if (startEN == null) return false; // fix #8128 … … 784 784 */ 785 785 private void useLastMoveCommandIfPossible() { 786 Command c = getLastCommand(); 787 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(getLayerManager().getEditDataSet().getSelected()); 786 DataSet dataSet = getLayerManager().getEditDataSet(); 787 Command c = getLastCommandInDataset(dataSet); 788 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(dataSet.getSelected()); 788 789 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 789 790 // old command was created with different base point of movement, we need to recalculate it … … 794 795 /** 795 796 * Obtain command in undoRedo stack to "continue" when dragging 797 * @param ds The data set the command needs to be in. 796 798 * @return last command 797 799 */ 798 private static Command getLastCommand() { 799 Command c = !Main.main.undoRedo.commands.isEmpty() 800 ? Main.main.undoRedo.commands.getLast() : null; 801 if (c instanceof SequenceCommand) { 802 c = ((SequenceCommand) c).getLastCommand(); 803 } 804 return c; 800 private Command getLastCommandInDataset(DataSet ds) { 801 LinkedList<Command> commands = Main.main.undoRedo.commands; 802 if (!commands.isEmpty()) { 803 Command lastCommand = commands.getLast(); 804 if (lastCommand instanceof SequenceCommand) { 805 lastCommand = ((SequenceCommand) lastCommand).getLastCommand(); 806 } 807 if (ds.equals(lastCommand.getAffectedDataSet())) { 808 return lastCommand; 809 } 810 } 811 return null; 805 812 } 806 813 … … 898 905 Collection<OsmPrimitive> selection = ds.getSelectedNodesAndWays(); 899 906 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 900 Command c = getLastCommand ();907 Command c = getLastCommandInDataset(ds); 901 908 ds.beginUpdate(); 902 if (c instanceof MoveCommand 903 && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 909 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) { 904 910 Node selectedNode = selNodes.iterator().next(); 905 911 EastNorth selectedEN = selectedNode.getEastNorth();
Note:
See TracChangeset
for help on using the changeset viewer.