Sha256: 72acd9b9195be3ccbaaa0f0a50bc7c2e2860a4b5a4150a610ef94459f1f0a6eb

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

/* Copyright 2008 Theo Hultberg/Iconara */

package <%= base_package %>.controllers.command
{

	import <%= base_package %>.models.domain.Document;
	import <%= base_package %>.models.domain.Snapshot;	

	public class UpdateDocumentCommand implements Undoable {
		
		private var _timestamp:Date;
		
		private var undoSnapshot:Snapshot;
		
		private var document:Document;
		
		public var title:String;
		public var body:String;
		public var abstract:String;
		public var menuTitle:String;
		public var subTitle:String;


		public function get timestamp():Date {
			return _timestamp;
		}
		
		public function get description():String {
			return "Update document";
		}
		
		
		public function UpdateDocumentCommand() {
		}
		
		public function prepare(document:Document, vars:*):void {
			this.document = document;
			document.mapProperties(this, vars, document.desiredProperties);
			/*this.title = vars.title;
			this.body = vars.body;
			this.abstract = vars.abstract;
			this.menuTitle = vars.menuTitle;
			this.subTitle = vars.subTitle;*/
		}
		
		public function execute():void {
			undoSnapshot = document.createSnapshot();
			
			document.mapProperties(document.content, this, document.desiredProperties);
			/*document.title = title;
			document.body = body;
			document.abstract = abstract;
			document.menuTitle = menuTitle;
			document.subTitle = subTitle;*/
			
			if ( _timestamp == null ) {
				// don't overwrite the timestamp on redo
				
				_timestamp = new Date();
			}
		}
		
		public function undo():void {
			document.loadSnapshot(undoSnapshot);
		}
		
		public function redo():void {
			execute();
		}

	}

}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
emergent-core-0.1.0 rails_generators/emergent_config/templates/app/flex/application/controllers/command/UpdateDocumentCommand.as
emergent-core-0.1.01 rails_generators/emergent_config/templates/app/flex/application/controllers/command/UpdateDocumentCommand.as
emergent-core-0.1.02 rails_generators/emergent_config/templates/app/flex/application/controllers/command/UpdateDocumentCommand.as