Index: lams_central/src/flash/lams_monitoring_v1.fla =================================================================== diff -u Binary files differ Index: lams_central/src/flash/org/lamsfoundation/lams/monitoring/Application.as =================================================================== diff -u --- lams_central/src/flash/org/lamsfoundation/lams/monitoring/Application.as (revision 0) +++ lams_central/src/flash/org/lamsfoundation/lams/monitoring/Application.as (revision 278c3f6f0251d98d690a4c02cd75da76e7b6e7fb) @@ -0,0 +1,673 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +//import org.lamsfoundation.lams.authoring.* //Design Data model n stuffimport org.lamsfoundation.lams.authoring.* //Design Data model n stuff +import org.lamsfoundation.lams.monitoring.* +import org.lamsfoundation.lams.monitoring.ls.* //Lessons +import org.lamsfoundation.lams.authoring.tb.* //Toolbar +//import org.lamsfoundation.lams.authoring.cv.* //Canvas +import org.lamsfoundation.lams.common.ws.* //Workspace +import org.lamsfoundation.lams.common.comms.* //communications +import org.lamsfoundation.lams.common.util.* //Utils +import org.lamsfoundation.lams.common.dict.* //Dictionary +import org.lamsfoundation.lams.common.ui.* //User interface +import org.lamsfoundation.lams.common.style.* //Themes/Styles +import org.lamsfoundation.lams.common.* +import mx.managers.* +import mx.utils.* + +/** +* Application - LAMS Application +* @author DI +*/ +class org.lamsfoundation.lams.monitoring.Application extends ApplicationParent { + + + private static var SHOW_DEBUGGER:Boolean = false; + /* + private static var TOOLBAR_X:Number = 10; + private static var TOOLBAR_Y:Number = 35; +*/ + private static var _controlKeyPressed:String; + private static var TOOLBAR_X:Number = 0; + private static var TOOLBAR_Y:Number = 21; + + private static var LESSONS_X:Number = 0; + private static var LESSONS_Y:Number = 55; + + private static var CANVAS_X:Number = 180; + private static var CANVAS_Y:Number = 55; + private static var CANVAS_W:Number = 1000; + private static var CANVAS_H:Number = 200; + + private static var WORKSPACE_X:Number = 200; + private static var WORKSPACE_Y:Number = 200; + private static var WORKSPACE_W:Number = 300; + private static var WORKSPACE_H:Number = 200; + + private static var APP_ROOT_DEPTH:Number = 10; //depth of the application root + private static var DIALOGUE_DEPTH:Number = 20; //depth of the cursors + private static var TOOLTIP_DEPTH:Number = 30; //depth of the cursors + private static var CURSOR_DEPTH:Number = 40; //depth of the cursors + private static var MENU_DEPTH:Number = 25; //depth of the menu + + private static var UI_LOAD_CHECK_INTERVAL:Number = 50; + private static var UI_LOAD_CHECK_TIMEOUT_COUNT:Number = 200; + private static var DATA_LOAD_CHECK_INTERVAL:Number = 50; + private static var DATA_LOAD_CHECK_TIMEOUT_COUNT:Number = 200; + + private static var QUESTION_MARK_KEY:Number = 191; + private static var X_KEY:Number = 88; + private static var C_KEY:Number = 67; + private static var D_KEY:Number = 68; + //private static var T_KEY:Number = 84; + private static var V_KEY:Number = 86; + private static var Z_KEY:Number = 90; + private static var Y_KEY:Number = 89; + + + + private var _uiLoadCheckCount = 0; // instance counter for number of times we have checked to see if theme and dict are loaded + private var _dataLoadCheckCount = 0; + + //private var _ddm:DesignDataModel; + private var _toolbar:Toolbar; + private var _lessons:Lesson; + //private var _canvas:Canvas; + private var _workspace:Workspace; + private var _comms:Communication; + private var _themeManager:ThemeManager; + private var _dictionary:Dictionary; + private var _config:Config; + private var _debugDialog:MovieClip; //Reference to the debug dialog + + + private var _appRoot_mc:MovieClip; //Application root clip + private var _dialogueContainer_mc:MovieClip; //Dialog container + private var _tooltipContainer_mc:MovieClip; //Tooltip container + private var _cursorContainer_mc:MovieClip; //Cursor container + private var _menu_mc:MovieClip; //Menu bar clip + private var _container_mc:MovieClip; //Main container + + //Data flags + private var _dictionaryLoaded:Boolean; //Dictionary loaded flag + private var _dictionaryEventDispatched:Boolean //Event status flag + private var _themeLoaded:Boolean; //Theme loaded flag + private var _themeEventDispatched:Boolean //Dictionary loaded flag + private var _UILoadCheckIntervalID:Number; //Interval ID for periodic check on UILoad status + private var _UILoaded:Boolean; //UI Loading status + + private var _DataLoadCheckIntervalID:Number; + + //UI Elements + private var _toolbarLoaded:Boolean; //These are flags set to true when respective element is 'loaded' + private var _canvasLoaded:Boolean; + private var _lessonsLoaded:Boolean; + private var _menuLoaded:Boolean; + private var _showCMItem:Boolean; + + //clipboard + private var _clipboardData:Object; + // set up Key Listener + //private var keyListener:Object; + + //Application instance is stored as a static in the application class + private static var _instance:Application = null; + + /** + * Application - Constructor + */ + private function Application(){ + super(); + _menuLoaded = false; + _lessonsLoaded = false; + _toolbarLoaded = false; + //Mouse.addListener(someListener); + } + + /** + * Retrieves an instance of the Application singleton + */ + public static function getInstance():Application{ + if(Application._instance == null){ + Application._instance = new Application(); + } + return Application._instance; + } + + /** + * Main entry point to the application + */ + public function main(container_mc:MovieClip){ + _container_mc = container_mc; + _UILoaded = false; + + //add the cursors: + Cursor.addCursor(C_HOURGLASS); + //Cursor.addCursor(C_OPTIONAL); + //Cursor.addCursor(C_TRANSITION); + //Cursor.addCursor(C_GATE); + //Cursor.addCursor(C_GROUP); + + + //Comms object - do this before any objects are created that require it for server communication + _comms = new Communication(); + + //Get the instance of config class + _config = Config.getInstance(); + + //Assign the config load event to + _config.addEventListener('load',Delegate.create(this,configLoaded)); + + //Set up Key handler + //TODO take out after testing and uncomment same key handler in ready(); + Key.addListener(this); + //setupUI(); + //setupData(); + //checkDataLoaded(); + } + + /** + * Called when the config class has loaded + */ + private function configLoaded(){ + //Now that the config class is ready setup the UI and data, call to setupData() first in + //case UI element constructors use objects instantiated with setupData() + setupData(); + checkDataLoaded(); + + } + + /** + * Loads and sets up event listeners for Theme, Dictionary etc. + */ + private function setupData() { + + //Get the language, create+load dictionary and setup load handler. + var language:String = String(_config.getItem('language')); + _dictionary = Dictionary.getInstance(); + _dictionary.addEventListener('load',Delegate.create(this,onDictionaryLoad)); + _dictionary.load(language); + + + + //Set reference to StyleManager and load Themes and setup load handler. + var theme:String = String(_config.getItem('theme')); + _themeManager = ThemeManager.getInstance(); + _themeManager.addEventListener('load',Delegate.create(this,onThemeLoad)); + _themeManager.loadTheme(theme); + Debugger.getInstance().crashDumpSeverityLevel = Number(_config.getItem('crashDumpSeverityLevelLog')); + Debugger.getInstance().severityLevel = Number(_config.getItem('severityLevelLog')); + + } + + /** + * Called when Dictionary loaded + * @param evt:Object the event object + */ + private function onDictionaryLoad(evt:Object){ + if(evt.type=='load'){ + _dictionaryLoaded = true; + Debugger.log('Dictionary loaded :',Debugger.CRITICAL,'onDictionaryLoad','Application'); + } else { + Debugger.log('event type not recognised :'+evt.type,Debugger.CRITICAL,'onDictionaryLoad','Application'); + } + } + + /** + * Called when the current selected theme has been loaded + * @param evt:Object the event object + */ + private function onThemeLoad(evt:Object) { + if(evt.type=='load'){ + _themeLoaded = true; + Debugger.log('!Theme loaded :',Debugger.CRITICAL,'onThemeLoad','Application'); + } else { + Debugger.log('event type not recognised :'+evt.type,Debugger.CRITICAL,'onThemeLoad','Application'); + } + + } + + /** + * Periodically checks if data has been loaded + */ + private function checkDataLoaded() { + // first time through set interval for method polling + if(!_DataLoadCheckIntervalID) { + _DataLoadCheckIntervalID = setInterval(Proxy.create(this, checkDataLoaded), DATA_LOAD_CHECK_INTERVAL); + } else { + _dataLoadCheckCount++; + // if dictionary and theme data loaded setup UI + if(_dictionaryLoaded && _themeLoaded) { + clearInterval(_DataLoadCheckIntervalID); + + setupUI(); + checkUILoaded(); + + + } else if(_dataLoadCheckCount >= DATA_LOAD_CHECK_TIMEOUT_COUNT) { + Debugger.log('reached timeout waiting for data to load.',Debugger.CRITICAL,'checkUILoaded','Application'); + clearInterval(_UILoadCheckIntervalID); + + + } + } + } + + /** + * Runs periodically and dispatches events as they are ready + */ + private function checkUILoaded() { + //If it's the first time through then set up the interval to keep polling this method + if(!_UILoadCheckIntervalID) { + _UILoadCheckIntervalID = setInterval(Proxy.create(this,checkUILoaded),UI_LOAD_CHECK_INTERVAL); + } else { + _uiLoadCheckCount++; + //If all events dispatched clear interval and call start() + if(_dictionaryEventDispatched && _themeEventDispatched){ + //Debugger.log('Clearing Interval and calling start :',Debugger.CRITICAL,'checkUILoaded','Application'); + clearInterval(_UILoadCheckIntervalID); + start(); + }else { + //If UI loaded check which events can be broadcast + if(_UILoaded){ + //Debugger.log('ALL UI LOADED, waiting for all true to dispatch init events: _dictionaryLoaded:'+_dictionaryLoaded+'_themeLoaded:'+_themeLoaded ,Debugger.GEN,'checkUILoaded','Application'); + + //If dictionary is loaded and event hasn't been dispatched - dispatch it + if(_dictionaryLoaded && !_dictionaryEventDispatched){ + _dictionaryEventDispatched = true; + _dictionary.broadcastInit(); + } + //If theme is loaded and theme event hasn't been dispatched - dispatch it + if(_themeLoaded && !_themeEventDispatched){ + _themeEventDispatched = true; + _themeManager.broadcastThemeChanged(); + } + + if(_uiLoadCheckCount >= UI_LOAD_CHECK_TIMEOUT_COUNT){ + //if we havent loaded the dict or theme by the timeout count then give up + Debugger.log('raeached time out waiting to load dict and themes, giving up.',Debugger.CRITICAL,'checkUILoaded','Application'); + var msg:String = ""; + if(!_themeEventDispatched){ + msg+=Dictionary.getValue("app_chk_themeload"); + } + if(!_dictionaryEventDispatched){ + msg+="The lanaguage data has not been loaded."; + } + msg+=Dictionary.getValue("app_fail_continue"); + var e:LFError = new LFError(msg,"Canvas.setDroppedTemplateActivity",this,'_themeEventDispatched:'+_themeEventDispatched+' _dictionaryEventDispatched:'+_dictionaryEventDispatched); + e.showErrorAlert(); + //todo: give the user a message + clearInterval(_UILoadCheckIntervalID); + } + } + } + } + } + + /** + * This is called by each UI element as it loads to notify Application that it's loaded + * When all UIElements are loaded the Application can set UILoaded flag true allowing events to be dispatched + * and methods called on the UI Elements + * + * @param UIElementID:String - Identifier for the Element that was loaded + */ + public function UIElementLoaded(evt:Object) { + //Debugger.log('UIElementLoaded: ' + evt.target.className,Debugger.GEN,'UIElementLoaded','Application'); + if(evt.type=='load'){ + //Which item has loaded + switch (evt.target.className) { + case 'Lesson' : + _lessonsLoaded = true; + break; + case 'Canvas' : + _canvasLoaded = true; + break; + case 'LFMenuBar' : + _menuLoaded = true; + break; + case 'Toolbar' : + _toolbarLoaded = true; + break; + default: + } + + //If all of them are loaded set UILoad accordingly + if(_menuLoaded && _toolbarLoaded && _lessonsLoaded){ + _UILoaded=true; + } + //if(_toolkitLoaded && _canvasLoaded && _menuLoaded && _toolbarLoaded){ + // _UILoaded=true; + //} + + } + } + + public function showCustomCM(showCMItem:Boolean, cmItems):Object{ + + var root_cm:ContextMenu = new ContextMenu(); + root_cm.hideBuiltInItems(); + trace("CM Item label: "+cmItems.cmlabel) + for (var i=0; i "+myAccordion.height) + var lsns:MovieClip = lessonState_acc.active.createChild("DataGrid", "Data_dtg"); + lsns.setSize(lessonState_acc.width, lessonState_acc.height-63); + + //set SP the content path: + //learningSequences_sp.contentPath = "empty_mc"; + + var lbv = LessonView(this); + var lbm = LessonModel(o); + + //get the hashtable + var mySeqs:Hashtable = lbm.getLessonSequences(); + + //loop through the sequences + var keys:Array = mySeqs.keys(); + trace("Length of Keys: "+keys.length) + for(var i=0; i 0 && spHeight>0) { + //toolkitLibraries_sp.setSize(spWidth,spHeight); + //} + + } + + /** + * Sets the position of the Lesson on stage, called from update + * @param lm Lesson model object + */ + private function setPosition(lm:LessonModel):Void{ + var p:Object = lm.getPosition(); + this._x = p.x; + this._y = p.y; + } + + /** + * Gets the LibraryModel + * + * @returns model + */ + public function getModel():LessonModel{ + return LessonModel(model); + } + + + /** + * Returns the default controller for this view (LessonController). + * Overrides AbstractView.defaultController() + */ + public function defaultController (model:Observable):Controller { + return new LessonController(model); + } +} \ No newline at end of file Index: lams_central/src/flash/org/lamsfoundation/lams/monitoring/ls/Sequence.as =================================================================== diff -u --- lams_central/src/flash/org/lamsfoundation/lams/monitoring/ls/Sequence.as (revision 0) +++ lams_central/src/flash/org/lamsfoundation/lams/monitoring/ls/Sequence.as (revision 278c3f6f0251d98d690a4c02cd75da76e7b6e7fb) @@ -0,0 +1,221 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.monitoring.ls.*; + +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ + +import org.lamsfoundation.lams.common.util.Observable; +import org.lamsfoundation.lams.monitoring.ls.*; +import org.lamsfoundation.lams.common.util.*; +import org.lamsfoundation.lams.authoring.DesignDataModel; + + +/* +* Model for the Sequence +*/ +class Sequence { + private var _className:String = "Sequence"; + + private static var _instance:Sequence = null; + + /** + * View state data + */ + private var _seqName:String; + private var _seqDescription:String; + private var _seqStateID:Number; + private var _seqID:Number; + + private var _seqCreatedDate:Date; + private var _seqStartDate:Date; + + private var _learningDesignID:Number; + private var _learningDesignModel:DesignDataModel; + + private var _active:Boolean; + + + /** + * Constructor. + */ + public function Sequence (){ + _active = false; + _learningDesignModel = null; + } + + /** + * + * @return the Sequence + */ + public static function getInstance():Sequence{ + if(Sequence._instance == null){ + Sequence._instance = new Sequence(); + } + return Sequence._instance; + } + + public function populateFromDTO(dto:Object){ + trace('populating seq object for seq:' + dto.lessonID); + _seqID = dto.lessonID; + _seqName = dto.lessonName; + _seqDescription = dto.lessonDescription; + _seqStateID = dto.lessonStateID; + _seqCreatedDate = dto.createDateTime; + _seqStartDate = dto.startDateTime; + } + + + /** + * Set seq's unique ID + * + * @param seqID + */ + + public function setSequenceID(seqID:Number){ + _seqID = seqID; + } + + /** + * Get Sequence's unique ID + * + * @return Sequence ID + */ + + public function getSequenceID():Number { + return _seqID; + } + + /** + * Set the seq's name + * + * @param seqName + */ + + public function setSequenceName(seqName:String){ + _seqName = seqName; + + } + + /** + * Get the seq's name + * + * @return Sequence Name + */ + + public function getSequenceName():String { + return _seqName; + } + + /** + * Set the seq's description + * + * @param seqDescription + */ + + public function setSequenceDescription(seqDescription:String){ + _seqDescription = seqDescription; + + } + + /** + * Get the seq's description + * + * @return seq description + */ + public function getSequenceDescription():String { + return _seqDescription; + } + + public function setSequenceStateID(seqStateID:Number) { + _seqStateID = seqStateID; + + } + + public function getSequenceStateID():Number { + return _seqStateID; + } + + public function setLearningDesignID(learningDesignID:Number){ + _learningDesignID = learningDesignID; + + } + + public function getLearningDesignID():Number{ + return _learningDesignID; + } + + public function setLearningDesignModel(learningDesignModel:DesignDataModel){ + _learningDesignModel = learningDesignModel; + + } + + public function getLearningDesignModel():DesignDataModel{ + return _learningDesignModel; + } + + public function setActive() { + _active = true; + trace('setting seq active...'); + + } + + public function setInactive() { + _active = false; + trace('setting seq inactive...'); + + } + + public function getStatus():Boolean { + return _active; + } + + function get className():String{ + return 'Sequence'; + } + + + + +} \ No newline at end of file