[virtualcommons-svn] SF.net SVN: virtualcommons:[153] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
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. |