Index: lams_central/src/flash/org/lamsfoundation/lams/authoring/cv/PropertyInspectorNew.as
===================================================================
diff -u
--- lams_central/src/flash/org/lamsfoundation/lams/authoring/cv/PropertyInspectorNew.as	(revision 0)
+++ lams_central/src/flash/org/lamsfoundation/lams/authoring/cv/PropertyInspectorNew.as	(revision 7147848f90ca32d0bc45bbdab32ddc6f4e1e616e)
@@ -0,0 +1,966 @@
+/***************************************************************************
+ * 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.cv.*;
+import org.lamsfoundation.lams.authoring.*;
+import org.lamsfoundation.lams.common.util.*
+import org.lamsfoundation.lams.common.dict.*
+import org.lamsfoundation.lams.common.style.*
+import org.lamsfoundation.lams.common.ui.*
+import org.lamsfoundation.lams.common.*
+import mx.controls.*
+import mx.utils.*
+import mx.managers.*
+import mx.events.*
+/*
+*
+* @author      DC
+* @version     0.1
+* @comments    Property Inspector for the canvas
+* 
+*/
+class PropertyInspectorNew extends MovieClip{
+	
+	private var _canvasModel:CanvasModel;
+	private var _canvasController:CanvasController;
+	private var _dictionary:Dictionary;
+	 //References to components + clips 
+   	private var _piIsExpended:Boolean;
+	//private var PI_mc:MovieClip;
+    private var _tm:ThemeManager;
+    private var toolDisplayName_lbl:Label;
+	private var clickTarget_mc:MovieClip;
+	private var _depth:Number;
+	private var delimitLine:MovieClip;
+	
+	//Properties tab
+    private var title_lbl:Label;
+    private var title_txt:TextInput;
+    private var desc_lbl:Label;
+    private var desc_txt:TextInput;
+    private var piHeightHide:Number = 23;
+	private var piHeightFull:Number = 120;
+	private var grouping_lbl:Label;
+	private var grouping_opt_lbl:Label;
+	private var currentGrouping_lbl:Label;
+	private var appliedGroupingActivity_cmb:ComboBox;
+	private var appliedGroupingActivity_opt_cmb:ComboBox;
+	
+	private var editGrouping_btn:Button;
+    private var runOffline_chk:CheckBox;
+    private var defineLater_chk:CheckBox;
+	
+	//gates
+	private var gateType_lbl:Label;
+	private var gateType_cmb:ComboBox;
+	private var startOffset_lbl:Label;
+	private var endOffset_lbl:Label;
+	private var hours_lbl:Label;
+	private var mins_lbl:Label;
+	private var hoursEnd_lbl:Label;
+	private var minsEnd_lbl:Label;
+	private var hours_stp:NumericStepper;
+	private var mins_stp:NumericStepper;
+	private var endHours_stp:NumericStepper;
+	private var endMins_stp:NumericStepper;
+
+	//grouping 
+	private var groupType_lbl:Label;
+	private var numGroups_lbl:Label;
+	private var numLearners_lbl:Label;
+	private var groupType_cmb:ComboBox;
+	private var numGroups_rdo:RadioButton;
+	private var numLearners_rdo:RadioButton;
+	private var rndGroup_radio:RadioButtonGroup;
+	private var numGroups_stp:NumericStepper;
+	private var numRandomGroups_stp:NumericStepper;
+	private var numLearners_stp:NumericStepper;
+	
+	//Complex Activity
+	private var min_lbl:Label;
+	private var max_lbl:Label;
+	private var min_act:ComboBox;
+	private var max_act:ComboBox;
+	
+	//screen assets:
+	private var body_pnl:Label;
+	private var bar_pnl:Label;
+	
+	//Defined so compiler can 'see' events added at runtime by EventDispatcher
+    private var dispatchEvent:Function;     
+    public var addEventListener:Function;
+    public var removeEventListener:Function;
+	
+	
+	/**
+	 * Constructor
+	 */
+	public function PropertyInspectorNew(){
+		//register to recive updates form the model
+		Debugger.log('Constructor',Debugger.GEN,'PropertyInspectorNew','PropertyInspectorNew');
+		_tm = ThemeManager.getInstance();
+		//Set up this class to use the Flash event delegation model
+		EventDispatcher.initialize(this);
+		_dictionary = Dictionary.getInstance();
+		
+		//let it wait one frame to set up the components.
+		MovieClipUtils.doLater(Proxy.create(this,init));
+		
+		
+		//_dictionary.addEventListener('init',Proxy.create(this,setupLabels));
+	}
+	
+	public function init():Void{
+		
+		//var yPos:Number = 0;
+		//_depth = this.getNextHighestDepth();
+		//set SP the content path:
+		//PI_sp.contentPath = "empty_mc";
+		//PI_mc = PI_sp.content.attachMovie("PI_items","PI_items",_depth++);
+		
+		_canvasModel = _canvasModel;
+		_canvasController = _canvasController;
+		_piIsExpended = false;
+		_canvasModel.setPIHeight(piHeightHide);
+		//_global.breakpoint();
+		_canvasModel.addEventListener('viewUpdate',this);
+		clickTarget_mc.onRelease = Proxy.create (this, localOnRelease);
+		clickTarget_mc.onReleaseOutside = Proxy.create (this, localOnReleaseOutside);
+		//Debugger.log('_canvasModel: ' + _canvasModel,Debugger.GEN,'init','PropertyInspector');
+		
+		//set up handlers
+		title_txt.addEventListener("focusOut",this);
+		desc_txt.addEventListener("focusOut",this);
+		runOffline_chk.addEventListener("click",this);
+		defineLater_chk.addEventListener("click",this);
+		
+		rndGroup_radio.addEventListener("click",Delegate.create(this,onGroupingMethodChange));
+		groupType_cmb.addEventListener("change",Delegate.create(this,onGroupTypeChange));
+		gateType_cmb.addEventListener("change",Delegate.create(this,onGateTypeChange));
+		appliedGroupingActivity_cmb.addEventListener("change",Delegate.create(this,onAppliedGroupingChange));
+		appliedGroupingActivity_opt_cmb.addEventListener("change",Delegate.create(this,onAppliedGroupingChange));
+		hours_stp.addEventListener("change",Delegate.create(this,onScheduleOffsetChange));
+		mins_stp.addEventListener("change",Delegate.create(this,onScheduleOffsetChange));
+		hours_stp.addEventListener("focusOut",Delegate.create(this,onScheduleOffsetChange));
+		mins_stp.addEventListener("focusOut",Delegate.create(this,onScheduleOffsetChange));
+		endHours_stp.addEventListener("change",Delegate.create(this,onScheduleOffsetChange));
+		endMins_stp.addEventListener("change",Delegate.create(this,onScheduleOffsetChange));
+		endHours_stp.addEventListener("focusOut",Delegate.create(this,onScheduleOffsetChange));
+		endMins_stp.addEventListener("focusOut",Delegate.create(this,onScheduleOffsetChange));
+		numGroups_stp.addEventListener("change",Delegate.create(this,updateGroupingMethodData));
+		numLearners_stp.addEventListener("change",Delegate.create(this,updateGroupingMethodData));
+		numLearners_stp.addEventListener("focusOut",Delegate.create(this,updateGroupingMethodData));
+		numGroups_stp.addEventListener("focusOut",Delegate.create(this,updateGroupingMethodData));
+		numRandomGroups_stp.addEventListener("focusOut",Delegate.create(this,updateGroupingMethodData));
+		
+		dispatchEvent({type:'load',target:this});
+		this.onEnterFrame = setupLabels;
+		
+	}
+	
+	public function setupLabels(){
+		
+		//trace("I am in PI setupLabels")
+		//trace("PI_mc "+PI_mc)
+		toolDisplayName_lbl.text = ""+Dictionary.getValue('pi_title')+""
+		gateType_lbl.text = Dictionary.getValue('trans_dlg_gatetypecmb');
+		hours_lbl.text = Dictionary.getValue('pi_hours');
+		mins_lbl.text = Dictionary.getValue('pi_mins');
+		hoursEnd_lbl.text = Dictionary.getValue('pi_hours');
+		minsEnd_lbl.text = Dictionary.getValue('pi_mins');
+		startOffset_lbl.text = Dictionary.getValue('pi_start_offset');
+		endOffset_lbl.text = Dictionary.getValue('pi_end_offset');
+		
+		groupType_lbl.text = Dictionary.getValue('pi_group_type');
+		numGroups_lbl.text = Dictionary.getValue('pi_num_groups');
+		numLearners_lbl.text = Dictionary.getValue('pi_num_learners');
+		
+		//Properties tab
+		title_lbl.text = Dictionary.getValue('pi_lbl_title');
+		desc_lbl.text = Dictionary.getValue('pi_lbl_desc');
+		grouping_lbl.text = Dictionary.getValue('pi_lbl_group');
+		grouping_opt_lbl.text = Dictionary.getValue('pi_lbl_group');
+		currentGrouping_lbl.text = Dictionary.getValue('pi_lbl_currentgroup');
+		defineLater_chk.label = Dictionary.getValue('pi_definelater');
+		runOffline_chk.label = Dictionary.getValue('pi_runoffline');
+				
+		//Complex Activity
+		min_lbl.text = Dictionary.getValue('pi_min_act');
+		max_lbl.text = Dictionary.getValue('pi_max_act');
+		
+			//populate the synch type combo:
+		gateType_cmb.dataProvider = Activity.getGateActivityTypes();
+		groupType_cmb.dataProvider = Grouping.getGroupingTypesDataProvider();
+		
+		//Call to apply style to all the labels and input fields
+		setStyles();
+		
+		//fire event to say we have loaded
+		
+		delete this.onEnterFrame; 
+		//hide all the controls at startup
+		delimitLine._visible = false;
+		showGroupingControls(false);
+		showGeneralControls(false);
+		showOptionalControls(false);
+		showToolActivityControls(false);
+		showGateControls(false);
+		showAppliedGroupingControls(false);
+		
+		
+	}
+	
+	
+	public function localOnRelease():Void{
+		
+		if (_piIsExpended){
+			trace("P Pressed in 'localOnRelease' and _piIsExpended is: "+_piIsExpended)
+			_piIsExpended = false
+			_canvasModel.setPIHeight(piHeightHide);
+			
+		}else {
+			trace("P Pressed in 'localOnRelease' and _piIsExpended is: "+_piIsExpended)
+			_piIsExpended = true
+			_canvasModel.setPIHeight(piHeightFull);
+			//Application.getInstance().onResize();
+		}
+	}
+	
+	public function localOnReleaseOutside():Void{
+		Debugger.log('Release outside so no event has been fired, current state is: ' + _piIsExpended,Debugger.GEN,'localOnReleaseOutside','PropertyInspectorNew');
+		
+	}
+	/**
+	 * Recieves update events from the model.
+	 * @usage   
+	 * @param   event 
+	 * @return  
+	 */
+	public function viewUpdate(event:Object):Void{
+		Debugger.log('Recived an Event dispather UPDATE!, updateType:'+event.updateType+', target'+event.target,4,'viewUpdate','PropertyInspectorNew');
+		 //Update view from info object
+       
+       var cm:CanvasModel = event.target;
+	   
+	   switch (event.updateType){
+            case 'SELECTED_ITEM' :
+                updateItemProperties(cm);
+                break;
+                   
+				
+            default :
+                //Debugger.log('unknown update type :' + event.updateType,Debugger.CRITICAL,'update','org.lamsfoundation.lams.CanvasView');
+		}
+
+	}
+	
+	/**
+	 * Get called when something is selected in the cavas.
+	 * Updates the details in the property inspector widgets
+	 * Depending on the type of item selected, different controls will be shown
+	 * @usage   
+	 * @param   cm 
+	 * @return  
+	 */
+	private function updateItemProperties(cm:CanvasModel):Void{
+		//try to cast the selected item to see what we have (instance of des not seem to work)
+		if(CanvasActivity(cm.selectedItem) != null){
+			// its a Canvas activity then
+			Debugger.log('Its a canvas activity',4,'updateItemProperties','PropertyInspector');
+			var ca = CanvasActivity(cm.selectedItem);
+			var a:Activity = ca.activity;			
+			if(a.isGateActivity()){
+				//its a gate
+				delimitLine._visible = true;
+				showGroupingControls(false);
+				showToolActivityControls(false);
+				showOptionalControls(false);
+				showGateControls(true);
+				showAppliedGroupingControls(true);
+				//showGeneralProperties(a)
+				showGateActivityProperties(GateActivity(a));
+				checkEnableGateControls();
+				showAppliedGroupingProperties(a);
+				//show the title
+				title_txt.text = StringUtils.cleanNull(a.title);
+				desc_txt.text = StringUtils.cleanNull(a.description);
+				showGeneralControls(true);
+				//PI_sp.refreshPane();
+			}else if(a.isGroupActivity()){
+				//its a grouping activity
+				delimitLine._visible = true;
+				showGroupingControls(true);
+				showGeneralControls(true);
+				showOptionalControls(false);
+				showRelevantGroupOptions();
+				showToolActivityControls(false);
+				showGateControls(false);
+				showAppliedGroupingControls(true);
+				//showGeneralProperties(a)
+				populateGroupingProperties(GroupingActivity(a));
+				showAppliedGroupingProperties(a);
+				//show the title
+				title_txt.text = StringUtils.cleanNull(a.title);
+				desc_txt.text = StringUtils.cleanNull(a.description);
+				//PI_sp.refreshPane();
+			
+			}else{
+				//its a tool activity
+				delimitLine._visible = false;	
+				showOptionalControls(false);
+				showGeneralControls(true);
+				showGroupingControls(false);
+				showToolActivityControls(true);
+				showGateControls(false);
+				showAppliedGroupingControls(true);
+				showToolActivityProperties(ToolActivity(a));
+				//showGeneralProperties(a)
+				showAppliedGroupingProperties(a);
+				//show the title
+				title_txt.text = StringUtils.cleanNull(a.title);
+				desc_txt.text = StringUtils.cleanNull(a.description);
+				//PI_sp.refreshPane();
+			}
+
+			
+		}else if(CanvasOptionalActivity(cm.selectedItem) != null){
+			var co = CanvasOptionalActivity(cm.selectedItem);
+			var cca:ComplexActivity = ComplexActivity(co.activity);
+				//its an optional activity
+				delimitLine._visible = true;
+				showOptionalControls(true);
+				showGeneralControls(true);
+				showGroupingControls(false);
+				//showRelevantGroupOptions();
+				showToolActivityControls(false);
+				showGateControls(false);
+				showAppliedGroupingControls(true);
+				//showGeneralProperties(cca)
+				populateGroupingProperties(GroupingActivity(cca));
+				showAppliedGroupingProperties(cca);
+				showOptionalActivityProperties(cca);
+				//show the title
+				title_txt.text = StringUtils.cleanNull(cca.title);
+				desc_txt.text = StringUtils.cleanNull(cca.description);
+				//PI_sp.refreshPane();
+		}else if(CanvasParallelActivity(cm.selectedItem) != null){
+			var co = CanvasParallelActivity(cm.selectedItem);
+			var cca:ComplexActivity = ComplexActivity(co.activity);
+				delimitLine._visible = true;
+				//its an parallel activity
+				showOptionalControls(false);
+				showGeneralControls(true);
+				showGroupingControls(false);
+				//showRelevantGroupOptions();
+				showToolActivityControls(false);
+				showGateControls(false);
+				showAppliedGroupingControls(true);
+				//showGeneralProperties(cca)
+				populateGroupingProperties(GroupingActivity(cca));
+				showAppliedGroupingProperties(cca);
+				showParallelActivityProperties(cca);
+				//show the title
+				title_txt.text = StringUtils.cleanNull(cca.title);
+				desc_txt.text = StringUtils.cleanNull(cca.description);
+		}else if(CanvasTransition(cm.selectedItem) != null){
+			var ct = CanvasTransition(cm.selectedItem);
+			var t:Transition = ct.transition;
+				Debugger.log('Its a canvas transition',4,'updateItemProperties','PropertyInspector');
+				delimitLine._visible = false;
+				showTransitionProperties(t);
+				//showGeneralProperties(t)
+				showGeneralControls(false);
+				showOptionalControls(false);
+				showGroupingControls(false);
+				showToolActivityControls(false);
+				showGateControls(false);
+				showAppliedGroupingControls(false);
+				//PI_sp.complete;
+			
+		}else{
+				Debugger.log('Its a something we dont know',Debugger.CRITICAL,'updateItemProperties','PropertyInspector');
+				delimitLine._visible = false;
+				toolDisplayName_lbl.text = ""+Dictionary.getValue('pi_title')+""
+				showGroupingControls(false);
+				showGeneralControls(false);
+				showOptionalControls(false);
+				showRelevantGroupOptions();
+				showToolActivityControls(false);
+				showGateControls(false);
+				showAppliedGroupingControls(false);
+		
+				//PI_sp.complete
+		}
+	}
+	
+	private function showToolActivityControls(v:Boolean){
+		
+			
+		//desc_lbl.visible = v;
+		//desc_txt.visible = v;
+		grouping_lbl.visible = v;
+		currentGrouping_lbl.visible = v;
+		runOffline_chk.visible = v;
+		defineLater_chk.visible = v;
+		editGrouping_btn.visible = v;
+	}
+	
+	
+	private function showGeneralControls(v:Boolean){
+
+		title_lbl.visible = v;
+		title_txt.visible = v;
+	} 
+	
+	private function showOptionalControls(v:Boolean){
+		
+		min_lbl.visible = v;	
+		max_lbl.visible = v;
+		min_act.visible = v;
+		max_act.visible = v;
+		desc_lbl.visible = v;
+		desc_txt.visible = v;
+		grouping_opt_lbl.visible = v; 
+		appliedGroupingActivity_opt_cmb.visible = v;
+		
+		
+	}
+	
+	private function showGateControls(v:Boolean){
+		trace('showGateControls....'+v);
+		hours_lbl.visible = v;
+		mins_lbl.visible = v;
+		hoursEnd_lbl.visible = v;
+		minsEnd_lbl.visible = v;
+		hours_stp.visible = v;
+		mins_stp.visible = v;
+		endHours_stp.visible = v;
+		endMins_stp.visible = v;
+		gateType_lbl.visible = v;
+		gateType_cmb.visible = v;
+		startOffset_lbl.visible = v;
+		endOffset_lbl.visible = v;
+		
+	}
+	
+	/**
+	 * Shows or hides the app.lied grouping
+	 * AND title fields
+	 * @usage   
+	 * @param   v 
+	 * @return  
+	 */
+	private function showAppliedGroupingControls(v:Boolean){
+		//trace('show grp controls.....'+v);
+		grouping_lbl.visible = v;
+		appliedGroupingActivity_cmb.visible = v;
+		
+		
+		
+	}
+	
+	private function showGroupingControls(v:Boolean){
+		//grouping 
+		groupType_lbl.visible = v;
+		groupType_cmb.visible = v;
+		if(v){
+			showRelevantGroupOptions();
+		}else{
+			numGroups_lbl.visible = v;
+			numLearners_lbl.visible = v;
+			numGroups_rdo.visible = v;
+			numLearners_rdo.visible = v;
+			numGroups_stp.visible = v;
+			numRandomGroups_stp.visible = v;
+			numLearners_stp.visible = v;
+			
+		}
+		
+	}
+	
+	private function showToolActivityProperties(ta:ToolActivity){
+		
+		
+		toolDisplayName_lbl.text = ""+Dictionary.getValue('pi_title')+" - "+StringUtils.cleanNull(ta.toolDisplayName);
+		//title_txt.text = StringUtils.cleanNull(ta.title);
+		//desc_txt.text = StringUtils.cleanNull(ta.description);
+		runOffline_chk.selected = ta.runOffline;
+		defineLater_chk.selected = ta.defineLater;
+					
+		currentGrouping_lbl.text = "GroupingUIID:"+StringUtils.cleanNull(ta.runOffline.groupingUIID);
+			
+
+	}
+	
+	private function showGeneralProperties(ta:ToolActivity){
+		
+		//desc_txt.text = StringUtils.cleanNull(ta.description);
+	}
+	
+	private function showOptionalActivityProperties(ca:ComplexActivity){
+		
+	
+		toolDisplayName_lbl.text = ""+Dictionary.getValue('pi_title')+" - "+Dictionary.getValue('pi_optional_title');
+		//title_txt.text = StringUtils.cleanNull(ta.title);
+		//desc_txt.text = StringUtils.cleanNull(ta.description);
+		runOffline_chk.selected = ca.runOffline;
+		defineLater_chk.selected = ca.defineLater;
+					
+		currentGrouping_lbl.text = "GroupingUIID:"+StringUtils.cleanNull(ca.runOffline.groupingUIID);
+			
+
+	}
+	
+	private function showParallelActivityProperties(ca:ComplexActivity){
+		
+		
+		toolDisplayName_lbl.text = ""+Dictionary.getValue('pi_title')+" - "+Dictionary.getValue('pi_parallel_title');
+		//title_txt.text = StringUtils.cleanNull(ta.title);
+		//desc_txt.text = StringUtils.cleanNull(ta.description);
+		runOffline_chk.selected = ca.runOffline;
+		defineLater_chk.selected = ca.defineLater;
+					
+		currentGrouping_lbl.text = "GroupingUIID:"+StringUtils.cleanNull(ca.runOffline.groupingUIID);
+			
+
+	}
+	
+	private function showGateActivityProperties(ga:GateActivity){
+		toolDisplayName_lbl.text = ""+Dictionary.getValue('pi_title')+" - "+Dictionary.getValue('pi_activity_type_gate');
+		//loop through combo to find SI of our gate activity type
+		trace("gate Type is: "+ga.activityTypeID)
+		for (var i=0; i - "+Dictionary.getValue('pi_activity_type_grouping');
+		Debugger.log('This is the grouping object:',Debugger.GEN,'populateGroupingProperties','PropertyInspector');
+		ObjectUtils.printObject(g);
+		//loop through combo to fins SI of our gate activity type
+		for (var i=0; i