[virtualcommons-svn] SF.net SVN: virtualcommons:[161] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-06-13 23:20:32
|
Revision: 161 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=161&view=rev Author: kjonas Date: 2009-06-13 23:18:00 +0000 (Sat, 13 Jun 2009) Log Message: ----------- save():ArrayCollection and load(ArrayCollection):void methods have been written for each of the following: ForecastComponent.mxml PlannerPage.mxml CategoricalQuestionC.mxml PsychometricQuestionC.mxml TextQuestionC.mxml The methods have been tested by calling the save function, and then loading the resulting ArrayCollection, after modifying the component. The components were observed to return to the state in which they were saved, in terms of the data stored. (see: TestForecast.mxml for manipulation and fiddling.) Modified Paths: -------------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/Planner.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -2,14 +2,18 @@ <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> <mx:VBox id="content" minWidth="160"> + <comp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> <comp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> <comp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> <comp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> <mx:HBox> <mx:Button label="Save" click="save()"/> - <!--<mx:Button label="Load" click="load()"/>--> + <mx:Button label="Load" click="load()"/> </mx:HBox> + + <comp:PlannerPage id="planner"/> + </mx:VBox> <mx:Script> @@ -17,7 +21,8 @@ import mx.collections.ArrayCollection; import mx.controls.Alert; - public var saved:ArrayCollection = null; + public var forecastSaved:ArrayCollection = null; + public var plannerSaved:ArrayCollection = null; // try // { @@ -30,17 +35,16 @@ public function init():void { - //forecastComponent0.changed(); + } public function save():void { try { - saved = forecastComponent0.save(); - forecastComponent1.load(saved); - forecastComponent2.load(saved); - forecastComponent3.load(saved); + forecastSaved = forecastComponent0.save(); + + plannerSaved = planner.save(); } catch(error:Error) { @@ -52,7 +56,9 @@ { try { - forecastComponent1.load(saved); + forecastComponent1.load(forecastSaved); + + planner.load(plannerSaved); } catch(error:Error) { Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> + <mx:Script> <![CDATA[ import actionscript.FishUtil; @@ -9,6 +10,20 @@ return FishUtil.fix(index, list); } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(comboTopic.selectedIndex); + saveArray.addItem(comboSpecific.selectedIndex); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + comboTopic.selectedIndex = loadArray.getItemAt(0) as int; + comboSpecific.selectedIndex = loadArray.getItemAt(1) as int; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -23,7 +23,7 @@ numbers.removeChildAt(numbers.numChildren-1); } - public function addRow():void + public function addRow():PlannerRow { var newRow:PlannerRow = new PlannerRow(); newRow.valueRequired = this.valueRequired; @@ -33,6 +33,8 @@ grid.addChildAt(newRow, grid.numChildren); numbers.addChild(newNumber); + + return newRow; } public function getPlannerRow(index:Number):PlannerRow @@ -53,19 +55,40 @@ var list:ArrayCollection = new ArrayCollection([row.getLocation(), row.getDays(), row.getThreshold()]); return list; } - public function toArrayCollection():ArrayCollection + public function setPlannerList(index:Number, newValues:ArrayCollection):void { - var array:ArrayCollection = new ArrayCollection(); + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + row = addRow(); + } + row.setLocation(newValues.getItemAt(0) as String); + row.setDays(newValues.getItemAt(1) as Number); + row.setThreshold(newValues.getItemAt(2) as Number); + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); for(var index:Number = 0; index < grid.numChildren; index++) { - var temp:ArrayCollection = getPlannerList(index); - array.addItem(temp); + saveArray.addItem(getPlannerList(index)); } - return array; + return saveArray; } + public function load(loadArray:ArrayCollection):void + { + grid.removeAllChildren(); + numbers.removeAllChildren(); + for(var index:Number = 0; index < loadArray.length; index++) + { + setPlannerList(index, loadArray.getItemAt(index) as ArrayCollection); + } + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -35,16 +35,34 @@ import mx.collections.ArrayCollection; public function getNotRepeated():ArrayCollection - { return notRepeated.toArrayCollection(); } + { return notRepeated.save(); } public function getRepeated():ArrayCollection - { return repeated.toArrayCollection(); } + { return repeated.save(); } public function accept():Boolean { return true; } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(notRepeated.save()); + saveArray.addItem(repeated.save()); + saveArray.addItem(suspendWeight.value); + saveArray.addItem(suspendDays.value); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + notRepeated.load(loadArray.getItemAt(0) as ArrayCollection); + repeated.load(loadArray.getItemAt(1) as ArrayCollection); + suspendWeight.value = loadArray.getItemAt(2) as Number; + suspendDays.value = loadArray.getItemAt(3) as Number; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -28,10 +28,22 @@ } return "Bay " + location.selectedIndex; } + public function setLocation(newValue:String):void + { + if(newValue == "Harbor") location.selectedIndex = 0; + if(newValue == "Bay 1") location.selectedIndex = 1; + if(newValue == "Bay 2") location.selectedIndex = 2; + if(newValue == "Bay 3") location.selectedIndex = 3; + changedLocation(); + } public function getDays():Number { return days.value; } + public function setDays(newValue:Number):void + { + days.value = newValue; + } public function getThreshold():Number { if(location.selectedIndex == 0) @@ -40,6 +52,11 @@ } return threshold.value; } + public function setThreshold(newValue:Number):void + { + if(newValue == -1) return; + threshold.value = newValue; + } ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -84,6 +84,20 @@ } } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(slider1.sliderButton.visible); + saveArray.addItem(slider1.sliderButton.x); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + slider1.sliderButton.visible = loadArray.getItemAt(0) as Boolean; + slider1.sliderButton.move(loadArray.getItemAt(1) as Number, 0); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -10,7 +10,6 @@ [Embed(source="../images/SliderImage.png")] private var sliderImage:Class; - // Psychometric Variables - (Left = Positive, Right = Negative) public var maxValue:Number = 10; // Leftmost value public static var abstainValue:Number = -999; // Refusal to answer @@ -21,8 +20,7 @@ private var minValue:Number; // Rightmost value private var value:Number; // value selected - [Bindable] - public var getVal:Number; // (for binding: same value as last getValue() method call) + [Bindable] public var getVal:Number; // (for binding: same value as last getValue() method call) public var isBipolar:Boolean; // double slider = true, single slider = false // prepare Slider in default (abstain) position Deleted: mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - - <mx:Label id="header"/> - <mx:TextInput id="text"/> - -</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-12 23:08:38 UTC (rev 160) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-13 23:18:00 UTC (rev 161) @@ -1,12 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - <!--<mx:String id="title"></mx:String> - <mx:String id="description"></mx:String> - <mx:VBox id="headers" paddingBottom="-3"> - <mx:Label text="{title}" paddingBottom="-8"/> - <mx:Text text="{description}" paddingBottom="-8"/> - </mx:VBox>--> <mx:String id="title"></mx:String> <mx:String id="description"></mx:String> <mx:VBox id="headers"> @@ -25,23 +19,23 @@ <mx:Number id="txtWidth">200</mx:Number> <mx:Number id="txtHeight">24</mx:Number> <mx:String id="defaultText"/> - <mx:TextArea id="text" text="{defaultText}" width="{txtWidth}" height="{txtHeight}"/> + <mx:TextArea id="textAnswer" text="{defaultText}" width="{txtWidth}" height="{txtHeight}"/> <mx:Script> <![CDATA[ + import mx.collections.ArrayCollection; - public function back():Boolean + public function save():ArrayCollection { - return false; + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(textAnswer.text); + return saveArray; } - public function forward():Boolean + + public function load(loadArray:ArrayCollection):void { - return false; + textAnswer.text = loadArray.getItemAt(0) as String; } - public function accept():Boolean - { - return true; - } ]]> </mx:Script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |