fix dupe nodes stuff
[potlatch2.git] / net / systemeD / halcyon / connection / UndoableEntityAction.as
1 package net.systemeD.halcyon.connection {
2
3     public class UndoableEntityAction extends UndoableAction {
4         public var wasDirty:Boolean;
5                 public var connectionWasDirty:Boolean;
6         private var initialised:Boolean = false;
7         protected var name:String;
8         protected var entity:Entity;
9             
10         public function UndoableEntityAction(entity:Entity, name:String) {
11             this.entity = entity;
12             this.name = name;
13         }
14             
15         protected function markDirty():void {
16             if ( !initialised ) init();
17
18             if ( !wasDirty ) {
19               entity.markDirty();
20             }
21
22             if ( !connectionWasDirty ) {
23               Connection.getConnectionInstance().markDirty();
24             }
25         }
26             
27         protected function markClean():void {
28             if ( !initialised ) init();
29
30             if ( !wasDirty ) {
31               entity.markClean();
32             }
33
34             if ( !connectionWasDirty ) {
35               Connection.getConnectionInstance().markClean();
36             }
37         }
38         
39         private function init():void {
40             wasDirty = entity.isDirty;
41             connectionWasDirty = Connection.getConnectionInstance().isDirty;
42             initialised = true;
43         }
44             
45         public function toString():String {
46             return name + " " + entity.getType() + " " + entity.id;
47         }
48     }
49 }
50