1 package net.systemeD.halcyon.connection.actions {
3 import net.systemeD.halcyon.connection.*;
4 import net.systemeD.halcyon.Globals;
6 public class SplitWayAction extends CompositeUndoableAction {
8 private var selectedWay:Way;
9 private var selectedNode:Node;
10 private var newWay:Way;
12 public function SplitWayAction(selectedWay:Way, selectedNode:Node) {
13 super("Split way "+selectedWay.id);
14 this.selectedWay = selectedWay;
15 this.selectedNode = selectedNode;
18 public override function doAction():uint {
20 newWay = Connection.getConnection().createWay(
21 selectedWay.getTagsCopy(),
22 selectedWay.sliceNodes(selectedWay.indexOfNode(selectedNode),selectedWay.length),
25 selectedWay.deleteNodesFrom(selectedWay.indexOfNode(selectedNode)+1, push);
28 // FIXME make this reversible
29 // FIXME should be more clever about the position (for ordered relations).
30 // It should either be before, or after, the selectedWay, depending
31 // on the relative sequence of the relation members compared to the
32 // direction of selectedWay.
33 // FIXME if we insert twice into the same relation, the position may become
34 // boggled (i.e. "10th position" is no longer valid if we previously
35 // inserted something earlier).
36 for each (var o:Object in selectedWay.memberships) {
37 o.relation.insertMember(o.position, new RelationMember(newWay, o.role));
41 selectedWay.suspend();
48 public override function undoAction():uint {
49 selectedWay.suspend();