better Save button detection
[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         protected var name:String;
7         protected var entity:Entity;
8             
9         public function UndoableEntityAction(entity:Entity, name:String) {
10             this.entity = entity;
11             this.name = name;
12         }
13             
14         protected function markDirty():void {
15                         var conn:Connection = Connection.getConnectionInstance();
16             wasDirty = entity.isDirty;
17                         connectionWasDirty = conn.isDirty;
18
19             if ( !wasDirty )
20                 entity.markDirty();
21
22             if ( !connectionWasDirty )
23                 conn.markDirty();
24         }
25             
26         protected function markClean():void {
27             if ( !wasDirty )
28                 entity.markClean(entity.id, entity.version);
29
30             if ( !connectionWasDirty )
31                 Connection.getConnectionInstance().markClean();
32         }
33             
34         public function toString():String {
35             return name + " " + entity.getType() + " " + entity.id;
36         }
37     }
38 }
39