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