Index: lams_central/src/flash/org/lamsfoundation/lams/monitoring/Application.as =================================================================== diff -u -r3d370bf2dca8dff17a9c3c73c7676f0f8abc5a7b -re78b7795cb852851a59fdd8e5442305b89a752ee --- lams_central/src/flash/org/lamsfoundation/lams/monitoring/Application.as (.../Application.as) (revision 3d370bf2dca8dff17a9c3c73c7676f0f8abc5a7b) +++ lams_central/src/flash/org/lamsfoundation/lams/monitoring/Application.as (.../Application.as) (revision e78b7795cb852851a59fdd8e5442305b89a752ee) @@ -464,14 +464,24 @@ if(SHOW_DEBUGGER){ showDebugger(); } + + //_monitor.getOrganisations(); } /** * Opens the preferences dialog - */ + public function showPrefsDialog() { PopUpManager.createPopUp(Application.root, LFWindow, true,{title:Dictionary.getValue("prefs_dlg_title"),closeButton:true,scrollContentPath:'preferencesDialog'}); } + */ + + /** + * Opens the lesson manager dialog + */ + //public function showLessonManagerDialog() { + // PopUpManager.createPopUp(Application.root, LFWindow, true,{title:Dictionary.getValue("lesson_dlg_title"),closeButton:true,scrollContentPath:'selectClass'}); + //} /** * Receives events from the Stage resizing Index: lams_central/src/flash/org/lamsfoundation/lams/monitoring/LessonManagerDialog.as =================================================================== diff -u --- lams_central/src/flash/org/lamsfoundation/lams/monitoring/LessonManagerDialog.as (revision 0) +++ lams_central/src/flash/org/lamsfoundation/lams/monitoring/LessonManagerDialog.as (revision e78b7795cb852851a59fdd8e5442305b89a752ee) @@ -0,0 +1,321 @@ +/*************************************************************************** + * 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 mx.controls.* +import mx.utils.* +import mx.managers.* +import mx.events.* + +import it.sephiroth.TreeDnd +import org.lamsfoundation.lams.common.ws.* +import org.lamsfoundation.lams.common.util.* +import org.lamsfoundation.lams.common.dict.* +import org.lamsfoundation.lams.common.style.* +import org.lamsfoundation.lams.common.* +import org.lamsfoundation.lams.monitoring.* +import org.lamsfoundation.lams.monitoring.mv.* +import org.lamsfoundation.lams.monitoring.mv.tabviews.* + +/* +* Lesson Manager Dialog window for selecting an organisation class +* @author DI +*/ +class LessonManagerDialog extends MovieClip implements Dialog{ + //References to components + clips + private var _container:MovieClip; //The container window that holds the dialog + private var cfg:Config; //local config reference + + private var ok_btn:Button; //OK+Cancel buttons + private var cancel_btn:Button; + + private var panel:MovieClip; //The underlaying panel base + + private var treeview:Tree; //Treeview for navigation through workspace folder structure + private var org_dnd:TreeDnd; + + private var staff_scp:MovieClip; // staff/teachers container + private var learner_scp:MovieClip; // learners container + + private var fm:FocusManager; //Reference to focus manager + private var themeManager:ThemeManager; //Theme manager + + //Dimensions for resizing + private var xOkOffset:Number; + private var yOkOffset:Number; + private var xCancelOffset:Number; + private var yCancelOffset:Number; + + private var _lessonTabView:LessonTabView; + private var _monitorModel:MonitorModel; + + private var _resultDTO:Object; + private var _selectedOrgId:Number; // selected organisation + + //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 + */ + function LessonManagerDialog(){ + //Set up this class to use the Flash event delegation model + EventDispatcher.initialize(this); + _resultDTO = new Object(); + + //Create a clip that will wait a frame before dispatching init to give components time to setup + this.onEnterFrame = init; + } + + /** + * Called a frame after movie attached to allow components to initialise + */ + private function init():Void{ + //Delete the enterframe dispatcher + delete this.onEnterFrame; + + + //set the reference to the StyleManager + themeManager = ThemeManager.getInstance(); + + // Set the styles + setStyles(); + + //Set the text for buttons + //ok_btn.label = Dictionary.getValue('lesson_dlg_ok'); + //cancel_btn.label = Dictionary.getValue('lesson_dlg_cancel'); + ok_btn.label = "ok"; + cancel_btn.label = "cancel"; + + + //Set the labels + + //get focus manager + set focus to OK button, focus manager is available to all components through getFocusManager + fm = _container.getFocusManager(); + fm.enabled = true; + ok_btn.setFocus(); + + //EVENTS + //Add event listeners for ok, cancel and close buttons + ok_btn.addEventListener('click',Delegate.create(this, ok)); + cancel_btn.addEventListener('click',Delegate.create(this, cancel)); + //Assign Click (close button) and resize handlers + _container.addEventListener('click',this); + _container.addEventListener('size',this); + + //work out offsets from bottom RHS of panel + xOkOffset = panel._width - ok_btn._x; + yOkOffset = panel._height - ok_btn._y; + xCancelOffset = panel._width - cancel_btn._x; + yCancelOffset = panel._height - cancel_btn._y; + + treeview = org_dnd.getTree(); + + } + + /** + * Called on initialisation + */ + private function setStyles(){ + //LFWindow, goes first to prevent being overwritten with inherited styles. + var styleObj = themeManager.getStyleObject('LFWindow'); + _container.setStyle('styleName',styleObj); + + //Get the button style from the style manager and apply to both buttons + styleObj = themeManager.getStyleObject('button'); + ok_btn.setStyle('styleName',styleObj); + cancel_btn.setStyle('styleName',styleObj); + + //Apply label style + styleObj = themeManager.getStyleObject('label'); + + } + + /** + * Event fired by StyleManager class to notify listeners that Theme has changed + * it is up to listeners to then query Style Manager for relevant style info + */ + public function themeChanged(event:Object):Void{ + if(event.type=='themeChanged') { + //Theme has changed so update objects to reflect new styles + setStyles(); + }else { + Debugger.log('themeChanged event broadcast with an object.type not equal to "themeChanged"',Debugger.CRITICAL,'themeChanged','org.lamsfoundation.lams.WorkspaceDialog'); + } + } + + /** + * Called by the cancel button + */ + private function cancel(){ + trace('Cancel'); + //close parent window + _container.deletePopUp(); + } + + /** + * Called by the OK button + */ + private function ok(){ + Debugger.log('OK Clicked',Debugger.GEN,'ok','org.lamsfoundation.lams.LessonManagerDialog'); + + _global.breakpoint(); + + var snode = treeview.selectedNode; + _selectedOrgId = Number(snode.attributes.data.organisationID); + + doOrganisationDispatch(); + } + + public function doOrganisationDispatch(){ + + var snode = treeview.selectedNode; + _resultDTO.selectedOrgID = Number(snode.attributes.data.resourceID); + + // add selected users to dto + + dispatchEvent({type:'okClicked',target:this}); + + closeThisDialogue(); + + } + + public function closeThisDialogue(){ + _container.deletePopUp(); + } + + /** + * If an alert was spawned by this dialog this method is called when it's closed + */ + private function alertClosed(evt:Object){ + //Should prefs dialog be closed? + //TODO DI 01/06/05 check for delete of dialog + //_container.deletePopUp(); + } + + /** + * Event dispatched by parent container when close button clicked + */ + public function click(e:Object):Void{ + trace('LessonManagerDialog.click'); + e.target.deletePopUp(); + } + + + /** + * Recursive function to set any folder with children to be a branch + * TODO: Might / will have to change this behaviour once designs are being returned into the mix + * @usage + * @param node + * @return + */ + private function setBranches(node:XMLNode){ + if(node.hasChildNodes() || node.attributes.isBranch){ + treeview.setIsBranch(node, true); + for (var i = 0; i