Thread: [virtualcommons-svn] SF.net SVN: virtualcommons:[84] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-03-18 20:19:46
|
Revision: 84 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=84&view=rev Author: kjonas Date: 2009-03-18 20:19:28 +0000 (Wed, 18 Mar 2009) Log Message: ----------- DataGridHandler actionscript class added Added Paths: ----------- mentalmodels/trunk/flex/src/FisheryExperiment.mxml mentalmodels/trunk/flex/src/Forecasting.mxml mentalmodels/trunk/flex/src/MME.mxml mentalmodels/trunk/flex/src/Mental.mxml mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml mentalmodels/trunk/flex/src/Socio_demographic.mxml mentalmodels/trunk/flex/src/TableTest.mxml mentalmodels/trunk/flex/src/TestApp.mxml mentalmodels/trunk/flex/src/actionscript/ mentalmodels/trunk/flex/src/actionscript/ASResults.as mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/actionscript/RoundConfig.as mentalmodels/trunk/flex/src/customComponents/ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml mentalmodels/trunk/flex/src/customComponents/LongScale.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/PsychometricQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ShortHScale.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/customComponents/TimeLabel.mxml mentalmodels/trunk/flex/src/display.mxml Added: mentalmodels/trunk/flex/src/FisheryExperiment.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperiment.mxml (rev 0) +++ mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,162 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" + backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" + width="760" height="510" clipContent="false" layout="absolute" + currentState="instructions" initialize="init()"> + + <mx:states> + <mx:State name="instructions"> + <mx:AddChild relativeTo="{content}"> + <comp:InstructionPage id="instructions"/> + </mx:AddChild> + </mx:State> + + <mx:State name="socioDemographic"> + <mx:AddChild relativeTo="{content}"> + <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> + </mx:AddChild> + </mx:State> + + <mx:State name="planner"> + <mx:AddChild relativeTo="{content}"> + <comp:PlannerPage id="planner"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"/> + </mx:states> + + <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> + <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> + + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> + + <mx:Script> + <![CDATA[ + import mx.controls.Label; + import customComponents.*; + + private var shared:SharedObject; + private var flushMessage:String; + + public function init():void + { + var sharedObjTest:Boolean = false; + if(sharedObjTest) + { + var got:Boolean = getLocal(); + if(got) + { + getData().saved1 = "Hello, World!"; + getData().thisIsATest = 283; + + var testLabel:Label = new Label(); + testLabel.text = "This is a test"; + testLabel.x = getData().thisIsATest; + testLabel.y = getData().thisIsATest; + + testLabel.text += ", " +flushMessage+"x"+shared.toString()+"x"; + getData().testLabel = testLabel; + + if(getData().exists) testLabel.text += "SharedObject existed before initialization"; + else getData().exists = true; + + this.addChild(getData().testLabel); + } + } + } + public function getData():Object + { + return shared.data; + } + public function getLocal():Boolean + { + try{ + shared = SharedObject.getLocal("thisIsForWork"); + }catch(err:Error){ + return false; + } + return true; + } + public function flush():Boolean + { + try{ + flushMessage = shared.flush(10000); + }catch(err:Error){ + return false; + } + return true; + } + + public function back():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + (InstructionPage)(obj).back(); + } + return false; + } + + public function forward():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + (InstructionPage)(obj).forward(); + } + return false; + } + + public function accept():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + if( (InstructionPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "socioDemographic"; + return true; + } + } + if(obj is SocioDemographicPage) + { + if( (SocioDemographicPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "planner"; + return true; + } + } + if(obj is PlannerPage) + { + if( (PlannerPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "none"; + return true; + } + } + + return false; + } + + ]]> + </mx:Script> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/FisheryExperiment.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Forecasting.mxml =================================================================== --- mentalmodels/trunk/flex/src/Forecasting.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Forecasting.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:local="*" xmlns:comp="customComponents.*"> + <mx:Grid top="10" bottom="10" right="10" left="10"> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:VDividedBox width="100%" height="100%" id="vdboxOuter" liveDragging="false"> + <mx:VBox width="100%" height="50%" id="vboxLeftInnerDown" verticalGap="20"> + <mx:VBox width="100%" height="50%" id="vboxLeftInnerUpper" verticalGap="20"> + <mx:Image id="imgIsland" source="../libs/island.png"/> + <mx:ComboBox width="50%" id="cmbUpper"></mx:ComboBox> + </mx:VBox> + <mx:TextArea width="50%" height="70%"/> + <mx:ComboBox width="50%"></mx:ComboBox> + </mx:VBox> + </mx:VDividedBox> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:VBox width="100%" height="100%" id="vboxRightSideMainContainer" verticalGap="10"> + <mx:VBox width="100%" height="20%" id="vboxRightInnerUpper" verticalGap="20"> + <mx:Form width="100%" height="8%" id="frmGeneralInfoOfPlayer_Time"> + <mx:FormItem label="Clock" horizontalAlign="right" fontSize="14" fontWeight="bold"> + <!-- <mx:Text id="txtclock" text="10:50"/> --> + <comp:TimeLabel/> + </mx:FormItem> + <mx:FormItem label="Round Number:" horizontalAlign="right" fontSize="14" fontWeight="bold"> + <mx:Text id="txtroundno" text="1"/> + </mx:FormItem> + <mx:FormItem label="You Are Player Number:" fontSize="14" fontWeight="bold"> + <mx:Text id="txtplayerno" text="2"/> + </mx:FormItem> + <mx:FormItem label="You Are in Group Number:" fontSize="14" fontWeight="bold"> + <mx:Text id="txtgroupno" text="3"/> + </mx:FormItem> + + </mx:Form> + <mx:ProgressBar id="progressbarRoundInfo" label="Round" width="100%" height="10%" minimum="0" maximum="100" indeterminate="false" enabled="true"/> + </mx:VBox> + <mx:VBox width="100%" height="70%" id="vboxRightInnerDown" verticalGap="20"> + <mx:Form width="100%" height="90%" id="frmSurvey"> + <mx:FormHeading label="Survey Questions"/> + <mx:TextArea id="txtaSurvey" width="100%" height="100%" wordWrap="true"/> + </mx:Form> + <mx:HBox width="100%" height="10%" id="hboxButtons" horizontalAlign="center" horizontalGap="20" verticalAlign="middle"> + <mx:Button label="Previous" fontSize="14" id="btnPrevious"/> + <mx:Button label="Next" fontSize="14" id="btnNext"/> + </mx:HBox> + </mx:VBox> + </mx:VBox> + </mx:GridItem> + </mx:GridRow> + </mx:Grid> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/Forecasting.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/MME.mxml =================================================================== --- mentalmodels/trunk/flex/src/MME.mxml (rev 0) +++ mentalmodels/trunk/flex/src/MME.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" + backgroundGradientAlphas="[1.0, 1.0]" + backgroundGradientColors="[#9DDBED, #BFED9D]" + xmlns:ns1="*" + pageTitle="Fishery Experiment"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import actionscript.RoundConfig; + + // request config data from server + private var rndConfig:RoundConfig = getConfig(); + + public function getConfig():RoundConfig + { + // temporary fix: + return new RoundConfig( 1, + new ArrayCollection([0.5, 0.15, 0.05]), + new ArrayCollection([10, 20, 30]), + new ArrayCollection([5, 10, 15])); + } + + ]]> + </mx:Script> + + <mx:states> + <mx:State name="forecasting"> + <mx:RemoveChild target="{socio_demographic_information1}"/> + <mx:RemoveChild target="{hbox1}"/> + <mx:AddChild relativeTo="{containerContent}" position="lastChild"> + <ns1:Forecasting top="10" bottom="10" right="10" left="10" id="forecasting1"> + </ns1:Forecasting> + </mx:AddChild> + </mx:State> + </mx:states> + <mx:Canvas left="10" right="10" bottom="10" top="10" id="containerMain" label="OutsideContainer"> + <mx:VBox right="10" top="10" bottom="10" left="10"> + <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle" id="hboxheading"> + <mx:Label text="Fishery Experiment" id="lblHeading" enabled="true" fontSize="36" textAlign="center" fontWeight="bold" color="#4D992C"/> + </mx:HBox> + <mx:Canvas width="100%" height="90%" id="containerContent"> + <ns1:Socio_Demographic_Information top="10" left="10" right="0" bottom="10" id="socio_demographic_information1"> + </ns1:Socio_Demographic_Information> + + <mx:HBox x="42" width="100%" height="10%" verticalAlign="bottom" horizontalAlign="center" bottom="5" id="hbox1"> + <mx:Button label="Submit" id="btnSubmit_Socio_Demographic_Info" click="currentState='forecasting'" fontSize="12"/> + </mx:HBox> + </mx:Canvas> + <mx:HBox width="100%" id="hboxfooter" horizontalAlign="center" verticalAlign="bottom"> + <mx:Text text="School of Human Evolution & Social Change + Tempe, AZ 85287-2402 + T: 480-965-6213 / Fax: 480-965-7671" + id="txtFooter"/> + </mx:HBox> + </mx:VBox> + </mx:Canvas> +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/MME.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Mental.mxml =================================================================== --- mentalmodels/trunk/flex/src/Mental.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Mental.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#ACD1EE, #D989E5]"> + <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> + + + <mx:VBox height="100%" id="vboxGatherInfo"> + <mx:HBox width="100%" id="hboxSubHeading"> + <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> + </mx:HBox> + <mx:RadioButtonGroup id="radiogroupGender"/> + <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle"> + <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButtonGroup id="radiogroup1Gender"/> + <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> + </mx:HBox> + <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="left" verticalAlign="middle"> + <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbBirthYear" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for the range: make combo box as text box 4 digit --> + <mx:Array> + <mx:String>1980</mx:String> + <mx:String>1981</mx:String> + <mx:String>1982</mx:String> + <mx:String>1983</mx:String> + <mx:String>1984</mx:String> + <mx:String>1985</mx:String> + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle"> + <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> + <mx:TextInput id="txtMajor" editable="true" enabled="true"/> + + + </mx:HBox> + + <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle"> + <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbEthnicity" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for this one also --> + <mx:Array> + <mx:String>Freshman</mx:String> + <mx:String>Sophomore</mx:String> + <mx:String>Junior</mx:String> + <mx:String>Senior</mx:String> + + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> + <mx:Button label="Submit" id="butSubmit"/> + </mx:HBox> + + </mx:VBox> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/Mental.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="698" height="407" textAlign="center"> + <mx:VBox id="vboxouterBox" horizontalAlign="center" verticalAlign="middle" width="100%" height="50%" horizontalCenter="0" top="10" verticalGap="0"> + + + <mx:Form top="5" bottom="5" id="frmSocioDemographic" right="5" left="5" width="50%" height="50%" textAlign="center"> + <mx:FormHeading label="Socio DemographicInformation " id="frmheadingSocioDemographicInfo" fontSize="24" textAlign="left" themeColor="#1200FF" color="#186BE8" width="5%" height="10%"/> + <mx:FormItem id="frmitemStudy" horizontalAlign="left" fontSize="14" required="true"> + <mx:Label text="What year are you in your study?"/> + <mx:RadioButton id="freshman" groupName="study"> + <mx:label>Freshman</mx:label> + </mx:RadioButton> + <mx:RadioButton id="sophomore" groupName="study"> + <mx:label>Sophomore</mx:label> + </mx:RadioButton> + <mx:RadioButton id="junior" groupName="study"> + <mx:label>Junior</mx:label> + </mx:RadioButton> + <mx:RadioButton id="senior" groupName="study"> + <mx:label>Senior</mx:label> + </mx:RadioButton> + + </mx:FormItem> + <mx:FormItem label="What is your major?" id="frmitemMajor" horizontalAlign="left" fontSize="14" required="true"> + <mx:TextInput id="txtipMajor"/> + </mx:FormItem> + <mx:FormItem label="Year of Birth" id="frmitemYOB" horizontalAlign="left" fontSize="14" required="true"> + <mx:TextInput id="txtipYOB" maxChars="4"/> + </mx:FormItem> + <mx:FormItem label="Gender" id="frmitemGender" horizontalAlign="left" fontSize="14" required="true"> + <mx:RadioButton id="male" groupName="gender"> + <mx:label>Male</mx:label> + </mx:RadioButton> + <mx:RadioButton id="female" groupName="gender"> + <mx:label>Female</mx:label> + </mx:RadioButton> + + </mx:FormItem> + + </mx:Form> + + + </mx:VBox> +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/Socio_Demographic_Information.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/Socio_demographic.mxml =================================================================== --- mentalmodels/trunk/flex/src/Socio_demographic.mxml (rev 0) +++ mentalmodels/trunk/flex/src/Socio_demographic.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="80%"> + + + + + <mx:VBox height="100%" id="vboxGatherInfo" width="100%"> + <mx:HBox horizontalAlign="center" verticalAlign="middle" id="hboxSocio_demographic_info"> + <mx:Label text="Socio-demographic Information" id="lblHeading" enabled="true" fontSize="16" color="#230869" textAlign="center" fontWeight="bold"/> + </mx:HBox> + <mx:HBox width="100%" id="hboxSubHeading"> + <mx:Label text="Before starting the actual experiment, we would like to ask you for some general information." id="lblSubHeading" fontFamily="Verdana" fontSize="12" height="5%" fontWeight="bold" color="#0D18A9"/> + </mx:HBox> + <mx:RadioButtonGroup id="radiogroupGender"/> + <mx:HBox width="100%" id="hboxGender" label="Gender" height="5%" verticalAlign="middle" horizontalAlign="center"> + <mx:Label text="Gender:" id="lblGender" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButtonGroup id="radiogroup1Gender"/> + <mx:RadioButton label="Female" groupName="radiogroupGender" id="radioFemale" fontFamily="Verdana" fontSize="12"/> + <mx:RadioButton label="Male" groupName="radiogroup1Gender" id="radioMale" fontFamily="Verdana" fontSize="12"/> + </mx:HBox> + <mx:HBox width="100%" id="hboxBirthYear" height="5%" horizontalAlign="center" verticalAlign="middle"> + <mx:Label text="Year of Birth:" id="lblBirthYear" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbBirthYear" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for the range: make combo box as text box 4 digit --> + <mx:Array> + <mx:String>1980</mx:String> + <mx:String>1981</mx:String> + <mx:String>1982</mx:String> + <mx:String>1983</mx:String> + <mx:String>1984</mx:String> + <mx:String>1985</mx:String> + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" id="hboxStudySubject" height="5%" verticalAlign="middle" horizontalAlign="center"> + <mx:Label text="What is your major?" id="lblStudySubject" fontFamily="Verdana" fontSize="12"/> + <mx:TextInput id="txtMajor" editable="true" enabled="true"/> + + + </mx:HBox> + + <mx:HBox width="100%" id="hboxethnicity" height="5%" verticalAlign="middle" horizontalAlign="center"> + <mx:Label text="In which year your are you in your study?" id="lblEthnicity" fontFamily="Verdana" fontSize="12"/> + <mx:ComboBox id="cmbEthnicity" fontSize="12"> + <mx:dataProvider> + <!-- Ask Robert for this one also --> + <mx:Array> + <mx:String>Freshman</mx:String> + <mx:String>Sophomore</mx:String> + <mx:String>Junior</mx:String> + <mx:String>Senior</mx:String> + + </mx:Array> + + </mx:dataProvider> + + </mx:ComboBox> + + + </mx:HBox> + <mx:HBox width="100%" height="5%" id="hboxSubmit" verticalAlign="middle" horizontalAlign="center"> + <mx:Button label="Submit" id="butSubmit"/> + </mx:HBox> + + </mx:VBox> + + + +</mx:Canvas> Added: mentalmodels/trunk/flex/src/TableTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/TableTest.mxml (rev 0) +++ mentalmodels/trunk/flex/src/TableTest.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="absolute"> + + <mx:VBox> + <mx:HBox> + <comp:Forecast id="legacy" numColumns="10"/> + <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> + <comp:Forecast2 id="forecastFull" numColumns="6" oldForecast1="{this.forecastPeople}"/> + </mx:HBox> + <mx:Label initialize="init()"/> + </mx:VBox> + + <mx:Script> + <![CDATA[ + import mx.messaging.channels.StreamingAMFChannel; + import customComponents.*; + import mx.collections.ArrayCollection; + + public function init():void + { + var X:String="X"; + forecastPeople.setItem(0,0,X); + forecastPeople.setItem(1,1,X); + forecastPeople.setItem(2,2,X); + } + + ]]> + </mx:Script> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/TableTest.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/TestApp.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestApp.mxml (rev 0) +++ mentalmodels/trunk/flex/src/TestApp.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*" + width="700" height="500"> + + <comp:LongHScale id="slider1" label="blah"/> + <mx:Label id="slideinfo1" text="{slider1.slider.value}"/> + + <comp:ShortHScale id="slider2"/> + <mx:Label id="slideinfo2" text="{slider2.slider.value}"/> + + <mx:Label/> + <mx:Label/> + <mx:Label/> + + <mx:ArrayCollection id="slider3Labels"> + <mx:String>label1</mx:String> + <mx:String>label2</mx:String> + <mx:String>label3</mx:String> + </mx:ArrayCollection> + + <mx:ArrayCollection id="slider4Labels"> + <mx:String>label1</mx:String> + <mx:String>label2</mx:String> + </mx:ArrayCollection> + + <comp:PsychometricQuestion id="slider3" labels="{slider3Labels}"/> + <mx:Label id="slideinfo3" text="{slider3.slider.getVal}"/> + + <comp:PsychometricQuestion id="slider4" labels="{slider4Labels}"/> + <mx:Label id="slideinfo4" text="{slider4.slider.getVal}"/> + +</mx:Application> Property changes on: mentalmodels/trunk/flex/src/TestApp.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/actionscript/ASResults.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASResults.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASResults.as 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,18 @@ +package actionscript +{ + import mx.messaging.channels.StreamingHTTPChannel; + + public class ASResults + { + public function ASResults() + { + } + public function calculateString():String + { + var greeting:String; + greeting="Welcome Kalin!!"; + return String(greeting); + } + + } +} \ No newline at end of file Property changes on: mentalmodels/trunk/flex/src/actionscript/ASResults.as ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,225 @@ +// ActionScript file +package actionscript +{ + import mx.collections.ArrayCollection; + import mx.controls.DataGrid; + + [Bindable] + public class DataGridHandler + { + private var myDataGrid:DataGrid; + private var myProvider:ArrayCollection; + + private var errorMessage:String = ""; + + private var numFields:Number; + private var numCols:Number; + private var minValue:Number; + private var maxValue:Number; + private var sumOfEachColumn:Number; + + + public function get grid():DataGrid + { return myDataGrid; } + public function set grid(newValue:DataGrid):void + { myDataGrid = newValue; } + public function get dataProvider():ArrayCollection + { return myProvider; } + public function set dataProvider(newValue:ArrayCollection):void + { myProvider = newValue; } + + public function get errorMessage():String + { return errorMessage; } + public function set errorMessage(newValue:String):void + { errorMessage = newValue; } + + public function get numFields():Number + { return numFields; } + public function set numFields(newValue:Number):void + { numFields = newValue; } + public function get numCols():Number + { return numCols; } + public function set numCols(newValue:Number):void + { numCols = newValue; } + public function get minValue():Number + { return minValue; } + public function set minValue(newValue:Number):void + { minValue = newValue; } + public function get maxValue():Number + { return maxValue; } + public function set maxValue(newValue:Number):void + { maxValue = newValue; } + public function get sumOfEachColumn():Number + { return sumOfEachColumn; } + public function set sumOfEachColumn(newValue:Number):void + { sumOfEachColumn = newValue; } + + public function DataGridHandler(fields:Number, cols:Number, min:Number = 0, max:Number = 9999, colSum:Number = -1) + { + numFields = fields; + numCols = cols; + minValue = min; + maxValue = max; + sumOfEachColumn = colSum; + + createGrid(); + } + + public function getItem(field:Number, col:Number):Object + { + return myProvider.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + myProvider.getItemAt(field)["day"+(col+1)] = value; + } + + private function createGrid() + { + var tempArray:Array = myDataGrid.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + myDataGrid.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + myProvider.addItem(field); + } + + myDataGrid.height = (23)*(numFields+1)+2; + } + + public function clone():DataGrid + { + var dgClone:DataGrid = new DataGrid(); + var myProviderClone:ArrayCollection = new ArrayCollection(); + dgClone.dataProvider = myProviderClone; + + var tempArray:Array = dgClone.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dgClone.columns = tempArray; + + // fill data + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + myProviderClone.addItem(field); + for(var k:Number=0; k<numColumns; k++) + { + myProviderClone.getItemAt(j)["day"+(k+1)] = getItem(j,k); + } + } + + dgClone.height = (23)*(numFields+1)+2; + + return dgClone; + } + + public function changed():void + { + markNoError(); + errorMessage = "Complete." + + var error:Boolean = false; + var value:Object; + + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + value = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + + // if no other errors yet, and there is a required sum for columns, + // then check actual sum against expected + if( ! (error || sumOfEachColumn == -1 || colSum == sumOfEachColumn) ) + { + errorMessage = "Sum of all columns must be exactly "+sumOfEachColumn+"."; + error = true; + markError(-1,col); + } + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + //the entire string must be consecutive digits + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#3333FF"); + myDataGrid.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + myDataGrid.selectedIndex = -1; + } + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/RoundConfig.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/RoundConfig.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/RoundConfig.as 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,34 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + public class RoundConfig + { + private var number:Number; // what round is it? + + // bay information + private var bayRegen:ArrayCollection; + private var bayMax:ArrayCollection; + private var bayStart:ArrayCollection; + + public function RoundConfig(number:Number, bayRegen:ArrayCollection, bayMax:ArrayCollection, bayStart:ArrayCollection) + { + this.number = number; + this.bayRegen = bayRegen; + this.bayMax = bayMax; + this.bayStart = bayStart; + } + + public function getRegen():ArrayCollection + { return this.bayRegen; } + + public function getMax():ArrayCollection + { return this.bayMax; } + + public function getStart():ArrayCollection + { return this.bayStart; } + + public function getNumber():Number + { return this.number; } + } +} \ No newline at end of file Property changes on: mentalmodels/trunk/flex/src/actionscript/RoundConfig.as ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:ArrayCollection id="sched"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" + horizontalScrollPolicy="on" + verticalScrollPolicy="off"/> + <mx:Button label="{dgMain.columns.length}" click="clicked()"/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + private var colIndex:Number=0; + [Bindable] + public var numColumns:Number = 3; + [Bindable] + public var numFields:Number = 6; + [Bindable] + public var finished:Boolean = false; + + public function init():void + { + createColumns(); + + /* dgMain.selectedIndex = 0; dgMain.selectedItem.day1 = 5; + dgMain.selectedIndex = 1; dgMain.selectedItem.day1 = 10; + dgMain.selectedIndex = 2; dgMain.selectedItem.day1 = 15; + dgMain.selectedIndex = -1; */ + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dgMain.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = false; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + if(0 == i) + { + temp.editable = true; + } + + tempArray[i] = temp; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + if(0 == i) + { + var field:Object = new Object(); + sched.addItem(field); + } + } + } + dgMain.columns = tempArray; + + dgMain.height = 23*(numFields+1)+17 + dgMain.width = 30*Math.min(numColumns, 6)+1 + } + + public function clicked():void + { + for(var i:Number = 0; i < numFields; i++) + { +// dgMain.selectedIndex = i; +// dgMain.selectedItem.day2 = Number(dgMain.selectedItem.day1)*0; + var num:Object = getItem(i, colIndex); + var col:DataGridColumn = dgMain.columns[colIndex]; + if(num == null || !(num is Number)) + { + col.setStyle("backgroundColor", "#FF0000"); + break; + } + else + { + col.setStyle("backgroundColor", "#FFFFFF"); + } + } + // all numbers in the current column are actually numbers + // after executing the above loop + +// dgMain.selectedItem.day3 = "success"; + if(i >= numFields) + { + changeColumn(); + dgMain.selectedIndex = -1; + } + } + + public function getItem(field:Number, col:Number):Object + { + return sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + sched.getItemAt(field)["day"+(col+1)] = value; + } + + private function changeColumn():void + { + DataGridColumn(dgMain.columns[colIndex]).editable = false; + colIndex++; + if(colIndex == numColumns) + { + colIndex--; + finished = true; + } + DataGridColumn(dgMain.columns[colIndex]).editable = true; + } + + public function changed():void + { + // check the values of the current column + // and point out any errors (TextBox) + } + + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + //return Number(n) < minValue || Number(n) > maxValue; + return false; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Forecast.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:ArrayCollection id="sched"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()"/> + </mx:HBox> + + <mx:Label id="lbl"/> + <mx:Label id="debug"/> + + <mx:Script> + <![CDATA[ + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 15; + [Bindable] + public var numFields:Number = 4; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 10; + + private var errorMessage:String = null; + + //not used + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + } + private function createColumns():void + { + var tempArray:Array = dgMain.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dgMain.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + sched.addItem(field); + } + + dgMain.height = (23)*(numFields+1)+2; + } + + public function getItem(field:Number, col:Number):Object + { + return sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + sched.getItemAt(field)["day"+(col+1)] = value; + } + + public function changed():void + { + markNoError(); + + var error:Boolean = false; + var value:Object; + + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + value = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + } + + if(error) + { + lbl.text = errorMessage; + } + else + { + lbl.text = "Complete."; + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + dgMain.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dgMain.selectedIndex = -1; + } + + public function clone():DataGrid + { + var dgClone:DataGrid = new DataGrid(); + var schedClone:ArrayCollection = new ArrayCollection(); + dgClone.dataProvider = schedClone; + + var tempArray:Array = dgClone.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = true; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + tempArray[i] = temp; + } + + dgClone.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + schedClone.addItem(field); + for(var k:Number=0; k<numColumns; k++) + { + schedClone.getItemAt(j)["day"+(k+1)] = getItem(j,k); + } + } + + dgClone.height = (23)*(numFields+1)+2; + + return dgClone; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,211 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" creationComplete="init()"> + + <mx:ArrayCollection id="sched"/> + <mx:ArrayCollection id="schedPeople"/> + <mx:ArrayCollection id="calculated"/> + + <comp:Forecast1 id="newForecast1" visible="false" includeInLayout="false"/> + + <mx:HBox> + <mx:VBox id="labels"> + </mx:VBox> + + <mx:VBox id="dgRows" verticalGap="0"> + <mx:HBox id="dgRow1" horizontalGap="0"> + <mx:DataGrid id="dgMain" + editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/> + </mx:HBox> + + <mx:HBox id="dgRow2"> + <!--<mx:DataGrid id="dgPeople" + editable="false" textAlign="right" dataProvider="{schedPeople}" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/>--> + </mx:HBox> + + <mx:HBox id="dgRow3"> + <mx:DataGrid id="dgCalculated" headerHeight="1" + editable="false" textAlign="right" dataProvider="{calculated}" + width="300" horizontalScrollPolicy="off" + verticalScrollPolicy="off"/> + </mx:HBox> + </mx:VBox> + </mx:HBox> + + <mx:Label id="lbl"/> + + + <mx:Script> + <![CDATA[ + import mx.controls.Button; + import mx.utils.StringUtil; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] + public var numColumns:Number = 5; + [Bindable] + public var numFields:Number = 3; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 50; + [Bindable] + public var oldForecast1:Forecast1 = null; + + private var errorMessage:String = null; + private var colIndex:Number=0; + private var finished:Boolean = false; + + public function init():void + { + createColumns(); + getPeople(); + + setItem(0,0,5); + setItem(1,0,10); + setItem(2,0,15); + } + private function createColumns():void + { + var tempArray:Array = dgMain.columns; + var i:Number; + var temp:DataGridColumn; + + for(i=0; i<numColumns; i++) + { + temp = new DataGridColumn("day"+(i+1)); + + temp.headerText = ""+(i+1); + temp.dataField = "day"+(i+1); + temp.editable = false; + temp.draggable = false; + temp.sortable = false; + temp.resizable = false; + temp.width = 30; + + if(0 != i) + { + temp.editable = true; + } + + tempArray[i] = temp; + } + + dgMain.columns = tempArray; + + // add day1, day2, etc to each field + for(var j:Number=0; j<numFields; j++) + { + var field:Object = new Object(); + sched.addItem(field); + } + + dgMain.height = (23)*(numFields+1)+2; + } + + public function getPeople():void + { + if(oldForecast1 == null) + { + setItem(0,1,1); + dgRow2.addChild(newForecast1.dgMain); + setItem(1,1,2); + } + else + { + setItem(0,2,3); + dgRow2.addChild(oldForecast1.clone()); + setItem(1,2,4); + } + } + + public function getItem(field:Number, col:Number):Object + { + return this.sched.getItemAt(field)["day"+(col+1)]; + } + public function setItem(field:Number, col:Number, value:Object):void + { + this.sched.getItemAt(field)["day"+(col+1)] = value; + } + + public function changed():void + { + markNoError(); + + var error:Boolean = false; + // check the values of the current column + // and point out any errors (TextBox) + for(var col:Number=0; col < numColumns && !error; col++) + { + var colStr:String = "day"+(col+1); + var colSum:Number = 0; + for(var field:Number=0; field < numFields && !error; field++) + { + var value:Object = getItem(field, col); + if(invalidNum(value)) + { + errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else if(outOfBoundsNum(value)) + { + errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; + error = true; + markError(field,col); + } + else + { + colSum += Number(value); + } + } + } + + if(error) + { + lbl.text = errorMessage; + } + else + { + lbl.text = "Complete."; + } + } + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < minValue || Number(n) > maxValue; + } + + private function markError(field:Number, col:Number):void + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + dgMain.selectedIndex = field; + } + private function markNoError():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + } + dgMain.selectedIndex = -1; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + [Bindable] + public var numPages:Number; //temporary hard-coded value *fix this* + + // Contains ArrayCollections filled with DisplayObjects + // *see: getDisp(pageNum, index) + private var allPageList:ArrayCollection; + + // Variables with default settings + [Bindable] + public var currPageNumber:Number = 0; + public var pagesRead:Number = 1; + + public function init():void + { + numPages = loadAllPages(); + showPage(); + } + + public function loadAllPages():Number + { + allPageList = new ArrayCollection(); + // load allPageList from file - return length + var done:Boolean = false; + do + { + var tempPage:ArrayCollection = new ArrayCollection(); + + var doneItems:Boolean = false; + do + { + var tempItem:DisplayObject = new PsychometricQuestion(); + ((PsychometricQuestion)(tempItem)).labels = new ArrayCollection(["Big", "Small"]); + + tempPage.addItem(tempItem); + doneItems = true; + }while(!doneItems) + + allPageList.addItem(tempPage); + done = true; + }while(!done) + + return allPageList.length; + } + + private function getPage(pageNum:Number):ArrayCollection + { + if(pageNum < 0 || allPageList == null || pageNum >= allPageList.length) + { return null; } + + return (ArrayCollection)(allPageList.getItemAt(pageNum)); + } + + private function getDisp(pageNum:Number, index:Number):DisplayObject + { + var tempList:ArrayCollection = getPage(pageNum); + + if(tempList == null || index < 0 || index >= tempList.length) + { return null; } + + return (DisplayObject)(tempList.getItemAt(index)); + } + public function showPage():Boolean + { + try + { + var list:ArrayCollection = getPage(currPageNumber); + for(var index:Number = 0; index < list.length; index++) + { + content.addChild(getDisp(currPageNumber, index)); + } + + if(currPageNumber >= pagesRead) + { + pagesRead = currPageNumber+1; + } + return true; + } + catch(error:Error) + {} + return false; + } + + private function fixNum():Boolean + { + if(currPageNumber < 0) + { + currPageNumber = 0; + return false; + } + if(currPageNumber >= numPages) + { + currPageNumber = numPages - 1; + return false; + } + return showPage(); + } + + public function back():Boolean + { + currPageNumber--; + return fixNum(); + } + + public function forward():Boolean + { + currPageNumber++; + return fixNum(); + } + + public function accept():Boolean + { + return pagesRead >= numPages; + } + + ]]> + </mx:Script> + + <mx:Label text="{currPageNumber+1} / {numPages}"/> + + <mx:VBox id="content"/> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30"> + + <mx:Image source="../libs/LongScale.jpg" y="0"/> + + <mx:HSlider xmlns:mx="http://www.adobe.com/2006/mxml" id="slider" + width="495" height="20" y="0" + minimum="-15" maximum="15" snapInterval="1" value="0" + allowTrackClick="true" + fillAlphas="[1.0, 1.0]" fillColors="[#20B4D4, #20B4D4]" alpha="1.0"/> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/customComponents/LongHScale.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/LongScale.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/LongScale.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/LongScale.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" + width="500" height="30" layout="absolute"> + + <mx:Image x="10" y="0" source="../libs/LongSlider.jpg" /> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/customComponents/LongScale.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Planner.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Planner.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()" + width="350" height="200" + borderStyle="solid" verticalScrollPolicy="off" horizontalScrollPolicy="off"> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + + public var valueRequired:Boolean = false; + + private function init():void + { + if(valueRequired) + { + addRow(); + } + } + + public function childRemoved():void + { + numbers.removeChildAt(numbers.numChildren-1); + } + + public function addRow():void + { + var newRow:PlannerRow = new PlannerRow(); + newRow.valueRequired = this.valueRequired; + var newNumber:Label = new Label(); + newNumber.text = "" + (numbers.numChildren+1); + newNumber.height = 22; + + grid.addChildAt(newRow, grid.numChildren); + numbers.addChild(newNumber); + } + + public function getPlannerRow(index:Number):PlannerRow + { + if(index < grid.numChildren && index >= 0) + { + return (PlannerRow)(grid.getChildAt(index)); + } + return null; + } + public function getPlannerList(index:Number):ArrayCollection + { + var row:PlannerRow = getPlannerRow(index); + if(row == null) + { + return null; + } + var list:ArrayCollection = new ArrayCollection([row.getLocation(), row.getDays(), row.getThreshold()]); + return list; + } + public function toArrayCollection():ArrayCollection + { + var array:ArrayCollection = new ArrayCollection(); + + for(var index:Number = 0; index < grid.numChildren; index++) + { + var temp:ArrayCollection = getPlannerList(index); + array.addItem(temp); + } + + return array; + } + + ]]> + </mx:Script> + + <mx:HBox id="newButtonBox"> + <mx:Label text="" width="12"/> + <mx:Button id="newButton" label="New" click="addRow()" width="60"/> + <!--<mx:Label text="-" width="80" textAlign="center"/> + <mx:Label text="-" width="50" textAlign="center"/> + <mx:Label text="-" width="80" textAlign="center"/>--> + </mx:HBox> + + <mx:HBox id="headerBox"> + <mx:Label text="#" fontWeight="bold" paddingBottom="-3" width="12"/> + <mx:Label text="Remove" fontWeight="bold" paddingBottom="-3" width="60" textAlign="center"/> + <mx:Label text="Location" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + <mx:Label text="Days" fontWeight="bold" paddingBottom="-3" width="50" textAlign="center"/> + <mx:Label text="Threshold" fontWeight="bold" paddingBottom="-3" width="80" textAlign="center"/> + </mx:HBox> + + <mx:HBox horizontalScrollPolicy="off" height="147" width="100%"> + <mx:VBox id="numbers" width="12"/> + <mx:VBox id="grid" childRemove="childRemoved()"/> + </mx:HBox> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/Planner.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:Label text="Planning Stage" fontSize="24"/> + <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, and repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." + width="600"/> + <mx:Label/> + + <mx:HBox> + <mx:VBox> + <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> + <comp:Planner id="notRepeated"/> + </mx:VBox> + <mx:VBox> + <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> + <comp:Planner id="repeated" valueRequired="true"/> + </mx:VBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Suspend repetition:" fontWeight="bold" width="130"/> + <mx:Label text="If during one repetition"/> + <mx:NumericStepper id="suspendWeight" value="5" minimum="0.1" maximum="100" stepSize="0.1" height="20" width="50"/> + <mx:Label text="lbs could not be fished,"/> + </mx:HBox> + <mx:HBox> + <mx:Label width="113"/> + <mx:Label text="then stay in the harbor for"/> + <mx:NumericStepper id="suspendDays" value="1" minimum="0" maximum="30" stepSize="1" height="20" width="50"/> + <mx:Label text="days before starting the next repetition."/> + </mx:HBox> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public function getNotRepeated():ArrayCollection + { return notRepeated.toArrayCollection(); } + + public function getRepeated():ArrayCollection + { return repeated.toArrayCollection(); } + + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + +</mx:VBox> Property changes on: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml ___________________________________________________________________ Added: svn:executable + * Added: mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PlannerRow.mxml 2009-03-18 20:19:28 UTC (rev 84) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Script> + <![CDATA[ + + public var valueReq... [truncated message content] |
From: <kj...@us...> - 2009-03-28 00:49:41
|
Revision: 85 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=85&view=rev Author: kjonas Date: 2009-03-28 00:49:27 +0000 (Sat, 28 Mar 2009) Log Message: ----------- DataGridHandler actionscript class completed Forecast1, Forecast2 utilize DataGridHandler Forecast2 can be filled from older Forecast1 Modified Paths: -------------- mentalmodels/trunk/flex/src/TableTest.mxml mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml Modified: mentalmodels/trunk/flex/src/TableTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/TableTest.mxml 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/TableTest.mxml 2009-03-28 00:49:27 UTC (rev 85) @@ -2,12 +2,13 @@ <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="absolute"> <mx:VBox> - <mx:HBox> + <mx:HBox id="cast"> <comp:Forecast id="legacy" numColumns="10"/> <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> - <comp:Forecast2 id="forecastFull" numColumns="6" oldForecast1="{this.forecastPeople}"/> + <!--<comp:Forecast2 id="forecastFull" numColumns="6" oldForecast1="{this.forecastPeople}"/>--> </mx:HBox> <mx:Label initialize="init()"/> + <mx:Button id="next" label="Next" click="testNext()"/> </mx:VBox> <mx:Script> @@ -24,6 +25,16 @@ forecastPeople.setItem(2,2,X); } + public function testNext(evt:Event=null):void + { + if(!forecastPeople.isFinished()) return; + var f2:Forecast2 = new Forecast2(); + f2.id = "forecastFull_AS"; + f2.numColumns = 6; + f2.oldForecast1 = forecastPeople; + cast.addChild(f2); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-03-28 00:49:27 UTC (rev 85) @@ -2,81 +2,106 @@ package actionscript { import mx.collections.ArrayCollection; + import mx.controls.Alert; import mx.controls.DataGrid; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.utils.StringUtil; + [Bindable] public class DataGridHandler { - private var myDataGrid:DataGrid; - private var myProvider:ArrayCollection; + private var _myDataGrid:DataGrid; + private var _myProvider:ArrayCollection; - private var errorMessage:String = ""; + private var _errorMessage:String = ""; +public var debug:String = new String(); + private var finished:Boolean = false; - private var numFields:Number; - private var numCols:Number; - private var minValue:Number; - private var maxValue:Number; - private var sumOfEachColumn:Number; + private var _numFields:Number; + private var _numColumns:Number; + private var _minValue:Number; + private var _maxValue:Number; + private var _sumOfEachColumn:Number; public function get grid():DataGrid - { return myDataGrid; } + { return _myDataGrid; } public function set grid(newValue:DataGrid):void - { myDataGrid = newValue; } + { _myDataGrid = newValue; } public function get dataProvider():ArrayCollection - { return myProvider; } + { return _myProvider; } public function set dataProvider(newValue:ArrayCollection):void - { myProvider = newValue; } + { _myProvider = newValue; } public function get errorMessage():String - { return errorMessage; } + { return _errorMessage; } public function set errorMessage(newValue:String):void - { errorMessage = newValue; } + { _errorMessage = newValue; } + public function isFinished():Boolean + { + return finished; + } public function get numFields():Number - { return numFields; } + { return _numFields; } public function set numFields(newValue:Number):void - { numFields = newValue; } - public function get numCols():Number - { return numCols; } - public function set numCols(newValue:Number):void - { numCols = newValue; } + { _numFields = newValue; } + public function get numColumns():Number + { return _numColumns; } + public function set numColumns(newValue:Number):void + { _numColumns = newValue; } public function get minValue():Number - { return minValue; } + { return _minValue; } public function set minValue(newValue:Number):void - { minValue = newValue; } + { _minValue = newValue; } public function get maxValue():Number - { return maxValue; } + { return _maxValue; } public function set maxValue(newValue:Number):void - { maxValue = newValue; } + { _maxValue = newValue; } public function get sumOfEachColumn():Number - { return sumOfEachColumn; } + { return _sumOfEachColumn; } public function set sumOfEachColumn(newValue:Number):void - { sumOfEachColumn = newValue; } + { _sumOfEachColumn = newValue; } - public function DataGridHandler(fields:Number, cols:Number, min:Number = 0, max:Number = 9999, colSum:Number = -1) + public function DataGridHandler(fields:Number, cols:Number, min:Number=0, max:Number=9999, colSum:Number=-1) { - numFields = fields; - numCols = cols; - minValue = min; - maxValue = max; - sumOfEachColumn = colSum; - - createGrid(); + try{ + numFields = fields; + numColumns = cols; + minValue = min; + maxValue = max; + sumOfEachColumn = colSum; + + errorMessage = ""; + + createGrid(); + + grid.addEventListener("change", changed); +// dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, changed, false); +// dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, changed, true); + }catch(e:Error){ + Alert.show(e.message); + } } public function getItem(field:Number, col:Number):Object { - return myProvider.getItemAt(field)["day"+(col+1)]; + return dataProvider.getItemAt(field)["day"+(col+1)]; } public function setItem(field:Number, col:Number, value:Object):void { - myProvider.getItemAt(field)["day"+(col+1)] = value; + dataProvider.getItemAt(field)["day"+(col+1)] = value; } - private function createGrid() + private function createGrid():void { - var tempArray:Array = myDataGrid.columns; + grid = new DataGrid(); + + dataProvider = new ArrayCollection(); + + //_myDataGrid.columns = new Array(); + var tempArray:Array = grid.columns; var i:Number; var temp:DataGridColumn; @@ -95,16 +120,19 @@ tempArray[i] = temp; } - myDataGrid.columns = tempArray; + grid.columns = tempArray; // add day1, day2, etc to each field for(var j:Number=0; j<numFields; j++) { var field:Object = new Object(); - myProvider.addItem(field); + dataProvider.addItem(field); } - myDataGrid.height = (23)*(numFields+1)+2; + grid.dataProvider = dataProvider; + grid.height = (23)*(_numFields+1)+2; + grid.editable = true; +debug += ""; } public function clone():DataGrid @@ -135,7 +163,7 @@ dgClone.columns = tempArray; // fill data - for(var j:Number=0; j<numFields; j++) + for(var j:Number=0; j<_numFields; j++) { var field:Object = new Object(); myProviderClone.addItem(field); @@ -145,15 +173,15 @@ } } - dgClone.height = (23)*(numFields+1)+2; + dgClone.height = (23)*(_numFields+1)+2; return dgClone; } - public function changed():void + public function changed(evt:Event=null):void { markNoError(); - errorMessage = "Complete." + errorMessage = ""; var error:Boolean = false; var value:Object; @@ -164,7 +192,7 @@ { var colStr:String = "day"+(col+1); var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) + for(var field:Number=0; field < _numFields && !error; field++) { value = getItem(field, col); if(invalidNum(value)) @@ -187,21 +215,27 @@ // if no other errors yet, and there is a required sum for columns, // then check actual sum against expected - if( ! (error || sumOfEachColumn == -1 || colSum == sumOfEachColumn) ) + if( !error && sumOfEachColumn != -1 && colSum != sumOfEachColumn ) { errorMessage = "Sum of all columns must be exactly "+sumOfEachColumn+"."; error = true; markError(-1,col); - } + debug += "{"+colSum+"}"; + } + else + { + debug += "["+colSum+"]"; + } } + + finished = !error; } private function invalidNum(n:Object):Boolean { if(n == null) return true; - //the entire string must be consecutive digits - var pattern:RegExp = /^\d+$/; + var pattern:RegExp = /^\d+$/; //the entire string must be consecutive digits var s:String = StringUtil.trim(String(n)); - return !pattern.test(s); + return !pattern.test(s) && !(n is Number); } private function outOfBoundsNum(n:Object):Boolean { @@ -210,16 +244,16 @@ private function markError(field:Number, col:Number):void { - DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#3333FF"); - myDataGrid.selectedIndex = field; + DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#ee82ee"); + grid.selectedIndex = field; } private function markNoError():void { for(var col:Number=0; col < numColumns; col++) { - DataGridColumn(myDataGrid.columns[col]).setStyle("backgroundColor", "#FFFFFF"); + DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#FFFFFF"); } - myDataGrid.selectedIndex = -1; + grid.selectedIndex = -1; } } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-03-28 00:49:27 UTC (rev 85) @@ -1,25 +1,30 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> <mx:ArrayCollection id="sched"/> - <mx:HBox> + <mx:HBox id="gridContainer"> <mx:VBox id="labels"> </mx:VBox> - <mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" - change="changed()" click="changed()"/> + <!--<mx:DataGrid id="dgMain" editable="true" textAlign="right" dataProvider="{sched}" + change="changed()" click="changed()"/>--> </mx:HBox> - <mx:Label id="lbl"/> - <mx:Label id="debug"/> + <mx:Label id="lbl" text="{dgh.errorMessage}"/> + <!--<mx:Label id="debug" text="{dgh.debug}"/>--> <mx:Script> <![CDATA[ + import mx.controls.DataGrid; + import actionscript.DataGridHandler; import mx.utils.StringUtil; import mx.controls.dataGridClasses.DataGridColumn; [Bindable] + public var dgh:DataGridHandler; + + [Bindable] public var numColumns:Number = 15; [Bindable] public var numFields:Number = 4; @@ -27,19 +32,44 @@ public var minValue:Number = 0; [Bindable] public var maxValue:Number = 10; + [Bindable] + public var colSum:Number = 30; private var errorMessage:String = null; //not used private var colIndex:Number=0; - private var finished:Boolean = false; public function init():void { - createColumns(); + dgh = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); + gridContainer.addChildAt(dgh.grid, 1); +// createColumns(); } - private function createColumns():void + public function changed():void { + dgh.changed(); + } + public function isFinished():Boolean + { + return dgh.isFinished(); + } + public function getItem(field:Number, col:Number):Object + { + return dgh.getItem(field, col); + } + public function setItem(field:Number, col:Number, value:Object):void + { + dgh.setItem(field, col, value); + } + public function clone():DataGrid + { + return dgh.clone(); + } + + + /* private function createColumns():void + { var tempArray:Array = dgMain.columns; var i:Number; var temp:DataGridColumn; @@ -143,7 +173,7 @@ private function markError(field:Number, col:Number):void { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#ee82ee"); dgMain.selectedIndex = field; } private function markNoError():void @@ -196,7 +226,7 @@ dgClone.height = (23)*(numFields+1)+2; return dgClone; - } + } */ ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-18 20:19:28 UTC (rev 84) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-03-28 00:49:27 UTC (rev 85) @@ -112,7 +112,7 @@ if(oldForecast1 == null) { setItem(0,1,1); - dgRow2.addChild(newForecast1.dgMain); + dgRow2.addChild(newForecast1.dgh.grid); setItem(1,1,2); } else @@ -193,7 +193,7 @@ private function markError(field:Number, col:Number):void { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#3333FF"); + DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#ee82ee"); dgMain.selectedIndex = field; } private function markNoError():void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-04-10 21:44:41
|
Revision: 96 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=96&view=rev Author: kjonas Date: 2009-04-10 21:44:32 +0000 (Fri, 10 Apr 2009) Log Message: ----------- DataGridHandler actionscript integration complete DataGrids seem to be functioning adequately Modified Paths: -------------- mentalmodels/trunk/flex/src/TableTest.mxml mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml Modified: mentalmodels/trunk/flex/src/TableTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/TableTest.mxml 2009-04-10 20:28:29 UTC (rev 95) +++ mentalmodels/trunk/flex/src/TableTest.mxml 2009-04-10 21:44:32 UTC (rev 96) @@ -3,9 +3,8 @@ <mx:VBox> <mx:HBox id="cast"> - <comp:Forecast id="legacy" numColumns="10"/> + <!--<comp:Forecast id="legacy" numColumns="10"/>--> <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> - <!--<comp:Forecast2 id="forecastFull" numColumns="6" oldForecast1="{this.forecastPeople}"/>--> </mx:HBox> <mx:Label initialize="init()"/> <mx:Button id="next" label="Next" click="testNext()"/> @@ -19,10 +18,7 @@ public function init():void { - var X:String="X"; - forecastPeople.setItem(0,0,X); - forecastPeople.setItem(1,1,X); - forecastPeople.setItem(2,2,X); + for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); } public function testNext(evt:Event=null):void Modified: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-04-10 20:28:29 UTC (rev 95) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-04-10 21:44:32 UTC (rev 96) @@ -11,6 +11,7 @@ [Bindable] public class DataGridHandler { + public var enabled:Boolean = true; private var _myDataGrid:DataGrid; private var _myProvider:ArrayCollection; @@ -111,7 +112,7 @@ temp.headerText = ""+(i+1); temp.dataField = "day"+(i+1); - temp.editable = true; + temp.editable = enabled; temp.draggable = false; temp.sortable = false; temp.resizable = false; @@ -131,7 +132,7 @@ grid.dataProvider = dataProvider; grid.height = (23)*(_numFields+1)+2; - grid.editable = true; + grid.editable = enabled; debug += ""; } Modified: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-04-10 20:28:29 UTC (rev 95) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-04-10 21:44:32 UTC (rev 96) @@ -28,10 +28,10 @@ </mx:HBox> <mx:HBox id="dgRow3"> - <mx:DataGrid id="dgCalculated" headerHeight="1" + <!--<mx:DataGrid id="dgCalculated" headerHeight="1" editable="false" textAlign="right" dataProvider="{calculated}" width="300" horizontalScrollPolicy="off" - verticalScrollPolicy="off"/> + verticalScrollPolicy="off"/>--> </mx:HBox> </mx:VBox> </mx:HBox> @@ -41,6 +41,7 @@ <mx:Script> <![CDATA[ + import actionscript.DataGridHandler; import mx.controls.Button; import mx.utils.StringUtil; import mx.controls.dataGridClasses.DataGridColumn; @@ -56,6 +57,8 @@ [Bindable] public var oldForecast1:Forecast1 = null; + private var dgCalculated:DataGridHandler = new DataGridHandler(numFields+3,numColumns); + private var errorMessage:String = null; private var colIndex:Number=0; private var finished:Boolean = false; @@ -68,6 +71,9 @@ setItem(0,0,5); setItem(1,0,10); setItem(2,0,15); + + dgCalculated.enabled = false; + dgRow3.addChild(dgCalculated.grid); } private function createColumns():void { @@ -111,15 +117,11 @@ { if(oldForecast1 == null) { - setItem(0,1,1); dgRow2.addChild(newForecast1.dgh.grid); - setItem(1,1,2); } else { - setItem(0,2,3); dgRow2.addChild(oldForecast1.clone()); - setItem(1,2,4); } } @@ -134,6 +136,8 @@ public function changed():void { + calculateValues(); + markNoError(); var error:Boolean = false; @@ -173,6 +177,7 @@ { lbl.text = "Complete."; } + } private function invalidNum(n:Object):Boolean { @@ -205,6 +210,57 @@ dgMain.selectedIndex = -1; } + public function calculateValues():void + { + for(var col:Number=0; col < numColumns; col++) + { + var t_location:Number = 0; // get thru Planner, -1=harbor + + var t_capacity:Array = [10, 20, 30]; + var t_population:Array = new Array(3); + var t_people:Array = new Array(3); + + var t_fish_mined:Number = 0; + var t_fish_mined_total:Number = 0; + + //lbs in bay 1...N + for(var x:Number = 0; x < numFields; x++) + { + t_population[x] = getItem(x, col); //update fishies + t_people[x] = oldForecast1.getItem(x+1,col); //update fishers + if(x == t_location) + { + t_people[x]++; //add this player + } + + var t_fish_each:Number = 5*t_population[x]/t_capacity[x]; + var t_fish_mined_this:Number = t_people[x] * t_fish_each; + if(t_fish_mined_this > t_population[x]) + { + t_fish_each = t_population[x] / t_people[x]; + } + + if(x == t_location) + { + t_fish_mined = t_fish_each; + } + + dgCalculated.setItem(3+x,col,t_population[x]); + } + + //location + dgCalculated.setItem(0,col,t_location); + + //you get + dgCalculated.setItem(1,col, 5* t_fish_mined); // in USD$ + + //others get + dgCalculated.setItem(2,col, 5* (t_fish_mined_total - t_fish_mined)); + + + } + } + ]]> </mx:Script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-22 00:49:37
|
Revision: 145 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=145&view=rev Author: seematalele Date: 2009-05-22 00:49:28 +0000 (Fri, 22 May 2009) Log Message: ----------- Added Block and QuestionGroup custom component. Working perfectly. Validation is also done. Added Question component also but it needs lot of improvement. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/Block.mxml mentalmodels/trunk/flex/src/customComponents/Question.mxml mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-21 22:53:03 UTC (rev 144) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" - width="760" height="510" clipContent="false" layout="absolute" currentState="none"> + width="100%" height="100%" clipContent="false" layout="absolute" currentState="none"> <mx:Script> <![CDATA[ import mx.effects.Fade; @@ -9,22 +9,28 @@ import mx.collections.XMLListCollection; import mx.controls.Alert; +/* id field of module, block and questiongroup and questions should come from database, +so when module info is transfered to the server, it should return the id for that module */ + [Bindable] private var company:XML = - <list> - <module title="Preexperiment" sequenceNo="200"> + + <module title="Preexperiment" sequenceNo="200" id="1"> <block name="John H"> - <item name="item"/> + <questiongroup header="hello" description="world" sequenceNo="200" id="1"/> + </block> - <block name="Sam K"/> + <block name="Sam K" /> + <block name="Erin M"/> + <block name="Ann B"/> </module> - <!--<module title="Operations" code="400"> + <module title="Operations" code="400"> <block name="Bill C"/> <block name="Jill W"/> </module> - <module title="Engineering" code="300"> + <!-- <module title="Engineering" code="300"> <block name="Erin M"/> <block name="Ann B"/> @@ -34,21 +40,25 @@ [Bindable] private var companyData:XMLListCollection = new XMLListCollection(company.module); - private function treeLabel(item:Object):String + private function treeLabel(item:Object):String { var node:XML = XML(item); if( node.localName() == "module" ) - return node.@title; - else + + + else if( node.localName() == "block" ) return node.@name; - + else if( node.localName() == "questiongroup" ) + return node.@header; + else + return node.@name; + } private function addModule():void - { currentState = "module"; @@ -56,6 +66,10 @@ var moduleInfo:Module = Module(obj); moduleInfo.reset(); btnsaveModule.enabled = true; + + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; /*var saveModule:Button = new Button; var isExists:Boolean = pnlComponent.contains(saveModule as DisplayObject); Alert.show(isExists.toString()); @@ -71,7 +85,7 @@ private function saveModule(event:Event):void { - //btnsaveModule.enabled = false; + var obj:DisplayObject = pnlComponent.getChildAt(1); var moduleInfo:Module = Module(obj); @@ -92,6 +106,7 @@ company.appendChild(newNode); currentState = "none"; btnsaveModule.enabled = false; + // pnlComponent.removeChildAt(1); } @@ -111,14 +126,22 @@ private function addBlock():void { + currentState = "block"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var blockInfo:Block = Block(obj); + blockInfo.reset(); + btnsaveBlock.enabled = true; + btnsaveModule.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; + //currentState = "block"; - btnsaveModule.enabled = true; - + - var node:XML = tree.selectedItem as XML; + /*var node:XML = tree.selectedItem as XML; - Alert.show("Selected node is " + node.@title); + Alert.show("Selected node is " + node.@title);*/ /* var newNode:XML = <block/>; newNode.@name = "block1"; @@ -131,30 +154,206 @@ } - private function addItem():void - + private function saveBlock(event:Event):void { - var newNode:XML = <item/>; - newNode.@name = "item1"; - var module:XMLList =company.module.(@title == "first module"); - var i:int; - for (i = 0; i < module.length(); i++) - { - if(module[i].block.@name == "block1") - { - var item:XMLList =company.module.block.(@name == "block1"); - if( item.length() > 0 ) - { + + var obj:DisplayObject = pnlComponent.getChildAt(1); + var blockInfo:Block = Block(obj); + + var node:XML = tree.selectedItem as XML; + + if(tree.selectedItem == null) + { + Alert.show("Please select the module from tree to which block should be added."); + } + else + { - item[0].appendChild(newNode); - - } - } - } - - } + var isBlockFormValid:Boolean = blockInfo.validateForm(event); + if(isBlockFormValid) + { + var durationflag:Boolean = this.isDurationValid(blockInfo.getHours(),blockInfo.getMinutes(),blockInfo.getSeconds()); + if(durationflag) + { + Alert.show("Please enter the valid duration for the given block."); + } + else + { + var newNode:XML = <block/> + newNode.setLocalName("block"); + newNode.@name=blockInfo.getName(); + newNode.@sequenceNo =blockInfo.getSequenceNo(); + var module:XMLList =company.module.(@title == node.@title); + if( module.length() > 0 ) + { + module[0].appendChild(newNode); + currentState = "none"; + btnsaveBlock.enabled = false; + + } + + } + } + else + { + Alert.show("Please fill the form correctly"); + } + } + + } - + private function addQuestionGroup():void + { + currentState = "questionGroup"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + questionGroupInfo.reset(); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = true; + btnsaveQuestion.enabled = false; + + + } + + private function saveQuestionGroup(event:Event):void + { + + + var node:XML = tree.selectedItem as XML; + + if(tree.selectedItem == null) + { + Alert.show("Please select the block from tree to which Question Group should be added."); + return; + } + else + { + + //if(tree.getParentItem(tree.selectedItem) == null) + if(node.localName() == "module") + { + Alert.show("You can not add QuestionGroup to Module."); + return; + } + else + { + if(node.localName() == "questiongroup" ) + { + Alert.show("You can not add QuestionGroup to QuestionGroup."); + return; + } + + else + { + //find out the parent module + var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + var isQuestionGroupFormValid:Boolean = questionGroupInfo.validateForm(event); + + if(isQuestionGroupFormValid) + { + + var newNode:XML = <questiongroup/>; + newNode.setLocalName("questiongroup"); + newNode.@header = questionGroupInfo.getHeader(); + newNode.@description = questionGroupInfo.getDescription(); + newNode.@sequenceNo = questionGroupInfo.getSequenceNo(); + + /*var module:XMLList = company.module.(@title == parentModule.@title); + //Alert.show("ParentModule node is: " + parentModule.@title); + Alert.show("ParentBlock node is: " + module.children().length()); + var blockList:XMLList = module.children(); + var i:int; + //Alert.show(module.length() + "is length of module"); + for (i = 0; i < blockList.length(); i++) + { + if(blockList[i].block.@name == node.@name) + { + Alert.show(blockList[i].block.@name + "is found"); + */ + var block:XMLList =company.module.block.(@name == node.@name); + Alert.show(block.@name + "is name of the block"); + if( block.length() > 0 ) + { + block[0].appendChild(newNode); + currentState = "none"; + btnsaveQuestionGroup.enabled = false; + + } + //} + //} + } + } + } + } + } + private function addQuestion():void + { + currentState = "question"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(obj); + questionGroupInfo.reset(); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = true; + } + + private function saveQuestion(event:Event):void + { + var node:XML = tree.selectedItem as XML; + + if(tree.selectedItem == null) + { + Alert.show("Please select the block from tree to which Question Group should be added."); + return; + } + else + { + + //if(tree.getParentItem(tree.selectedItem) == null) + if(node.localName() != "questiongroup") + { + Alert.show("You can add Question to QuestionGroup only."); + return; + } + else + { + //find out the parent module + var parentModule:XML = tree.getParentItem(tree.selectedItem) as XML; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var questionInfo:Question = Question(obj); + var isQuestionGroupFormValid:Boolean = questionInfo.validateForm(event); + + if(isQuestionGroupFormValid) + { + + var newNode:XML = <question/>; + newNode.setLocalName("question"); + newNode.@header = questionInfo.getHeader(); + newNode.@description = questionInfo.getDescription(); + newNode.@sequenceNo = questionInfo.getSequenceNo(); + + var block:XMLList =company.module.block.(@name == node.@name); + Alert.show(block.@name + "is name of the block"); + if( block.length() > 0 ) + { + block[0].appendChild(newNode); + currentState = "none"; + btnsaveQuestion.enabled = false; + + } + } + } + } + + } + + private function removeEmployee():void { var node:XML = XML(tree.selectedItem); @@ -193,27 +392,36 @@ </mx:AddChild> </mx:State> - <!--<mx:State name="block"> + <mx:State name="block"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> + <comp:Block id="block"/> </mx:AddChild> </mx:State> - <mx:State name="item"> + <mx:State name="questionGroup"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:PlannerPage id="planner"/> + <comp:QuestionGroup id="questionGroup"/> </mx:AddChild> - </mx:State>--> + </mx:State> + <mx:State name="question"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:Question id="question"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"/> </mx:states> - + <mx:Spacer width="40"/> <mx:HDividedBox width="100%" height="100%" id="hdMain"> + <mx:Spacer width="40"/> <mx:VBox height="100%" id="vboxLeft"> + <mx:Spacer width="40"/> <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" labelFunction="treeLabel" allowMultipleSelection="false" selectable="true" showRoot="true" change="{treeChanged(event)}" - height="224" width="179" /> + height="50%" width="80%" textAlign="center"/> <mx:Canvas height="35%"> <mx:Grid x="0" y="0"> @@ -239,14 +447,26 @@ </mx:GridRow> <mx:GridRow width="100%" height="100%"> <mx:GridItem width="100%" height="100%"> - <mx:Button label="Add Item" id="butAddItem" click="{addItem()}"/> + <mx:Button label="Add QuestionGroup" id="butAddQuestionGroup" click="{addQuestionGroup()}"/> </mx:GridItem> + <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Item" id="butremItem"/> + <mx:Button label="Remove QuestionGroup" id="butremQuestionGroup"/> </mx:GridItem> <mx:GridItem width="100%" height="100%"> </mx:GridItem> </mx:GridRow> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Question" id="butAddQuestion" click="{addQuestion()}"/> + </mx:GridItem> + + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Question" id="butremQuestion"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> </mx:Grid> </mx:Canvas> @@ -256,10 +476,12 @@ <mx:Spacer width="40"/> <mx:Button id = "btnsaveModule" label="Save Module" enabled="false" click="{saveModule(event)}"/> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveBlock" enabled="false" label="Save Block" /> + <mx:Button id = "btnsaveBlock" enabled="false" label="Save Block" click="{saveBlock(event)}"/> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveItem" enabled="false" label="Save Item" /> + <mx:Button id = "btnsaveQuestionGroup" enabled="false" label="Save QuestionGroup" click="{saveQuestionGroup(event)}" /> <mx:Spacer width="40"/> + <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" click="{saveQuestion(event)}" /> + <mx:Spacer width="40"/> </mx:HBox> </mx:Panel> Added: mentalmodels/trunk/flex/src/customComponents/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Block.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Block.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Block Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Description:"> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> + </mx:HBox> + + + + +</mx:FormItem> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Modified: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-21 22:53:03 UTC (rev 144) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -113,6 +113,7 @@ ]]> </mx:Script> + <mx:FormHeading label="Module Information"/> <mx:FormItem label="Sequence Number:"> <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> Added: mentalmodels/trunk/flex/src/customComponents/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Question.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getQuestion():String + { + return txtQuestion.text; + } + + /*public function getDescription():String + { + return txtDescription.text; + }*/ + + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtQuestion.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtQuestion.text = ""; + + txtSeqNo.errorString =""; + txtQuestion.errorString =""; + + } + + ]]> + </mx:Script> + + <mx:FormHeading label="QuestionGroup"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Question:"> + <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Select Question Type:"> + <mx:ComboBox id="cmbType" change="{validateForm(event)}" width="100%"> + <mx:ArrayCollection> + <mx:String>-Select-</mx:String> + <mx:String>Categorical</mx:String> + <mx:String>Psychometric</mx:String> + </mx:ArrayCollection> + </mx:ComboBox> + + </mx:FormItem> + <mx:FormItem> + <mx:Panel width="250" height="200" layout="absolute"> + + </mx:Panel> + </mx:FormItem> + + + +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Added: mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml 2009-05-22 00:49:28 UTC (rev 145) @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getHeader():String + { + return txtHeader.text; + } + public function getDescription():String + { + return txtDescription.text; + } + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtHeader.text == "" && txtDescription.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtHeader.text = ""; + txtDescription.text =""; + txtSeqNo.errorString =""; + txtHeader.errorString =""; + txtDescription.errorString =""; + + } + + ]]> + </mx:Script> + + <mx:FormHeading label="QuestionGroup"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Header:"> + <mx:TextInput id="txtHeader" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Decsription:"> + <mx:TextArea id="txtDescription" change="{validateForm(event)}" width="100%" height="100"/> + </mx:FormItem> + + +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-06-01 16:52:05
|
Revision: 150 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=150&view=rev Author: seematalele Date: 2009-06-01 16:52:02 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Psychometric interface is complete including validation. Following things needs to be done - 1)Remove functionality for all elements 2)Find out way for Psychometric and Categorical Component values in Question.mxml 3)Write methods in QuestionCreatorService class Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/actionscript/Location.as Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/db/ mentalmodels/trunk/flex/src/customComponents/db/Block.mxml mentalmodels/trunk/flex/src/customComponents/db/Module.mxml mentalmodels/trunk/flex/src/customComponents/db/Question.mxml mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/ mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/Block.mxml mentalmodels/trunk/flex/src/customComponents/Categorical.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml mentalmodels/trunk/flex/src/customComponents/Question.mxml mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.db.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" width="100%" height="100%" clipContent="false" layout="absolute" currentState="none"> <mx:Script> @@ -16,25 +16,24 @@ private var company:XML = <list> - <module title="Preexperiment" sequenceNo="200" id="1"> - <block name="John H"> - <questiongroup header="hello" description="world" sequenceNo="200" id="1"/> + <module title="Preexperiment" sequenceNo="1" id="1"> + <block name="Introduction"> + <questiongroup header="Welcome to E-Fishery Experiment" description="In this experiment you will design..." sequenceNo="1" id="1"/> </block> - <block name="Sam K" /> - <block name="Erin M"/> - <block name="Ann B"/> + </module> - <module title="Operations" code="400"> - - <block name="Bill C"/> - <block name="Jill W"/> - </module> - <!-- <module title="Engineering" code="300"> - - <block name="Erin M"/> - <block name="Ann B"/> - </module>--> + <module title ="Game Round" sequenceNo="2" id="2"> + <block name="Characterizing Own Strategy"> + <questiongroup header="What goals did you follow when designing your strategy" description="Please specify three goals..." sequenceNo="1" id="2"> + <question title="Most important goal" type="categorical" sequenceNo="1" id="1" > + </question> + </questiongroup> + + </block> + + </module> + </list>; [Bindable] @@ -54,7 +53,10 @@ else if( node.localName() == "questiongroup" ) return node.@header; - else + else if( node.localName() == "question" ) + return node.@title; + + else return node.@name; } Modified: mentalmodels/trunk/flex/src/actionscript/Location.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Location.as 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/actionscript/Location.as 2009-06-01 16:52:02 UTC (rev 150) @@ -11,5 +11,6 @@ public var maxCapacity:int; public var growthRate:Number; public var initialPopulation:int; + public var roundConfigs:ArrayCollection; } } \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/customComponents/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Block.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Block.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,138 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> -<mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getName():String - { - return txtName.text; - } - /*public function getDuration():String - { - //return txtMajor.text; - }*/ - - public function getHours():Number - { - return hours.value; - - } - public function getMinutes():Number - { - return minutes.value; - - } - public function getSeconds():Number - { - return seconds.value; - - } - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtName.text = ""; - hours.value =0; - minutes.value =0; - seconds.value =0; - txtSeqNo.errorString =""; - txtName.errorString =""; - - } - - - - ]]> - </mx:Script> - <mx:FormHeading label="Block Information"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Description:"> - <mx:TextInput id="txtName" change="{validateForm(event)}"/> - </mx:FormItem> - -<mx:FormItem label="Duration(hr:min:sec):"> - <mx:HBox> - <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> - <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> - </mx:HBox> - - - - -</mx:FormItem> -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,142 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.*"> - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - [Bindable] - public var header1:ArrayCollection = new ArrayCollection(); - - [Bindable] - public var header2:ArrayCollection = new ArrayCollection(); - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (type.selectedValue == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - //validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - - type.selectedValue =""; - } - - private function showRelativeFields():void - { - currentState = "relative"; - var obj:DisplayObject = canvasComponent.getChildAt(0); - var relativeInfo:CategoricalRelative = CategoricalRelative(obj); - relativeInfo.reset(); - } - - private function showSimpleFields():void - { - currentState = "simple"; - var obj:DisplayObject = canvasComponent.getChildAt(0); - var simpleInfo:CategoricalSimple = CategoricalSimple(obj); - simpleInfo.reset(); - } - - ]]> - </mx:Script> - - - <mx:states> - <mx:State name="relative"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalRelative id="relative"/> - </mx:AddChild> - </mx:State> - - <mx:State name="simple"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalSimple id="simple"/> - </mx:AddChild> - </mx:State> - - <mx:State name="none"/> - - </mx:states> - - <mx:FormHeading label="Categorical"/> - <mx:FormItem label="Type:"> - <mx:RadioButtonGroup id="type"/> - - <mx:RadioButton id="rdoRelative" groupName="{type}" label="Relative" click="showRelativeFields()"/> - <mx:RadioButton id="rdoSimple" groupName="{type}" label="Simple" click="showSimpleFields()" /> - </mx:FormItem> - <mx:Canvas id="canvasComponent" height="100%" /> - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - <mx:Script> - <![CDATA[ - import actionscript.FishUtil; - - private function fix(index:int, list:ArrayCollection):int - { - return FishUtil.fix(index, list); - } - - ]]> - </mx:Script> - - <mx:Label id="header"/> - <mx:ComboBox id="comboTopic" dataProvider="{topics}" selectedIndex="0"/> - <mx:ComboBox id="comboSpecific" dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> - - - <mx:ArrayCollection id="topics"> - <mx:String>- Select -</mx:String> - <mx:String>topic1</mx:String> - <mx:String>topic2</mx:String> - <mx:String>topic3</mx:String> - </mx:ArrayCollection> - - <!-- each element of this ArrayCollection will serve as a dataProvider --> - <mx:ArrayCollection id="specifics"> - <mx:ArrayCollection id="topic0"> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic1"> - <mx:String>- Select -</mx:String> - <mx:String>specific1.0</mx:String> - <mx:String>specific1.1</mx:String> - <mx:String>specific1.2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic2"> - <mx:String>- Select -</mx:String> - <mx:String>specific2.0</mx:String> - <mx:String>specific2.1</mx:String> - <mx:String>specific2.2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="topic3"> - <mx:String>- Select -</mx:String> - <mx:String>specific3.0</mx:String> - <mx:String>specific3.1</mx:String> - <mx:String>specific3.2</mx:String> - </mx:ArrayCollection> - </mx:ArrayCollection> - -</mx:HBox> Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalRelative.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,256 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - import flash.utils.Dictionary; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - [Bindable] - public var header1:ArrayCollection = new ArrayCollection(); - [Bindable] - public var header:Object = new Object(); - - public var dict:Dictionary = new Dictionary(); - - [Bindable] - public var header2:ArrayCollection = new ArrayCollection(); - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtHeader1.text == "" && txtHeader2.text == "" && txtChoice1.text == "" && txtChoice2.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - //validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - - txtHeader1.text = ""; - txtHeader2.text = ""; - txtChoice1.text = ""; - txtChoice2.text = ""; - } - - - private function addHeader():void - { - - lblHeader1.text = txtHeader1.text; - lblHeader2.text = txtHeader2.text; - vboxSecondHeader.visible = true; - frmitmAddChoice1.label="Choice for " + txtHeader1.text + ":"; - frmitmAddChoice2.label="Choice for " + txtHeader2.text + ":"; - - } - - private function addChoice1():void - { - if(txtChoice1.text == null || txtChoice1.text == "") - { - Alert.show("Please Enter the " + frmitmAddChoice1.label); - return; - - } - header1.addItem(txtChoice1.text); - dict[txtChoice1.text] = new ArrayCollection(); - - txtChoice1.text = ""; - - } - - private function addChoice2():void - { - if(header1.length < 0) - { - Alert.show("There are no choices for "+ txtHeader1.text +"Please Enter the " + frmitmAddChoice1.label); - return; - } - if(txtChoice2.text == null || txtChoice2.text == "") - { - Alert.show("Please Enter the " + frmitmAddChoice2.label); - return; - - } - if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") - { - Alert.show("Please Select the Item from " + txtHeader1. text); - return; - } - - else - { - - //header2.addItem(txtChoice2.text); - if(dict[lstHeader1.selectedItem].hasOwnProperty("addItem")) - { - dict[lstHeader1.selectedItem].addItem(txtChoice2.text); - } - else - Alert.show("addItem property is NOT suceesul"); - //header[lstHeader1.selectedItem] = txtChoice2.text; - txtChoice2.text = ""; - } - - } - - private function removeChoice1():void - { - if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") - { - Alert.show("Please Select the Item from " + txtHeader1. text); - return; - } - else - { - delete dict[lstHeader1.selectedItem]; - } - } - - private function removeChoice2():void - { - if(lstHeader2.selectedItem == null ||lstHeader2.selectedItem == "") - { - Alert.show("Please Select the Item from " + txtHeader1. text); - return; - } - else - { - //header1.removeItemAt(header1.getItemIndex(lstHeader2.selectedItem)); - if(dict[lstHeader1.selectedItem].hasOwnProperty("removeItemAt") && dict[lstHeader1.selectedItem].hasOwnProperty("getItemIndex")) - { - dict[lstHeader1.selectedItem].removeItemAt(dict[lstHeader1.selectedItem].getItemIndex(lstHeader2.selectedItem)); - - } - } - } - - private function showChoices():void - { - if(lstHeader1.selectedItem == null ||lstHeader1.selectedItem == "") - { - Alert.show("Please Enter the items in the " + txtHeader1. text); - return; - } - else - { - lstHeader2.dataProvider = dict[lstHeader1.selectedItem]; - } - } - ]]> - </mx:Script> - <mx:VBox id="vboxHeaders"> - <mx:FormItem label="Header1:"> - <mx:TextInput id="txtHeader1" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:FormItem label="Header2:"> - <mx:TextInput id="txtHeader2" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnsaveHeader" label="Save" click="addHeader()"/> - - </mx:VBox> - - <mx:HBox id="vboxSecondHeader" visible="false"> - <mx:VBox> - <mx:Label text="" id="lblHeader1" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> - <mx:List id="lstHeader1" wordWrap="true" dataProvider="{header1}" allowMultipleSelection="false" click="showChoices()"/> - <mx:FormItem id="frmitmAddChoice1"> - <mx:TextInput id="txtChoice1" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnaddChoice1" label="Add Choice1" click="addChoice1()"/> - <mx:Button id="btnremoveChoice1" label="Remove Choice1" click="removeChoice1()"/> - - </mx:VBox> - <mx:Spacer width="50"/> - - - <mx:VBox> - <mx:Label text="" id="lblHeader2" fontWeight="bold" fontSize="12" fontFamily="Verdana"/> - <mx:List id="lstHeader2" wordWrap="false" dataProvider="{header2}" allowMultipleSelection="false" /> - - <mx:FormItem id="frmitmAddChoice2"> - <mx:TextInput id="txtChoice2" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnaddChoice2" label="Add Choice2" click="addChoice2()"/> - <mx:Button id="btnremoveChoice2" label="Remove Choice2" click="removeChoice2()"/> - </mx:VBox> - - - - </mx:HBox> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalSimple.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,158 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - [Bindable] - public var header:ArrayCollection = new ArrayCollection(); - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtHeader.text == "" && txtChoice.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - //validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - - txtHeader.text = ""; - - txtChoice.text = ""; - - } - - private function showRelativeFields():void - { - vboxHeaders.visible = true; - - } - - private function showSimpleFields():void - { - vboxHeaders.visible = false; - vboxSecondHeader.visible = false; - } - - private function addHeader():void - { - - lblHeader.text = txtHeader.text; - vboxSecondHeader.visible = true; - frmitmAddChoice.label="Choice for " + txtHeader.text + ":"; - - } - - private function addChoice():void - { - if(txtChoice.text == null || txtChoice.text == "") - { - Alert.show("Please Enter the " + frmitmAddChoice.label); - return; - - } - header.addItem(txtChoice.text); - txtChoice.text = ""; - - } - - - ]]> - </mx:Script> - <mx:VBox id="vboxHeaders"> - <mx:FormItem label="Header:"> - <mx:TextInput id="txtHeader" change="{validateForm(event)}"/> - </mx:FormItem> - - <mx:Button id="btnsaveHeader" label="Save" click="addHeader()"/> - - </mx:VBox> - - <mx:HBox id="vboxSecondHeader" visible="false"> - <mx:VBox> - <mx:Label text="" id="lblHeader" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> - <mx:List id="lstHeader" wordWrap="true" dataProvider="{header}" allowMultipleSelection="false"/> - <mx:FormItem id="frmitmAddChoice"> - <mx:TextInput id="txtChoice" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:Button id="btnaddChoice" label="Add Choice" click="addChoice()"/> - - </mx:VBox> - - </mx:HBox> - -</mx:VBox> Deleted: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,141 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - - -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="10%" autoLayout="true"> -<mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getName():String - { - return txtName.text; - } - /*public function getDuration():String - { - //return txtMajor.text; - }*/ - - public function getHours():Number - { - return hours.value; - - } - public function getMinutes():Number - { - return minutes.value; - - } - public function getSeconds():Number - { - return seconds.value; - - } - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtName.text = ""; - hours.value =0; - minutes.value =0; - seconds.value =0; - txtSeqNo.errorString =""; - txtName.errorString =""; - - } - - - - ]]> - </mx:Script> - <mx:FormHeading label="Module Information"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Name:"> - <mx:TextInput id="txtName" change="{validateForm(event)}"/> - </mx:FormItem> - -<mx:FormItem label="Duration(hr:min:sec):"> - <mx:HBox> - <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> - <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> - <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> - </mx:HBox> - - - - -</mx:FormItem> -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,159 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.*"> - <mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - } - - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtQuestion.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - - return formIsValid; - - } - - private function showQuestionType():void - { - - - //Alert.show("selected item is: " + cmbType.selectedItem); - if(cmbType.selectedItem == "Categorical") - { - currentState = "categorical"; - var obj:DisplayObject = canvasQuestionType.getChildAt(0); - var categoricalInfo:Categorical = Categorical(obj); - categoricalInfo.reset(); - - } - else - { - currentState = "none"; - } - } - - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtQuestion.text = ""; - - txtSeqNo.errorString =""; - txtQuestion.errorString =""; - - } - - ]]> - </mx:Script> - <mx:states> - <mx:State name="categorical"> - <mx:AddChild relativeTo="{canvasQuestionType}"> - <comp:Categorical id="categorical"/> - </mx:AddChild> - </mx:State> - - <!--<mx:State name="psychometric"> - <mx:AddChild relativeTo="{canvasQuestionType}"> - <comp:Psychometric id="psychometri"/> - </mx:AddChild> - </mx:State>--> - - <mx:State name="none"/> - - </mx:states> - - - <mx:FormHeading label="QuestionGroup"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Question:"> - <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Select Question Type:"> - <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%"> - <mx:ArrayCollection> - <mx:String>-Select-</mx:String> - <mx:String>Categorical</mx:String> - <mx:String>Psychometric</mx:String> - <mx:String>Text</mx:String> - </mx:ArrayCollection> - </mx:ComboBox> - - </mx:FormItem> - - <mx:Canvas id="canvasQuestionType" height="100%"/> - -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - -</mx:Form> Deleted: mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml 2009-05-31 02:24:04 UTC (rev 149) +++ mentalmodels/trunk/flex/src/customComponents/QuestionGroup.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -1,111 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> - <mx:Script> - <![CDATA[ - import mx.validators.NumberValidator; - import mx.validators.Validator; - import mx.events.ValidationResultEvent; - import mx.controls.Alert; - - [Bindable] - public var formIsEmpty:Boolean = true; - - [Bindable] - public var formIsValid:Boolean = false; - - - // Holds a reference to the currently focussed - // control on the form. - private var focussedFormControl:DisplayObject; - - public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getHeader():String - { - return txtHeader.text; - } - public function getDescription():String - { - return txtDescription.text; - } - - - public function validateForm(event:Event):Boolean - { - // Save a reference to the currently focussed form control - // so that the isValid() helper method can notify only - // the currently focussed form control and not affect - // any of the other form controls. - focussedFormControl = event.target as DisplayObject; - - // Mark the form as valid to start with - formIsValid = true; - - // Check if form is empty - formIsEmpty = (txtSeqNo.text == "" && txtHeader.text == "" && txtDescription.text == ""); - - // Run each validator in turn, using the isValid() - // helper method and update the value of formIsValid - // accordingly. - validate(validateSeqNo); - return formIsValid; - - } - - private function validate(validator:Validator):Boolean - { - // Get a reference to the component that is the - // source of the validator. - var validatorSource:DisplayObject = validator.source as DisplayObject; - - // Suppress events if the current control being validated is not - // the currently focussed control on the form. This stops the user - // from receiving visual validation cues on other form controls. - // var suppressEvents:Boolean = (validatorSource != focussedFormControl); - var suppressEvents:Boolean = false; - // Carry out validation. Returns a ValidationResultEvent. - // Passing null for the first parameter makes the validator - // use the property defined in the property tag of the - // <mx:Validator> tag. - var event:ValidationResultEvent = validator.validate(null, suppressEvents); - - // Check if validation passed and return a boolean value accordingly. - var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); - - // Update the formIsValid flag - formIsValid = formIsValid && currentControlIsValid; - - return currentControlIsValid; - } - - public function reset():void - { - txtSeqNo.text =""; - txtHeader.text = ""; - txtDescription.text =""; - txtSeqNo.errorString =""; - txtHeader.errorString =""; - txtDescription.errorString =""; - - } - - ]]> - </mx:Script> - - <mx:FormHeading label="QuestionGroup"/> - <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Header:"> - <mx:TextInput id="txtHeader" change="{validateForm(event)}"/> - </mx:FormItem> - <mx:FormItem label="Decsription:"> - <mx:TextArea id="txtDescription" change="{validateForm(event)}" width="100%" height="100"/> - </mx:FormItem> - - -<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> - -</mx:Form> Added: mentalmodels/trunk/flex/src/customComponents/db/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Block.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/db/Block.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Block Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Description:"> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> + </mx:HBox> + + + + +</mx:FormItem> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + +</mx:Form> Added: mentalmodels/trunk/flex/src/customComponents/db/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Module.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/db/Module.mxml 2009-06-01 16:52:02 UTC (rev 150) @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="utf-8"?> + + +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="100%" autoLayout="true"> +<mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + /*public function getDuration():String + { + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + + } + public function getMinutes():Number + { + return minutes.value; + + } + public function getSeconds():Number + { + return seconds.value; + + } + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + + + ]]> + </mx:Script> + <mx:FormHeading label="Module Information"/> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> + </mx:FormItem> + <mx:FormItem label="Name:"> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper ... [truncated message content] |
From: <kj...@us...> - 2009-06-09 20:18:50
|
Revision: 154 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=154&view=rev Author: kjonas Date: 2009-06-09 20:17:56 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Trying to fix Forecasting - might start over. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as mentalmodels/trunk/flex/src/actionscript/Location.as mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -38,9 +38,9 @@ <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8" enabled="false"/> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> @@ -167,8 +167,12 @@ if(obj is InstructionPage) { - (InstructionPage)(obj).back(); + return (InstructionPage)(obj).back(); } + if(obj is ForecastPage_TEMP) + { + return (ForecastPage_TEMP)(obj).back(); + } return false; } @@ -180,11 +184,11 @@ if(obj is InstructionPage) { - (InstructionPage)(obj).forward(); + return (InstructionPage)(obj).forward(); } if(obj is ForecastPage_TEMP) { - (ForecastPage_TEMP)(obj).forward(); + return (ForecastPage_TEMP)(obj).forward(); } return false; } @@ -194,6 +198,7 @@ if(content.numChildren == 0) { return false; } var obj:DisplayObject = content.getChildAt(0); + var returnValue:Boolean = false; if(obj is SocioDemographicPage) { @@ -211,7 +216,7 @@ Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); // Alert.show("Before invoking createstudent()"); - return true; + returnValue = true; } } if(obj is PlannerPage) @@ -221,8 +226,7 @@ obj.visible = false; expiredContent.addChild(obj); currentState = "instructions"; - - return true; + returnValue = true; } } if(obj is InstructionPage_TEMP) @@ -233,7 +237,7 @@ expiredContent.addChild(obj); currentState = "forecasting"; //consumer.subscribe(); - return true; + returnValue = true; } } if(obj is ForecastPage_TEMP) @@ -244,11 +248,14 @@ expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); - return true; + returnValue = true; } } - return false; + btnBack.enabled = (currentState == "instructions" || currentState == "forecasting"); + btnForward.enabled = btnBack.enabled; + + return returnValue; } Modified: mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/actionscript/DataGridHandler.as 2009-06-09 20:17:56 UTC (rev 154) @@ -245,6 +245,7 @@ private function markError(field:Number, col:Number):void { + if(sumOfEachColumn == -1) return; DataGridColumn(grid.columns[col]).setStyle("backgroundColor", "#ee82ee"); grid.selectedIndex = field; } @@ -256,5 +257,14 @@ } grid.selectedIndex = -1; } + + public function deactivate():void + { + for(var col:Number=0; col < numColumns; col++) + { + DataGridColumn(grid.columns[col]).editable = false; + } + grid.selectedIndex = -1; + } } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Location.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Location.as 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/actionscript/Location.as 2009-06-09 20:17:56 UTC (rev 154) @@ -11,6 +11,5 @@ public var maxCapacity:int; public var growthRate:Number; public var initialPopulation:int; - public var roundConfigs:ArrayCollection; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -37,19 +37,19 @@ private var errorMessage:String = null; - //not used - private var colIndex:Number=0; - public function init():void { dgh = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); gridContainer.addChildAt(dgh.grid, 1); -// createColumns(); } public function changed():void { dgh.changed(); } + public function deactivate():void + { + dgh.deactivate(); + } public function isFinished():Boolean { return dgh.isFinished(); @@ -67,167 +67,6 @@ return dgh.clone(); } - - /* private function createColumns():void - { - var tempArray:Array = dgMain.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = true; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - tempArray[i] = temp; - } - - dgMain.columns = tempArray; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - var field:Object = new Object(); - sched.addItem(field); - } - - dgMain.height = (23)*(numFields+1)+2; - } - - public function getItem(field:Number, col:Number):Object - { - return sched.getItemAt(field)["day"+(col+1)]; - } - public function setItem(field:Number, col:Number, value:Object):void - { - sched.getItemAt(field)["day"+(col+1)] = value; - } - - public function changed():void - { - markNoError(); - - var error:Boolean = false; - var value:Object; - - // check the values of the current column - // and point out any errors (TextBox) - for(var col:Number=0; col < numColumns && !error; col++) - { - var colStr:String = "day"+(col+1); - var colSum:Number = 0; - for(var field:Number=0; field < numFields && !error; field++) - { - value = getItem(field, col); - if(invalidNum(value)) - { - errorMessage = "Enter a value between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else if(outOfBoundsNum(value)) - { - errorMessage = "Value must be between "+minValue+" and "+maxValue+"."; - error = true; - markError(field,col); - } - else - { - colSum += Number(value); - } - } - } - - if(error) - { - lbl.text = errorMessage; - } - else - { - lbl.text = "Complete."; - } - } - private function invalidNum(n:Object):Boolean - { - if(n == null) return true; - - var pattern:RegExp = /^\d+$/; - var s:String = StringUtil.trim(String(n)); - -// debug.text = "."+n+"."+pattern.test(s)+(s is String); - - // if it does not match the pattern, it is invalid - return !pattern.test(s); - } - private function outOfBoundsNum(n:Object):Boolean - { - return Number(n) < minValue || Number(n) > maxValue; - } - - private function markError(field:Number, col:Number):void - { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#ee82ee"); - dgMain.selectedIndex = field; - } - private function markNoError():void - { - for(var col:Number=0; col < numColumns; col++) - { - DataGridColumn(dgMain.columns[col]).setStyle("backgroundColor", "#FFFFFF"); - } - dgMain.selectedIndex = -1; - } - - public function clone():DataGrid - { - var dgClone:DataGrid = new DataGrid(); - var schedClone:ArrayCollection = new ArrayCollection(); - dgClone.dataProvider = schedClone; - - var tempArray:Array = dgClone.columns; - var i:Number; - var temp:DataGridColumn; - - for(i=0; i<numColumns; i++) - { - temp = new DataGridColumn("day"+(i+1)); - - temp.headerText = ""+(i+1); - temp.dataField = "day"+(i+1); - temp.editable = true; - temp.draggable = false; - temp.sortable = false; - temp.resizable = false; - temp.width = 30; - - tempArray[i] = temp; - } - - dgClone.columns = tempArray; - - // add day1, day2, etc to each field - for(var j:Number=0; j<numFields; j++) - { - var field:Object = new Object(); - schedClone.addItem(field); - for(var k:Number=0; k<numColumns; k++) - { - schedClone.getItemAt(j)["day"+(k+1)] = getItem(j,k); - } - } - - dgClone.height = (23)*(numFields+1)+2; - - return dgClone; - } */ - ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -46,16 +46,11 @@ import mx.utils.StringUtil; import mx.controls.dataGridClasses.DataGridColumn; - [Bindable] - public var numColumns:Number = 5; - [Bindable] - public var numFields:Number = 3; - [Bindable] - public var minValue:Number = 0; - [Bindable] - public var maxValue:Number = 50; - [Bindable] - public var oldForecast1:Forecast1 = null; + [Bindable] public var numColumns:Number = 5; + [Bindable] public var numFields:Number = 3; + [Bindable] public var minValue:Number = 0; + [Bindable] public var maxValue:Number = 100; + [Bindable] public var oldForecast1:Forecast1 = null; private var dgCalculated:DataGridHandler = new DataGridHandler(numFields+3,numColumns); @@ -72,7 +67,7 @@ setItem(1,0,10); setItem(2,0,15); - dgCalculated.enabled = false; + dgCalculated.deactivate(); dgRow3.addChild(dgCalculated.grid); } private function createColumns():void @@ -257,8 +252,9 @@ //others get dgCalculated.setItem(2,col, 5* (t_fish_mined_total - t_fish_mined)); - } + + dgCalculated.grid.invalidateList(); } public function isFinished():Boolean @@ -276,6 +272,18 @@ return true; } + public function updateOld():void + { + try{ + dgRow2.removeAllChildren(); + dgRow2.addChild(oldForecast1.clone()); + } + catch(errObject:Error) + { + lbl.text = errObject.message + "\n" + errObject.getStackTrace(); + } + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-03 01:29:45 UTC (rev 153) +++ mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-09 20:17:56 UTC (rev 154) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> <mx:VBox id="content"> <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30"/> @@ -12,28 +12,45 @@ import mx.collections.ArrayCollection; import mx.controls.Alert; - private var clicks:int = 0; + private var firstPage:Boolean = true; + private var tries:int = 0; + private var f2:Forecast2; + public function init():void + { + f2 = new Forecast2(); + f2.id = "forecastFull_AS"; + f2.numColumns = 6; + } + public function testNext(evt:Event=null):Boolean { - clicks++; - if(!(forecastPeople.isFinished() || clicks > 1)) + if(! firstPage) return false; + + tries++; + if(!(forecastPeople.isFinished() || tries > 1)) { Alert.show("Not finished forecasting Predictions of People. Click again to disregard."); return false; } - if(clicks > 2) return false; - var f2:Forecast2 = new Forecast2(); - f2.id = "forecastFull_AS"; - f2.numColumns = 6; + Alert.show("!"); + f2.oldForecast1 = forecastPeople; + f2.updateOld(); + content.removeAllChildren(); content.addChild(f2); + firstPage = false; return true; } public function back():Boolean { - return false; + //if(content.contains(forecastPeople)) return false; + + content.removeAllChildren(); + content.addChild(forecastPeople); + firstPage = true; + return true; } public function forward():Boolean This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-06-10 23:33:12
|
Revision: 157 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=157&view=rev Author: seematalele Date: 2009-06-10 23:32:36 +0000 (Wed, 10 Jun 2009) Log Message: ----------- Created new Forecasting component named as ForecastingSeema.mxml which creates Data grid and XML is used as data provider. Created CustomNumericStepper.as which extends NumericStepper. CustomNumericStepper.as is embedded into the each Datagrid column. Added Update button in Forecasting component. Only one column can be edited at a time. Once the first column is filled, you click on Update button; Control automatically shift to next column. The editable column is highlighted with Yellow color. Things needs to be done- 1) When user click Update button, all columns should have some value and also the sum of the column should be (groupsize-1). 2) Update data into the XML whenever data grid is updated. 3) Develop other forecasting component for fish population the similar way or better way. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-09 23:38:59 UTC (rev 156) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-10 23:32:36 UTC (rev 157) @@ -1,14 +1,16 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - width="760" height="510" clipContent="false" layout="absolute" - currentState="socioDemographic" initialize="init()"> + width="90%" height="70%" clipContent="false" layout="absolute" + currentState="forecasting" initialize="init()"> <mx:states> <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> </mx:AddChild> + <mx:SetProperty target="{content}" name="x"/> + <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> </mx:State> <mx:State name="planner"> @@ -25,7 +27,7 @@ <mx:State name="forecasting"> <mx:AddChild relativeTo="{content}"> - <comp:ForecastPage_TEMP id="forecasting"/> + <comp:ForecastingSeema id="forecasting"/> </mx:AddChild> </mx:State> @@ -35,12 +37,15 @@ - <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> + <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> + <mx:Canvas id="content" x="5" y="5" width="1000" height="470"/> <mx:Canvas id="expiredContent" x="-100" y="-100" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8" enabled="false"/> + <mx:Button id="btnBack" label="« Back" click="back()" left="8" bottom="8"/> <mx:Button id="btnAccept" label="Accept" click="accept()" left="375" bottom="10"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8" enabled="false"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="8" bottom="8"/> + + <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> @@ -167,12 +172,8 @@ if(obj is InstructionPage) { - return (InstructionPage)(obj).back(); + (InstructionPage)(obj).back(); } - if(obj is ForecastPage_TEMP) - { - return (ForecastPage_TEMP)(obj).back(); - } return false; } @@ -184,11 +185,11 @@ if(obj is InstructionPage) { - return (InstructionPage)(obj).forward(); + (InstructionPage)(obj).forward(); } if(obj is ForecastPage_TEMP) { - return (ForecastPage_TEMP)(obj).forward(); + (ForecastPage_TEMP)(obj).forward(); } return false; } @@ -198,7 +199,6 @@ if(content.numChildren == 0) { return false; } var obj:DisplayObject = content.getChildAt(0); - var returnValue:Boolean = false; if(obj is SocioDemographicPage) { @@ -216,7 +216,7 @@ Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); // Alert.show("Before invoking createstudent()"); - returnValue = true; + return true; } } if(obj is PlannerPage) @@ -226,7 +226,8 @@ obj.visible = false; expiredContent.addChild(obj); currentState = "instructions"; - returnValue = true; + + return true; } } if(obj is InstructionPage_TEMP) @@ -237,7 +238,7 @@ expiredContent.addChild(obj); currentState = "forecasting"; //consumer.subscribe(); - returnValue = true; + return true; } } if(obj is ForecastPage_TEMP) @@ -248,19 +249,16 @@ expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); - returnValue = true; + return true; } } - btnBack.enabled = (currentState == "instructions" || currentState == "forecasting"); - btnForward.enabled = btnBack.enabled; - - return returnValue; + return false; } - ]]> </mx:Script> </mx:Application> + Added: mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/CustomNumericStepper.as 2009-06-10 23:32:36 UTC (rev 157) @@ -0,0 +1,20 @@ +package actionscript +{ + import mx.controls.NumericStepper; + + public class CustomNumericStepper extends mx.controls.NumericStepper + { + + public function CustomNumericStepper() + { + super(); + super.stepSize = 1; + super.maximum = 3; + super.minimum = 0; + + } + + + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastingSeema.mxml 2009-06-10 23:32:36 UTC (rev 157) @@ -0,0 +1,233 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- <mx:Application> --> + + +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" initialize="init()"> + <mx:Script> + + <![CDATA[ + + import mx.collections.XMLListCollection; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.controls.DataGrid; + import actionscript.DataGridHandler; + import mx.controls.Alert; + import mx.events.DataGridEvent; + import mx.utils.StringUtil; + import mx.collections.ArrayCollection; + import mx.controls.NumericStepper; + import mx.controls.TextInput; + import mx.events.ListEvent; + + import mx.controls.listClasses.IDropInListItemRenderer; + import actionscript.CustomNumericStepper; + + [Bindable] + private var forecast:XML = + <list> + <fishermen> + <name>Harbor</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + + </fishermen> + <fishermen> + <name>Bay1</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + + </fishermen> + <fishermen> + <name>Bay2</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + </fishermen> + <fishermen> + <name>Bay3</name> + <day1></day1> + <day2></day2> + <day3></day3> + <day4></day4> + <day5></day5> + <day6></day6> + <day7></day7> + <day8></day8> + <day9></day9> + <day10></day10> + <day11></day11> + <day12></day12> + <day13></day13> + <day14></day14> + <day15></day15> + </fishermen> + + </list>; + + [Bindable] + /*private var initDG:ArrayCollection = new ArrayCollection([ + {Artist:'Pavement', Album:'Slanted and Enchanted', + Price:11.99}, + {Artist:'Pavement', Album:'Brighten the Corners', + Price:11.99 } + ]);*/ + + private var initdg:ArrayCollection = new ArrayCollection(); + //initdg.addItem(name:"Harbor"); + + + [Bindable] + private var fishermenPopulation:XMLListCollection = new XMLListCollection(forecast.fishermen); + + [Bindable] public var numBays:int = 3; + + + [Bindable] + public var numColumns:Number = 15; + [Bindable] + public var numFields:Number = 4; + [Bindable] + public var minValue:Number = 0; + [Bindable] + public var maxValue:Number = 10; + [Bindable] + public var colSum:Number = 30; + + public var currentColumn:int =1; + + private function init():void + { + // var newColumnArray:Array = new Array(numColumns); + //dg = new DataGridHandler(numFields,numColumns,minValue,maxValue,colSum); + var cols:Array = dg.columns; + for(var columnNumber:int=0; columnNumber<15; columnNumber++) + { + var newDataGridColumn:DataGridColumn = new DataGridColumn(); + + newDataGridColumn.draggable = false; + newDataGridColumn.sortable = false; + newDataGridColumn.resizable = false; + newDataGridColumn.width = 50; + + var comp:CustomNumericStepper = new CustomNumericStepper(); + comp.stepSize = 1; + comp.maximum = 3; + comp.minimum = 0; + + // newDataGridColumn.itemEditor = comp; + if(columnNumber == 0) + { + newDataGridColumn.editable = true; + newDataGridColumn.setStyle("backgroundColor", "#FFFF00"); + } + else + { + newDataGridColumn.editable = false; + } + + newDataGridColumn.headerText = "Day"+(columnNumber+1); // 1, 2, 3, ... + + + newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... + // newDataGridColumn.dataField = "name"; + + // newDataGridColumn.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + + // newColumnArray[columnNumber] = newDataGridColumn; + /*newDataGridColumn.rendererIsEditor = true; + newDataGridColumn.itemRenderer = new ClassFactory(CustomNumericStepper);*/ + newDataGridColumn.itemEditor = new ClassFactory(CustomNumericStepper); + newDataGridColumn.editorDataField = "value"; + + + cols.push(newDataGridColumn); + + } + dg.columns = cols; + + lblSum.text = "Sum must be 4"; + + } + + + private function invalidNum(n:Object):Boolean + { + if(n == null) return true; + + var pattern:RegExp = /^\d+$/; + var s:String = StringUtil.trim(String(n)); + +// debug.text = "."+n+"."+pattern.test(s)+(s is String); + + // if it does not match the pattern, it is invalid + return !pattern.test(s); + } + private function outOfBoundsNum(n:Object):Boolean + { + return Number(n) < 3 || Number(n) > 0; + return false; + } + + private function updateNextColumn():void + { + dg.columns[currentColumn].setStyle("backgroundColor", "#FFFFFF"); + dg.columns[currentColumn].editable = false; + currentColumn = currentColumn + 1; + dg.columns[currentColumn].editable = true; + dg.columns[currentColumn].setStyle("backgroundColor", "#FFFF00"); + + } + + ]]> +</mx:Script> + + <mx:DataGrid id="dg" width="100%" editable="true" rowCount="5" dataProvider="{fishermenPopulation}"> + <mx:columns> + <mx:DataGridColumn dataField="name" headerText="Fishermen (w/o you) in" sortable="false" draggable="false" width="180" fontSize="13" color="Green" editable="false"/> + </mx:columns> + </mx:DataGrid> +<mx:Label id="lblSum" fontSize="12" fontWeight="bold" textAlign="center" color="#E71039"/> +<mx:Button id="btnUpdate" label="Update" click="updateNextColumn()"/> + + + +</mx:VBox> +<!-- </mx:Application> --> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-12 02:39:13
|
Revision: 159 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=159&view=rev Author: kjonas Date: 2009-06-12 02:39:11 +0000 (Fri, 12 Jun 2009) Log Message: ----------- ForecastComponent.mxml renders on screen All "modes" render properly. No value-checking implemented. Modified Paths: -------------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> - <comp:ForecastComponent id="forecastComponent" numColumns="15" numBays="3" style="0"/> + <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:VBox> <mx:Script> <![CDATA[ Modified: mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/customComponents/Forecast1.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> - <mx:ArrayCollection id="sched"/> - <mx:HBox id="gridContainer"> <mx:VBox id="labels"> </mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-10 23:47:06 UTC (rev 158) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-12 02:39:11 UTC (rev 159) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> - <mx:VBox id="labels" verticalGap="2"/> + <mx:VBox id="labels" verticalGap="5" minWidth="{minimumWidth}" horizontalAlign="right"/> <mx:Script> <![CDATA[ @@ -14,20 +14,49 @@ [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); [Bindable] public var numBays:int = 3; [Bindable] public var numColumns:int = 15; + [Bindable] public var minimumWidth:int = 30; [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated public function init():void { + createGrid(); + fillGridColumns(); + fillGridFields(); + setGridHeight(); + addChild(dataGrid); + } + + private function addLabel(text:String="", html:Boolean=false):void + { + var newLabel:Label = new Label(); + if(text != "" && !html) + { + newLabel.text = text; + } + else if(html) + { + newLabel.htmlText = text; + } + labels.addChild(newLabel); + } + + private function addField():void + { + dataProvider.addItem(new Object()); + } + + private function createGrid():void + { dataGrid = new DataGrid; dataGrid.id = "dataGrid"; dataGrid.editable = true; dataGrid.enabled = true; - dataGrid.dataProvider = dataProvider; - - dataGrid.initialize(); - + } + + private function fillGridColumns():void + { var newColumnArray:Array = new Array(numColumns); - for(var columnNumber:int=0; columnNumber<newColumnArray.length; columnNumber++) + for(var columnNumber:int = 0; columnNumber < numColumns; columnNumber++) { var newDataGridColumn:DataGridColumn = new DataGridColumn(); newDataGridColumn.draggable = false; @@ -44,36 +73,76 @@ } dataGrid.columns = newColumnArray; + dataGrid.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + } + + private function fillGridFields():void + { var bayNumber:int = 0; if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing { - addLabel(); + if(style==0) + { + addLabel(" <b>Predict</b>:",true); + } + else + { + addLabel(" <b>You Predicted</b>:",true); + } + addLabel("# People in Harbor:"); + addField(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) { addLabel("# People in Bay " + (bayNumber+1) + ":"); + addField(); } } else if(style==2) { - addLabel(); + addLabel(" <b>Predict:</b>",true); + for(bayNumber=0; bayNumber<numBays; bayNumber++) { - addLabel("# Fish in Bay " + (bayNumber+1) + ":"); + addLabel("# Fish in Bay " + (bayNumber+1) + "(AM):"); + addField(); } } - - //end init() + else if(style==3) + { + addLabel(" <b>We calculate that:</b>",true); + + addLabel("You will be in location #:"); + addField(); + addLabel("You will get USD:"); + addField(); + addLabel("Others will get USD:"); + addField(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# Fish in Bay " + (bayNumber+1) + "(PM):"); + addField(); + } + } + dataGrid.dataProvider = dataProvider; } - public function addLabel(text:String=""):void + private function setGridHeight():void { - var newLabel:Label = new Label(); - if(text != "") + switch(style) { - newLabel.text = text; + case(0): + case(1): // 0:PeopleEntry, 1:PeopleViewing + dataGrid.height = (23)*(numBays+2)-1; + break; + case(2): // 2:FishEntry + dataGrid.height = (23)*(numBays+1); + break; + case(3): // 3:Calculated + dataGrid.height = (23)*(numBays+4)-3; + break; } - labels.addChild(newLabel); } ]]> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <kj...@us...> - 2009-07-10 07:04:08
|
Revision: 174 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=174&view=rev Author: kjonas Date: 2009-07-10 07:04:06 +0000 (Fri, 10 Jul 2009) Log Message: ----------- InformationWindowCreator.as method makeWindows() now returns a set of windows, descriptions, and an InformationWindowCreator.as object with which to update the windows. updateGoals has been tested with nested ArrayCollections of strings, and seems to work. (hence the strange "Update" button on the main page) "9 Notes - Yourself" is the information window that is updated by this button, and only on the first set of windows. It just tests the concept of updating. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -5,6 +5,8 @@ width="100%" height="100%" xmlns:custom="custom.*" initialize="init()"> + <mx:Button id="btnTemp" label="Update" click="updateObjectA.updateLearned(new ArrayCollection([new ArrayCollection(['test']),new ArrayCollection(['test']),new ArrayCollection(['test'])]))"/> + <mx:VBox id="vbxInfo"> <mx:TitleWindow id="InformationWindowA" width="400" height="200" title="Information Window A" clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> @@ -52,6 +54,8 @@ public var allInfoWindowsA:ArrayCollection = null; public var allInfoWindowsB:ArrayCollection = null; public var allInfoWindowsDescriptions:ArrayCollection = null; + public var updateObjectA:InformationWindowCreator = null; + public var updateObjectB:InformationWindowCreator = null; public var currInfoWindowsA:ArrayCollection = null; public var currInfoWindowsB:ArrayCollection = null; @@ -62,8 +66,19 @@ public function init():void { - allInfoWindowsA = makeWindows(); - allInfoWindowsB = makeWindows(); + // temporarily store all 3 objects returned... + allInfoWindowsA = makeWindows() as ArrayCollection; + allInfoWindowsB = makeWindows() as ArrayCollection; + + // extract the updaters + updateObjectA = allInfoWindowsA.getItemAt(2) as InformationWindowCreator; + updateObjectB = allInfoWindowsB.getItemAt(2) as InformationWindowCreator; + + // extract the information windows themselves + allInfoWindowsA = allInfoWindowsA.getItemAt(0) as ArrayCollection; + allInfoWindowsB = allInfoWindowsB.getItemAt(0) as ArrayCollection; + + var arry:ArrayCollection = new ArrayCollection(); // fix when communicating with server... for(var i:int=0;i<30;i++) arry.addItem(i); // fix when communicating with server... selectCurrentWindows( arry ); // fix when communicating with server... @@ -144,7 +159,8 @@ { var windowData:ArrayCollection = InformationWindowCreator.makeWindows(); allInfoWindowsDescriptions = windowData.getItemAt(1) as ArrayCollection; - return windowData.getItemAt(0) as ArrayCollection; + + return windowData; } public function selectCurrentWindows(selectedWindows:ArrayCollection):void Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -1,41 +1,27 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="custom.*" xmlns:as="actionscript.*" layout="horizontal" - backgroundGradientColors="[#FFFFFF, #B0B0FF]"> + backgroundGradientColors="[#FFFFFF, #B0B0FF]" xmlns:strategyDesign="custom.questions.strategyDesign.*" xmlns:dayByDayDecisions="custom.questions.dayByDayDecisions.*"> - <mx:VBox id="vbxInfo"> - <mx:TitleWindow id="InformationWindowA" width="300" height="200" title="Information Window A"/> - <mx:HBox id="hbxPickerA"> - <mx:ComboBox id="cbxPickerA"/> - <mx:Button id="btnPickerA" click="popupInformationWindow(1)"/> - </mx:HBox> - - <mx:TitleWindow id="InformationWindowB" width="300" height="200" title="Information Window B"/> - <mx:HBox id="hbxPickerB"> - <mx:ComboBox id="cbxPickerB"/> - <mx:Button id="btnPickerB" click="popupInformationWindow(2)"/> - </mx:HBox> + <mx:VBox> + <mx:Button id="save" click="save_click()" label="Save"/> + <mx:Button id="load" click="bak_click()" label="Load"/> + <dayByDayDecisions:DayByDayDecisionsQuestionC id="day1"/> + <dayByDayDecisions:DayByDayDecisionsQuestionC id="day2"/> </mx:VBox> <mx:Script> <![CDATA[ - import custom.InformationWindowPopup; - import mx.managers.PopUpManager; - public function popupInformationWindow(source:int):void + public var arry:ArrayCollection = new ArrayCollection(); + + public function save_click():void { -// Alert.cancelLabel = "Close"; -// var flags:uint = Alert.NONMODAL | Alert.CANCEL; -// var alert:Alert = Alert.show("::","Information Window",flags,null,null,null,Alert.CANCEL) - - var win:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; - PopUpManager.centerPopUp(win); - win.closedFunction = closedFunction; + arry = day1.save(); } - - public function closedFunction():void + public function bak_click():void { - btnPickerA.label += "."; + day2.load(arry); } ]]> @@ -43,29 +29,26 @@ <mx:Script> <![CDATA[ + import mx.controls.Alert; import custom.questions.CategoricalQuestionC; import actionscript.* import actionscript.questions.*; import actionscript.Block; import mx.collections.ArrayCollection; - public var block1:Block = new Block(); - - - // - // InstructionPage Testing below here - // - - public function fillBlock():void + public function makeBlock():Block { + var block1:Block = new Block(); try{ var questionGroups1:ArrayCollection = new ArrayCollection(); + var qg0:QuestionGroup = new QuestionGroup(); var qg1:QuestionGroup = new QuestionGroup(); var qg2:QuestionGroup = new QuestionGroup(); var qg3:QuestionGroup = new QuestionGroup(); var qg4:QuestionGroup = new QuestionGroup(); var qg5:QuestionGroup = new QuestionGroup(); var qg6:QuestionGroup = new QuestionGroup(); + qg0.questions = new ArrayCollection(); qg1.questions = new ArrayCollection(); qg2.questions = new ArrayCollection(); qg3.questions = new ArrayCollection(); @@ -75,8 +58,13 @@ block1.questionGroups = new ArrayCollection(); // create questions + var ddq1:Question = new Question(); + ddq1.question = "dayByDayDecisionsQuestion"; + ddq1.type = "dayByDayDecisions"; + var cat1:Categorical = new Categorical(); cat1.question = "categoricalQuestion"; + cat1.type = "categorical"; cat1.topics = new ArrayCollection(); cat1.specifics = new ArrayCollection(); @@ -84,29 +72,35 @@ var for2:ForecastingFish = new ForecastingFish(); var psy1:PsychometricQuestion = new PsychometricQuestion(); - psy1.question = "psychQuestion"; + psy1.question = "psychometricQuestion"; + psy1.type = "psychometric"; psy1.numberOfIntervals = 10; psy1.choices = new ArrayCollection(); psy1.choices.addItem("Highly Agree"); psy1.choices.addItem("Highly Neutral"); psy1.choices.addItem("Highly Disagree"); - var str1:StrategyDesign = new StrategyDesign(); - str1.question = "stratDesQuestion"; + var str1:Question = new Question(); + str1.question = "strategyDesignQuestion"; + str1.type = "strategyDesign"; var txt1:Question = new Question(); txt1.question = "textQuestion"; + txt1.type = "text"; // insert questions into groups + qg0.questions.addItem(ddq1); qg1.questions.addItem(cat1); - qg1.description = "testDesc"; - qg1.header = "testHead"; qg2.questions.addItem(for1); qg3.questions.addItem(for2); qg4.questions.addItem(psy1); qg5.questions.addItem(str1); qg6.questions.addItem(txt1); + qg1.description = "testDesc"; + qg1.header = "testHead"; + + block1.questionGroups.addItem(qg0); block1.questionGroups.addItem(qg1); block1.questionGroups.addItem(qg2); block1.questionGroups.addItem(qg3); @@ -114,25 +108,15 @@ block1.questionGroups.addItem(qg5); block1.questionGroups.addItem(qg6); -// debg.text += "finished\n"; + }catch(errObject:Error){ - debug.text += "block creation failure\n" + - errObject.message + "\n" + errObject.getStackTrace(); + Alert.show("block creation failure\n" + + errObject.message + "\n" + errObject.getStackTrace()); } + return block1; } ]]> </mx:Script> - <mx:VBox id="vbxContent" minWidth="700" horizontalAlign="center"> - <mx:HBox> - <mx:Button id="back" click="iPage.back()" label="back"/> - <mx:Button id="forward" click="iPage.forward()" label="forward"/> - </mx:HBox> - - <mx:Text id="debug" text=""/> - - <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> - </mx:VBox> - </mx:Application> Modified: mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-10 07:04:06 UTC (rev 174) @@ -17,18 +17,71 @@ public class InformationWindowCreator { - public var listeners:ArrayCollection; + public var goals:ArrayCollection; + public var learned:ArrayCollection; + public var learnedComm:ArrayCollection; + public var strategy:StrategyDesignQuestionC; + public var forecasting:ForecastingFishQuestionC; + public var dayByDayResults:DayByDayDecisionsQuestionC; + public var strategyResults:DayByDayDecisionsQuestionC; public function InformationWindowCreator() { - listeners = new ArrayCollection(); + goals = new ArrayCollection(); + learned = new ArrayCollection(); + learnedComm = new ArrayCollection(); + strategy = null; + forecasting = null; + dayByDayResults = null; + strategyResults = null; } + public function updateGoals(saved:ArrayCollection):void + { + (goals.getItemAt(0) as CategoricalQuestionC).load(saved.getItemAt(0) as ArrayCollection); + (goals.getItemAt(1) as CategoricalQuestionC).load(saved.getItemAt(1) as ArrayCollection); + (goals.getItemAt(2) as CategoricalQuestionC).load(saved.getItemAt(2) as ArrayCollection); + } + + public function updateLearned(saved:ArrayCollection):void + { + (learned.getItemAt(0) as TextQuestionC).load(saved.getItemAt(0) as ArrayCollection); + (learned.getItemAt(1) as TextQuestionC).load(saved.getItemAt(1) as ArrayCollection); + (learned.getItemAt(2) as TextQuestionC).load(saved.getItemAt(2) as ArrayCollection); + } + + public function updateLearnedWithCommunication(saved:ArrayCollection):void + { + (learnedComm.getItemAt(0) as TextQuestionC).load(saved.getItemAt(0) as ArrayCollection); + (learnedComm.getItemAt(1) as TextQuestionC).load(saved.getItemAt(1) as ArrayCollection); + (learnedComm.getItemAt(2) as TextQuestionC).load(saved.getItemAt(2) as ArrayCollection); + (learnedComm.getItemAt(3) as TextQuestionC).load(saved.getItemAt(3) as ArrayCollection); + } + + public function updateStrategyDesign(saved:ArrayCollection):void + { + strategy.load(saved); + strategyResults.loadFromStrategy(saved); + } + + public function updateForecasting(savedFish:ArrayCollection, savedPeople:ArrayCollection):void + { + forecasting.load(savedFish, savedPeople); + } + + public function updateDayByDayDecisions(saved:ArrayCollection):void + { + dayByDayResults.load(saved); + } + + //// + // Static functions for creating windows + //// public static var maxWidth:int = 460; public static function makeWindows():ArrayCollection { - var listenerObject:InformationWindowCreator = new InformationWindowCreator(); + var updateObject:InformationWindowCreator = new InformationWindowCreator(); var allInfoWindows:ArrayCollection = new ArrayCollection(); var allInfoWindowsDescriptions:ArrayCollection = new ArrayCollection(); @@ -47,7 +100,7 @@ tempWindow.addItem(temp); temp = new Text(); - (temp as Text).htmlText = "What is presented in an information window can be selected from the drop-down list below each window!<br><br>Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”).<br><br><br>If you would like to look at the contents of an information window bigger, click the “Pop Up” button below."; + (temp as Text).htmlText = "What is presented in an information window can be selected from the drop-down list below each window!<br><br>Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”).<br><br>If the information window looks too small or broken, click the “Pop Up” button below."; (temp as Text).width = maxWidth; tempWindow.addItem(temp); @@ -267,6 +320,7 @@ (temp as StrategyDesignQuestionC).description = "This is the strategy that you designed previously. Use it for reference."; (temp as StrategyDesignQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.strategy = temp as StrategyDesignQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Your Strategy"); @@ -292,6 +346,7 @@ temp = new CategoricalQuestionC(); (temp as CategoricalQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.goals.addItem(temp as CategoricalQuestionC); temp = new Label(); (temp as Label).text = "Your second most important goal is to"; @@ -299,6 +354,7 @@ temp = new CategoricalQuestionC(); (temp as CategoricalQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.goals.addItem(temp as CategoricalQuestionC); temp = new Label(); (temp as Label).text = "Your third most important goal is to"; @@ -306,6 +362,7 @@ temp = new CategoricalQuestionC(); (temp as CategoricalQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.goals.addItem(temp as CategoricalQuestionC); allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Your Goals"); @@ -323,6 +380,7 @@ temp = new ForecastingFishQuestionC(); (temp as ForecastingFishQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.forecasting = temp as ForecastingFishQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Your Forecast"); @@ -340,6 +398,7 @@ temp = new DayByDayDecisionsQuestionC(); (temp as DayByDayDecisionsQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.dayByDayResults = temp as DayByDayDecisionsQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Day-by-Day Results"); @@ -357,6 +416,7 @@ temp = new DayByDayDecisionsQuestionC(); (temp as DayByDayDecisionsQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.strategyResults = temp as DayByDayDecisionsQuestionC; allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Strategy Results"); @@ -377,6 +437,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learned.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "New Expectations on How the Others of the Group Will Act"; @@ -384,6 +445,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learned.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "Ideas for Improving Your Strategy"; @@ -391,6 +453,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learned.addItem(temp as TextQuestionC); allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Notes - Yourself"); @@ -411,6 +474,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "New Understanding of Fish Dynamics"; @@ -418,6 +482,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "New Expectations on How the Others of the Group Will Act"; @@ -425,6 +490,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); temp = new Label(); (temp as Label).text = "Ideas for Improving Your Strategy"; @@ -432,6 +498,7 @@ temp = new TextQuestionC(); (temp as TextQuestionC).enabled = false; tempWindow.addItem(temp); + updateObject.learnedComm.addItem(temp as TextQuestionC); allInfoWindows.addItem(tempWindow); allInfoWindowsDescriptions.addItem("Notes - With Group"); @@ -471,10 +538,11 @@ var content:ArrayCollection = new ArrayCollection(); content.addItem(allInfoWindows); content.addItem(allInfoWindowsDescriptions); + content.addItem(updateObject); for(var endLoop:int; endLoop < allInfoWindowsDescriptions.length; endLoop++) { - allInfoWindowsDescriptions.setItemAt(endLoop + (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); + allInfoWindowsDescriptions.setItemAt(endLoop +" "+ (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); } return content; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -3,7 +3,7 @@ <mx:String id="description"></mx:String> - <mx:Label id="txtPrompt" text="It's Day {currentDay}. Where will you go to fish, or will you stay in the harbor?"/> + <mx:Label id="txtPrompt" text="It's Day 1. Where will you go to fish, or will you stay in the harbor?"/> <mx:Label id="lblChosen" text="location chosen: {deciding}"/> <mx:HBox id="buttons"/> @@ -16,6 +16,8 @@ <mx:Script> <![CDATA[ + import mx.controls.Alert; + import mx.collections.ArrayCollection; import mx.controls.Button; import mx.controls.Text; import actionscript.questions.*; @@ -23,7 +25,6 @@ public var numBays:int = 3; [Bindable] public var deciding:int = 0; - [Bindable] public var currentDay:int = 1; [Bindable] public var cumTotal:Number = 0; [Bindable] public var dollarPerLb:Number = 3.99; @@ -71,7 +72,7 @@ txtTemp = new Text(); txtTemp = stylize(txtTemp); - txtTemp.htmlText = "Cumulative<br>Total"; + txtTemp.htmlText = "Total"; txtTemp.minWidth = 60; labels.addChild(txtTemp); } @@ -103,7 +104,7 @@ public function advance(event:MouseEvent=null):void { - if(currentDay == 30) + if(dayByDayContent.numChildren == 30) { return; } @@ -111,27 +112,65 @@ var newDay:OneDay = new OneDay(); newDay.numBays = numBays; newDay.initialize(); - newDay.day = currentDay++; + newDay.day = dayByDayContent.numChildren + 1; newDay.dollarPerLb = dollarPerLb; dayByDayContent.addChild(newDay.load(deciding)); cumTotal += newDay.presentTotal; -// try -// { -// var last:Object = dayByDayContent.getChildAt(dayByDayContent.numChildren - 1); -// if(last is OneDay) -// { -// cumTotal += (last as OneDay).presentTotal; -// } -// } -// catch(err:Error) -// { -// // silent failure -// } + txtPrompt.text = "It's Day "+(dayByDayContent.numChildren+1)+". Where will you go to fish, or will you stay in the harbor?"; + deciding = 0; - deciding = 0; + dayByDayContent.validateNow(); + dayByDayContent.verticalScrollPosition = dayByDayContent.maxVerticalScrollPosition; } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + + for(var i:int = 0; i < dayByDayContent.numChildren; i++) + { + var day:OneDay = dayByDayContent.getChildAt(i) as OneDay; + + var newDay:OneDay = new OneDay(); + newDay.numBays = numBays; + newDay.initialize(); + newDay.day = day.day; + newDay.dollarPerLb = day.day; + + newDay.decisions = new ArrayCollection(); + for(var j:int=0; j<day.decisions.length; j++) + { + var tempDecision:OneDecision = new OneDecision(); + tempDecision.lbsFished = (day.decisions.getItemAt(j) as OneDecision).lbsFished; + tempDecision.active = (day.decisions.getItemAt(j) as OneDecision).active; + tempDecision.peopleFishing = (day.decisions.getItemAt(j) as OneDecision).peopleFishing; + newDay.decisions.addItem(tempDecision); + } + + saveArray.addItem(newDay); + } + + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + dayByDayContent.removeAllChildren(); + cumTotal = 0; + + for(var i:int = 0; i < loadArray.length; i++) + { + var day:OneDay = loadArray.getItemAt(i) as OneDay; + + day.drawPartial(); + dayByDayContent.addChild(day); + cumTotal += day.presentTotal; + } + + txtPrompt.text = "It's Day "+(dayByDayContent.numChildren+1)+". Where will you go to fish, or will you stay in the harbor?"; + } + public function loadFromQuestion(question:Question):void { description = question.question; @@ -166,6 +205,70 @@ return moneyString; } + public function loadFromStrategy(saved:ArrayCollection):void + { + dayByDayContent.removeAllChildren(); + cumTotal = 0; + + var notRepeated:ArrayCollection = saved.getItemAt(0) as ArrayCollection; + var repeated:ArrayCollection = saved.getItemAt(1) as ArrayCollection; + var suspendWeight:Number = saved.getItemAt(2) as Number; + var suspendDays:Number = saved.getItemAt(3) as Number; + + var dayTotal:int = 0; + var location:String; + var days:Number; + var threshold:Number; + + for(var i:int=0; notRepeated.length > 0 && i < notRepeated.length; i++) + { + var notRepeatedDay:ArrayCollection = notRepeated.getItemAt(i) as ArrayCollection; + location = (notRepeatedDay.getItemAt(0) as String); + days = (notRepeatedDay.getItemAt(1) as Number); + threshold = (notRepeatedDay.getItemAt(2) as Number); + + dayTotal = executeCommand(location,days,threshold,dayTotal); + } + for(var j:int=0; j < repeated.length; ) + { + var repeatedDay:ArrayCollection = repeated.getItemAt(j) as ArrayCollection; + location = (repeatedDay.getItemAt(0) as String); + days = (repeatedDay.getItemAt(1) as Number); + threshold = (repeatedDay.getItemAt(2) as Number); + + dayTotal = executeCommand(location,days,threshold,dayTotal); + + j++; + if(dayTotal < 30 && j == repeated.length) + { + j = 0; + } + } + +// Alert.show("done"); + } + + public function executeCommand(location:String,days:Number,threshold:Number,dayTotal:int):int + { + for(var day:int=0; day < days && dayTotal < 30; day++) + { + deciding = 0; +// Alert.show(location+","+day+","+threshold,"",Alert.NONMODAL); + if(location.indexOf("Bay ") == 0) + { + try{ + deciding = Number(location.substring(4)); + }catch(err:Error){ + deciding = 0; + } + } + advance(); + dayTotal++; + } +// Alert.show("Exited","",Alert.NONMODAL); + return dayTotal; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -109,7 +109,7 @@ } var tempActive:OneDecision = new OneDecision(); - tempActive.lbsFished = Math.round(Math.random()*50)/10.0; + tempActive.lbsFished = getLbsFromServer(locationChosen); tempActive.initialize(); decisions.addItem(tempActive); } @@ -119,6 +119,11 @@ return this; } + public function getLbsFromServer(loc:int):Number + { + return Math.round(Math.random()*50)/10.0; + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-09 00:39:46 UTC (rev 173) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-10 07:04:06 UTC (rev 174) @@ -34,6 +34,12 @@ if(newValue == "Bay 1") location.selectedIndex = 1; if(newValue == "Bay 2") location.selectedIndex = 2; if(newValue == "Bay 3") location.selectedIndex = 3; + if(newValue == "Bay 4") location.selectedIndex = 1; + if(newValue == "Bay 5") location.selectedIndex = 2; + if(newValue == "Bay 6") location.selectedIndex = 3; + if(newValue == "Bay 7") location.selectedIndex = 1; + if(newValue == "Bay 8") location.selectedIndex = 2; + if(newValue == "Bay 9") location.selectedIndex = 3; changedLocation(); } public function getDays():Number This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-15 22:51:20
|
Revision: 184 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=184&view=rev Author: kjonas Date: 2009-07-15 22:51:14 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Core of program now known as FisheryExperimentCore.mxml, to be less confusing. Various components that rely on the number of bays, and information about them should now store a list of the Locations and their parameters. I have yet to work on the error-checking to ensure that the number of fish is less than the maxCapacity of a bay. SocioDemographicPage.mxml now has a drop-down menu with options Freshman, Sophomore, Junior, Senior, and Graduate/Other. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -24,11 +24,11 @@ <mx:Button id="btnPickerB" label="{btnPickerA.label}" click="popupInformationWindow(2)"/> </mx:HBox> - <mx:Button id="btnResetPopups" label="Reset Popups" click="closedFunction()"/> + <mx:Button id="btnResetPopups" label="Reset Popups" click="{closedFunction(1);closedFunction(2)}"/> </mx:VBox> <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> - <custom:FisheryExperimentKalin id="fisheryContent" blockLoader="loadBlock"/> + <custom:FisheryExperimentCore id="fisheryContent" blockLoader="loadBlock"/> </mx:VBox> <mx:Script> @@ -87,22 +87,23 @@ cbxChanged(); } - public function popupInformationWindow(source:int):void + public function popupInformationWindow(window:int):void { var temp:DisplayObject = null; var popupNew:InformationWindowPopup = PopUpManager.createPopUp(this, InformationWindowPopup, false) as InformationWindowPopup; popupNew.closedFunction = closedFunction; + popupNew.window = window; var old:TitleWindow = null; - if(source == 1) + if(window == 1) { old = InformationWindowA; popupA = popupNew; btnPickerA.enabled = cbxPickerA.enabled = false; } - else if(source == 2) + else if(window == 2) { old = InformationWindowB; popupB = popupNew; @@ -124,10 +125,10 @@ PopUpManager.centerPopUp(popupNew); } - public function closedFunction():void + public function closedFunction(window:int):void { var temp:DisplayObject = null; - if(popupA != null) + if(popupA != null && window == 1) { while(popupA.numChildren > 0) { @@ -140,7 +141,7 @@ popupA = null; } - if(popupB != null) + if(popupB != null && window == 2) { while(popupB.numChildren > 0) { Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -5,28 +5,43 @@ <mx:VBox> <mx:Button id="save" click="save_click()" label="Save"/> - <mx:Button id="load" click="bak_click()" label="Load"/> - <dayByDayDecisions:DayByDayDecisionsQuestionC id="day1"/> - <dayByDayDecisions:DayByDayDecisionsQuestionC id="day2"/> + <mx:Button id="load" click="load_click()" label="Load"/> + <strategyDesign:StrategyDesignQuestionC id="strat" locations="{locations}"/> + <dayByDayDecisions:DayByDayDecisionsQuestionC id="dayby" locations="{locations}"/> </mx:VBox> <mx:Script> <![CDATA[ public var arry:ArrayCollection = new ArrayCollection(); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + public function save_click():void { - arry = day1.save(); + } - public function bak_click():void + public function load_click():void { - day2.load(arry); + dayby.loadFromStrategy(strat.save()); } ]]> </mx:Script> + + + + + <mx:Script> <![CDATA[ import mx.controls.Alert; Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-15 22:51:14 UTC (rev 184) @@ -13,7 +13,6 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; - import mx.controls.Label; import mx.controls.Text; @@ -26,15 +25,17 @@ public var minPagesRead:int; public var currentPageNumber:int; public var highestPageReached:int; + public var locations:ArrayCollection = null; public var currBlock:Block; - public function PageDisplay(newBlock:Block, minimumPagesRead:int=1) + public function PageDisplay(newBlock:Block, minimumPagesRead:int=1, locations:ArrayCollection=null) { currBlock = newBlock; minPagesRead = minimumPagesRead; currentPageNumber = 0; highestPageReached = currentPageNumber; + this.locations = locations; loadPages(); } @@ -74,6 +75,7 @@ if(tempQuestion is ForecastingPeople) { var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); + fpq.locations = locations; fpq.loadFromQuestion(ForecastingPeople(tempQuestion)); fpq.id = "q"+question; @@ -82,6 +84,7 @@ else if(tempQuestion is ForecastingFish) { var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); + ffq.locations = locations; ffq.loadFromQuestion(ForecastingFish(tempQuestion)); ffq.id = "q"+question; @@ -109,6 +112,7 @@ tempQuestion.type.toLowerCase() == "strategydesign") { var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); + sdq.locations = locations; sdq.loadFromQuestion(Question(tempQuestion)); sdq.id = "q"+question; @@ -118,6 +122,7 @@ tempQuestion.type.toLowerCase() == "daybydaydecisions") { var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); + ddq.locations = locations; ddq.loadFromQuestion(Question(tempQuestion)); ddq.id = "q"+question; Added: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml (rev 0) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -0,0 +1,399 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.*" + clipContent="false" verticalScrollPolicy="off" horizontalScrollPolicy="off" + currentState="socioDemographic" initialize="init()" + width="720" height="490"> + + <mx:RemoteObject id="moduleService" destination="moduleService" fault="moduleFaultHandler(event)" result="moduleResultHandler(event)"/> + + <mx:states> + <mx:State name="socioDemographic"> + <mx:AddChild relativeTo="{content}"> + <comp:SocioDemographicPage id="socioDemographic" + x="{(content.width-socioDemographic.width)/2}" + y="{(content.height-socioDemographic.height)/2}"/> + </mx:AddChild> + <mx:SetProperty target="{content}" name="x"/> + <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> + </mx:State> + + <mx:State name="instructionsLoad"> + <mx:AddChild relativeTo="{content}"> + <comp:InstructionPage id="instructions" initialize="gotoInstructions()" locations="{locations}"/> + </mx:AddChild> + </mx:State> + + <mx:State name="instructions" enterState="instructions.initModule(currModule)"> + <mx:RemoveChild target="{instructions}"/> + <mx:AddChild relativeTo="{content}" target="{instructions}"/> + <mx:SetProperty target="{instructions}" name="visible" value="true"/> + </mx:State> + + <mx:State name="wait"> + <mx:AddChild relativeTo="{content}"> + <mx:Label id="lblWaiting" text="Waiting for next Module from server..." fontSize="16"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"> + <mx:AddChild relativeTo="{content}"> + <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> + </mx:AddChild> + <mx:SetProperty target="{btnAccept}" name="enabled" value="false"/> + <mx:SetProperty target="{btnBack}" name="enabled" value="false"/> + <mx:SetProperty target="{btnForward}" name="enabled" value="false"/> + </mx:State> + </mx:states> + + <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> + <mx:Canvas id="content" x="0" y="0" width="720" height="475"/> + <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> + + <mx:Button id="btnBack" label="« Back" click="back()" left="0" bottom="0" enabled="false"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="0"/> + <mx:Button id="btnForward" label="Forward »" click="forward()" right="0" bottom="0" enabled="false"/> + + <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> + <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> + <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> + + <mx:Script> + <![CDATA[ + import actionscript.*; + import actionscript.questions.*; + import custom.*; + import mx.controls.Label; + import mx.controls.Alert; + import mx.collections.ArrayCollection; + import flash.sampler.getInvocationCount; + import mx.rpc.events.ResultEvent; + import mx.rpc.events.FaultEvent; + import mx.messaging.messages.IMessage; + import mx.messaging.events.MessageAckEvent; + import mx.messaging.events.MessageFaultEvent; + import mx.messaging.FlexClient; + import mx.messaging.messages.AsyncMessage; + + // + // Important Variables + // + public var currModule:Module = null; + public var currModuleNumber:int = 0; + public var currBlock:Block = null; + public var currBlockNumber:int = 0; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + + public var blockLoader:Function = null; + + public var updateObjectA:InformationWindowCreator = null; + public var updateObjectB:InformationWindowCreator = null; + + public var instructionsLoaded:Boolean = false; + + private var shared:SharedObject; + private var flushMessage:String; + [Bindable] + public var Id : uint; + + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + + [Bindable] + public var randomNumbers:String; + private function ack(event:MessageAckEvent):void + { + //chart.setVisible(true); + randomNumbers = event.message.body as String; + //Alert.show("in ack method" + randomNumbers); + } + + public function init():void + { + moduleService.setToModule(1); + } + + private function gotoInstructions():void + { + btnForward.enabled = btnBack.enabled = true; + instructionsLoaded = true; + currentState = "instructions"; + } + private function sendBlockQuestions():void + { + + } + private function getNextModule():void + { + sendBlockQuestions(); + currModule = null; + currModuleNumber++; + + moduleService.getModule(currModuleNumber); + } + private function moduleResultHandler(event:ResultEvent):void + { + /* try{ + Alert.show("module==null:"+(event.result==null)+ + "\nblock==null:"+((event.result as Module).blocks == null)+ + "\nblock.length:"+((event.result as Module).blocks.length)+ + "\nblock1.questionGroups==null:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups==null)+ + "\nblock1.questionGroups.length:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups.length) + ); + }catch(err:Error){ + + } */ + + currModule = (event.result as actionscript.Module); + + if(currModule == null) + { + currentState = "none"; + } + else if(currModule.blocks == null || currModule.blocks.length < 1 || + (currModule.blocks.getItemAt(0) as Block) == null || + (currModule.blocks.getItemAt(0) as Block).questionGroups == null || + (currModule.blocks.getItemAt(0) as Block).questionGroups.length < 1) + { + currentState = "none"; + } + else if(!instructionsLoaded) + { + currentState = "instructionsLoad"; + } + else + { + gotoInstructions(); + } + } + private function moduleFaultHandler(event:FaultEvent):void + { + Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); + } + + public function getLocation():void + { + + } + private function locationResultHandler(event:ResultEvent):void + { + locations = new ArrayCollection(); + locations.addItem(newLocation(10, 0.50)); + locations.addItem(newLocation(20, 0.15)); + locations.addItem(newLocation(30, 0.05)); + } + private function locationFaultHandler(event:FaultEvent):void + { + + } + + private function resultHandler(event:ResultEvent):void + { + Id = event.result as uint; +// Alert.show("Student id is " + Id ); + consumer.disconnect(); + } + private function faultHandler(event:FaultEvent):void + { +// Alert.show("event fault is " + event.fault.faultDetail); + } + + + private function messageHandler(message:IMessage):void + { + randomNumbers = message.body as String; +// Alert.show( ""+randomNumbers); + } + + public function back():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + try + { + return (InstructionPage)(obj).back(); + } + catch(err:Error){} + } + return false; + } + + public function forward():Boolean + { + if(content.numChildren == 0) + { return false; } + var obj:DisplayObject = content.getChildAt(0); + + if(obj is InstructionPage) + { + try + { + return (InstructionPage)(obj).forward(); + } + catch(err:Error){} + } + return false; + } + + public function accept():Boolean + { + if(content.numChildren == 0) + { return false; } + + var obj:DisplayObject = content.getChildAt(0); + var returnValue:Boolean = false; + + if(obj is SocioDemographicPage) + { + var Id:uint = 0; + if( (SocioDemographicPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + + currentState = "wait"; + getNextModule(); + + + var info:SocioDemographicPage = SocioDemographicPage(obj); + Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); + + btnBack.enabled = btnForward.enabled = true; + + returnValue = true; + } + } + if(obj is InstructionPage) + { + try + { + if( (InstructionPage)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "wait"; + getNextModule(); + //consumer.subscribe(); + returnValue = true; + } + else + { + var newCurrBlock:Block = (InstructionPage)(obj).block; + if(newCurrBlock != currBlock) + { + currBlock = newCurrBlock; + currBlockNumber++; + blockLoader.call(); + } + } + } + catch(err:Error){} + } + + btnBack.enabled = btnForward.enabled = (currentState == "instructions"); + + return returnValue; + } + + public function makeBlock():Block + { + var block1:Block = new Block(); + try{ + var questionGroups1:ArrayCollection = new ArrayCollection(); + var qg0:QuestionGroup = new QuestionGroup(); + var qg1:QuestionGroup = new QuestionGroup(); + var qg2:QuestionGroup = new QuestionGroup(); + var qg3:QuestionGroup = new QuestionGroup(); + var qg4:QuestionGroup = new QuestionGroup(); + var qg5:QuestionGroup = new QuestionGroup(); + var qg6:QuestionGroup = new QuestionGroup(); + qg0.questions = new ArrayCollection(); + qg1.questions = new ArrayCollection(); + qg2.questions = new ArrayCollection(); + qg3.questions = new ArrayCollection(); + qg4.questions = new ArrayCollection(); + qg5.questions = new ArrayCollection(); + qg6.questions = new ArrayCollection(); + block1.questionGroups = new ArrayCollection(); + + // create questions + var ddq1:Question = new Question(); + ddq1.question = "dayByDayDecisionsQuestion"; + ddq1.type = "dayByDayDecisions"; + + var cat1:Categorical = new Categorical(); + cat1.question = "categoricalQuestion"; + cat1.type = "categorical"; + cat1.categoricalOptions = new ArrayCollection(); + + var for1:ForecastingPeople = new ForecastingPeople(); + var for2:ForecastingFish = new ForecastingFish(); + + var psy1:Psychometric = new Psychometric(); + psy1.question = "psychometricQuestionBipolar"; + psy1.type = "psychometric"; + psy1.maxSliderValue = 10; + psy1.choices = new ArrayCollection(); + psy1.choices.addItem("Highly Agree"); + psy1.choices.addItem("Neutral"); + psy1.choices.addItem("Highly Disagree"); + + var psy2:Psychometric = new Psychometric(); + psy2.question = "psychometricQuestionUnipolar"; + psy2.type = "psychometric"; + psy2.maxSliderValue = 10; + psy2.choices = new ArrayCollection(); + psy2.choices.addItem("Strong"); + psy2.choices.addItem("Neutral"); + + var str1:Question = new Question(); + str1.question = "strategyDesignQuestion"; + str1.type = "strategyDesign"; + + var txt1:Question = new Question(); + txt1.question = "textQuestion"; + txt1.type = "text"; + + // insert questions into groups + qg0.questions.addItem(ddq1); + qg1.questions.addItem(cat1); + qg2.questions.addItem(for1); + qg3.questions.addItem(for2); + qg4.questions.addItem(psy1); + qg4.questions.addItem(psy2); + qg5.questions.addItem(str1); + qg6.questions.addItem(txt1); + + qg1.description = "testDesc"; + qg1.header = "testHead"; + + block1.questionGroups.addItem(qg0); + block1.questionGroups.addItem(qg1); + block1.questionGroups.addItem(qg2); + block1.questionGroups.addItem(qg3); + block1.questionGroups.addItem(qg4); + block1.questionGroups.addItem(qg5); + block1.questionGroups.addItem(qg6); + + + }catch(errObject:Error){ + Alert.show("block creation failure\n" + + errObject.message + "\n" + errObject.getStackTrace()); + } + return block1; + } + + ]]> + </mx:Script> + +</mx:Canvas> + Deleted: mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentKalin.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -1,406 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="custom.*" - clipContent="false" verticalScrollPolicy="off" horizontalScrollPolicy="off" - currentState="socioDemographic" initialize="init()" - width="720" height="490"> - - <mx:RemoteObject id="moduleService" destination="moduleService" fault="moduleFaultHandler(event)" result="moduleResultHandler(event)"/> - - <mx:states> - <mx:State name="socioDemographic"> - <mx:AddChild relativeTo="{content}"> - <comp:SocioDemographicPage id="socioDemographic" - x="{(content.width-socioDemographic.width)/2}" - y="{(content.height-socioDemographic.height)/2}"/> - </mx:AddChild> - <mx:SetProperty target="{content}" name="x"/> - <mx:SetStyle target="{content}" name="horizontalCenter" value="0"/> - </mx:State> - - <mx:State name="instructionsLoad"> - <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage id="instructions" initialize="gotoInstructions()"/> - </mx:AddChild> - </mx:State> - - <mx:State name="instructions" enterState="instructions.initModule(currModule)"> - <mx:RemoveChild target="{instructions}"/> - <mx:AddChild relativeTo="{content}" target="{instructions}"/> - <mx:SetProperty target="{instructions}" name="visible" value="true"/> - </mx:State> - - <mx:State name="wait"> - <mx:AddChild relativeTo="{content}"> - <mx:Label id="lblWaiting" text="Waiting for next Module from server..." fontSize="16"/> - </mx:AddChild> - </mx:State> - - <mx:State name="none"> - <mx:AddChild relativeTo="{content}"> - <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> - </mx:AddChild> - </mx:State> - </mx:states> - - <!-- <mx:Canvas id="content" x="5" y="5" width="750" height="470"/> --> - <mx:Canvas id="content" x="0" y="0" width="720" height="475"/> - <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - - <mx:Button id="btnBack" label="« Back" click="back()" left="0" bottom="0" enabled="false"/> - <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="0"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="0" bottom="0" enabled="false"/> - - <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> - <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> - <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> - - <mx:Script> - <![CDATA[ - import actionscript.*; - import actionscript.questions.*; - import custom.*; - import mx.controls.Label; - import mx.controls.Alert; - import mx.collections.ArrayCollection; - import flash.sampler.getInvocationCount; - import mx.rpc.events.ResultEvent; - import mx.rpc.events.FaultEvent; - import mx.messaging.messages.IMessage; - import mx.messaging.events.MessageAckEvent; - import mx.messaging.events.MessageFaultEvent; - import mx.messaging.FlexClient; - import mx.messaging.messages.AsyncMessage; - - // - // Important Variables - // - public var currModule:Module = null; - public var currBlock:Block = null; - public var currBlockNumber:int = 0; - public var blockLoader:Function = null; - - public var updateObjectA:InformationWindowCreator = null; - public var updateObjectB:InformationWindowCreator = null; - - public var instructionsLoaded:Boolean = false; - - private var shared:SharedObject; - private var flushMessage:String; - [Bindable] - public var Id : uint; - - [Bindable] - public var randomNumbers:String; - private function ack(event:MessageAckEvent):void - { - //chart.setVisible(true); - randomNumbers = event.message.body as String; - //Alert.show("in ack method" + randomNumbers); - } - - public function init():void - { - moduleService.setToModule(1); - } - - private function gotoInstructions():void - { - instructionsLoaded = true; - currentState = "instructions"; - } - private function sendBlockQuestions():void - { - if(1==1)return; - if(currBlock == null) return; - var qgroups:ArrayCollection = currBlock.questionGroups; - for(var qgroupNum:int=0; qgroupNum<qgroups.length; qgroupNum++) - { - var questions:ArrayCollection = (qgroups.getItemAt(qgroupNum) as QuestionGroup).questions; - for(var qNum:int=0; qNum<questions.length; qNum++) - { - var question:Question = questions.getItemAt(qNum) as Question; - sendQuestion(question,currBlockNumber,qgroupNum,qNum); - } - } - } - private function sendQuestion(databaseObject:Object,blockNumber:int,questionGroupNumber:int,questionNumber:int):void - { - if(databaseObject is ArrayCollection) - { - var array:ArrayCollection = databaseObject as ArrayCollection; - if(array != null && array.length > 0) - { - if(array.getItemAt(0) is StudentStrategy) - { - var sstrat:StudentStrategy = array.getItemAt(0) as StudentStrategy; - // invoke service here - } - } - } - - } - - private function getModule():Module - { - sendBlockQuestions(); - // server request here - moduleService.getNextModule(); - - currModule = null; - return currModule; // set to null for now (clear old) - } - private function moduleResultHandler(event:ResultEvent):void - { -// try{ -// Alert.show("module==null:"+(event.result==null)+ -// "\nblock==null:"+((event.result as Module).blocks == null)+ -// "\nblock.length:"+((event.result as Module).blocks.length)+ -// "\nblock1.questionGroups==null:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups==null)+ -// "\nblock1.questionGroups.length:"+(((event.result as Module).blocks.getItemAt(0) as Block).questionGroups.length) -// ); -// }catch(err:Error){ -// -// } - - currModule = (event.result as actionscript.Module); - - if(currModule.description == "result of setModule - ignore!") - { - return; - } - else if(currModule == null || currModule.blocks == null || currModule.blocks.length < 1 || - (currModule.blocks.getItemAt(0) as Block) == null || - (currModule.blocks.getItemAt(0) as Block).questionGroups == null || - (currModule.blocks.getItemAt(0) as Block).questionGroups.length < 1) - { - currentState = "none"; - } - else if(!instructionsLoaded) - { - currentState = "instructionsLoad"; - } - else - { - gotoInstructions(); - } - - btnBack.enabled = btnForward.enabled = true; - } - private function moduleFaultHandler(event:FaultEvent):void - { - Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); - } - - private function resultHandler(event:ResultEvent):void - { - Id = event.result as uint; -// Alert.show("Student id is " + Id ); - consumer.disconnect(); - } - private function faultHandler(event:FaultEvent):void - { -// Alert.show("event fault is " + event.fault.faultDetail); - } - private function handleFault(event:MessageFaultEvent):void - { -// Alert.show("Message event fault is " + event.faultString); - } - - - private function messageHandler(message:IMessage):void - { - randomNumbers = message.body as String; -// Alert.show( ""+randomNumbers); - } - - public function back():Boolean - { - if(content.numChildren == 0) - { return false; } - var obj:DisplayObject = content.getChildAt(0); - - if(obj is InstructionPage) - { - try - { - return (InstructionPage)(obj).back(); - } - catch(err:Error){} - } - return false; - } - - public function forward():Boolean - { - if(content.numChildren == 0) - { return false; } - var obj:DisplayObject = content.getChildAt(0); - - if(obj is InstructionPage) - { - try - { - return (InstructionPage)(obj).forward(); - } - catch(err:Error){} - } - return false; - } - - public function accept():Boolean - { - if(content.numChildren == 0) - { return false; } - - var obj:DisplayObject = content.getChildAt(0); - var returnValue:Boolean = false; - - if(obj is SocioDemographicPage) - { - var Id:uint = 0; - if( (SocioDemographicPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - - currentState = "wait"; - getModule(); - // - // END TEMPORARY CODE - // - - - var info:SocioDemographicPage = SocioDemographicPage(obj); - Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); - - btnBack.enabled = true; - btnForward.enabled = true; - - returnValue = true; - } - } - if(obj is InstructionPage) - { - try - { - if( (InstructionPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "wait"; - getModule(); - //consumer.subscribe(); - returnValue = true; - } - else - { - var newCurrBlock:Block = (InstructionPage)(obj).block; - if(newCurrBlock != currBlock) - { - currBlock = newCurrBlock; - currBlockNumber++; - blockLoader.call(); - } - } - } - catch(err:Error){} - } - - btnBack.enabled = btnForward.enabled = (currentState == "instructions"); - - return returnValue; - } - - public function makeBlock():Block - { - var block1:Block = new Block(); - try{ - var questionGroups1:ArrayCollection = new ArrayCollection(); - var qg0:QuestionGroup = new QuestionGroup(); - var qg1:QuestionGroup = new QuestionGroup(); - var qg2:QuestionGroup = new QuestionGroup(); - var qg3:QuestionGroup = new QuestionGroup(); - var qg4:QuestionGroup = new QuestionGroup(); - var qg5:QuestionGroup = new QuestionGroup(); - var qg6:QuestionGroup = new QuestionGroup(); - qg0.questions = new ArrayCollection(); - qg1.questions = new ArrayCollection(); - qg2.questions = new ArrayCollection(); - qg3.questions = new ArrayCollection(); - qg4.questions = new ArrayCollection(); - qg5.questions = new ArrayCollection(); - qg6.questions = new ArrayCollection(); - block1.questionGroups = new ArrayCollection(); - - // create questions - var ddq1:Question = new Question(); - ddq1.question = "dayByDayDecisionsQuestion"; - ddq1.type = "dayByDayDecisions"; - - var cat1:Categorical = new Categorical(); - cat1.question = "categoricalQuestion"; - cat1.type = "categorical"; - cat1.categoricalOptions = new ArrayCollection(); - - var for1:ForecastingPeople = new ForecastingPeople(); - var for2:ForecastingFish = new ForecastingFish(); - - var psy1:Psychometric = new Psychometric(); - psy1.question = "psychometricQuestionBipolar"; - psy1.type = "psychometric"; - psy1.maxSliderValue = 10; - psy1.choices = new ArrayCollection(); - psy1.choices.addItem("Highly Agree"); - psy1.choices.addItem("Neutral"); - psy1.choices.addItem("Highly Disagree"); - - var psy2:Psychometric = new Psychometric(); - psy2.question = "psychometricQuestionUnipolar"; - psy2.type = "psychometric"; - psy2.maxSliderValue = 10; - psy2.choices = new ArrayCollection(); - psy2.choices.addItem("Strong"); - psy2.choices.addItem("Neutral"); - - var str1:Question = new Question(); - str1.question = "strategyDesignQuestion"; - str1.type = "strategyDesign"; - - var txt1:Question = new Question(); - txt1.question = "textQuestion"; - txt1.type = "text"; - - // insert questions into groups - qg0.questions.addItem(ddq1); - qg1.questions.addItem(cat1); - qg2.questions.addItem(for1); - qg3.questions.addItem(for2); - qg4.questions.addItem(psy1); - qg4.questions.addItem(psy2); - qg5.questions.addItem(str1); - qg6.questions.addItem(txt1); - - qg1.description = "testDesc"; - qg1.header = "testHead"; - - block1.questionGroups.addItem(qg0); - block1.questionGroups.addItem(qg1); - block1.questionGroups.addItem(qg2); - block1.questionGroups.addItem(qg3); - block1.questionGroups.addItem(qg4); - block1.questionGroups.addItem(qg5); - block1.questionGroups.addItem(qg6); - - - }catch(errObject:Error){ - Alert.show("block creation failure\n" + - errObject.message + "\n" + errObject.getStackTrace()); - } - return block1; - } - - ]]> - </mx:Script> - -</mx:Canvas> - Modified: mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -14,10 +14,11 @@ public var closedFunction:Function = null; public var valid:Boolean = true; + public var window:int = -1; private function titleWindow_close(evt:CloseEvent):void { - closedFunction.call(); + closedFunction.call(this,window); } ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -3,6 +3,7 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import actionscript.QuestionGroup; import actionscript.Module; import custom.questions.forecasting.*; @@ -18,8 +19,21 @@ [Bindable] public var numPages:int = 1; [Bindable] public var currPage:int = 0; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + public var savedForecastPeople:ArrayCollection = null; + public var savedForecastFish:ArrayCollection = null; + public var savedStrategyDesign:ArrayCollection = null; + public var savedDayByDayDecisions:ArrayCollection = null; + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } public function initModule(newModule:actionscript.Module):void { @@ -53,33 +67,27 @@ if(block != null && block.questionGroups != null) { minPagesRead = block.questionGroups.length - pageDisplay = new PageDisplay(block, minPagesRead); + pageDisplay = new PageDisplay(block, minPagesRead,locations); } if(pageDisplay == null) { debug2.text += "pageDisplay is null\n"; - pageDisplay = new PageDisplay(makeBlock(),0); + pageDisplay = new PageDisplay(makeBlock(),0,locations); } // pageDisplay = new PageDisplay(block, block.questionGroups.length); - - }catch(errObject:Error){ debug2.text += "pageDisplay creation failure\n" + errObject.message +"\n"+ errObject.getStackTrace() +"\n"; - pageDisplay = new PageDisplay(makeBlock(),0); + pageDisplay = new PageDisplay(makeBlock(),0,locations); // Alert.show(debug2.text); } -// debug2.text += "setting currPage...\n"; currPage = pageDisplay.currentPageNumber; -// debug2.text += "setting numPages...\n"; numPages = pageDisplay.pages.length; -// debug2.text += "adding currentPage...\n"; content.removeAllChildren(); content.addChild(pageDisplay.currentPage); -// debug2.text += "currentPage added.\n"; } public function back():Boolean Modified: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -21,7 +21,7 @@ } public function getSemester():String { - return txtSemester.text; + return cbxSemester.selectedItem as String; } public function accept():Boolean @@ -57,14 +57,6 @@ txtMajor.setStyle(bgcolor, white); } - if(getSemester().length == 0) - { - txtSemester.setStyle(bgcolor, red); - ready=false; - }else{ - txtSemester.setStyle(bgcolor, white); - } - enable(!ready); return ready; } @@ -74,7 +66,7 @@ boxGender.enabled = enabled; txtYear.enabled = enabled; txtMajor.enabled = enabled; - txtSemester.enabled = enabled; + cbxSemester.enabled = enabled; } public function save():ArrayCollection @@ -95,9 +87,13 @@ radioMale.selected = (gender == "M"); radioFemale.selected = (gender == "F"); } + else + { + radioMale.selected = radioFemale.selected = false; + } txtYear.text = (loadArray.getItemAt(1) as String); txtMajor.text = (loadArray.getItemAt(2) as String); - txtSemester.text = (loadArray.getItemAt(3) as String); + cbxSemester.selectedIndex = (cbxSemester.dataProvider as ArrayCollection).getItemIndex(loadArray.getItemAt(3) as String); } ]]> @@ -130,7 +126,8 @@ <mx:HBox> <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtSemester" width="75" maxChars="6"/> + <mx:ComboBox id="cbxSemester" selectedIndex="0" dataProvider="{new ArrayCollection(['Freshman','Sophomore','Junior','Senior','Graduate/Other'])}"/> + <!--<mx:TextInput id="txtSemester" width="75" maxChars="6"/>--> </mx:HBox> </mx:VBox> Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -21,6 +21,7 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.controls.Alert; import mx.collections.ArrayCollection; import mx.controls.Button; @@ -28,11 +29,20 @@ import actionscript.questions.*; import custom.questions.dayByDayDecisions.OneDay; - public var numBays:int = 3; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var deciding:int = 0; [Bindable] public var cumTotal:Number = 0; [Bindable] public var dollarPerLb:Number = 3.99; + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + public function init():void { buttons.removeAllChildren(); @@ -55,7 +65,7 @@ txtTemp.text = "Harbor"; labels.addChild(txtTemp); - for(var i:int = 0; i < numBays; i++) + for(var i:int = 0; i < locations.length; i++) { btnTemp = new Button(); btnTemp.label = "Bay" + (i+1); @@ -115,7 +125,7 @@ } var newDay:OneDay = new OneDay(); - newDay.numBays = numBays; + newDay.locations = locations; newDay.initialize(); newDay.day = dayByDayContent.numChildren + 1; newDay.dollarPerLb = dollarPerLb; @@ -138,7 +148,7 @@ var day:OneDay = dayByDayContent.getChildAt(i) as OneDay; var newDay:OneDay = new OneDay(); - newDay.numBays = numBays; + newDay.locations = locations; newDay.initialize(); newDay.day = day.day; newDay.dollarPerLb = day.day; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -3,11 +3,12 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.controls.Text; import mx.controls.Label; import mx.collections.ArrayCollection; - [Bindable] public var numBays:int = 3; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var decisions:ArrayCollection; public var previousTotal:Number = 0; @@ -15,13 +16,22 @@ public var day:int = 1; public var dollarPerLb:Number = 3.99; + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + public function init():void { if(decisions == null) { drawNull(); } - else if(decisions.length < numBays+1) + else if(decisions.length < locations.length+1) { drawPartial(); } @@ -47,7 +57,7 @@ public function drawPartial():void { var temp:OneDecision; - for(var i:int = decisions.length; i < numBays+1; i++) + for(var i:int = decisions.length; i < locations.length+1; i++) { temp = new OneDecision(); temp.active = false; @@ -70,7 +80,7 @@ dayText.minWidth = 50; addChild(dayText); - for(var i:int = 0; i < numBays+1 && i < decisions.length; i++) + for(var i:int = 0; i < locations.length+1 && i < decisions.length; i++) { var temp:OneDecision = (decisions.getItemAt(i) as OneDecision); presentTotal += temp.lbsFished; @@ -100,7 +110,7 @@ } else { - for(var i:int = 0; i < locationChosen && i < numBays; i++) + for(var i:int = 0; i < locationChosen && i < locations.length; i++) { var tempInactive:OneDecision = new OneDecision(); tempInactive.active = false; Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -33,8 +33,9 @@ public var loadFish:ArrayCollection = null; public var loadPeople:ArrayCollection = null; + [Bindable] public var locations:ArrayCollection = new ArrayCollection(); - [Bindable] public var numBays:int = 3; + [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 6; public function init():void Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -26,8 +26,9 @@ import custom.questions.forecasting.ForecastComponent; public var loadPeople:ArrayCollection = null; + [Bindable] public var locations:ArrayCollection = new ArrayCollection(); - [Bindable] public var numBays:int = 3; + [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 15; public function init():void Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -5,11 +5,22 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.collections.ArrayCollection; import mx.controls.Label; public var valueRequired:Boolean = false; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + private function init():void { if(valueRequired) @@ -27,6 +38,8 @@ { var newRow:PlannerRow = new PlannerRow(); newRow.valueRequired = this.valueRequired; + newRow.locations = locations; + newRow.initialize(); var newNumber:Label = new Label(); newNumber.text = "" + (numbers.numChildren+1); newNumber.height = 22; Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -1,11 +1,39 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> <mx:Script> <![CDATA[ + import actionscript.Location; public var valueRequired:Boolean = false; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + + public function init():void + { + locs.removeAll(); + var obj:Object = new Object(); + obj.data = "Harbor"; + obj.label = obj.data; + locs.addItem(obj); + + for(var i:int=0; i<locations.length; i++) + { + obj = new Object(); + obj.data = "Bay " + (i+1); + obj.label = obj.data; + locs.addItem(obj); + } + } + public function deleteMe():void { if(!valueRequired || parent.numChildren > 1) @@ -30,16 +58,19 @@ } 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; - if(newValue == "Bay 4") location.selectedIndex = 1; - if(newValue == "Bay 5") location.selectedIndex = 2; - if(newValue == "Bay 6") location.selectedIndex = 3; - if(newValue == "Bay 7") location.selectedIndex = 1; - if(newValue == "Bay 8") location.selectedIndex = 2; - if(newValue == "Bay 9") location.selectedIndex = 3; + try{ + if(newValue.indexOf("Bay ") == 0) + { + location.selectedIndex = int(newValue.substring(4)); + } + else + { + location.selectedIndex = 0; + } + }catch(err:Error){ + location.selectedIndex = 0; + } + changedLocation(); } public function getDays():Number @@ -67,12 +98,7 @@ ]]> </mx:Script> - <mx:ArrayCollection id="locs"> - <mx:Object label="Harbor" data="Harbor"/> - <mx:Object label="Bay 1" data="Bay 1"/> - <mx:Object label="Bay 2" data="Bay 2"/> - <mx:Object label="Bay 3" data="Bay 3"/> - </mx:ArrayCollection> + <mx:ArrayCollection id="locs"/> <mx:Button id="deleteRow" label="Del" click="deleteMe()" width="60"/> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-15 21:54:25 UTC (rev 183) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-15 22:51:14 UTC (rev 184) @@ -11,11 +11,11 @@ <mx:HBox> <mx:VBox> <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> - <qComp:Planner id="notRepeated"/> + <qComp:Planner id="notRepeated" locations="{locations}"/> </mx:VBox> <mx:VBox> <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> - <qComp:Planner id="repeated" valueRequired="true"/> + <qComp:Planner id="repeated" valueRequired="true" locations="{locations}"/> </mx:VBox> </mx:HBox> @@ -39,6 +39,17 @@ import actionscript.questions.Question; import mx.collections.ArrayCollection; + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); + + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + public function getNotRepeated():ArrayCollection { return notRepeated.save(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-17 23:21:41
|
Revision: 187 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=187&view=rev Author: kjonas Date: 2009-07-17 23:21:35 +0000 (Fri, 17 Jul 2009) Log Message: ----------- trying to extract the information from questions into a form that we can use to send them to the server. A bit of text has been added to the ForecastingPeople component, which tells the user right at the start what the maximum number of people is for when they are filling in information. I need to have services created so that I know what I'm going to be sending back and forth with the server to give it the answers to the questions and simulate a game. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -94,8 +94,8 @@ public function init():void { // temporarily store all 3 objects returned... - allInfoWindowsA = makeWindows() as ArrayCollection; - allInfoWindowsB = makeWindows() as ArrayCollection; + allInfoWindowsA = makeWindows(); + allInfoWindowsB = makeWindows(); // extract the updaters updateObjectA = allInfoWindowsA.getItemAt(2) as InformationWindowCreator; Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-17 23:21:35 UTC (rev 187) @@ -13,6 +13,7 @@ import mx.collections.ArrayCollection; import mx.containers.VBox; + import mx.controls.Alert; import mx.controls.Text; @@ -67,10 +68,11 @@ { var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); - var txt:Text = new Text(); - txt.width = 300; - txt.htmlText = tempQuestion.question; - tempBox.addChild(txt); +// //This should be handled inside the question itself. +// var txt:Text = new Text(); +// txt.width = 300; +// txt.htmlText = tempQuestion.question; +// tempBox.addChild(txt); if(tempQuestion is ForecastingPeople) { @@ -175,9 +177,9 @@ { return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT } - return (DisplayObject)(pages.getItemAt(pages.length - 1)); // too high + return (DisplayObject)(pages.getItemAt(currentPageNumber = pages.length - 1)); // too high } - return (DisplayObject)(pages.getItemAt(0)); // too low + return (DisplayObject)(pages.getItemAt(currentPageNumber = 0)); // too low } return null; // no pages @@ -199,5 +201,108 @@ if(n > max) return max; return n; } + + public function reset():void + { + var curr:VBox = currentPage as VBox; + var messages:String = ""; + + if(curr != null) + { + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + + if(tempQuestion is PsychometricQuestionC) + { + (tempQuestion as PsychometricQuestionC).slider1.reset(); + messages += "P"; + } + else if(tempQuestion is CategoricalQuestionC) + { + (tempQuestion as CategoricalQuestionC).comboTopic.selectedIndex = 0; + (tempQuestion as CategoricalQuestionC).comboSpecific.selectedIndex = -1; + messages += "C"; + } + else + { + messages += "x"; + } + } +// Alert.show(messages); + } + } + + public function getQuestionResults():ArrayCollection + { + var curr:VBox = currentPage as VBox; + var questionResults:ArrayCollection = new ArrayCollection(); + var messages:String = ""; + + if(curr != null) + { + var tempQuestion:DisplayObject; + for(var i:int=0; i < curr.numChildren; i++) + { + tempQuestion = (curr.getChildAt(i) as DisplayObject); + var tempArray:ArrayCollection; + + if(tempQuestion == null) + { + messages += "(-)"; + } + else if(tempQuestion is ForecastingPeopleQuestionC) + { + messages += "(FP)"; + (tempQuestion as ForecastingPeopleQuestionC); + } + else if(tempQuestion is ForecastingFishQuestionC) + { + messages += "(FF)"; + (tempQuestion as ForecastingFishQuestionC); + } + else if(tempQuestion is CategoricalQuestionC) + { + messages += "(C)"; + tempArray = new ArrayCollection(); + tempArray.addItem((tempQuestion as CategoricalQuestionC).comboTopic.selectedItem); + var tempStr:String = (tempQuestion as CategoricalQuestionC).comboSpecific.selectedItem as String; + if(tempStr != null) + { + tempArray.addItem(tempStr); + } + } + else if(tempQuestion is PsychometricQuestionC) + { + messages += "(P)"; + (tempQuestion as PsychometricQuestionC).slider1.getValue(); + } + else if(tempQuestion is StrategyDesignQuestionC) + { + messages += "(S)"; + (tempQuestion as StrategyDesignQuestionC); + } + else if(tempQuestion is DayByDayDecisions) + { + messages += "(D)"; + (tempQuestion as DayByDayDecisionsQuestionC); + } + else if(tempQuestion is TextQuestionC) + { + messages += "(T)"; + (tempQuestion as TextQuestionC).textAnswer.text; + } + else + { + messages += "(-)"; + } + } +// Alert.show(messages); + } + + return questionResults; + } + } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -40,6 +40,7 @@ <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> </mx:AddChild> <mx:SetProperty target="{btnAccept}" name="enabled" value="false"/> + <mx:SetProperty target="{btnReset}" name="enabled" value="false"/> <mx:SetProperty target="{btnBack}" name="enabled" value="false"/> <mx:SetProperty target="{btnForward}" name="enabled" value="false"/> </mx:State> @@ -49,9 +50,10 @@ <mx:Canvas id="content" x="0" y="0" width="720" height="475"/> <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - <mx:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="150"> + <mx:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="100"> <mx:Button id="btnBack" label="« Back" click="back()" enabled="false"/> <mx:Button id="btnAccept" label="Accept" click="accept()" /> + <mx:Button id="btnReset" label="Reset" click="reset()" enabled="false"/> <mx:Button id="btnForward" label="Forward »" click="forward()" enabled="false"/> </mx:HBox> @@ -106,8 +108,7 @@ return newLoc; } - [Bindable] - public var randomNumbers:String; + [Bindable] public var randomNumbers:String; private function ack(event:MessageAckEvent):void { //chart.setVisible(true); @@ -117,12 +118,12 @@ public function init():void { - moduleService.setToModule(1); + } private function gotoInstructions():void { - btnForward.enabled = btnBack.enabled = true; + btnForward.enabled = btnBack.enabled = btnReset.enabled = true; instructionsLoaded = true; currentState = "instructions"; } @@ -272,7 +273,7 @@ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); currentState = "wait"; - btnBack.enabled = btnForward.enabled = true; + btnBack.enabled = btnForward.enabled = btnReset.enabled = true; getNextModule(); returnValue = true; @@ -309,11 +310,19 @@ } } - btnBack.enabled = btnForward.enabled = (currentState == "instructions"); + btnBack.enabled = btnForward.enabled = btnReset.enabled = (currentState == "instructions"); return returnValue; } + public function reset():void + { + if(content.getChildAt(0) is InstructionPage) + { + (content.getChildAt(0) as InstructionPage).reset(); + } + } + public function makeBlock():Block { var block1:Block = new Block(); Modified: mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/InformationWindowPopup.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" - layout="vertical" - title="Information Window Popup" - showCloseButton="true" - close="titleWindow_close(event);" - horizontalScrollPolicy="on" verticalScrollPolicy="on" - width="720" height="550"> + width="720" height="550" layout="vertical" + title="Information Window Popup" close="titleWindow_close(event);" showCloseButton="true" + horizontalScrollPolicy="on" verticalScrollPolicy="on"> <mx:Script> <![CDATA[ Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -179,6 +179,14 @@ return 0; } + public function reset():void + { + if(pageDisplay != null) + { + pageDisplay.reset(); + } + } + public function save():ArrayCollection { var saveArray:ArrayCollection = new ArrayCollection(); Modified: mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/CategoricalQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -10,7 +10,7 @@ <mx:HBox id="content"> <mx:ComboBox id="comboTopic" - dataProvider="{topics}" selectedIndex="0"/> + dataProvider="{topics}"/> <mx:ComboBox id="comboSpecific" prompt="Select" dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> </mx:HBox> @@ -55,6 +55,8 @@ topics.addItem((arry.getItemAt(i) as CategoricalOption).optionKey); specifics.addItem((arry.getItemAt(i) as CategoricalOption).choices); } + comboTopic.selectedIndex = 0; + comboSpecific.selectedIndex = -1; description = question.question; } Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -26,6 +26,7 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import mx.controls.Alert; import actionscript.questions.ForecastingFish; import mx.collections.ArrayCollection; @@ -33,11 +34,20 @@ public var loadFish:ArrayCollection = null; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection(); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 6; + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + public function init():void { fishEntry.initialize(); fishEntry.init(); Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -8,6 +8,8 @@ ]]> </mx:Script> + <mx:Text width="600" text="The sum of expected fishermen each day is {(peopleEntry.groupSize-1)}.\nDo not include yourself in the count."/> + <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> @@ -21,16 +23,26 @@ <mx:Script> <![CDATA[ + import actionscript.Location; import actionscript.questions.ForecastingPeople; import mx.collections.ArrayCollection; import custom.questions.forecasting.ForecastComponent; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection(); + [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(10, 0.50),newLocation(20, 0.15),newLocation(30, 0.05)]); [Bindable] public var numBays:int = locations.length; [Bindable] public var numColumns:int = 15; + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.maxCapacity = maxCapacity; + newLoc.growthRate = growth; + newLoc.initialPopulation = maxCapacity / 2.0; + return newLoc; + } + public function init():void { peopleEntry.initialize(); peopleEntry.init(); Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-16 21:00:46 UTC (rev 186) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2009-07-17 23:21:35 UTC (rev 187) @@ -11,11 +11,11 @@ <mx:HBox> <mx:VBox> <mx:Label text="Not Repeated decisions (start-up)" fontSize="18"/> - <qComp:Planner id="notRepeated" locations="{locations}"/> + <qComp:Planner id="notRepeated" preinitialize="notRepeated.locations=this.locations"/> </mx:VBox> <mx:VBox> <mx:Label text="Repeated decisions (after start-up)" fontSize="18"/> - <qComp:Planner id="repeated" valueRequired="true" locations="{locations}"/> + <qComp:Planner id="repeated" valueRequired="true" preinitialize="repeated.locations=this.locations"/> </mx:VBox> </mx:HBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-07-22 19:22:21
|
Revision: 196 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=196&view=rev Author: kjonas Date: 2009-07-22 18:42:10 +0000 (Wed, 22 Jul 2009) Log Message: ----------- created structure (but not necessarily code) for submitting answers for each question created StudentResponse.as as alias for StudentResponse.java, for sending responses Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/StudentResponse.as Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-22 01:16:38 UTC (rev 195) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-07-22 18:42:10 UTC (rev 196) @@ -170,11 +170,13 @@ public function componentsNotFinished():Boolean { var returnValue:Boolean = false; - var curr:VBox = currentPage as VBox; + var curr:VBox; var messages:String = ""; - if(curr != null) + for(var pageNumber:int=0; pageNumber < pages.length; pageNumber++) { + curr = pages.getItemAt(pageNumber) as VBox; + var tempQuestion:DisplayObject; for(var i:int=0; i < curr.numChildren; i++) { Added: mentalmodels/trunk/flex/src/actionscript/StudentResponse.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StudentResponse.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/StudentResponse.as 2009-07-22 18:42:10 UTC (rev 196) @@ -0,0 +1,14 @@ +package actionscript +{ + import actionscript.questions.Question; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.StudentResponse")] + public class StudentResponse + { + public var id:Number; + public var student:Student; + public var question:Question; + public var response:String; + } +} Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-22 01:16:38 UTC (rev 195) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-22 18:42:10 UTC (rev 196) @@ -4,8 +4,6 @@ currentState="socioDemographic" initialize="init()" width="720" height="490"> - <mx:RemoteObject id="moduleService" destination="moduleService" fault="moduleFaultHandler(event)" result="moduleResultHandler(event)"/> - <mx:states> <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> @@ -36,6 +34,7 @@ </mx:State> <mx:State name="none"> + <mx:RemoveChild target="{instructions}"/> <mx:AddChild relativeTo="{content}"> <mx:Label id="end" text="Thank you for playing!" fontSize="30"/> </mx:AddChild> @@ -57,15 +56,30 @@ <mx:Button id="btnForward" label="Forward »" click="forward()" enabled="false"/> </mx:HBox> - <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> + + <mx:RemoteObject id="roundService" destination="roundService" fault="faultHandler(event)"> + <mx:method name="getNextModule" result="moduleResultHandler(event)"/> + </mx:RemoteObject> + <mx:RemoteObject id="startupService" destination="startupService" fault="faultHandler(event)"> + <mx:method name="createStudent" result="studentResultHandler(event)"/> + <mx:method name="getFirstModule" result="moduleResultHandler(event)"/> + </mx:RemoteObject> + <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> <mx:Consumer id="consumer" destination="DataPush" message="messageHandler(event.message)" /> <mx:Script> <![CDATA[ + import custom.*; + import custom.questions.*; + import custom.questions.dayByDayDecisions.DayByDayDecisionsQuestionC; + import custom.questions.forecasting.ForecastingPeopleQuestionC; + import custom.questions.forecasting.ForecastingFishQuestionC; + import custom.questions.psychometric.PsychometricQuestionC; + import custom.questions.strategyDesign.StrategyDesignQuestionC; import actionscript.*; import actionscript.questions.*; - import custom.*; + import mx.containers.VBox; import mx.controls.Label; import mx.controls.Alert; import mx.collections.ArrayCollection; @@ -94,10 +108,7 @@ public var instructionsLoaded:Boolean = false; - private var shared:SharedObject; - private var flushMessage:String; - [Bindable] - public var Id : uint; + [Bindable] public var studentObject:Student; private function newLocation(maxCapacity:Number,growth:Number):Location { @@ -130,7 +141,59 @@ } private function sendBlockQuestions():void { + if(instructions == null) return; + var studentResponse:StudentResponse; + var pages:ArrayCollection = instructions.pageDisplay.pages; + + for(var i:int=0; i<pages.length; i++) + { + var curr:VBox = pages.getItemAt(i) as VBox + + for(var j:int=0; j<curr.numChildren; j++) + { + studentResponse = new StudentResponse(); +// studentResponse.student = Id; + + if(curr.getChildAt(j) is TextQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as TextQuestionC).description; + studentResponse.response = (curr.getChildAt(j) as TextQuestionC).textAnswer.text; + } + else if(curr.getChildAt(j) is PsychometricQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as PsychometricQuestionC).description; + studentResponse.response = (curr.getChildAt(j) as PsychometricQuestionC).slider1.getValue() + ""; + } + else if(curr.getChildAt(j) is CategoricalQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as CategoricalQuestionC).description; + studentResponse.response = (curr.getChildAt(j) as CategoricalQuestionC).comboTopic.selectedItem as String; + studentResponse.response += ", "; + studentResponse.response += (curr.getChildAt(j) as CategoricalQuestionC).comboSpecific.selectedItem as String; + } + else if(curr.getChildAt(j) is DayByDayDecisionsQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as DayByDayDecisionsQuestionC).description; + studentResponse.response = null; + } + else if(curr.getChildAt(j) is ForecastingPeopleQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as ForecastingPeopleQuestionC).description; + studentResponse.response = null; + } + else if(curr.getChildAt(j) is ForecastingFishQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as ForecastingFishQuestionC).description; + studentResponse.response = null; + } + else if(curr.getChildAt(j) is StrategyDesignQuestionC) + { +// studentResponse.question = (curr.getChildAt(j) as StrategyDesignQuestionC).description; + studentResponse.response = null; + } + } + } } private function reportBlockFinished():void { @@ -140,11 +203,11 @@ } private function getNextModule():void { - reportBlockFinished(); + if(instructions != null) reportBlockFinished(); currModule = null; currModuleNumber++; - moduleService.getModule(currModuleNumber); + roundService.getNextModule(currModuleNumber); } private function moduleResultHandler(event:ResultEvent):void { @@ -170,10 +233,6 @@ gotoInstructions(); } } - private function moduleFaultHandler(event:FaultEvent):void - { - Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); - } public function getLocation():void { @@ -186,20 +245,15 @@ locations.addItem(newLocation(20, 0.15)); locations.addItem(newLocation(30, 0.05)); } - private function locationFaultHandler(event:FaultEvent):void - { - - } - private function resultHandler(event:ResultEvent):void + private function studentResultHandler(event:ResultEvent):void { - Id = event.result as uint; -// Alert.show("Student id is " + Id ); + studentObject = event.result as Student; consumer.disconnect(); } private function faultHandler(event:FaultEvent):void { -// Alert.show("event fault is " + event.fault.faultDetail); + Alert.show(event.fault.message + "\n" + event.fault.getStackTrace()); } @@ -260,7 +314,7 @@ expiredContent.addChild(obj); var info:SocioDemographicPage = SocioDemographicPage(obj); - Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); + Id = startupService.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); currentState = "wait"; btnBack.enabled = btnForward.enabled = btnReset.enabled = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2010-01-15 19:13:15
|
Revision: 429 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=429&view=rev Author: kjonas Date: 2010-01-15 19:12:57 +0000 (Fri, 15 Jan 2010) Log Message: ----------- working on CommunicationC, Seema has an error to resolve with the server (messages sent to server, but not pushed to clients) DataModel.as made to store Singleton variables. Modified Paths: -------------- mentalmodels/trunk/flex/src/StartGame.mxml mentalmodels/trunk/flex/src/actionscript/Communication.as mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/actionscript/Student.as mentalmodels/trunk/flex/src/custom/CommunicationC.mxml mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/DataModel.as Modified: mentalmodels/trunk/flex/src/StartGame.mxml =================================================================== --- mentalmodels/trunk/flex/src/StartGame.mxml 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/StartGame.mxml 2010-01-15 19:12:57 UTC (rev 429) @@ -137,9 +137,8 @@ // Server Response Events public function gameObjectResultHandler(event:ResultEvent):void { - if(event.result != null) + if(event.result as Game != null) { - var description:String = (event.result as Game).gameCode; btnStartGame.enabled = true; game = event.result as Game; @@ -197,10 +196,7 @@ { Alert.show((event.message.body as int).toString()); } - - - - + } ]]> Modified: mentalmodels/trunk/flex/src/actionscript/Communication.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Communication.as 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/actionscript/Communication.as 2010-01-15 19:12:57 UTC (rev 429) @@ -6,7 +6,7 @@ { public var id:Number; public var message:String; - public var date:Date; + public var timestamp:Date; public var student:actionscript.Student; public var round:Round; } Added: mentalmodels/trunk/flex/src/actionscript/DataModel.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataModel.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/DataModel.as 2010-01-15 19:12:57 UTC (rev 429) @@ -0,0 +1,34 @@ +package actionscript +{ + public class DataModel + { + private static const INSTANCE:DataModel = new DataModel(); + + public var studentObject:actionscript.Student = null; + public var gameObject:actionscript.Game = null; + + public function DataModel():void + { + if (INSTANCE != null) + { + //Flash forces constructors to be public + //An error is thrown to prevent any new instances from being created. + throw new Error("An instance of DataModel already exists."); + } + else + { + initialize(); + } + } + + private function initialize():void + { + trace("DataModel created"); + } + + public static function get instance():DataModel + { + return INSTANCE; + } + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2010-01-15 19:12:57 UTC (rev 429) @@ -23,6 +23,7 @@ public var msg:String = ""; public var gameObject:actionscript.Game = null; + public var studentObject:actionscript.Student = null; public var pages:ArrayCollection; public var minPagesRead:int; public var currentPageNumber:int; @@ -149,6 +150,16 @@ tempBox.addChild(ffq); } + else if(tempQuestion.type.toLowerCase() == "communication") + { + var coq:CommunicationC = new CommunicationC(); + coq.id = "q"+question; + + coq.initialize(); + coq.init(); + + tempBox.addChild(coq); + } // when all else fails, text question else { Modified: mentalmodels/trunk/flex/src/actionscript/Student.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Student.as 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/actionscript/Student.as 2010-01-15 19:12:57 UTC (rev 429) @@ -8,7 +8,7 @@ public class Student { public var id:int; - public var group:int; + public var group:Group; public var studentNo:int; public var birthYear:int; public var major:String; @@ -17,6 +17,7 @@ public var gender:String; public var gameCode:String; public var game:Game; + public var money:Number; /** * input: @@ -30,7 +31,7 @@ * returns: * modified list of students */ - public static function assignGroups(students:ArrayCollection, maxGroupSize:int=5):ArrayCollection + /* public static function assignGroups(students:ArrayCollection, maxGroupSize:int=5):ArrayCollection { var groupSize:int = 0; var groupNum:int = 1; @@ -49,6 +50,6 @@ } return students; - } + } */ } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/custom/CommunicationC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/CommunicationC.mxml 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/custom/CommunicationC.mxml 2010-01-15 19:12:57 UTC (rev 429) @@ -3,6 +3,9 @@ <mx:Script> <![CDATA[ + import actionscript.DataModel; + import actionscript.DataModel; + import mx.controls.Alert; import mx.messaging.events.MessageEvent; import mx.rpc.events.FaultEvent; import actionscript.Communication; @@ -10,15 +13,24 @@ import mx.controls.Label; import mx.controls.Text; - public var student:Student = null; + public function init():void + { + Alert.show("commCons:"+(communicationConsumer == null) + +"\nstudent:"+(DataModel.instance.studentObject == null) + +"\ngroup:"+(DataModel.instance.studentObject==null || DataModel.instance.studentObject.group == null),"Null = true"); + + communicationConsumer.subtopic = DataModel.instance.studentObject.gameCode + "." + DataModel.instance.studentObject.group.id; + Alert.show(communicationConsumer.subtopic,"subtopic is"); + communicationConsumer.subscribe(); + } - public function faultHandler(event:FaultEvent):void + public function faultHandler(event:Object):void { // Silent Failure } public function messageHandler(event:MessageEvent):void { - if(event.message.body is actionscript.Communication) + if(event.message.body != null && event.message.body is actionscript.Communication) { commReceived(event.message.body as actionscript.Communication); } @@ -27,18 +39,19 @@ public function btnSend_click():void { var tempCommunication:actionscript.Communication = new actionscript.Communication(); - tempCommunication.date = new Date(); + tempCommunication.timestamp = new Date(); tempCommunication.message = txtMessage.text; - tempCommunication.student = this.student; + tempCommunication.student = DataModel.instance.studentObject; + tempCommunication.round = DataModel.instance.gameObject.currentRound; txtMessage.text = ""; - //<service>.<method>(tempCommunication); + communicationService.saveCommunication(tempCommunication); } public function btnSelfComm_click():void { var comm:actionscript.Communication = new actionscript.Communication(); comm.message = txtMessage.text; - comm.date = new Date(); + comm.timestamp = new Date(); comm.student = new actionscript.Student(); comm.student.id = 1; txtMessage.text = ""; @@ -61,7 +74,7 @@ private function commToText(comm:actionscript.Communication):Text { var newText:Text = new Text(); - newText.text = "["+comm.date.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; + newText.text = "["+comm.timestamp.toLocaleTimeString()+"] "+comm.student.id+": "+comm.message; return newText; } @@ -69,15 +82,16 @@ </mx:Script> <mx:RemoteObject id="communicationService" destination="communicationService" fault="faultHandler(event)"> - <mx:method name="sendCommunication" result="messageHandler(event)"/> + <mx:method name="saveCommunication" result="messageHandler(event)"/> </mx:RemoteObject> + <mx:Consumer id="communicationConsumer" destination="mme" fault="faultHandler(event)" message="messageHandler(event)"/> <mx:VBox id="vbxMessages" width="500" height="300" verticalScrollPolicy="on"/> <mx:HBox> - <mx:TextInput id="txtMessage" width="500"/> - <mx:Button id="btnSend" label="Send" click="btnSend_click()" visible="false"/> + <mx:TextInput id="txtMessage" width="400"/> + <mx:Button id="btnSend" label="Send" click="btnSend_click()" visible="true"/> <mx:Button id="btnSelfComm" label="SelfComm" click="btnSelfComm_click()" visible="false"/> </mx:HBox> Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2010-01-15 19:12:57 UTC (rev 429) @@ -144,19 +144,21 @@ // Responds to ArrayCollection by assuming it is of Student objects // This code assigns group and student numbers based on the object whose id // matches studentObject - if(event.message.body is actionscript.Block) + if(event.message.body is actionscript.Game) { - setBlock(event.message.body as actionscript.Block); - } - else if(event.message.body is actionscript.Game) - { gameObject = event.message.body as actionscript.Game; + DataModel.instance.gameObject = gameObject; setBlock(gameObject.currentBlock); if(instructions != null) { instructions.setGameObject(this.gameObject); } } + else if(event.message.body is actionscript.Block) + { + Alert.show("Server sent Block, not Game.",""); + setBlock(event.message.body as actionscript.Block); + } else if(event.message.body is ArrayCollection) { var students:ArrayCollection = new ArrayCollection(); @@ -170,10 +172,17 @@ { studentObject.group = actionscript.Student(students.getItemAt(i)).group; studentObject.studentNo = actionscript.Student(students.getItemAt(i)).studentNo; + + DataModel.instance.studentObject = studentObject; + + if(DataModel.instance.studentObject.group == null) + { + Alert.show("student group is null. Student ID is"+DataModel.instance.studentObject.id,"Error!"); + } } } } -// Alert.show("Current Student Information is: " + "\n"+studentObject.id +"\n"+studentObject.gameCode+"\n"+studentObject.studentNo); +// Alert.show("Current Student Information is: " + "\n"+SingletonStudent.instance.studentObject.id +"\n"+SingletonStudent.instance.studentObject.gameCode+"\n"+SingletonStudent.instance.studentObject.studentNo); } } @@ -285,7 +294,7 @@ studentResponse.response += ", "; studentResponse.response += (curr.getChildAt(j) as CategoricalQuestionC).comboSpecific.selectedItem as String; } - else if(curr.getChildAt(j) is DayByDayDecisionsQuestionC) + else if(curr.getChildAt(j) is DayByDayDecisionsQuestionC || curr.getChildAt(j) is CommunicationC) { //SKIP IT studentResponse.question = null; @@ -460,7 +469,7 @@ { consumer.subtopic = studentObject.gameCode; consumer.subscribe(); - //Alert.show("GameCode is '" + studentObject.gameCode + "'"); +// Alert.show("GameCode is '" + studentObject.gameCode + "'"); //Alert.show("subscribed to destination: " + consumer.destination); } } Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2010-01-15 19:12:57 UTC (rev 429) @@ -16,6 +16,7 @@ import mx.collections.ArrayCollection; [Bindable] public var gameObject:actionscript.Game = null; + public var studentObject:actionscript.Student = null; //[Bindable] public var moduleNumber:int = 1; //[Bindable] public var module:Module; [Bindable] public var blockNumber:int = 0; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2010-01-14 06:30:33 UTC (rev 428) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2010-01-15 19:12:57 UTC (rev 429) @@ -100,6 +100,7 @@ public function clicked(event:MouseEvent):void { + //event.currentTarget. try { deciding = 0; @@ -136,6 +137,7 @@ dayByDayContent.validateNow(); dayByDayContent.verticalScrollPosition = dayByDayContent.maxVerticalScrollPosition; + } public function save():ArrayCollection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-04-17 22:40:48
|
Revision: 103 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=103&view=rev Author: kjonas Date: 2009-04-17 22:40:37 +0000 (Fri, 17 Apr 2009) Log Message: ----------- Stub InstructionPageLoader created Modified Paths: -------------- mentalmodels/trunk/flex/src/TableTest.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as Modified: mentalmodels/trunk/flex/src/TableTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/TableTest.mxml 2009-04-17 22:32:45 UTC (rev 102) +++ mentalmodels/trunk/flex/src/TableTest.mxml 2009-04-17 22:40:37 UTC (rev 103) @@ -2,6 +2,7 @@ <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="absolute"> <mx:VBox> + <comp:InstructionPage id="instructionPage"/> <mx:HBox id="cast"> <!--<comp:Forecast id="legacy" numColumns="10"/>--> <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> @@ -18,7 +19,8 @@ public function init():void { - for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); +instructionPage.txt.htmlText = "this is a test <img src=\"http://www.google.com/intl/en_ALL/images/logo.gif\"><br>asdfghjkl;"; +//for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); } public function testNext(evt:Event=null):void Added: mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as 2009-04-17 22:40:37 UTC (rev 103) @@ -0,0 +1,10 @@ +package actionscript +{ + public class InstructionPageLoader + { + public function InstructionPageLoader() + { + } + + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-04-17 22:32:45 UTC (rev 102) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-04-17 22:40:37 UTC (rev 103) @@ -1,6 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> + <mx:Text width="800" height="300" id="html"> + <mx:htmlText/> + </mx:Text> + <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-04-29 02:34:00
|
Revision: 132 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=132&view=rev Author: kjonas Date: 2009-04-29 02:33:55 +0000 (Wed, 29 Apr 2009) Log Message: ----------- PageDisplay and InstructionPage should be working, but don't seem to be. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperiment.mxml mentalmodels/trunk/flex/src/actionscript/Block.as mentalmodels/trunk/flex/src/actionscript/Categorical.as mentalmodels/trunk/flex/src/actionscript/Forecasting.as mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/actionscript/Psychometric.as mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/QuestionPage_TEMP.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperiment.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/FisheryExperiment.mxml 2009-04-29 02:33:55 UTC (rev 132) @@ -85,7 +85,7 @@ { module = Module(event.result); - var block:Block = module.block.getItemAt(0) as Block + var block:Block = module.blocks.getItemAt(0) as Block Alert.show("block is " + block.description); } Added: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml (rev 0) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-04-29 02:33:55 UTC (rev 132) @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:actionscript="actionscript.*"> + + <!--this is a test file, don't hardcode everything like this, it's terrible practice--> + + <mx:ArrayCollection id="ch1"> + <mx:String>blah1</mx:String> + <mx:String>blah1</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection id="ch2"> + <mx:String>blah2</mx:String> + <mx:String>blah2</mx:String> + <mx:String>blah2</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection id="ch3"> + <mx:String>blah3</mx:String> + <mx:String>blah3</mx:String> + </mx:ArrayCollection> + + <mx:ArrayCollection id="q1"> + <actionscript:Psychometric choices="{ch1}" numberOfIntervals="5" question="Question1"/> + </mx:ArrayCollection> + + <mx:ArrayCollection id="q2"> + <actionscript:Psychometric choices="{ch2}" numberOfIntervals="5" question="Question2"/> + </mx:ArrayCollection> + + <mx:ArrayCollection id="q3"> + <actionscript:Psychometric choices="{ch3}" numberOfIntervals="5" question="Question3"/> + </mx:ArrayCollection> + + <mx:ArrayCollection id="qgrs"> + <actionscript:QuestionGroup questions="{q1}" description="desc" header="HEADER"/> + <actionscript:QuestionGroup questions="{q2}" description="desc" header="HEADER"/> + <actionscript:QuestionGroup questions="{q3}" description="desc" header="HEADER"/> + </mx:ArrayCollection> + + <actionscript:Block id="blk" questionGroups="{qgrs}"/> + + + + <comp:InstructionPage id="iPage" block="{blk}"/> + +</mx:Application> Modified: mentalmodels/trunk/flex/src/actionscript/Block.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Block.as 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/actionscript/Block.as 2009-04-29 02:33:55 UTC (rev 132) @@ -10,6 +10,6 @@ public var sequenceNo:int; public var description:String; public var duration:int; - public var questionGroup:ArrayCollection; + public var questionGroups:ArrayCollection; } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Categorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Categorical.as 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/actionscript/Categorical.as 2009-04-29 02:33:55 UTC (rev 132) @@ -4,7 +4,7 @@ [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.Categorical")] - public class Categorical + public class Categorical extends Question { public var choices:Object; } Modified: mentalmodels/trunk/flex/src/actionscript/Forecasting.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Forecasting.as 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/actionscript/Forecasting.as 2009-04-29 02:33:55 UTC (rev 132) @@ -4,7 +4,7 @@ [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.Forecasting")] - public class Forecasting + public class Forecasting extends Question { public var dayNo:int; } Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-04-29 02:33:55 UTC (rev 132) @@ -1,104 +1,163 @@ // ActionScript file package actionscript { - import mx.collections.ArrayCollection; + import customComponents.PsychometricQuestion; + import flash.display.DisplayObject; + import mx.collections.ArrayCollection; + import mx.containers.VBox; + import mx.controls.ComboBox; + import mx.controls.Label; + import mx.controls.Text; + import mx.controls.TextArea; + + [Bindable] public class PageDisplay { - private var _pages:ArrayCollection; - private var _minPagesRead:Number; - private var _currentPage; - private var _highestPageReached; + /* + pages:ArrayCollection should be a bunch of VBoxes. + The structure of an element of the pages:ArrayCollection is as follows: + (element / type / description) - public function PageDisplay(pages:ArrayCollection, minPagesRead:Number=1) + 0 / Label / this is the header + 1 / Text / description (USE THIS FOR INSTRUCTION PAGES) + + 2+2*N / Label / question description for N'th question + 3+2*N / TextArea,ComboBox,PsychometricQuestion,Forecasting / the question itself + + */ + + public var pages:ArrayCollection; + public var minPagesRead:Number; + public var currentPageNumber:Number; + public var highestPageReached:Number; + + public var currBlock:Block; + + public function PageDisplay(currBlock:Block, minPagesRead:Number=1) { - if(pages == null) this.pages = new ArrayCollection(); - _minPagesRead = minPagesRead; + this.currBlock = currBlock; + this.pages = new ArrayCollection(); + this.minPagesRead = minPagesRead; + this.currentPageNumber = 0; + this.highestPageReached = currentPageNumber; + + loadPages(); } - public function get pages():ArrayCollection - { return _pages; } - public function set pages(newValue:ArrayCollection):void + public function loadPages():void { - setPages(newValue); - } - public function setPages(newValue:ArrayCollection, adding:Boolean=false):void - { - if(adding) + for(var group:int=0; group<currBlock.questionGroups.length; group++) { - // concatenate the newValue ArrayCollection onto the end of _pages - for(var index:Number = 0; index < newValue.length; index++) + var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); + var tempBox:VBox = new VBox(); + + if(questionGroup.questions != null && questionGroup.questions.length != 0) { - addPage( newValue.getItemAt(index) ); + for(var question:int=0; question<questionGroup.questions.length; question++) + { + var tempQuestion:Question = Question(questionGroup.questions.getItemAt(question)); + + var txt:Text = new Text(); + txt.width = 300; + txt.htmlText = tempQuestion.question; + tempBox.addChild(txt); + + if(tempQuestion is actionscript.Forecasting) + { + // ??? how is this going to be worked in ??? + //tempBox.addChild(new mx.containers.HBox()); + } + else if(tempQuestion is Categorical) + { + var tempCat:Categorical = Categorical(tempQuestion); + var cq:ComboBox = new ComboBox(); + cq.id = "q"+question; + cq.dataProvider = tempCat.choices; + cq.initialize(); + tempBox.addChild(cq); + } + else if(tempQuestion is Psychometric) + { + var tempPsych:Psychometric = Psychometric(tempQuestion); + var pq:PsychometricQuestion = new PsychometricQuestion(); + pq.id = "q"+question; + pq.labels = tempPsych.choices; + pq.slider.maxValue = 3; + pq.init(); + tempBox.addChild(pq); + } + else + { + var tq:TextArea = new TextArea(); + tq.id = "q"+question; + tq.width = 150; + tq.height = 14; + tq.initialize(); + tempBox.addChild(tq); + } + } + var head:Label = new Label(); + var desc:Text = new Text(); + head.text = questionGroup.header; + desc.htmlText = questionGroup.description; + tempBox.addChildAt(head,0); + tempBox.addChildAt(desc,1); + pages.addItem(tempBox); } } - else - { - // replace _pages with newValue - _pages = newValue; - - // totally new list, reset to 0 - currentPageNumber = 0; - highestPageReached = currentPageNumber + 1; - } + } - public function addPage(newValue):void - { - if(newValue != null) - { - _pages.addItem(newValue); - } - } - public function get currentPageNumber():Number - { return _currentPage; } - public function set currentPageNumber(newValue:Number):void - { _currentPage = newValue; } - - public function get minPagesRead():Number - { return _minPagesRead; } - public function set minPagesRead(newValue:Number):void - { _minPagesRead = newValue; } - - public function get highestPageReached():Number - { return _highestPageReached; } - public function set highestPageReached(newValue:Number):void - { _highestPageReached = newValue; } - public function finished():Boolean - { return highestPageReached <= minPagesRead; } + { return highestPageReached >= minPagesRead - 1; } public function get length():Number - { return _pages.length; } + { return pages.length; } public function get currentPage():DisplayObject { - if(_pages != null && _pages.length > 0) // pages? + if(pages != null && pages.length > 0) // pages? { - if(_currentPage >= 0) // how low? + if(currentPageNumber >= 0) // how low? { - if(_currentPage < _pages.length) // how high? + if(currentPageNumber < pages.length) // how high? { - return (DisplayObject)(_pages.getItemAt(_currentPage)); // VALID_RESULT + return (DisplayObject)(pages.getItemAt(currentPageNumber)); // VALID_RESULT } - return (DisplayObject)(_pages.getItemAt(pages.length - 1)); // too high + return (DisplayObject)(pages.getItemAt(pages.length - 1)); // too high } - return (DisplayObject)(_pages.getItemAt(0)); // too low + return (DisplayObject)(pages.getItemAt(0)); // too low } return null; // no pages } - public function nextPage():void + public function nextPage():Boolean { currentPageNumber++; + if(currentPageNumber >= pages.length) + { + currentPageNumber = pages.length - 1; + return false; + } + if( currentPageNumber > highestPageReached ) { - highestPageReached = currentPageNumber + 1; + highestPageReached = currentPageNumber; } + return true; } - public function prevPage():void - { currentPageNumber--; } + public function prevPage():Boolean + { + currentPageNumber--; + if(currentPageNumber < 0) + { + currentPageNumber = 0; + return false; + } + return true; + } } } \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/Psychometric.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/Psychometric.as 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/actionscript/Psychometric.as 2009-04-29 02:33:55 UTC (rev 132) @@ -4,7 +4,7 @@ [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.Psychometric")] - public class Psychometric + public class Psychometric extends Question { public var scale:String; public var numberOfIntervals:int; Modified: mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/actionscript/QuestionGroup.as 2009-04-29 02:33:55 UTC (rev 132) @@ -4,7 +4,6 @@ [Bindable] [RemoteClass(alias="edu.asu.commons.mme.entity.QuestionGroup")] - public class QuestionGroup { public var id:Number; Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-04-29 02:33:55 UTC (rev 132) @@ -1,23 +1,58 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="init()"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> <mx:Script> <![CDATA[ + import actionscript.Block; + import actionscript.PageDisplay; import mx.collections.ArrayCollection; - [Bindable] - public var numPages:Number; //temporary hard-coded value *fix this* + public var block:Block; + public var pageDisplay:PageDisplay; + [Bindable] public var numPages:Number; + [Bindable] public var currPage:Number; - // Contains ArrayCollections filled with DisplayObjects - // *see: getDisp(pageNum, index) - private var allPageList:ArrayCollection; + public function init():void + { + pageDisplay = new PageDisplay(block, block.questionGroups.length); + currPage = pageDisplay.currentPageNumber; + numPages = pageDisplay.pages.length; + content.addChild(pageDisplay.currentPage); + } + public function back():Boolean + { + return pageDisplay.prevPage(); + } + + public function forward():Boolean + { + return pageDisplay.nextPage(); + } + + public function accept():Boolean + { + if(pageDisplay.finished()) + { + //do stuff + + + //and finish + return true; + } + return false; + } + + // Mutilate the following code: + + /* private var allPageList:ArrayCollection; + // Variables with default settings [Bindable] public var currPageNumber:Number = 0; public var pagesRead:Number = 1; - public function init():void + public function init_obsolete():void { numPages = loadAllPages(); showPage(); @@ -100,29 +135,12 @@ return false; } return showPage(); - } + } */ - public function back():Boolean - { - currPageNumber--; - return fixNum(); - } - - public function forward():Boolean - { - currPageNumber++; - return fixNum(); - } - - public function accept():Boolean - { - return pagesRead >= numPages; - } - ]]> </mx:Script> - <mx:Label text="{currPageNumber+1} / {numPages}"/> + <mx:Label text="{currPage+1} / {numPages}"/> <mx:VBox id="content"/> Added: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-04-29 02:33:55 UTC (rev 132) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> + + <mx:ArrayCollection id="pageSet1"> + + </mx:ArrayCollection> + + <mx:VBox id="p1"> + <mx:Text text="This is an information window." width="300"/> + <mx:Text text="What is presented in an information window can be selected from the drop-down list above each window!" width="300"/> + <mx:Text text="Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”)." width="300"/> + </mx:VBox> + <mx:VBox id="p2"> + <mx:Text text="num2" width="300"/> + </mx:VBox> + <mx:VBox id="p3"> + <mx:Text text="Welcome to the E-Fishery experiment" width="300"/> + <mx:Text text="In this experiment you will design a strategy to fish an abstract fishing ground together with three other persons. As we are mainly interested in the reasons why you choose a certain strategy, we will ask you a number of questions. For the same reason, there are no ‘correct’ or ‘wrong’ strategies and no ‘correct’ or ‘wrong’ answers. However, since for each pound of fish you get during the experiment you will receive #.### US$, you might be interested in finding a strategy that fits your goals well. For this, you have to understand the dynamics of the (simulated) fish population and anticipate well the behavior of the other persons of your group." width="300"/> + </mx:VBox> + + <!--<as:PageDisplay pages="{pageSet1}"/>--> + +</mx:Canvas> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-04-29 01:13:56 UTC (rev 131) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-04-29 02:33:55 UTC (rev 132) @@ -7,7 +7,7 @@ public var labels:ArrayCollection; - private function init():void + public function init():void { if(labels != null) { Added: mentalmodels/trunk/flex/src/customComponents/QuestionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/QuestionPage_TEMP.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/QuestionPage_TEMP.mxml 2009-04-29 02:33:55 UTC (rev 132) @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + +</mx:Canvas> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-15 22:36:23
|
Revision: 140 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=140&view=rev Author: seematalele Date: 2009-05-15 22:36:12 +0000 (Fri, 15 May 2009) Log Message: ----------- Created InitialiseDatabase.mxml and Module.mxml for facilitator to add questions into the database. Needs lot of modification. Added Paths: ----------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml Added: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml (rev 0) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-15 22:36:12 UTC (rev 140) @@ -0,0 +1,210 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" + backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" + width="760" height="510" clipContent="false" layout="absolute" currentState="none"> + <mx:Script> + <![CDATA[ + + import mx.collections.XMLListCollection; + import mx.controls.Alert; + + [Bindable] + private var company:XML = + + <list> + <module title="Preexperiment" sequenceNo="200"> + <block name="John H"> + <item name="item"/> + </block> + <block name="Sam K"/> + </module> + <!--<module title="Operations" code="400"> + + <block name="Bill C"/> + <block name="Jill W"/> + </module> + <module title="Engineering" code="300"> + + <block name="Erin M"/> + <block name="Ann B"/> + </module>--> + </list>; + + [Bindable] + + private var companyData:XMLListCollection = new XMLListCollection(company.module); + private function treeLabel(item:Object):String + { + + var node:XML = XML(item); + + if( node.localName() == "module" ) + + return node.@title; + else + return node.@name; + + + } + private function addModule():void + + { + + currentState = "module"; + /*var saveModule:Button = new Button; + saveModule.label ="Save Module"; + + pnlComponent.addChild(saveModule as DisplayObject); + //saveModule.*/ + + } + + private function saveModule():void + { + + Alert.show("in add module"); + + var newNode:XML = <module/> + newNode.setLocalName("module"); + + newNode.@title="first module"; + newNode.@sequenceNo ="1"; + + company.appendChild(newNode); + <!-- var newNode:XML = <employee/>; + // newNode.@name = empName.text; + var dept:XMLList =company.department.(@title == "Operations"); + if( dept.length() > 0 ) { + + dept[0].appendChild(newNode); + // empName.text = ""; + }--> + } + + + private function addBlock():void + + { + var newNode:XML = <block/>; + newNode.@name = "block1"; + var module:XMLList =company.module.(@title == "first module"); + if( module.length() > 0 ) { + + module[0].appendChild(newNode); + // empName.text = ""; + } + } + + private function addItem():void + + { + var newNode:XML = <item/>; + newNode.@name = "item1"; + var module:XMLList =company.module.(@title == "first module"); + var i:int; + for (i = 0; i < module.length(); i++) + { + if(module[i].block.@name == "block1") + { + var item:XMLList =company.module.block.(@name == "block1"); + if( item.length() > 0 ) + { + + item[0].appendChild(newNode); + + } + } + } + + } + + + private function removeEmployee():void + { + var node:XML = XML(tree.selectedItem); + if( node == null ) return; + if( node.localName() != "employee" ) return; + + var children:XMLList = XMLList(node.parent()).children(); + for(var i:Number=0; i < children.length(); i++) { + + if( children[i].@name == node.@name ) { + delete children[i]; + } + + } + } + ]]> + </mx:Script> + + <mx:states> + <mx:State name="module"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:Module id="module"/> + </mx:AddChild> + </mx:State> + + <!--<mx:State name="block"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> + </mx:AddChild> + </mx:State> + + <mx:State name="item"> + <mx:AddChild relativeTo="{pnlComponent}"> + <comp:PlannerPage id="planner"/> + </mx:AddChild> + </mx:State>--> + + <mx:State name="none"/> + </mx:states> + + <mx:HDividedBox width="100%" height="100%" id="hdMain"> + <mx:VBox height="100%" id="vboxLeft"> + <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" + labelFunction="treeLabel" + showRoot="true" + height="224" width="179"/> + + <mx:Canvas height="35%"> + <mx:Grid x="0" y="0"> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Module" id="butAddModule" click="{addModule()}"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Module" id="butRemModule"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Block" id="butAddBlock" click="{addBlock()}"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Block" id="butremBlock"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> + <mx:GridRow width="100%" height="100%"> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Add Item" id="butAddItem" click="{addItem()}"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + <mx:Button label="Remove Item" id="butremItem"/> + </mx:GridItem> + <mx:GridItem width="100%" height="100%"> + </mx:GridItem> + </mx:GridRow> + </mx:Grid> + + </mx:Canvas> + </mx:VBox> + <mx:Panel id = "pnlComponent" height="100%"> + + </mx:Panel> + </mx:HDividedBox> + +</mx:Application> Added: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-15 22:36:12 UTC (rev 140) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="utf-8"?> + + <!--<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" > + + <mx:Label text="Module Information" fontWeight="bold" width="150" textAlign="center" fontSize="12"/> + <mx:HBox> + <mx:Label text="Sequence Number:" fontWeight="bold" width="150" textAlign="right"/> + <mx:TextInput id="txtSeqNo" width="75" maxChars="3"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Name:" fontWeight="bold" width="150" textAlign="right"/> + <mx:TextInput id="txtName" width="120" maxChars="255"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Duration:" fontWeight="bold" width="150" textAlign="right"/> + <mx:TextInput id="txtDuration" width="75" maxChars="6"/> + </mx:HBox> +</mx:VBox>--> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="10%" autoLayout="true"> +<mx:Script> + <![CDATA[ + + public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getName():String + { + return txtName.text; + } + public function getMajor():String + { + return txtMajor.text; + } + public function getSemester():String + { + return txtSemester.text; + } + + + ]]> + </mx:Script> + <mx:FormItem label="Sequence Number:"> + <mx:TextInput id="txtSeqNo" maxChars="3"/> + </mx:FormItem> + <mx:FormItem label="Name:"> + <mx:TextInput id="txtName"/> + </mx:FormItem> + +<mx:FormItem label="Duration(hr:min:sec):"> + <mx:HBox> + <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1"/> + <mx:Label text=":" textAlign="center"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1"/> + </mx:HBox> + + +</mx:FormItem> + + </mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-19 01:12:06
|
Revision: 141 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=141&view=rev Author: seematalele Date: 2009-05-19 01:11:57 +0000 (Tue, 19 May 2009) Log Message: ----------- Made changes in Module.mxml and InitialiseDatabase.mxml. Worked on - Validation for module - Tested and working perfectly. Added functionality of getting selected current module in the tree. This functionality is used to add block for that particular module. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Module.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-15 22:36:12 UTC (rev 140) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-19 01:11:57 UTC (rev 141) @@ -4,6 +4,7 @@ width="760" height="510" clipContent="false" layout="absolute" currentState="none"> <mx:Script> <![CDATA[ + import mx.effects.Fade; import mx.collections.XMLListCollection; import mx.controls.Alert; @@ -51,48 +52,83 @@ { currentState = "module"; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var moduleInfo:Module = Module(obj); + moduleInfo.reset(); + btnsaveModule.enabled = true; /*var saveModule:Button = new Button; - saveModule.label ="Save Module"; + var isExists:Boolean = pnlComponent.contains(saveModule as DisplayObject); + Alert.show(isExists.toString()); + if(!pnlComponent.contains(saveModule as DisplayObject)) + { + saveModule.label ="Save Module"; - pnlComponent.addChild(saveModule as DisplayObject); + pnlComponent.addChild(saveModule as DisplayObject); + } //saveModule.*/ } - private function saveModule():void + private function saveModule(event:Event):void { - - Alert.show("in add module"); + //btnsaveModule.enabled = false; + var obj:DisplayObject = pnlComponent.getChildAt(1); + var moduleInfo:Module = Module(obj); - var newNode:XML = <module/> - newNode.setLocalName("module"); + var isModuleFormValid:Boolean = moduleInfo.validateForm(event); + if(isModuleFormValid) + { + var durationflag:Boolean = this.isDurationValid(moduleInfo.getHours(),moduleInfo.getMinutes(),moduleInfo.getSeconds()); + if(durationflag) + { + Alert.show("Please enter the valid duration for the given module."); + } + else + { + var newNode:XML = <module/> + newNode.setLocalName("module"); + newNode.@title=moduleInfo.getName(); + newNode.@sequenceNo =moduleInfo.getSequenceNo(); + company.appendChild(newNode); + currentState = "none"; + btnsaveModule.enabled = false; + + } + + } + else + { + Alert.show("Please fill the form correctly"); + } - newNode.@title="first module"; - newNode.@sequenceNo ="1"; - - company.appendChild(newNode); - <!-- var newNode:XML = <employee/>; - // newNode.@name = empName.text; - var dept:XMLList =company.department.(@title == "Operations"); - if( dept.length() > 0 ) { - - dept[0].appendChild(newNode); - // empName.text = ""; - }--> } + public function isDurationValid(hours:Number,minutes:Number,seconds:Number):Boolean + { + return (hours == 0 && minutes == 0 && seconds == 0); + + } - private function addBlock():void { - var newNode:XML = <block/>; + //currentState = "block"; + btnsaveModule.enabled = true; + + + + var node:XML = tree.selectedItem as XML; + + Alert.show("Selected node is " + node.@title); + + /* var newNode:XML = <block/>; newNode.@name = "block1"; var module:XMLList =company.module.(@title == "first module"); if( module.length() > 0 ) { module[0].appendChild(newNode); // empName.text = ""; - } + }*/ + } private function addItem():void @@ -134,13 +170,26 @@ } } + + private function treeChanged(event:Event):void + { + /* var selectedNode:int; + + //selectedNode=Tree(event.target).selectedItem; + var obj:DisplayObject = tree.getChildAt(selectedNode); + var newNode:XML = XML(obj); + Alert.show("Selected node is " + newNode.toString());*/ + + } + + ]]> </mx:Script> <mx:states> <mx:State name="module"> <mx:AddChild relativeTo="{pnlComponent}"> - <comp:Module id="module"/> + <comp:Module id="module"/> </mx:AddChild> </mx:State> @@ -162,9 +211,9 @@ <mx:HDividedBox width="100%" height="100%" id="hdMain"> <mx:VBox height="100%" id="vboxLeft"> <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" - labelFunction="treeLabel" - showRoot="true" - height="224" width="179"/> + labelFunction="treeLabel" allowMultipleSelection="false" selectable="true" + showRoot="true" change="{treeChanged(event)}" + height="224" width="179" /> <mx:Canvas height="35%"> <mx:Grid x="0" y="0"> @@ -202,9 +251,19 @@ </mx:Canvas> </mx:VBox> - <mx:Panel id = "pnlComponent" height="100%"> - + <mx:Panel id = "pnlComponent" height="100%" layout="vertical"> + <mx:HBox width="100%"> + <mx:Spacer width="40"/> + <mx:Button id = "btnsaveModule" label="Save Module" enabled="false" click="{saveModule(event)}"/> + <mx:Spacer width="40"/> + <mx:Button id = "btnsaveBlock" enabled="false" label="Save Block" /> + <mx:Spacer width="40"/> + <mx:Button id = "btnsaveItem" enabled="false" label="Save Item" /> + <mx:Spacer width="40"/> + + </mx:HBox> </mx:Panel> </mx:HDividedBox> + </mx:Application> Modified: mentalmodels/trunk/flex/src/customComponents/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-15 22:36:12 UTC (rev 140) +++ mentalmodels/trunk/flex/src/customComponents/Module.mxml 2009-05-19 01:11:57 UTC (rev 141) @@ -1,27 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> - <!--<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" > - - <mx:Label text="Module Information" fontWeight="bold" width="150" textAlign="center" fontSize="12"/> - <mx:HBox> - <mx:Label text="Sequence Number:" fontWeight="bold" width="150" textAlign="right"/> - <mx:TextInput id="txtSeqNo" width="75" maxChars="3"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Name:" fontWeight="bold" width="150" textAlign="right"/> - <mx:TextInput id="txtName" width="120" maxChars="255"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Duration:" fontWeight="bold" width="150" textAlign="right"/> - <mx:TextInput id="txtDuration" width="75" maxChars="6"/> - </mx:HBox> -</mx:VBox>--> + <mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="30%" height="10%" autoLayout="true"> <mx:Script> <![CDATA[ - + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + public function getSequenceNo():String { return txtSeqNo.text; @@ -30,36 +28,113 @@ { return txtName.text; } - public function getMajor():String + /*public function getDuration():String { - return txtMajor.text; + //return txtMajor.text; + }*/ + + public function getHours():Number + { + return hours.value; + } - public function getSemester():String + public function getMinutes():Number { - return txtSemester.text; + return minutes.value; + } + public function getSeconds():Number + { + return seconds.value; + + } + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (txtSeqNo.text == "" && txtName.text == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + txtSeqNo.text =""; + txtName.text = ""; + hours.value =0; + minutes.value =0; + seconds.value =0; + txtSeqNo.errorString =""; + txtName.errorString =""; + + } + + ]]> </mx:Script> <mx:FormItem label="Sequence Number:"> - <mx:TextInput id="txtSeqNo" maxChars="3"/> + <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Name:"> - <mx:TextInput id="txtName"/> + <mx:TextInput id="txtName" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Duration(hr:min:sec):"> <mx:HBox> <!--<mx:TextInput id="txtDuration" maxChars="8"/>--> - <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1"/> + <mx:NumericStepper id="hours" minimum="0" maximum="12" stepSize="1" change="{getHours()}"/> <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1"/> + <mx:NumericStepper id="minutes" minimum="0" maximum="60" stepSize="1" change="{getMinutes()}"/> <mx:Label text=":" textAlign="center"/> - <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1"/> + <mx:NumericStepper id="seconds" minimum="0" maximum="60" stepSize="1" change="{getSeconds()}"/> </mx:HBox> + + </mx:FormItem> - - </mx:Form> +<mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> + + +</mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-05-20 20:23:32
|
Revision: 143 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=143&view=rev Author: kjonas Date: 2009-05-20 20:23:22 +0000 (Wed, 20 May 2009) Log Message: ----------- created *Question components and corresponding actionscript files Modified Paths: -------------- mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml Added: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml (rev 0) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> + + <comp:TextQuestion id="question1"/> + <comp:CategoricalQuestion id="question2"/> + <comp:ForecastQuestion id="question3"/> + +</mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-19 17:42:25 UTC (rev 142) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:actionscript="actionscript.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:as="actionscript.*"> <!--this is a test file, don't hardcode everything like this, it's terrible practice--> @@ -18,24 +18,24 @@ </mx:ArrayCollection> <mx:ArrayCollection id="q1"> - <actionscript:Psychometric choices="{ch1}" numberOfIntervals="5" question="Question1"/> + <as:PsychometricQuestion choices="{ch1}" numberOfIntervals="5" question="Question1"/> </mx:ArrayCollection> <mx:ArrayCollection id="q2"> - <actionscript:Psychometric choices="{ch2}" numberOfIntervals="5" question="Question2"/> + <as:PsychometricQuestion choices="{ch2}" numberOfIntervals="5" question="Question2"/> </mx:ArrayCollection> <mx:ArrayCollection id="q3"> - <actionscript:Psychometric choices="{ch3}" numberOfIntervals="5" question="Question3"/> + <as:PsychometricQuestion choices="{ch3}" numberOfIntervals="5" question="Question3"/> </mx:ArrayCollection> <mx:ArrayCollection id="qgrs"> - <actionscript:QuestionGroup questions="{q1}" description="desc" header="HEADER"/> - <actionscript:QuestionGroup questions="{q2}" description="desc" header="HEADER"/> - <actionscript:QuestionGroup questions="{q3}" description="desc" header="HEADER"/> + <as:QuestionGroup questions="{q1}" description="desc" header="HEADER"/> + <as:QuestionGroup questions="{q2}" description="desc" header="HEADER"/> + <as:QuestionGroup questions="{q3}" description="desc" header="HEADER"/> </mx:ArrayCollection> - <actionscript:Block id="blk" questionGroups="{qgrs}"/> + <as:Block id="blk" questionGroups="{qgrs}"/> Added: mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/CategoricalQuestion.as 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.CategoricalQuestion")] + public class CategoricalQuestion extends Question + { + public var choices:Object; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingQuestion.as 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingQuestion")] + public class ForecastingQuestion extends Question + { + public var dayNo:int; + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-19 17:42:25 UTC (rev 142) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-20 20:23:22 UTC (rev 143) @@ -39,7 +39,6 @@ public function PageDisplay(currBlock:Block, minPagesRead:Number=1) { this.currBlock = currBlock; - this.pages = new ArrayCollection(); this.minPagesRead = minPagesRead; this.currentPageNumber = 0; this.highestPageReached = currentPageNumber; @@ -49,6 +48,9 @@ public function loadPages():void { + this.pages = new ArrayCollection(); + + for(var group:int=0; group<currBlock.questionGroups.length; group++) { var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); @@ -65,24 +67,24 @@ txt.htmlText = tempQuestion.question; tempBox.addChild(txt); - if(tempQuestion is actionscript.Forecasting) + if(tempQuestion is actionscript.ForecastingQuestion) { // ??? how is this going to be worked in ??? //tempBox.addChild(new mx.containers.HBox()); } - else if(tempQuestion is Categorical) + else if(tempQuestion is actionscript.CategoricalQuestion) { - var tempCat:Categorical = Categorical(tempQuestion); + var tempCat:CategoricalQuestion = CategoricalQuestion(tempQuestion); var cq:ComboBox = new ComboBox(); cq.id = "q"+question; cq.dataProvider = tempCat.choices; cq.initialize(); tempBox.addChild(cq); } - else if(tempQuestion is Psychometric) + else if(tempQuestion is actionscript.PsychometricQuestion) { - var tempPsych:Psychometric = Psychometric(tempQuestion); - var pq:PsychometricQuestion = new PsychometricQuestion(); + var tempPsych:actionscript.PsychometricQuestion = actionscript.PsychometricQuestion(tempQuestion); + var pq:customComponents.PsychometricQuestion = new customComponents.PsychometricQuestion(); pq.id = "q"+question; pq.labels = tempPsych.choices; pq.slider.maxValue = 3; Added: mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/PsychometricQuestion.as 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,13 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.PsychometricQuestion")] + public class PsychometricQuestion extends Question + { + public var scale:String; + public var numberOfIntervals:int; + public var choices:ArrayCollection; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + + <mx:Label id="header"/> + <mx:ComboBox id="comboTopic" dataProvider="{topics}" selectedIndex="0"/> + <mx:ComboBox id="comboSpecific" dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> + + + <mx:ArrayCollection id="topics"> + <mx:String>topic0</mx:String> + <mx:String>topic1</mx:String> + <mx:String>topic2</mx:String> + </mx:ArrayCollection> + + <!-- each element of this ArrayCollection will serve as a dataProvider --> + <mx:ArrayCollection id="specifics"> + <mx:ArrayCollection id="topic0"> + <mx:String>specific0.0</mx:String> + <mx:String>specific0.1</mx:String> + <mx:String>specific0.2</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection id="topic1"> + <mx:String>specific1.0</mx:String> + <mx:String>specific1.1</mx:String> + <mx:String>specific1.2</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection id="topic2"> + <mx:String>specific2.0</mx:String> + <mx:String>specific2.1</mx:String> + <mx:String>specific2.2</mx:String> + </mx:ArrayCollection> + </mx:ArrayCollection> + + <mx:Script> + <![CDATA[ + + public function fix(index:Number, list:ArrayCollection):Number + { + if( index < 0 ) return 0; + if( index >= list.length ) return list.length - 1; + return index; + } + + ]]> + </mx:Script> + +</mx:HBox> Added: mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:Label id="header"/> + <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> + <mx:Button id="next" label="Next" click="testNext()"/> + + <mx:Script> + <![CDATA[ + import mx.messaging.channels.StreamingAMFChannel; + import customComponents.*; + import mx.collections.ArrayCollection; + + public function init():void + { + for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); + } + + public function testNext(evt:Event=null):void + { + if(!forecastPeople.isFinished()) return; + var f2:Forecast2 = new Forecast2(); + f2.id = "forecastFull_AS"; + f2.numColumns = 6; + f2.oldForecast1 = forecastPeople; + this.addChild(f2); + } + + ]]> + </mx:Script> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-19 17:42:25 UTC (rev 142) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -6,6 +6,8 @@ import mx.collections.ArrayCollection; public var labels:ArrayCollection; + [Bindable] + public var maxValue:Number; public function init():void { @@ -49,6 +51,6 @@ <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center"/> <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center"/> - <comp:Slider id="slider" initialize="false"/> + <comp:Slider id="slider" initialize="false" maxValue="{maxValue}"/> </mx:Canvas> Added: mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/QuestionList.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> + + <mx:ArrayCollection id="questions"/> + + <mx:Script> + <![CDATA[ + import actionscript.Question; + + public function getItemAt(index:Number):Question + { + if(questions != null && questions.length > 0) + { + return questions.getItemAt(index) as Question; + } + return null; + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestion.mxml 2009-05-20 20:23:22 UTC (rev 143) @@ -0,0 +1,7 @@ +<?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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-05-27 01:15:53
|
Revision: 146 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=146&view=rev Author: seematalele Date: 2009-05-27 01:15:31 +0000 (Wed, 27 May 2009) Log Message: ----------- Added Categorical.mxml Created the interface. Some part is tested, some part needs to be tested. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/Question.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-22 00:49:28 UTC (rev 145) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-05-27 01:15:31 UTC (rev 146) @@ -294,8 +294,8 @@ { currentState = "question"; var obj:DisplayObject = pnlComponent.getChildAt(1); - var questionGroupInfo:QuestionGroup = QuestionGroup(obj); - questionGroupInfo.reset(); + var questionInfo:Question = Question(obj); + questionInfo.reset(); btnsaveModule.enabled = false; btnsaveBlock.enabled = false; @@ -334,8 +334,8 @@ var newNode:XML = <question/>; newNode.setLocalName("question"); - newNode.@header = questionInfo.getHeader(); - newNode.@description = questionInfo.getDescription(); + // newNode.@header = questionInfo.getHeader(); + //newNode.@description = questionInfo.getDescription(); newNode.@sequenceNo = questionInfo.getSequenceNo(); var block:XMLList =company.module.block.(@name == node.@name); @@ -480,7 +480,7 @@ <mx:Spacer width="40"/> <mx:Button id = "btnsaveQuestionGroup" enabled="false" label="Save QuestionGroup" click="{saveQuestionGroup(event)}" /> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" click="{saveQuestion(event)}" /> + <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" /> <mx:Spacer width="40"/> </mx:HBox> Added: mentalmodels/trunk/flex/src/customComponents/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Categorical.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/Categorical.mxml 2009-05-27 01:15:31 UTC (rev 146) @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> + <mx:Script> + <![CDATA[ + import mx.validators.NumberValidator; + import mx.validators.Validator; + import mx.events.ValidationResultEvent; + import mx.controls.Alert; + + [Bindable] + public var formIsEmpty:Boolean = true; + + [Bindable] + public var formIsValid:Boolean = false; + + + // Holds a reference to the currently focussed + // control on the form. + private var focussedFormControl:DisplayObject; + + /*public function getSequenceNo():String + { + return txtSeqNo.text; + } + public function getQuestion():String + { + return txtQuestion.text; + }*/ + + /*public function getDescription():String + { + return txtDescription.text; + }*/ + + + + public function validateForm(event:Event):Boolean + { + // Save a reference to the currently focussed form control + // so that the isValid() helper method can notify only + // the currently focussed form control and not affect + // any of the other form controls. + focussedFormControl = event.target as DisplayObject; + + // Mark the form as valid to start with + formIsValid = true; + + // Check if form is empty + formIsEmpty = (type.selectedValue == ""); + + // Run each validator in turn, using the isValid() + // helper method and update the value of formIsValid + // accordingly. + //validate(validateSeqNo); + return formIsValid; + + } + + private function validate(validator:Validator):Boolean + { + // Get a reference to the component that is the + // source of the validator. + var validatorSource:DisplayObject = validator.source as DisplayObject; + + // Suppress events if the current control being validated is not + // the currently focussed control on the form. This stops the user + // from receiving visual validation cues on other form controls. + // var suppressEvents:Boolean = (validatorSource != focussedFormControl); + var suppressEvents:Boolean = false; + // Carry out validation. Returns a ValidationResultEvent. + // Passing null for the first parameter makes the validator + // use the property defined in the property tag of the + // <mx:Validator> tag. + var event:ValidationResultEvent = validator.validate(null, suppressEvents); + + // Check if validation passed and return a boolean value accordingly. + var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID); + + // Update the formIsValid flag + formIsValid = formIsValid && currentControlIsValid; + + return currentControlIsValid; + } + + public function reset():void + { + + type.selectedValue =""; + } + + private function showRelativeFields():void + { + + vboxHeaders.visible = true; + vboxSecondHeader.visible = true; + + } + + private function showSimpleFields():void + { + Alert.show("Simple"); + } + + ]]> + </mx:Script> + + <mx:FormHeading label="Categorical"/> + <mx:FormItem label="Type:"> + <mx:RadioButtonGroup id="type"/> + + <mx:RadioButton id="rdoRelative" groupName="{type}" label="Relative" click="showRelativeFields()"/> + <mx:RadioButton id="rdoSimple" groupName="{type}" label="Simple" click="showSimpleFields()" /> + </mx:FormItem> + <mx:VBox> + + <mx:VBox id="vboxHeaders" visible="false"> + <mx:FormItem label="Header1:"> + <mx:TextInput id="txtHeader1" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:FormItem label="Header2:"> + <mx:TextInput id="txtHeader2" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:FormItem label="Choice for Header1:"> + <mx:TextInput id="txtchoiceHeader1" change="{validateForm(event)}"/> + </mx:FormItem> + + <mx:Button id="btnaddChoice1" label="Add Choice"/> + + </mx:VBox> + + <mx:HBox visible="false" id="vboxSecondHeader"> + <mx:VBox> + <mx:Label text="" id="lblHeader1"/> + <mx:List id="lstHeader1" wordWrap="true"/> + <mx:FormItem label="Choice for Header2:"> + <mx:TextInput id="txtaddChoice2" change="{validateForm(event)}"/> + </mx:FormItem> + + </mx:VBox> + <mx:VBox> + <mx:Label text="" id="lblHeader2"/> + <mx:List id="lstHeader2" wordWrap="true"/> + <mx:Button id="btnaddChoice2" label="Add Choice"/> + </mx:VBox> + + </mx:HBox> + + </mx:VBox> + + +</mx:Form> Modified: mentalmodels/trunk/flex/src/customComponents/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-22 00:49:28 UTC (rev 145) +++ mentalmodels/trunk/flex/src/customComponents/Question.mxml 2009-05-27 01:15:31 UTC (rev 146) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%"> +<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="80%" height="100%" currentState="none" xmlns:net="flash.net.*" xmlns:comp="customComponents.*"> <mx:Script> <![CDATA[ import mx.validators.NumberValidator; @@ -52,10 +52,28 @@ // helper method and update the value of formIsValid // accordingly. validate(validateSeqNo); + return formIsValid; } + private function showQuestionType():void + { + + currentState = "categorical"; + var obj:DisplayObject = canvasQuestionType.getChildAt(0); + //Alert.show("selected item is: " + cmbType.selectedItem); + if(cmbType.selectedItem == "Categorical") + { + + var categoricalInfo:Categorical = Categorical(obj); + categoricalInfo.reset(); + + + } + } + + private function validate(validator:Validator):Boolean { // Get a reference to the component that is the @@ -94,7 +112,24 @@ ]]> </mx:Script> + <mx:states> + <mx:State name="categorical"> + <mx:AddChild relativeTo="{canvasQuestionType}"> + <comp:Categorical id="categorical"/> + </mx:AddChild> + </mx:State> + <!--<mx:State name="psychometric"> + <mx:AddChild relativeTo="{canvasQuestionType}"> + <comp:Psychometric id="psychometri"/> + </mx:AddChild> + </mx:State>--> + + <mx:State name="none"/> + + </mx:states> + + <mx:FormHeading label="QuestionGroup"/> <mx:FormItem label="Sequence Number:"> <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> @@ -103,22 +138,23 @@ <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Select Question Type:"> - <mx:ComboBox id="cmbType" change="{validateForm(event)}" width="100%"> + <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%"> <mx:ArrayCollection> <mx:String>-Select-</mx:String> <mx:String>Categorical</mx:String> <mx:String>Psychometric</mx:String> + <mx:String>Text</mx:String> </mx:ArrayCollection> </mx:ComboBox> </mx:FormItem> - <mx:FormItem> - <mx:Panel width="250" height="200" layout="absolute"> + + <mx:Canvas id="canvasQuestionType" height="100%"/> - </mx:Panel> - </mx:FormItem> + + <mx:NumberValidator id ="validateSeqNo" source="{txtSeqNo}" property="text" minValue="1" maxValue="1000" domain="int"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-05-27 20:03:15
|
Revision: 147 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=147&view=rev Author: kjonas Date: 2009-05-27 20:02:40 +0000 (Wed, 27 May 2009) Log Message: ----------- Errors located and repaired in regards to PsychometricQuestion (renamed PsychometricQuestionC to indicate that it is a component and avoid compilation errors) PsychometricQuestionC does not seem to work anymore, cause unknown. Modified Paths: -------------- mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/TestApp.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/FishUtil.as mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml Modified: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,8 +1,47 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> + <mx:ArrayCollection id="topicList"> + <mx:String>- Select -</mx:String> + <mx:String>Your Earnings</mx:String> + <mx:String>Fish Population</mx:String> + <mx:String>Other Players</mx:String> + </mx:ArrayCollection> + + <mx:ArrayCollection id="specificList"> + <mx:ArrayCollection> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Earn as much as possible</mx:String> + <mx:String>Earn more than the others</mx:String> + <mx:String>Earn about the same as the others</mx:String> + <mx:String>Earn less then the others</mx:String> + <mx:String>Earn a fair amount but much less then would be possible</mx:String> + <mx:String>Earn nothing</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Let the fish population grow as much as possible</mx:String> + <mx:String>Keep the fish population at a high stable level</mx:String> + <mx:String>Keep the fish population at a medium stable level</mx:String> + <mx:String>Keep the fish population at a low stable level</mx:String> + <mx:String>Not to completely destroy the fish population</mx:String> + <mx:String>To destroy the fish population</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Act similarly to the others</mx:String> + <mx:String>Act differently than the others</mx:String> + <mx:String>Allow the others to have good earnings</mx:String> + <mx:String>Avoid that the others get good earnings</mx:String> + <mx:String>Act according to rules I expect the others to know</mx:String> + <mx:String>Act against rules I expect the others to know</mx:String> + </mx:ArrayCollection> + </mx:ArrayCollection> + <comp:TextQuestion id="question1"/> - <comp:CategoricalQuestion id="question2"/> + <comp:CategoricalQuestion id="question2" topics="{topicList}" specifics="{specificList}"/> <comp:ForecastQuestion id="question3"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/TestApp.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestApp.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/TestApp.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -23,10 +23,10 @@ <mx:String>label2</mx:String> </mx:ArrayCollection> - <comp:PsychometricQuestion id="slider3" labels="{slider3Labels}"/> - <mx:Label id="slideinfo3" text="{slider3.slider.getVal}"/> + <comp:PsychometricQuestionC id="slider3" labels="{slider3Labels}"/> + <mx:Label id="slideinfo3" text="{slider3.slider1.getVal}"/> - <comp:PsychometricQuestion id="slider4" labels="{slider4Labels}"/> - <mx:Label id="slideinfo4" text="{slider4.slider.getVal}"/> + <comp:PsychometricQuestionC id="slider4" labels="{slider4Labels}"/> + <mx:Label id="slideinfo4" text="{slider4.slider1.getVal}"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -37,8 +37,59 @@ <as:Block id="blk" questionGroups="{qgrs}"/> + <mx:Script> + <![CDATA[ + import actionscript.QuestionGroup; + import actionscript.PsychometricQuestion; + + public var choices1:ArrayCollection = new ArrayCollection(); + public var questions1:ArrayCollection = new ArrayCollection(); + public var questionGroups:ArrayCollection = new ArrayCollection(); + public var block1:Block = new Block(); + + public function fillBlock():void + { + try{ + debg.text += "creating choices\n"; + choices1.addItem("left"); + choices1.addItem("right"); + debg.text += "choices1.length="+choices1.length+"\n"; + + debg.text += "creating questions\n"; + questions1.addItem(new PsychometricQuestion()); + PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; + PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 5; + debg.text += "questions1.length="+questions1.length+"\n"; + + debg.text += "creating questiongroups\n"; + questionGroups.addItem(new QuestionGroup()); + QuestionGroup(questionGroups.getItemAt(0)).questions = questions1; + debg.text += "questionGroups.length="+questionGroups.length+"\n"; + + debg.text += "creating block\n"; + block1.questionGroups = questionGroups; + debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; + + debg.text += "finished\n"; + }catch(errObject:Error){ + debg.text += errObject.message + "\n" + errObject.getStackTrace(); + } + } + + ]]> + </mx:Script> + <mx:ArrayCollection id="labs"> + <mx:String>testLeft</mx:String> + <mx:String>testRight</mx:String> + </mx:ArrayCollection> + <comp:PsychometricQuestionC labels="{labs}"/> - <comp:InstructionPage id="iPage" block="{blk}"/> + <mx:Button id="forward" click="iPage.forward()" label="forward"/> + <mx:Button id="back" click="iPage.back()" label="back"/> + <mx:Text id="debg" text=""/> + + <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> + </mx:Application> Added: mentalmodels/trunk/flex/src/actionscript/FishUtil.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/FishUtil.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/FishUtil.as 2009-05-27 20:02:40 UTC (rev 147) @@ -0,0 +1,18 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + public class FishUtil + { + public function FishUtil() {} + + public static function fix(index:int, list:ArrayCollection):int + { + if( index < 0 ) return 0; + if( index >= list.length ) return list.length - 1; + return index; + } + } + +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-27 20:02:40 UTC (rev 147) @@ -1,7 +1,7 @@ // ActionScript file package actionscript { - import customComponents.PsychometricQuestion; + import customComponents.PsychometricQuestionC; import flash.display.DisplayObject; @@ -28,33 +28,45 @@ 3+2*N / TextArea,ComboBox,PsychometricQuestion,Forecasting / the question itself */ +public var msg:String = ""; public var pages:ArrayCollection; - public var minPagesRead:Number; - public var currentPageNumber:Number; - public var highestPageReached:Number; + public var minPagesRead:int; + public var currentPageNumber:int; + public var highestPageReached:int; public var currBlock:Block; - public function PageDisplay(currBlock:Block, minPagesRead:Number=1) + public function PageDisplay(newBlock:Block, minimumPagesRead:int=1) { - this.currBlock = currBlock; - this.minPagesRead = minPagesRead; - this.currentPageNumber = 0; - this.highestPageReached = currentPageNumber; + currBlock = newBlock; + minPagesRead = minimumPagesRead; + currentPageNumber = 0; + highestPageReached = currentPageNumber; loadPages(); } public function loadPages():void { - this.pages = new ArrayCollection(); + pages = new ArrayCollection(); + if(currBlock == null) + { + msg += "block is null"; + return; + } + if(currBlock.questionGroups == null || currBlock.questionGroups.length == 0) + { + msg += "no QuestionGroups found\n"; + return; + } for(var group:int=0; group<currBlock.questionGroups.length; group++) { var questionGroup:QuestionGroup = QuestionGroup(currBlock.questionGroups.getItemAt(group)); var tempBox:VBox = new VBox(); + tempBox.visible = true; if(questionGroup.questions != null && questionGroup.questions.length != 0) { @@ -84,11 +96,17 @@ else if(tempQuestion is actionscript.PsychometricQuestion) { var tempPsych:actionscript.PsychometricQuestion = actionscript.PsychometricQuestion(tempQuestion); - var pq:customComponents.PsychometricQuestion = new customComponents.PsychometricQuestion(); + var pq:customComponents.PsychometricQuestionC = new customComponents.PsychometricQuestionC(); pq.id = "q"+question; pq.labels = tempPsych.choices; - pq.slider.maxValue = 3; - pq.init(); + pq.maxValue = 3; + pq.initialize(); + + pq.init(); // ERROR FOUND SOMEWHERE IN HERE + +/* var e:Error = new Error(); +e.message = "haha"; +throw e; */ tempBox.addChild(pq); } else @@ -107,16 +125,21 @@ desc.htmlText = questionGroup.description; tempBox.addChildAt(head,0); tempBox.addChildAt(desc,1); - pages.addItem(tempBox); } + else + { + msg += "no Questions found\n"; + } + pages.addItem(tempBox); + msg += "item added\n"; } } public function finished():Boolean { return highestPageReached >= minPagesRead - 1; } - public function get length():Number + public function get length():int { return pages.length; } public function get currentPage():DisplayObject @@ -138,12 +161,7 @@ } public function nextPage():Boolean { - currentPageNumber++; - if(currentPageNumber >= pages.length) - { - currentPageNumber = pages.length - 1; - return false; - } + currentPageNumber = FishUtil.fix(currentPageNumber + 1, pages); if( currentPageNumber > highestPageReached ) { @@ -153,12 +171,7 @@ } public function prevPage():Boolean { - currentPageNumber--; - if(currentPageNumber < 0) - { - currentPageNumber = 0; - return false; - } + currentPageNumber = FishUtil.fix(currentPageNumber - 1, pages); return true; } } Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,5 +1,16 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> + <mx:Script> + <![CDATA[ + import actionscript.FishUtil; + + private function fix(index:int, list:ArrayCollection):int + { + return FishUtil.fix(index, list); + } + + ]]> + </mx:Script> <mx:Label id="header"/> <mx:ComboBox id="comboTopic" dataProvider="{topics}" selectedIndex="0"/> @@ -7,6 +18,7 @@ <mx:ArrayCollection id="topics"> + <mx:String>- Select -</mx:String> <mx:String>topic0</mx:String> <mx:String>topic1</mx:String> <mx:String>topic2</mx:String> @@ -15,33 +27,25 @@ <!-- each element of this ArrayCollection will serve as a dataProvider --> <mx:ArrayCollection id="specifics"> <mx:ArrayCollection id="topic0"> - <mx:String>specific0.0</mx:String> - <mx:String>specific0.1</mx:String> - <mx:String>specific0.2</mx:String> </mx:ArrayCollection> <mx:ArrayCollection id="topic1"> + <mx:String>- Select -</mx:String> <mx:String>specific1.0</mx:String> <mx:String>specific1.1</mx:String> <mx:String>specific1.2</mx:String> </mx:ArrayCollection> <mx:ArrayCollection id="topic2"> + <mx:String>- Select -</mx:String> <mx:String>specific2.0</mx:String> <mx:String>specific2.1</mx:String> <mx:String>specific2.2</mx:String> </mx:ArrayCollection> + <mx:ArrayCollection id="topic3"> + <mx:String>- Select -</mx:String> + <mx:String>specific3.0</mx:String> + <mx:String>specific3.1</mx:String> + <mx:String>specific3.2</mx:String> + </mx:ArrayCollection> </mx:ArrayCollection> - <mx:Script> - <![CDATA[ - - public function fix(index:Number, list:ArrayCollection):Number - { - if( index < 0 ) return 0; - if( index >= list.length ) return list.length - 1; - return index; - } - - ]]> - </mx:Script> - </mx:HBox> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -7,13 +7,12 @@ <mx:Script> <![CDATA[ - import mx.messaging.channels.StreamingAMFChannel; import customComponents.*; import mx.collections.ArrayCollection; public function init():void { - for(var x:Number=0;x<4;x++)for(var y:Number=0;y<15;y++)forecastPeople.setItem(x,y,7.5); + for(var x:int=0;x<4;x++)for(var y:int=0;y<15;y++)forecastPeople.setItem(x,y,7.5); } public function testNext(evt:Event=null):void Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> <mx:Script> <![CDATA[ @@ -7,17 +7,37 @@ import actionscript.PageDisplay; import mx.collections.ArrayCollection; - public var block:Block; - public var pageDisplay:PageDisplay; - [Bindable] public var numPages:Number; - [Bindable] public var currPage:Number; + [Bindable] public var block:Block; + [Bindable] public var pageDisplay:PageDisplay; + [Bindable] public var numPages:int = 1; + [Bindable] public var currPage:int = 0; - public function init():void + public function init(newBlock:Block):void { - pageDisplay = new PageDisplay(block, block.questionGroups.length); + block = newBlock; + try{ + debug.text += "creating pageDisplay...\n"; + pageDisplay = new PageDisplay(block, 3); + if(pageDisplay == null) + { + debug.text += "pageDisplay is null"; + } +// pageDisplay = new PageDisplay(block, block.questionGroups.length); + + + + }catch(errObject:Error){ + debug.text += "fail\n" + errObject.message +"\n"+ errObject.name +"\n"; + } + + debug.text += "setting currPage...\n"; currPage = pageDisplay.currentPageNumber; + debug.text += "setting numPages...\n"; numPages = pageDisplay.pages.length; + + debug.text += "adding currentPage...\n"; content.addChild(pageDisplay.currentPage); + debug.text += "currentPage added.\n"; } public function back():Boolean @@ -43,104 +63,12 @@ return false; } - // Mutilate the following code: - - /* private var allPageList:ArrayCollection; - - // Variables with default settings - [Bindable] - public var currPageNumber:Number = 0; - public var pagesRead:Number = 1; - - public function init_obsolete():void - { - numPages = loadAllPages(); - showPage(); - } - - public function loadAllPages():Number - { - allPageList = new ArrayCollection(); - // load allPageList from file - return length - var done:Boolean = false; - do - { - var tempPage:ArrayCollection = new ArrayCollection(); - - var doneItems:Boolean = false; - do - { - var tempItem:DisplayObject = new PsychometricQuestion(); - ((PsychometricQuestion)(tempItem)).labels = new ArrayCollection(["Big", "Small"]); - - tempPage.addItem(tempItem); - doneItems = true; - }while(!doneItems) - - allPageList.addItem(tempPage); - done = true; - }while(!done) - - return allPageList.length; - } - - private function getPage(pageNum:Number):ArrayCollection - { - if(pageNum < 0 || allPageList == null || pageNum >= allPageList.length) - { return null; } - - return (ArrayCollection)(allPageList.getItemAt(pageNum)); - } - - private function getDisp(pageNum:Number, index:Number):DisplayObject - { - var tempList:ArrayCollection = getPage(pageNum); - - if(tempList == null || index < 0 || index >= tempList.length) - { return null; } - - return (DisplayObject)(tempList.getItemAt(index)); - } - public function showPage():Boolean - { - try - { - var list:ArrayCollection = getPage(currPageNumber); - for(var index:Number = 0; index < list.length; index++) - { - content.addChild(getDisp(currPageNumber, index)); - } - - if(currPageNumber >= pagesRead) - { - pagesRead = currPageNumber+1; - } - return true; - } - catch(error:Error) - {} - return false; - } - - private function fixNum():Boolean - { - if(currPageNumber < 0) - { - currPageNumber = 0; - return false; - } - if(currPageNumber >= numPages) - { - currPageNumber = numPages - 1; - return false; - } - return showPage(); - } */ - ]]> </mx:Script> - <mx:Label text="{currPage+1} / {numPages}"/> + <mx:Label text="{currPage+1}"/> + <mx:Label text="{numPages}"/> +<mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> <mx:VBox id="content"/> Added: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <!-- Used for bipolar psychometric scales --> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right"/> + + <!-- Used for unipolar psychometric scales --> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center"/> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public var labels:ArrayCollection; + [Bindable] public var maxValue:Number; + [Bindable] public var slider1:Slider; + + public function init():void + { + if(labels != null) + { + slider1 = new Slider(); + + if(labels.length == 2) + { + topleft.visible = false; + topmid.visible = false; + topright.visible = false; + removeChild(topleft); + removeChild(topmid); + removeChild(topright); + farleft.text = (String)(labels.getItemAt(0)); + farright.text = (String)(labels.getItemAt(1)); + slider1.isBipolar = false; + slider1.x = 100; + slider1.y = 0; + } + else + { + farleft.visible = false; + farright.visible = false; + removeChild(farleft); + removeChild(farright); + topleft.text = (String)(labels.getItemAt(0)); + topmid.text = (String)(labels.getItemAt(1)); + topright.text = (String)(labels.getItemAt(2)); + slider1.isBipolar = true; + slider1.x = 0; + slider1.y = 36; + } + + slider1.maxValue = maxValue; + slider1.initialize(); + slider1.init(); + } + } + + ]]> + </mx:Script> + +</mx:Canvas> Property changes on: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml ___________________________________________________________________ Added: svn:executable + * Modified: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-05-27 01:15:31 UTC (rev 146) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-05-27 20:02:40 UTC (rev 147) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ @@ -27,8 +27,8 @@ // prepare Slider in default (abstain) position public function init():void { - this.addEventListener(MouseEvent.MOUSE_DOWN, mouseMove); - this.addEventListener(MouseEvent.MOUSE_UP, mouseMove); + addEventListener(MouseEvent.MOUSE_DOWN, mouseMove); + addEventListener(MouseEvent.MOUSE_UP, mouseMove); if(isBipolar) { @@ -58,7 +58,7 @@ tick.text = "."; tick.x = i*separation - imageWidth/2; tick.y = -10; - this.addChild(tick); + addChild(tick); } } @@ -73,13 +73,12 @@ if(sliderButton.visible) { getVal = value; - return value; } else { getVal = abstainValue; - return abstainValue; } + return getVal; } private function updateValue():void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-05-31 02:24:09
|
Revision: 149 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=149&view=rev Author: kjonas Date: 2009-05-31 02:24:04 +0000 (Sun, 31 May 2009) Log Message: ----------- Problems located and repaired in PsychometricQuestionC and Slider old PsychometricQuestion.mxml file deprecated and deleted displaying a Block in flex is underway; tested for PsychometricQuestionC Modified Paths: -------------- mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -1,46 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:as="actionscript.*"> - - <!--this is a test file, don't hardcode everything like this, it's terrible practice--> - - <mx:ArrayCollection id="ch1"> - <mx:String>blah1</mx:String> - <mx:String>blah1</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="ch2"> - <mx:String>blah2</mx:String> - <mx:String>blah2</mx:String> - <mx:String>blah2</mx:String> - </mx:ArrayCollection> - <mx:ArrayCollection id="ch3"> - <mx:String>blah3</mx:String> - <mx:String>blah3</mx:String> - </mx:ArrayCollection> - - <mx:ArrayCollection id="q1"> - <as:PsychometricQuestion choices="{ch1}" numberOfIntervals="5" question="Question1"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="q2"> - <as:PsychometricQuestion choices="{ch2}" numberOfIntervals="5" question="Question2"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="q3"> - <as:PsychometricQuestion choices="{ch3}" numberOfIntervals="5" question="Question3"/> - </mx:ArrayCollection> - - <mx:ArrayCollection id="qgrs"> - <as:QuestionGroup questions="{q1}" description="desc" header="HEADER"/> - <as:QuestionGroup questions="{q2}" description="desc" header="HEADER"/> - <as:QuestionGroup questions="{q3}" description="desc" header="HEADER"/> - </mx:ArrayCollection> - - <as:Block id="blk" questionGroups="{qgrs}"/> - + <mx:Script> <![CDATA[ import actionscript.QuestionGroup; import actionscript.PsychometricQuestion; + import actionscript.Block; public var choices1:ArrayCollection = new ArrayCollection(); public var questions1:ArrayCollection = new ArrayCollection(); @@ -50,29 +15,31 @@ public function fillBlock():void { try{ - debg.text += "creating choices\n"; - choices1.addItem("left"); - choices1.addItem("right"); - debg.text += "choices1.length="+choices1.length+"\n"; +// debg.text += "creating choices\n"; + choices1.addItem("Test1"); + choices1.addItem("Test2"); + choices1.addItem("Test3"); +// debg.text += "choices1.length="+choices1.length+"\n"; - debg.text += "creating questions\n"; +// debg.text += "creating questions\n"; questions1.addItem(new PsychometricQuestion()); PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 5; - debg.text += "questions1.length="+questions1.length+"\n"; +// debg.text += "questions1.length="+questions1.length+"\n"; - debg.text += "creating questiongroups\n"; +// debg.text += "creating questiongroups\n"; questionGroups.addItem(new QuestionGroup()); QuestionGroup(questionGroups.getItemAt(0)).questions = questions1; - debg.text += "questionGroups.length="+questionGroups.length+"\n"; +// debg.text += "questionGroups.length="+questionGroups.length+"\n"; - debg.text += "creating block\n"; +// debg.text += "creating block\n"; block1.questionGroups = questionGroups; - debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; +// debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; - debg.text += "finished\n"; +// debg.text += "finished\n"; }catch(errObject:Error){ - debg.text += errObject.message + "\n" + errObject.getStackTrace(); + debg.text += "block creation failure\n" + + errObject.message + "\n" + errObject.getStackTrace(); } } @@ -82,8 +49,10 @@ <mx:ArrayCollection id="labs"> <mx:String>testLeft</mx:String> <mx:String>testRight</mx:String> + <mx:String>testRight</mx:String> </mx:ArrayCollection> - <comp:PsychometricQuestionC labels="{labs}"/> + <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> + <comp:CategoricalQuestion/> <mx:Button id="forward" click="iPage.forward()" label="forward"/> <mx:Button id="back" click="iPage.back()" label="back"/> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-05-31 02:24:04 UTC (rev 149) @@ -99,13 +99,13 @@ var pq:customComponents.PsychometricQuestionC = new customComponents.PsychometricQuestionC(); pq.id = "q"+question; pq.labels = tempPsych.choices; - pq.maxValue = 3; + pq.maxValue = tempPsych.numberOfIntervals; pq.initialize(); pq.init(); // ERROR FOUND SOMEWHERE IN HERE /* var e:Error = new Error(); -e.message = "haha"; +e.message = "TEST"; throw e; */ tempBox.addChild(pq); } @@ -132,7 +132,7 @@ } pages.addItem(tempBox); - msg += "item added\n"; +// msg += "item added\n"; } } Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestion.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -19,9 +19,9 @@ <mx:ArrayCollection id="topics"> <mx:String>- Select -</mx:String> - <mx:String>topic0</mx:String> <mx:String>topic1</mx:String> <mx:String>topic2</mx:String> + <mx:String>topic3</mx:String> </mx:ArrayCollection> <!-- each element of this ArrayCollection will serve as a dataProvider --> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -16,7 +16,7 @@ { block = newBlock; try{ - debug.text += "creating pageDisplay...\n"; +// debug.text += "creating pageDisplay...\n"; pageDisplay = new PageDisplay(block, 3); if(pageDisplay == null) { @@ -27,17 +27,18 @@ }catch(errObject:Error){ - debug.text += "fail\n" + errObject.message +"\n"+ errObject.name +"\n"; + debug.text += "pageDisplay creation failure\n" + + errObject.message +"\n"+ errObject.name +"\n"; } - debug.text += "setting currPage...\n"; +// debug.text += "setting currPage...\n"; currPage = pageDisplay.currentPageNumber; - debug.text += "setting numPages...\n"; +// debug.text += "setting numPages...\n"; numPages = pageDisplay.pages.length; - debug.text += "adding currentPage...\n"; +// debug.text += "adding currentPage...\n"; content.addChild(pageDisplay.currentPage); - debug.text += "currentPage added.\n"; +// debug.text += "currentPage added.\n"; } public function back():Boolean Deleted: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestion.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" xmlns:comp="customComponents.*"> - - <mx:Script> - <![CDATA[ - import mx.collections.ArrayCollection; - - public var labels:ArrayCollection; - [Bindable] - public var maxValue:Number; - - public function init():void - { - if(labels != null) - { - if(labels.length == 2) - { - this.removeChild(topleft); - this.removeChild(topmid); - this.removeChild(topright); - farleft.text = (String)(labels.getItemAt(0)); - farright.text = (String)(labels.getItemAt(1)); - slider.isBipolar = false; - slider.x = 100; - slider.y = 0; - } - else - { - this.removeChild(farleft); - this.removeChild(farright); - topleft.text = (String)(labels.getItemAt(0)); - topmid.text = (String)(labels.getItemAt(1)); - topright.text = (String)(labels.getItemAt(2)); - slider.isBipolar = true; - slider.x = 0; - slider.y = 36; - } - } - slider.init(); - } - - ]]> - </mx:Script> - - <!-- Used for bipolar psychometric scales --> - <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left"/> - <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center"/> - <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right"/> - - <!-- Used for unipolar psychometric scales --> - <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center"/> - <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center"/> - - <comp:Slider id="slider" initialize="false" maxValue="{maxValue}"/> - -</mx:Canvas> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-05-28 00:31:15 UTC (rev 148) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-05-31 02:24:04 UTC (rev 149) @@ -2,13 +2,13 @@ <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> <!-- Used for bipolar psychometric scales --> - <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left"/> - <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center"/> - <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right"/> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left" visible="false"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> <!-- Used for unipolar psychometric scales --> - <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center"/> - <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center"/> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> <mx:Script> <![CDATA[ @@ -26,27 +26,27 @@ if(labels.length == 2) { - topleft.visible = false; - topmid.visible = false; - topright.visible = false; + farleft.text = (String)(labels.getItemAt(0)); + farright.text = (String)(labels.getItemAt(1)); + farleft.visible = true; + farright.visible = true; removeChild(topleft); removeChild(topmid); removeChild(topright); - farleft.text = (String)(labels.getItemAt(0)); - farright.text = (String)(labels.getItemAt(1)); slider1.isBipolar = false; slider1.x = 100; slider1.y = 0; } else { - farleft.visible = false; - farright.visible = false; - removeChild(farleft); - removeChild(farright); topleft.text = (String)(labels.getItemAt(0)); topmid.text = (String)(labels.getItemAt(1)); topright.text = (String)(labels.getItemAt(2)); + topleft.visible = true; + topmid.visible = true; + topright.visible = true; + removeChild(farleft); + removeChild(farright); slider1.isBipolar = true; slider1.x = 0; slider1.y = 36; @@ -55,6 +55,10 @@ slider1.maxValue = maxValue; slider1.initialize(); slider1.init(); + addChild(slider1); +/* var e:Error = new Error(); +e.message = "TEST"; +throw e; */ } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-06-02 00:53:33
|
Revision: 151 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=151&view=rev Author: seematalele Date: 2009-06-02 00:53:24 +0000 (Tue, 02 Jun 2009) Log Message: ----------- Remove functionality of module,block, QuestionGroup and Question is done. When you click on any node in the tree, it displays the corresponding information about that particular node except for questions it shows half information, so this functionality is needed to be done. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/db/Block.mxml mentalmodels/trunk/flex/src/customComponents/db/Module.mxml mentalmodels/trunk/flex/src/customComponents/db/Question.mxml mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -16,17 +16,18 @@ private var company:XML = <list> - <module title="Preexperiment" sequenceNo="1" id="1"> - <block name="Introduction"> + <module title="Preexperiment" sequenceNo="1" hours="0" min="3" sec="0" id="1"> + <block name="Introduction" sequenceNo="1" hours="0" min="3" sec="0" id="1"> <questiongroup header="Welcome to E-Fishery Experiment" description="In this experiment you will design..." sequenceNo="1" id="1"/> </block> </module> - <module title ="Game Round" sequenceNo="2" id="2"> - <block name="Characterizing Own Strategy"> + <module title ="Game Round" sequenceNo="2" hours="1" min="30" sec="0" id="2"> + <block name="Characterizing Own Strategy" sequenceNo="1" hours="0" min="30" sec="0" id="2"> <questiongroup header="What goals did you follow when designing your strategy" description="Please specify three goals..." sequenceNo="1" id="2"> - <question title="Most important goal" type="categorical" sequenceNo="1" id="1" > + <question title="Most important goal" type="psychometric" sequenceNo="1" id="1"> + <psychometric scale="bipolar" choice1="Good" choice2="Better" choice3="Best"/> </question> </questiongroup> @@ -60,6 +61,13 @@ return node.@name; } + + public function isDurationValid(hours:Number,minutes:Number,seconds:Number):Boolean + { + return (hours == 0 && minutes == 0 && seconds == 0); + + } + private function addModule():void { @@ -72,16 +80,7 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - /*var saveModule:Button = new Button; - var isExists:Boolean = pnlComponent.contains(saveModule as DisplayObject); - Alert.show(isExists.toString()); - if(!pnlComponent.contains(saveModule as DisplayObject)) - { - saveModule.label ="Save Module"; - pnlComponent.addChild(saveModule as DisplayObject); - } - //saveModule.*/ } @@ -105,6 +104,9 @@ newNode.setLocalName("module"); newNode.@title=moduleInfo.getName(); newNode.@sequenceNo =moduleInfo.getSequenceNo(); + newNode.@hours = moduleInfo.getHours(); + newNode.@min = moduleInfo.getMinutes(); + newNode.@sec = moduleInfo.getSeconds(); company.appendChild(newNode); currentState = "none"; btnsaveModule.enabled = false; @@ -119,12 +121,9 @@ } } - public function isDurationValid(hours:Number,minutes:Number,seconds:Number):Boolean - { - return (hours == 0 && minutes == 0 && seconds == 0); - - } + + private function addBlock():void { @@ -137,23 +136,7 @@ btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - //currentState = "block"; - - - - /*var node:XML = tree.selectedItem as XML; - - Alert.show("Selected node is " + node.@title);*/ - - /* var newNode:XML = <block/>; - newNode.@name = "block1"; - var module:XMLList =company.module.(@title == "first module"); - if( module.length() > 0 ) { - - module[0].appendChild(newNode); - // empName.text = ""; - }*/ - + } private function saveBlock(event:Event):void @@ -185,6 +168,11 @@ newNode.setLocalName("block"); newNode.@name=blockInfo.getName(); newNode.@sequenceNo =blockInfo.getSequenceNo(); + newNode.@hours = blockInfo.getHours(); + newNode.@min = blockInfo.getMinutes(); + newNode.@sec = blockInfo.getSeconds(); + + var module:XMLList =company.module.(@title == node.@title); if( module.length() > 0 ) { @@ -264,18 +252,7 @@ newNode.@description = questionGroupInfo.getDescription(); newNode.@sequenceNo = questionGroupInfo.getSequenceNo(); - /*var module:XMLList = company.module.(@title == parentModule.@title); - //Alert.show("ParentModule node is: " + parentModule.@title); - Alert.show("ParentBlock node is: " + module.children().length()); - var blockList:XMLList = module.children(); - var i:int; - //Alert.show(module.length() + "is length of module"); - for (i = 0; i < blockList.length(); i++) - { - if(blockList[i].block.@name == node.@name) - { - Alert.show(blockList[i].block.@name + "is found"); - */ + var block:XMLList =company.module.block.(@name == node.@name); Alert.show(block.@name + "is name of the block"); if( block.length() > 0 ) @@ -285,9 +262,7 @@ btnsaveQuestionGroup.enabled = false; } - //} - //} - } + } } } } @@ -339,12 +314,13 @@ // newNode.@header = questionInfo.getHeader(); //newNode.@description = questionInfo.getDescription(); newNode.@sequenceNo = questionInfo.getSequenceNo(); - - var block:XMLList =company.module.block.(@name == node.@name); - Alert.show(block.@name + "is name of the block"); - if( block.length() > 0 ) + newNode.@title = questionInfo.getQuestion(); + newNode.@type = questionInfo.getType(); + var questionGroup:XMLList =company.module.block.questiongroup.(@header == node.@header); + Alert.show(questionGroup.@header + "is name of the questionGroup"); + if( questionGroup.length() > 0 ) { - block[0].appendChild(newNode); + questionGroup[0].appendChild(newNode); currentState = "none"; btnsaveQuestion.enabled = false; @@ -355,35 +331,124 @@ } - - private function removeEmployee():void - { - var node:XML = XML(tree.selectedItem); - if( node == null ) return; - if( node.localName() != "employee" ) return; + public function removeItem():void + { + currentState = "none"; + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestion.enabled = false; + btnsaveQuestionGroup.enabled = false; + + var node:XML = XML(tree.selectedItem); + if( node == null ) + { + Alert.show("Please select the Item from tree."); + return; + + } + /*if( node.localName() != "module" ) + { + Alert.show("Please select the module from tree."); + return; + }*/ var children:XMLList = XMLList(node.parent()).children(); - for(var i:Number=0; i < children.length(); i++) { + for(var i:Number=0; i < children.length(); i++) + { - if( children[i].@name == node.@name ) { + if( children[i].@name == node.@name ) + { delete children[i]; } } - } + + } + private function treeChanged(event:Event):void { - /* var selectedNode:int; + var selectedNode:int; - //selectedNode=Tree(event.target).selectedItem; - var obj:DisplayObject = tree.getChildAt(selectedNode); - var newNode:XML = XML(obj); - Alert.show("Selected node is " + newNode.toString());*/ - + var node:XML = XML(tree.selectedItem); + if(node.localName() == "module") + { + currentState = "module"; + var module:DisplayObject = pnlComponent.getChildAt(1); + var moduleInfo:Module = Module(module); + + btnsaveModule.enabled = true; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; + + //set all fields + moduleInfo.setSequenceNo(node.@sequenceNo); + moduleInfo.setName(node.@title); + moduleInfo.setHours(node.@hours); + moduleInfo.setMinutes(node.@min); + moduleInfo.setSeconds(node.@sec); + + } + if(node.localName() == "block") + { + currentState = "block"; + var block:DisplayObject = pnlComponent.getChildAt(1); + var blockInfo:Block = Block(block); + btnsaveBlock.enabled = true; + btnsaveModule.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = false; + + //set all fields + blockInfo.setName(node.@name); + blockInfo.setSequenceNo(node.@sequenceNo); + blockInfo.setHours(node.@hours); + blockInfo.setMinutes(node.@min); + blockInfo.setSeconds(node.@sec); + + } + if(node.localName() == "questiongroup") + { + currentState = "questionGroup"; + var questionGroup:DisplayObject = pnlComponent.getChildAt(1); + var questionGroupInfo:QuestionGroup = QuestionGroup(questionGroup); + questionGroupInfo.reset(); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = true; + btnsaveQuestion.enabled = false; + + //set all fields + questionGroupInfo.setHeader(node.@header); + questionGroupInfo.setDescription(node.@description); + questionGroupInfo.setSequenceNo(node.@sequenceNo); + + } + + if(node.localName() == "question") + { + currentState = "question"; + var question:DisplayObject = pnlComponent.getChildAt(1); + var questionInfo:Question = Question(question); + + btnsaveModule.enabled = false; + btnsaveBlock.enabled = false; + btnsaveQuestionGroup.enabled = false; + btnsaveQuestion.enabled = true; + + //set all fields + questionInfo.setType(node.@type); + questionInfo.setQuestion(node.@title); + questionInfo.setSequenceNo(node.@sequenceNo); + + + + } } - - + + ]]> </mx:Script> @@ -413,61 +478,48 @@ </mx:State> - <mx:State name="none"/> + <mx:State name="none"> + </mx:State> </mx:states> <mx:Spacer width="40"/> <mx:HDividedBox width="100%" height="100%" id="hdMain"> <mx:Spacer width="40"/> - <mx:VBox height="100%" id="vboxLeft"> + <mx:VBox height="100%" id="vboxLeft" width ="40%"> <mx:Spacer width="40"/> - <mx:Tree id="tree" top="72" left="50" dataProvider="{companyData}" + <mx:Tree id="tree" dataProvider="{companyData}" labelFunction="treeLabel" allowMultipleSelection="false" selectable="true" showRoot="true" change="{treeChanged(event)}" height="50%" width="80%" textAlign="center"/> - <mx:Canvas height="35%"> - <mx:Grid x="0" y="0"> + <mx:Spacer height="30"/> + <mx:Canvas height="30%" id="canvas1" width="100%"> + <mx:Grid x="0" y="0" id="grid1" height="100%" width="100%"> <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> + <mx:GridItem width="100%" height="100%" id="griditem12"> <mx:Button label="Add Module" id="butAddModule" click="{addModule()}"/> </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Module" id="butRemModule"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> - </mx:GridRow> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> + <mx:GridItem width="100%" height="100%" id="griditem2"> <mx:Button label="Add Block" id="butAddBlock" click="{addBlock()}"/> </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Block" id="butremBlock"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> + </mx:GridRow> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> + + <mx:GridRow width="100%" height="100%" id="gridrow1"> + <mx:GridItem width="100%" height="100%" id="griditem6"> <mx:Button label="Add QuestionGroup" id="butAddQuestionGroup" click="{addQuestionGroup()}"/> </mx:GridItem> + <mx:GridItem width="100%" height="100%" id="griditem9"> + <mx:Button label="Add Question" id="butAddQuestion" click="{addQuestion()}"/> + </mx:GridItem> + - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove QuestionGroup" id="butremQuestionGroup"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> </mx:GridRow> - <mx:GridRow width="100%" height="100%"> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Add Question" id="butAddQuestion" click="{addQuestion()}"/> + <mx:GridRow width="100%" height="100%" id="gridrow2"> + <mx:GridItem width="100%" height="100%" id="griditem1"> + <mx:Button label="Remove Item" id="butRemModule" click ="{removeItem()}"/> </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - <mx:Button label="Remove Question" id="butremQuestion"/> - </mx:GridItem> - <mx:GridItem width="100%" height="100%"> - </mx:GridItem> + </mx:GridRow> </mx:Grid> @@ -482,7 +534,7 @@ <mx:Spacer width="40"/> <mx:Button id = "btnsaveQuestionGroup" enabled="false" label="Save QuestionGroup" click="{saveQuestionGroup(event)}" /> <mx:Spacer width="40"/> - <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" /> + <mx:Button id = "btnsaveQuestion" enabled="false" label="Save Question" click="{saveQuestion(event)}" /> <mx:Spacer width="40"/> </mx:HBox> Modified: mentalmodels/trunk/flex/src/customComponents/db/Block.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Block.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/Block.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -47,6 +47,34 @@ } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setName(name:String):void + { + txtName.text = name; + } + + + public function setHours(hour:Number):void + { + hours.value = hour; + + } + public function setMinutes(min:Number):void + { + minutes.value = min; + + } + public function setSeconds(sec:Number):void + { + seconds.value = sec; + + } + + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control @@ -116,7 +144,7 @@ <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Description:"> - <mx:TextInput id="txtName" change="{validateForm(event)}"/> + <mx:TextArea id="txtName" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Duration(hr:min:sec):"> Modified: mentalmodels/trunk/flex/src/customComponents/db/Module.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Module.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/Module.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -49,6 +49,34 @@ } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setName(name:String):void + { + txtName.text = name; + } + + + public function setHours(hour:Number):void + { + hours.value = hour; + + } + public function setMinutes(min:Number):void + { + minutes.value = min; + + } + public function setSeconds(sec:Number):void + { + seconds.value = sec; + + } + + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control Modified: mentalmodels/trunk/flex/src/customComponents/db/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -27,13 +27,47 @@ return txtQuestion.text; } - /*public function getDescription():String + public function getType():String { - return txtDescription.text; - }*/ + return String(cmbType.selectedItem); + } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setQuestion(question:String):void + { + txtQuestion.text = question; + } + public function setType(type:String):void + { + cmbType.selectedItem = type; + if(cmbType.selectedItem == "Categorical") + { + currentState = "categorical"; + var catobj:DisplayObject = canvasQuestionType.getChildAt(0); + var categoricalInfo:Categorical = Categorical(catobj); + categoricalInfo.reset(); + + } + if(cmbType.selectedItem == "Psychometric") + { + currentState = "psychometric"; + var psychobj:DisplayObject = canvasQuestionType.getChildAt(0); + var psychometricInfo:Psychometric = Psychometric(psychobj); + psychometricInfo.reset(); + + } + if(cmbType.selectedItem == "Text") + { + currentState = "none"; + } + } + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control @@ -61,7 +95,7 @@ { - //Alert.show("selected item is: " + cmbType.selectedItem); + if(cmbType.selectedItem == "Categorical") { currentState = "categorical"; @@ -70,7 +104,7 @@ categoricalInfo.reset(); } - else if(cmbType.selectedItem == "Psychometric") + if(cmbType.selectedItem == "Psychometric") { currentState = "psychometric"; var psychobj:DisplayObject = canvasQuestionType.getChildAt(0); @@ -78,10 +112,11 @@ psychometricInfo.reset(); } - else + if(cmbType.selectedItem == "Text") { currentState = "none"; - } + } + } @@ -135,9 +170,8 @@ <comp:Psychometric id="psychometric"/> </mx:AddChild> </mx:State> - - <mx:State name="none"/> - + <mx:State name="none" /> + </mx:states> @@ -146,7 +180,7 @@ <mx:TextInput id="txtSeqNo" maxChars="3" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Question:"> - <mx:TextInput id="txtQuestion" change="{validateForm(event)}"/> + <mx:TextArea id="txtQuestion" change="{validateForm(event)}"/> </mx:FormItem> <mx:FormItem label="Select Question Type:"> <mx:ComboBox id="cmbType" change="{showQuestionType()}" width="100%"> Modified: mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/QuestionGroup.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -31,7 +31,23 @@ return txtDescription.text; } + public function setSequenceNo(seqNo:String):void + { + txtSeqNo.text = seqNo; + } + public function setHeader(header:String):void + { + txtHeader.text = header; + } + + public function setDescription(description:String):void + { + txtDescription.text = description; + + } + + public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-01 16:52:02 UTC (rev 150) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-02 00:53:24 UTC (rev 151) @@ -23,22 +23,7 @@ // control on the form. private var focussedFormControl:DisplayObject; - /*public function getSequenceNo():String - { - return txtSeqNo.text; - } - public function getQuestion():String - { - return txtQuestion.text; - }*/ - /*public function getDescription():String - { - return txtDescription.text; - }*/ - - - public function validateForm(event:Event):Boolean { // Save a reference to the currently focussed form control This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kj...@us...> - 2009-06-02 22:37:12
|
Revision: 152 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=152&view=rev Author: kjonas Date: 2009-06-02 22:37:05 +0000 (Tue, 02 Jun 2009) Log Message: ----------- FisheryExperimentKalin is a working Demo to be displayed to Robert Tobias the only section that does not work quite as intended is the final section, Forecasting. I am working to manage this. all *QuestionComponents were fitted title and description fields. PsychometricQuestionC must have .initialize and .init() called in order to display properly Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/Slider.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,16 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:net="flash.net.*" xmlns:comp="customComponents.*" - backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #80FFAA]" + backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" width="760" height="510" clipContent="false" layout="absolute" - currentState="instructions" initialize="init()"> + currentState="socioDemographic" initialize="init()"> <mx:states> - <mx:State name="instructions"> - <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage id="instructions"/> - </mx:AddChild> - </mx:State> - <mx:State name="socioDemographic"> <mx:AddChild relativeTo="{content}"> <comp:SocioDemographicPage id="socioDemographic" x="265" y="100"/> @@ -23,7 +17,20 @@ </mx:AddChild> </mx:State> - <mx:State name="none"/> + <mx:State name="instructions"> + <mx:AddChild relativeTo="{content}"> + <comp:InstructionPage_TEMP id="instructions"/> + </mx:AddChild> + </mx:State> + + <mx:State name="forecasting"> + <mx:AddChild relativeTo="{content}"> + <comp:ForecastPage_TEMP id="forecasting"/> + </mx:AddChild> + </mx:State> + + <mx:State name="none"> + </mx:State> </mx:states> @@ -69,25 +76,25 @@ { Id = event.result as uint; - Alert.show("Student id is " + Id ); +// Alert.show("Student id is " + Id ); consumer.disconnect(); } private function faultHandler(event:FaultEvent):void { - Alert.show("event fault is " + event.fault.faultDetail); +// Alert.show("event fault is " + event.fault.faultDetail); } private function handleFault(event:MessageFaultEvent):void { - Alert.show("Message event fault is " + event.faultString); +// Alert.show("Message event fault is " + event.faultString); } private function messageHandler(message:IMessage):void { randomNumbers = message.body as String; - Alert.show( ""+randomNumbers); +// Alert.show( ""+randomNumbers); } public function init():void @@ -175,6 +182,10 @@ { (InstructionPage)(obj).forward(); } + if(obj is ForecastPage_TEMP) + { + (ForecastPage_TEMP)(obj).forward(); + } return false; } @@ -184,17 +195,6 @@ { return false; } var obj:DisplayObject = content.getChildAt(0); - if(obj is InstructionPage) - { - if( (InstructionPage)(obj).accept() ) - { - obj.visible = false; - expiredContent.addChild(obj); - currentState = "socioDemographic"; - //consumer.subscribe(); - return true; - } - } if(obj is SocioDemographicPage) { var Id:uint = 0; @@ -210,7 +210,7 @@ Alert.show(info.getSemester()); Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); - Alert.show("Before invoking createstudent()"); +// Alert.show("Before invoking createstudent()"); return true; } } @@ -220,11 +220,33 @@ { obj.visible = false; expiredContent.addChild(obj); - currentState = "none"; + currentState = "instructions"; return true; } } + if(obj is InstructionPage_TEMP) + { + if( (InstructionPage_TEMP)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "forecasting"; + //consumer.subscribe(); + return true; + } + } + if(obj is ForecastPage_TEMP) + { + if( (ForecastPage_TEMP)(obj).accept() ) + { + obj.visible = false; + expiredContent.addChild(obj); + currentState = "none"; + //consumer.subscribe(); + return true; + } + } return false; } Modified: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -40,8 +40,8 @@ </mx:ArrayCollection> </mx:ArrayCollection> - <comp:TextQuestion id="question1"/> - <comp:CategoricalQuestion id="question2" topics="{topicList}" specifics="{specificList}"/> + <comp:TextQuestionC id="question1"/> + <comp:CategoricalQuestionC id="question2" topics="{topicList}" specifics="{specificList}"/> <comp:ForecastQuestion id="question3"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -9,31 +9,43 @@ public var choices1:ArrayCollection = new ArrayCollection(); public var questions1:ArrayCollection = new ArrayCollection(); - public var questionGroups:ArrayCollection = new ArrayCollection(); + public var choices2:ArrayCollection = new ArrayCollection(); + public var questions2:ArrayCollection = new ArrayCollection(); + + public var questionGroups1:ArrayCollection = new ArrayCollection(); public var block1:Block = new Block(); public function fillBlock():void { try{ // debg.text += "creating choices\n"; - choices1.addItem("Test1"); - choices1.addItem("Test2"); - choices1.addItem("Test3"); + choices1.addItem("Highly Agree"); + choices1.addItem("Highly Neutral"); + choices1.addItem("Highly Disagree"); + + choices2.addItem("Agree"); + choices2.addItem("Neutral"); // debg.text += "choices1.length="+choices1.length+"\n"; // debg.text += "creating questions\n"; questions1.addItem(new PsychometricQuestion()); PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; - PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 5; + PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 3; + + questions2.addItem(new PsychometricQuestion()); + PsychometricQuestion(questions2.getItemAt(0)).choices = choices2; + PsychometricQuestion(questions2.getItemAt(0)).numberOfIntervals = 5; // debg.text += "questions1.length="+questions1.length+"\n"; // debg.text += "creating questiongroups\n"; - questionGroups.addItem(new QuestionGroup()); - QuestionGroup(questionGroups.getItemAt(0)).questions = questions1; + questionGroups1.addItem(new QuestionGroup()); + questionGroups1.addItem(new QuestionGroup()); + QuestionGroup(questionGroups1.getItemAt(0)).questions = questions1; + QuestionGroup(questionGroups1.getItemAt(1)).questions = questions2; // debg.text += "questionGroups.length="+questionGroups.length+"\n"; // debg.text += "creating block\n"; - block1.questionGroups = questionGroups; + block1.questionGroups = questionGroups1; // debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; // debg.text += "finished\n"; @@ -52,7 +64,7 @@ <mx:String>testRight</mx:String> </mx:ArrayCollection> <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> - <comp:CategoricalQuestion/> + <comp:CategoricalQuestionC/> <mx:Button id="forward" click="iPage.forward()" label="forward"/> <mx:Button id="back" click="iPage.back()" label="back"/> Added: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -0,0 +1,70 @@ +<?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; + + private function fix(index:int, list:ArrayCollection):int + { + return FishUtil.fix(index, list); + } + + ]]> + </mx:Script> + + <mx:String id="title"></mx:String> + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Label htmlText="{htmlBold(title)}"/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + <mx:Script> <![CDATA[ + public function htmlBold(str:String):String + { + if(str==null)return null; + return "<font size=\"12px\">" + str + "</font>"; + } + ]]> </mx:Script> + + <mx:HBox id="content"> + <mx:ComboBox id="comboTopic" + dataProvider="{topics}" selectedIndex="0"/> + <mx:ComboBox id="comboSpecific" + dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> + </mx:HBox> + + <!-- the selected element of this array determines which of the elements of + "specifics" will be used as the dataProvider --> + <mx:ArrayCollection id="topics"> + <mx:String>- Select -</mx:String> + <mx:String>topic1</mx:String> + <mx:String>topic2</mx:String> + <mx:String>topic3</mx:String> + </mx:ArrayCollection> + + <!-- each element of this ArrayCollection will serve as a dataProvider --> + <mx:ArrayCollection id="specifics"> + <mx:ArrayCollection id="topic0"> + </mx:ArrayCollection> + <mx:ArrayCollection id="topic1"> + <mx:String>- Select -</mx:String> + <mx:String>specific1.0</mx:String> + <mx:String>specific1.1</mx:String> + <mx:String>specific1.2</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection id="topic2"> + <mx:String>- Select -</mx:String> + <mx:String>specific2.0</mx:String> + <mx:String>specific2.1</mx:String> + <mx:String>specific2.2</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection id="topic3"> + <mx:String>- Select -</mx:String> + <mx:String>specific3.0</mx:String> + <mx:String>specific3.1</mx:String> + <mx:String>specific3.2</mx:String> + </mx:ArrayCollection> + </mx:ArrayCollection> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/Forecast2.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -261,6 +261,21 @@ } } + public function isFinished():Boolean + { + for(var col:Number=0; col < numColumns; col++) + { + for(var x:Number = 0; x < numFields; x++) + { + if(getItem(x, col) <= 0) + { + return false; + } + } + } + return true; + } + ]]> </mx:Script> Added: mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastPage_TEMP.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> + + <mx:VBox id="content"> + <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30"/> + <!--<mx:Button id="next" label="Forecast Fish Movements" click="testNext()"/>--> + </mx:VBox> + + <mx:Script> + <![CDATA[ + import customComponents.*; + import mx.collections.ArrayCollection; + import mx.controls.Alert; + + private var clicks:int = 0; + + public function testNext(evt:Event=null):Boolean + { + clicks++; + if(!(forecastPeople.isFinished() || clicks > 1)) + { + Alert.show("Not finished forecasting Predictions of People. Click again to disregard."); + return false; + } + if(clicks > 2) return false; + var f2:Forecast2 = new Forecast2(); + f2.id = "forecastFull_AS"; + f2.numColumns = 6; + f2.oldForecast1 = forecastPeople; + content.addChild(f2); + return true; + } + + public function back():Boolean + { + return false; + } + + public function forward():Boolean + { + return testNext(); + } + + public function accept():Boolean + { + if(forecastPeople.isFinished()) + { + var forecastFish:Forecast2 = content.getChildAt(1) as Forecast2; + return forecastFish.isFinished(); + } + return false; + } + + ]]> + </mx:Script> + +</mx:Canvas> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -43,12 +43,28 @@ public function back():Boolean { - return pageDisplay.prevPage(); + var pageSuccess:Boolean = pageDisplay.prevPage(); + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + if(pageSuccess) + { + content.removeAllChildren(); + content.addChild(pageDisplay.currentPage); + } + return pageSuccess; } public function forward():Boolean { - return pageDisplay.nextPage(); + var pageSuccess:Boolean = pageDisplay.nextPage(); + currPage = pageDisplay.currentPageNumber; + currPageLabel.text = "Page " + (currPage+1) + " / " + numPages; + if(pageSuccess) + { + content.removeAllChildren(); + content.addChild(pageDisplay.currentPage); + } + return pageSuccess; } public function accept():Boolean @@ -67,8 +83,7 @@ ]]> </mx:Script> - <mx:Label text="{currPage+1}"/> - <mx:Label text="{numPages}"/> + <mx:Label id="currPageLabel" text="Page {(currPage+1)} / {numPages}"/> <mx:Text id="debug" text="{pageDisplay.msg}" width="300"/> <mx:VBox id="content"/> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,23 +1,89 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*"> +<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" initialize="init()"> - <mx:ArrayCollection id="pageSet1"> - + <mx:ArrayCollection id="psychometricLabels"> + <mx:String>Very Much</mx:String> + <mx:String>Neutral</mx:String> + <!--<mx:String>Not at All</mx:String>--> </mx:ArrayCollection> - <mx:VBox id="p1"> - <mx:Text text="This is an information window." width="300"/> - <mx:Text text="What is presented in an information window can be selected from the drop-down list above each window!" width="300"/> - <mx:Text text="Please check the options of the drop-down list when entering a new module of the experiment (i.e. after leaving a module by clicking on “Accept”)." width="300"/> - </mx:VBox> - <mx:VBox id="p2"> - <mx:Text text="num2" width="300"/> - </mx:VBox> - <mx:VBox id="p3"> - <mx:Text text="Welcome to the E-Fishery experiment" width="300"/> - <mx:Text text="In this experiment you will design a strategy to fish an abstract fishing ground together with three other persons. As we are mainly interested in the reasons why you choose a certain strategy, we will ask you a number of questions. For the same reason, there are no ‘correct’ or ‘wrong’ strategies and no ‘correct’ or ‘wrong’ answers. However, since for each pound of fish you get during the experiment you will receive #.### US$, you might be interested in finding a strategy that fits your goals well. For this, you have to understand the dynamics of the (simulated) fish population and anticipate well the behavior of the other persons of your group." width="300"/> - </mx:VBox> + <mx:ArrayCollection id="categoricalTopics"> + <mx:String>- Select -</mx:String> + <mx:String>Your Earnings</mx:String> + <mx:String>Fish Population</mx:String> + <mx:String>Other Players</mx:String> + </mx:ArrayCollection> - <!--<as:PageDisplay pages="{pageSet1}"/>--> + <mx:ArrayCollection id="categoricalSpecifics"> + <mx:ArrayCollection> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Earn as much as possible</mx:String> + <mx:String>Earn more than the others</mx:String> + <mx:String>Earn about the same as the others</mx:String> + <mx:String>Earn less then the others</mx:String> + <mx:String>Earn a fair amount but much less then would be possible</mx:String> + <mx:String>Earn nothing</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Let the fish population grow as much as possible</mx:String> + <mx:String>Keep the fish population at a high stable level</mx:String> + <mx:String>Keep the fish population at a medium stable level</mx:String> + <mx:String>Keep the fish population at a low stable level</mx:String> + <mx:String>Not to completely destroy the fish population</mx:String> + <mx:String>To destroy the fish population</mx:String> + </mx:ArrayCollection> + <mx:ArrayCollection> + <mx:String>- Select -</mx:String> + <mx:String>Act similarly to the others</mx:String> + <mx:String>Act differently than the others</mx:String> + <mx:String>Allow the others to have good earnings</mx:String> + <mx:String>Avoid that the others get good earnings</mx:String> + <mx:String>Act according to rules I expect the others to know</mx:String> + <mx:String>Act against rules I expect the others to know</mx:String> + </mx:ArrayCollection> + </mx:ArrayCollection> + <mx:HBox> + <mx:VBox> + <mx:Label/> + </mx:VBox> + <mx:VBox id="p1"> + <mx:Text htmlText="<b><font size="16">Sample Questions</font></b>" width="300"/> + <comp:PsychometricQuestionC id="psychometricQuestion" title="Overall, how much do you like your group?" + labels="{psychometricLabels}" maxValue="3"/> + <comp:CategoricalQuestionC id="categoricalQuestion" title="What goals did you follow when designing your strategy?" + topics="{categoricalTopics}" specifics="{categoricalSpecifics}"/> + <comp:TextQuestionC id="textQuestion" title="Describe in your own words what the rule, agreement, or other coordination attempt states." + defaultText="Enter your response here..." txtHeight="48"/> + </mx:VBox> + </mx:HBox> + + <mx:Script> + <![CDATA[ + + public function init():void + { + psychometricQuestion.initialize(); + psychometricQuestion.init(); + } + + public function back():Boolean + { + return false; + } + public function forward():Boolean + { + return false; + } + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + </mx:Canvas> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> - <mx:Label text="Planning Stage" fontSize="24"/> + <mx:Label text="Strategy Design" fontSize="24"/> <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, and repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." width="600"/> <mx:Label/> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -1,14 +1,31 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="false"> - <!-- Used for bipolar psychometric scales --> - <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left" visible="false"/> - <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center" visible="false"/> - <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> + <mx:String id="title"></mx:String> + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Label htmlText="{htmlBold(title)}"/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + <mx:Script> <![CDATA[ + public function htmlBold(str:String):String + { + if(str==null)return null; + return "<font size=\"12px\">" + str + "</font>"; + } + ]]> </mx:Script> - <!-- Used for unipolar psychometric scales --> - <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> - <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> + <mx:Canvas id="content" minHeight="30" maxHeight="90"> + <!-- Used for bipolar psychometric scales --> + <mx:Label id="topleft" text="topleft" x="0" y="0" width="100" textAlign="left" visible="false"/> + <mx:Label id="topmid" text="topmid" x="150" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="topright" text="topright" x="300" y="0" width="100" textAlign="right" visible="false"/> + + <!-- Used for unipolar psychometric scales --> + <mx:Label id="farleft" text="farleft" x="0" y="0" width="100" textAlign="center" visible="false"/> + <mx:Label id="farright" text="farright" x="300" y="0" width="100" textAlign="center" visible="false"/> + </mx:Canvas> <mx:Script> <![CDATA[ @@ -30,14 +47,14 @@ farright.text = (String)(labels.getItemAt(1)); farleft.visible = true; farright.visible = true; - removeChild(topleft); - removeChild(topmid); - removeChild(topright); + content.removeChild(topleft); + content.removeChild(topmid); + content.removeChild(topright); slider1.isBipolar = false; slider1.x = 100; slider1.y = 0; } - else + else if(labels.length == 3) { topleft.text = (String)(labels.getItemAt(0)); topmid.text = (String)(labels.getItemAt(1)); @@ -45,24 +62,29 @@ topleft.visible = true; topmid.visible = true; topright.visible = true; - removeChild(farleft); - removeChild(farright); + content.removeChild(farleft); + content.removeChild(farright); slider1.isBipolar = true; slider1.x = 0; slider1.y = 36; } - slider1.maxValue = maxValue; - slider1.initialize(); - slider1.init(); - addChild(slider1); -/* var e:Error = new Error(); -e.message = "TEST"; -throw e; */ + initializeSlider(); } } + public function initializeSlider():void + { + slider1.maxValue = maxValue; + slider1.initialize(); + slider1.init(); + if(!(content.contains(slider1))) + { + content.addChild(slider1); + } + } + ]]> </mx:Script> -</mx:Canvas> +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/Slider.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/Slider.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -4,6 +4,7 @@ <mx:Script> <![CDATA[ import mx.controls.Label; + import mx.controls.Text; [Bindable] [Embed(source="../images/SliderImage.png")] @@ -55,7 +56,7 @@ for(var i:Number = 0; i < numTicks; i++) { var tick:Label = new Label(); - tick.text = "."; + tick.htmlText = "<b>.</b>"; tick.x = i*separation - imageWidth/2; tick.y = -10; addChild(tick); @@ -110,7 +111,7 @@ <!-- change X value to 1/2 the width of the sliderButton image --> <mx:HBox id="sliderBar" height="3" x="0" y="15" - borderStyle="solid" borderColor="#F0F0F0" borderThickness="2" + borderStyle="solid" borderColor="#000000" borderThickness="1" /> <mx:Image id="sliderButton" x="0" y="0" source="{sliderImage}"/> Modified: mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-02 00:53:24 UTC (rev 151) +++ mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -37,7 +37,7 @@ boxGender.setStyle("backgroundColor", ""); } - if(getYear().length != 4) + if(getYear().length != 4 || Number(getYear()) < 1900) { txtYear.setStyle("backgroundColor", "#FF0000"); ready=false; Added: mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-02 22:37:05 UTC (rev 152) @@ -0,0 +1,49 @@ +<?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"> + <mx:Label/> + <mx:Label htmlText="{htmlBold(title)}"/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + <mx:Script> <![CDATA[ + public function htmlBold(str:String):String + { + if(str==null)return null; + return "<font size=\"12px\">" + str + "</font>"; + } + ]]> </mx:Script> + + <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:Script> + <![CDATA[ + + public function back():Boolean + { + return false; + } + public function forward():Boolean + { + return false; + } + public function accept():Boolean + { + return true; + } + + ]]> + </mx:Script> + +</mx:VBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <see...@us...> - 2009-06-03 01:29:56
|
Revision: 153 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=153&view=rev Author: seematalele Date: 2009-06-03 01:29:45 +0000 (Wed, 03 Jun 2009) Log Message: ----------- When you click on the Question in the tree it should automatically show the corresponding information. Written code for it but not working at all. Modified Paths: -------------- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml mentalmodels/trunk/flex/src/customComponents/db/Question.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/ASCategorical.as mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as mentalmodels/trunk/flex/src/actionscript/ASQuestion.as Modified: mentalmodels/trunk/flex/src/InitialiseDatabase.mxml =================================================================== --- mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/InitialiseDatabase.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -4,14 +4,20 @@ width="100%" height="100%" clipContent="false" layout="absolute" currentState="none"> <mx:Script> <![CDATA[ + import customComponents.db.questions.CategoricalSimple; + import customComponents.db.questions.CategoricalRelative; + import customComponents.db.questions.Categorical; + import mx.collections.ArrayCollection; import mx.effects.Fade; import mx.collections.XMLListCollection; import mx.controls.Alert; + import actionscript.*; + /* id field of module, block and questiongroup and questions should come from database, so when module info is transfered to the server, it should return the id for that module */ - + public static var Qid:int = 2; [Bindable] private var company:XML = <list> @@ -27,8 +33,12 @@ <block name="Characterizing Own Strategy" sequenceNo="1" hours="0" min="30" sec="0" id="2"> <questiongroup header="What goals did you follow when designing your strategy" description="Please specify three goals..." sequenceNo="1" id="2"> <question title="Most important goal" type="psychometric" sequenceNo="1" id="1"> - <psychometric scale="bipolar" choice1="Good" choice2="Better" choice3="Best"/> + </question> + <question title="second important goal" type="catgorical" sequenceNo="2" id="2"> + + </question> + </questiongroup> </block> @@ -38,27 +48,29 @@ </list>; [Bindable] + private var companyData:XMLListCollection = new XMLListCollection(company.module); - private var companyData:XMLListCollection = new XMLListCollection(company.module); - private function treeLabel(item:Object):String + public var tempQuestion:ArrayCollection = new ArrayCollection(); + + private function treeLabel(item:Object):String { var node:XML = XML(item); if( node.localName() == "module" ) return node.@title; - - + else if( node.localName() == "block" ) return node.@name; else if( node.localName() == "questiongroup" ) return node.@header; + else if( node.localName() == "question" ) return node.@title; - else - return node.@name; + else + return null; } @@ -70,7 +82,6 @@ private function addModule():void { - currentState = "module"; var obj:DisplayObject = pnlComponent.getChildAt(1); var moduleInfo:Module = Module(obj); @@ -81,7 +92,6 @@ btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = false; - } private function saveModule(event:Event):void @@ -125,7 +135,6 @@ private function addBlock():void - { currentState = "block"; var obj:DisplayObject = pnlComponent.getChildAt(1); @@ -203,8 +212,7 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = true; btnsaveQuestion.enabled = false; - - + } private function saveQuestionGroup(event:Event):void @@ -251,17 +259,16 @@ newNode.@header = questionGroupInfo.getHeader(); newNode.@description = questionGroupInfo.getDescription(); newNode.@sequenceNo = questionGroupInfo.getSequenceNo(); - - - var block:XMLList =company.module.block.(@name == node.@name); - Alert.show(block.@name + "is name of the block"); - if( block.length() > 0 ) - { - block[0].appendChild(newNode); - currentState = "none"; - btnsaveQuestionGroup.enabled = false; + + var block:XMLList =company.module.block.(@name == node.@name); + Alert.show(block.@name + "is name of the block"); + if( block.length() > 0 ) + { + block[0].appendChild(newNode); + currentState = "none"; + btnsaveQuestionGroup.enabled = false; - } + } } } } @@ -311,20 +318,40 @@ var newNode:XML = <question/>; newNode.setLocalName("question"); - // newNode.@header = questionInfo.getHeader(); - //newNode.@description = questionInfo.getDescription(); newNode.@sequenceNo = questionInfo.getSequenceNo(); newNode.@title = questionInfo.getQuestion(); newNode.@type = questionInfo.getType(); + newNode.@id = ++Qid; var questionGroup:XMLList =company.module.block.questiongroup.(@header == node.@header); - Alert.show(questionGroup.@header + "is name of the questionGroup"); + if( questionGroup.length() > 0 ) { questionGroup[0].appendChild(newNode); currentState = "none"; btnsaveQuestion.enabled = false; - } + } + var ques:ASQuestion = new ASQuestion(newNode.@id); + if(questionInfo.getType().toLowerCase() == "categorical") + { + var cat:ASCategorical = new ASCategorical(newNode.@id); + + var compCategorical:Categorical = Categorical(questionInfo.getQuestionInfo()); + if(compCategorical.getCategoricalType().toLowerCase() == "relative") + { + var relative:CategoricalRelative = CategoricalRelative(compCategorical.getCategoricalInfo()); + cat.setDictionary(relative.dict); + } + else + { + var simple:CategoricalSimple = CategoricalSimple(compCategorical.getCategoricalInfo()); + cat.setDictionary(simple.dict); + } + ques.setQtype(cat); + } + + tempQuestion.addItem(ques); + } } } @@ -346,12 +373,7 @@ return; } - /*if( node.localName() != "module" ) - { - Alert.show("Please select the module from tree."); - return; - }*/ - + var children:XMLList = XMLList(node.parent()).children(); for(var i:Number=0; i < children.length(); i++) { @@ -437,12 +459,28 @@ btnsaveBlock.enabled = false; btnsaveQuestionGroup.enabled = false; btnsaveQuestion.enabled = true; - + //questionInfo.reset(); //set all fields questionInfo.setType(node.@type); questionInfo.setQuestion(node.@title); questionInfo.setSequenceNo(node.@sequenceNo); + var id:int = node.@id; + var Q:ASQuestion; + for(var i:int = 0; i<tempQuestion.length; i++) + { + Q = tempQuestion[i]; + if(Q.getId() == id ) + { + if(Q.getType().toLowerCase() == "categorical") + { + var cat:ASCategorical = ASCategorical(Q.getQtype()); + Alert.show(cat.dict[0]); + + } + + } + } } @@ -476,8 +514,7 @@ <comp:Question id="question"/> </mx:AddChild> </mx:State> - - + <mx:State name="none"> </mx:State> </mx:states> Added: mentalmodels/trunk/flex/src/actionscript/ASCategorical.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASCategorical.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASCategorical.as 2009-06-03 01:29:45 UTC (rev 153) @@ -0,0 +1,30 @@ +package actionscript +{ + import flash.utils.Dictionary; + + import mx.collections.ArrayCollection; + + public class ASCategorical + { + public var id:int; + + public function ASCategorical(id:int) + { + this.id = id; + } + + public var type:String; + public var dict:Dictionary = new Dictionary(); + + public function setDictionary(dictionary:Dictionary):void + { + dict = dictionary; + } + + public function getDictionary():Dictionary + { + return dict; + } + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASPsychometric.as 2009-06-03 01:29:45 UTC (rev 153) @@ -0,0 +1,20 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + public class ASPsychometric + { + public function ASPsychometric() + { + } + + + public var scale:String; + + public var numberOfIntervals:Number; + + public var choices:ArrayCollection; + + + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ASQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ASQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ASQuestion.as 2009-06-03 01:29:45 UTC (rev 153) @@ -0,0 +1,46 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + public class ASQuestion + { + private var id:int; + public var question:String; + private var type:String; + private var Qtype:Object; + + public function ASQuestion(id:int) + { + this.id = id; + + } + + public function setType(type:String):void + { + this.type = type; + + } + + public function getType():String + { + return type; + } + + public function setQtype(questionInfo:Object):void + { + this.Qtype = questionInfo; + } + + public function getQtype():Object + { + return Qtype; + } + + public function getId():int + { + return id; + } + + + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/db/Question.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/Question.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -13,7 +13,7 @@ [Bindable] public var formIsValid:Boolean = false; - + public var questionInfo:Object; // Holds a reference to the currently focussed // control on the form. private var focussedFormControl:DisplayObject; @@ -41,6 +41,17 @@ txtQuestion.text = question; } + public function setQuestionInfo():void + { + + } + + public function getQuestionInfo():Object + { + return questionInfo; + + } + public function setType(type:String):void { cmbType.selectedItem = type; @@ -94,22 +105,20 @@ private function showQuestionType():void { - - if(cmbType.selectedItem == "Categorical") { currentState = "categorical"; var catobj:DisplayObject = canvasQuestionType.getChildAt(0); - var categoricalInfo:Categorical = Categorical(catobj); - categoricalInfo.reset(); + questionInfo = Categorical(catobj); + questionInfo.reset(); } if(cmbType.selectedItem == "Psychometric") { currentState = "psychometric"; var psychobj:DisplayObject = canvasQuestionType.getChildAt(0); - var psychometricInfo:Psychometric = Psychometric(psychobj); - psychometricInfo.reset(); + questionInfo = Psychometric(psychobj); + questionInfo.reset(); } if(cmbType.selectedItem == "Text") @@ -148,12 +157,15 @@ public function reset():void { + currentState = "none"; txtSeqNo.text =""; txtQuestion.text = ""; txtSeqNo.errorString =""; txtQuestion.errorString =""; + cmbType.selectedIndex = 0; + } ]]> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/Categorical.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -8,6 +8,8 @@ import mx.events.ValidationResultEvent; import mx.controls.Alert; + public var categoricalInfo:Object; + [Bindable] public var formIsEmpty:Boolean = true; @@ -75,25 +77,37 @@ public function reset():void { - type.selectedValue =""; + currentState = "none"; + rdoRelative.value = null; + rdoSimple.value = null; } private function showRelativeFields():void { currentState = "relative"; var obj:DisplayObject = canvasComponent.getChildAt(0); - var relativeInfo:CategoricalRelative = CategoricalRelative(obj); - relativeInfo.reset(); + categoricalInfo = CategoricalRelative(obj); + categoricalInfo.reset(); } private function showSimpleFields():void { currentState = "simple"; var obj:DisplayObject = canvasComponent.getChildAt(0); - var simpleInfo:CategoricalSimple = CategoricalSimple(obj); - simpleInfo.reset(); + categoricalInfo = CategoricalSimple(obj); + categoricalInfo.reset(); } + public function getCategoricalInfo():Object + { + return categoricalInfo; + } + + public function getCategoricalType():String + { + return currentState.toString(); + } + ]]> </mx:Script> @@ -122,6 +136,8 @@ <mx:RadioButton id="rdoRelative" groupName="{type}" label="Relative" click="showRelativeFields()"/> <mx:RadioButton id="rdoSimple" groupName="{type}" label="Simple" click="showSimpleFields()" /> </mx:FormItem> - <mx:Canvas id="canvasComponent" height="100%" /> + <mx:Canvas id="canvasComponent" height="100%" width="100%"/> + + </mx:Form> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalRelative.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -262,7 +262,7 @@ </mx:VBox> - <mx:HBox id="vboxSecondHeader" visible="true"> + <mx:HBox id="vboxSecondHeader" visible="false"> <mx:VBox> <mx:Label text="" id="lblHeader1" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> <mx:List id="lstHeader1" wordWrap="true" dataProvider="{header1}" allowMultipleSelection="false" click="showChoices()" variableRowHeight="true"/> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/CategoricalSimple.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -18,7 +18,13 @@ [Bindable] public var header:ArrayCollection = new ArrayCollection(); + public var dict:Dictionary = new Dictionary(); + public function getChoices():ArrayCollection + { + return header; + } + // Holds a reference to the currently focussed // control on the form. private var focussedFormControl:DisplayObject; @@ -134,6 +140,7 @@ else { header.addItem(txtChoice.text); + dict[txtChoice.text] = null; txtChoice.text = ""; } @@ -153,10 +160,13 @@ } else { - header.removeItemAt(header.getItemIndex(lstHeader.selectedItem)); + header.removeItemAt(header.getItemIndex(lstHeader.selectedItem)); + delete dict[lstHeader.selectedItem]; } } + + ]]> Modified: mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml 2009-06-02 22:37:05 UTC (rev 152) +++ mentalmodels/trunk/flex/src/customComponents/db/questions/Psychometric.mxml 2009-06-03 01:29:45 UTC (rev 153) @@ -176,31 +176,11 @@ } } - - - ]]> </mx:Script> - <!-- <mx:states> - <mx:State name="relative"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalRelative id="relative"/> - </mx:AddChild> - </mx:State> - - <mx:State name="simple"> - <mx:AddChild relativeTo="{canvasComponent}"> - <comp:CategoricalSimple id="simple"/> - </mx:AddChild> - </mx:State> - - <mx:State name="none"/> - - </mx:states> --> - <mx:FormHeading label="Psychomtric"/> <mx:FormItem label="Type:"> <mx:RadioButtonGroup id="type"/> @@ -208,6 +188,12 @@ <mx:RadioButton id="rdoBipolar" groupName="{type}" label="Bipolar" click="showFields()" /> <mx:RadioButton id="rdoUnipolar" groupName="{type}" label="Unipolar" click="showFields()"/> </mx:FormItem> + + <mx:FormItem label="Number of Interval:"> + <mx:TextInput id="txtinterval" maxChars="2"/> + </mx:FormItem> + + <mx:HBox id="vboxChoices" visible="false"> <mx:VBox> <mx:Label text="Enter the choices below:" id="lblHeader" fontSize="12" fontWeight="bold" fontFamily="Verdana"/> @@ -221,4 +207,5 @@ </mx:VBox> </mx:HBox> + <mx:NumberValidator id ="validateInterval" source="{txtinterval}" property="text" minValue="1" maxValue="99" domain="int"/> </mx:Form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |