Index: lams_central/src/flash/org/lamsfoundation/lams/monitoring/mv/MonitorModel.as =================================================================== diff -u -r273f2923938c4251cb1246605da9cd9144bb9f14 -r972bfd9d0b75ee5e3e72c7626749f978e428d551 --- lams_central/src/flash/org/lamsfoundation/lams/monitoring/mv/MonitorModel.as (.../MonitorModel.as) (revision 273f2923938c4251cb1246605da9cd9144bb9f14) +++ lams_central/src/flash/org/lamsfoundation/lams/monitoring/mv/MonitorModel.as (.../MonitorModel.as) (revision 972bfd9d0b75ee5e3e72c7626749f978e428d551) @@ -20,18 +20,17 @@ * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ */ - + +import org.lamsfoundation.lams.monitoring.*; import org.lamsfoundation.lams.monitoring.mv.*; import org.lamsfoundation.lams.common.Sequence; import org.lamsfoundation.lams.common.util.Observable; -import org.lamsfoundation.lams.common.util.*; -import org.lamsfoundation.lams.monitoring.Application; -import mx.events.* +import org.lamsfoundation.lams.common.util.*; + /* * Model for the Monitoring Tabs */ -class org.lamsfoundation.lams.monitoring.mv.MonitorModel extends Observable{ - +class MonitorModel extends Observable{ private var _className:String = "MonitorModel"; private var __width:Number; @@ -45,131 +44,76 @@ // add model data private var _activeSeq:Sequence; - //private var _class:Class; // session class - //private var _todos:Array; // Array of ToDo ContributeActivities - + private var _org:Organisation; + private var _todos:Array; // Array of ToDo ContributeActivity(s) // state data private var _showLearners:Boolean; - - //These are defined so that the compiler can 'see' the events that are added at runtime by EventDispatcher - private var dispatchEvent:Function; - public var addEventListener:Function; - public var removeEventListener:Function; + /** * Constructor. */ - public function MonitorModel (monitor:Monitor){ - - //Set up this class to use the Flash event delegation model - //EventDispatcher.initialize(this); - + public function MonitorModel (monitor:Monitor){ _monitor = monitor; _showLearners = true; } - - public function setSize(width:Number,height:Number) { - __width = width; - __height = height; - - setChanged(); - - //send an update - infoObj = {}; - infoObj.updateType = "SIZE"; - notifyObservers(infoObj); - //broadcastViewUpdate("SIZE"); - } - - /** - * Used by View to get the size - * @returns Object containing width(w) & height(h). obj.w & obj.h - */ - public function getSize():Object{ - var s:Object = {}; - s.w = __width; - s.h = __height; - return s; - } - - /** - * sets the model x + y vars - */ - public function setPosition(x:Number,y:Number){ - - __x = x; - __y = y; - //Set flag for notify observers - setChanged(); - - //build and send update object - infoObj = {}; - infoObj.updateType = "POSITION"; - notifyObservers(infoObj); - //broadcastViewUpdate("POSITION"); - } - - /** - * Used by View to get the size - * @returns Object containing width(w) & height(h). obj.w & obj.h - */ - public function getPosition():Object{ - var p:Object = {}; - p.x = __x; - p.y = __y; - return p; - } + // add get/set methods - /** - public function setClass(class:Class){ - _class = class; + public function setSequence(activeSeq:Sequence){ + _activeSeq = activeSeq; setChanged(); //send an update infoObj = {}; - infoObj.updateType = "CLASS"; + infoObj.updateType = "SEQUENCE"; notifyObservers(infoObj); } - public function getClass():Class{ - return _class; + public function getSequence():Sequence{ + return _activeSeq; } - public function setToDos(todos:Array){ - _todos = todos; + public function setOrganisation(org:Organisation){ + _org = org; setChanged(); //send an update infoObj = {}; - infoObj.updateType = "TODOS"; + infoObj.updateType = "ORG"; notifyObservers(infoObj); } - public function getToDos():Array{ - return _todos; - } - - */ + public function getOrganisation():Organisation{ + return _org; + } - // add get/set methods - - public function setSequence(activeSeq:Sequence){ - _activeSeq = activeSeq; + + + public function setToDos(todos:Array){ - setChanged(); + _todos = new Array(); - //send an update - infoObj = {}; - infoObj.updateType = "SEQUENCE"; + for(var i=0; i< todos.length; i++){ + var t:Object = todos[i]; + var todo:ContributeActivity = new ContributeActivity(); + todo.populateFromDTO(t); + _todos.push(todo); + } + + setChanged(); + + //send an update + infoObj = {}; + infoObj.updateType = "TODOS"; notifyObservers(infoObj); - } - - public function getSequence():Sequence{ - return _activeSeq; - } + } + public function getToDos():Array{ + return _todos; + } + public function showLearners(){ _showLearners = true; @@ -196,15 +140,56 @@ return _showLearners; } - - /** - * Notify registered listeners that a data model change has happened - */ - public function broadcastViewUpdate(_updateType,_data){ - dispatchEvent({type:'viewUpdate',target:this,updateType:_updateType,data:_data}); - trace('broadcast'); - } + public function setSize(width:Number,height:Number) { + __width = width; + __height = height; + + setChanged(); + + //send an update + infoObj = {}; + infoObj.updateType = "SIZE"; + notifyObservers(infoObj); + } + /** + * Used by View to get the size + * @returns Object containing width(w) & height(h). obj.w & obj.h + */ + public function getSize():Object{ + var s:Object = {}; + s.w = __width; + s.h = __height; + return s; + } + + /** + * sets the model x + y vars + */ + public function setPosition(x:Number,y:Number):Void{ + //Set state variables + __x = x; + __y = y; + //Set flag for notify observers + setChanged(); + + //build and send update object + infoObj = {}; + infoObj.updateType = "POSITION"; + notifyObservers(infoObj); + } + + /** + * Used by View to get the size + * @returns Object containing width(w) & height(h). obj.w & obj.h + */ + public function getPosition():Object{ + var p:Object = {}; + p.x = __x; + p.y = __y; + return p; + } + //Accessors for x + y coordinates public function get x():Number{ return __x; @@ -231,5 +216,4 @@ return _monitor; } - }