Skip to content

Commit

Permalink
adding form fields [#28]
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultz committed Mar 8, 2011
1 parent a052451 commit 47251fc
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/mesh/view/helpers/form/CheckBoxField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mesh.view.helpers.form
{
import spark.components.CheckBox;

public class CheckBoxField extends FormField
{
private var _checkBox:spark.components.CheckBox;

/**
* Constructor.
*/
public function CheckBoxField()
{
super();
}

/**
* @private
*/
override protected function createChildren():void
{
super.createChildren();

_checkBox = new spark.components.CheckBox();
addElement(_checkBox);
}
}
}
21 changes: 21 additions & 0 deletions src/mesh/view/helpers/form/ComboBoxField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package mesh.view.helpers.form
{
import spark.components.ComboBox;
import spark.components.List;

public class ComboBoxField extends ListField
{
public function ComboBoxField()
{
super();
}

/**
* @inheritDoc
*/
override protected function createList():List
{
return new ComboBox();
}
}
}
21 changes: 21 additions & 0 deletions src/mesh/view/helpers/form/DropDownListField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package mesh.view.helpers.form
{
import spark.components.DropDownList;
import spark.components.List;

public class DropDownListField extends ListField
{
public function DropDownListField()
{
super();
}

/**
* @inheritDoc
*/
override protected function createList():List
{
return new DropDownList();
}
}
}
30 changes: 30 additions & 0 deletions src/mesh/view/helpers/form/Form.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package mesh.view.helpers.form
{
import mesh.Entity;

import spark.components.Form;

public class Form extends spark.components.Form
{
/**
* Constructor.
*/
public function Form()
{
super();
}

private var _entity:Entity;
/**
*
*/
public function get entity():Entity
{
return _entity;
}
public function set entity(value:Entity):void
{
_entity = value;
}
}
}
45 changes: 45 additions & 0 deletions src/mesh/view/helpers/form/FormField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package mesh.view.helpers.form
{
import mesh.core.inflection.humanize;
import mesh.core.string.capitalize;

import spark.components.FormItem;

public class FormField extends FormItem
{
public function FormField()
{
super();
}

private var _property:String;
/**
* The property name on the entity to use.
*/
public function get property():String
{
return _property;
}
public function set property(value:String):void
{
_property = value;

if (label == null || label.length == 0) {
label = capitalize(humanize(value));
}
}

private var _value:Object;
/**
* The value for the control of this field.
*/
public function get value():Object
{
return _value;
}
public function set value(value:Object):void
{
_value = value;
}
}
}
31 changes: 31 additions & 0 deletions src/mesh/view/helpers/form/ListField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package mesh.view.helpers.form
{
import spark.components.List;

public class ListField extends FormField
{
public function ListField()
{
super();
}

/**
* @private
*/
override protected function createChildren():void
{
super.createChildren();
addElement(createList());
}

/**
* Creates a list that is configured for this form field.
*
* @return A new lsit.
*/
protected function createList():List
{
return new List();
}
}
}
22 changes: 22 additions & 0 deletions src/mesh/view/helpers/form/NumberField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package mesh.view.helpers.form
{
import spark.components.TextInput;

public class NumberField extends TextField
{
public function NumberField()
{
super();
}

/**
* @inheritDoc
*/
override protected function createTextField():TextInput
{
var textField:TextInput = super.createTextField();
textField.restrict = "0-9.,";
return textField;
}
}
}
22 changes: 22 additions & 0 deletions src/mesh/view/helpers/form/PasswordField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package mesh.view.helpers.form
{
import spark.components.TextInput;

public class PasswordField extends TextField
{
public function PasswordField()
{
super();
}

/**
* @inheritDoc
*/
override protected function createTextField():TextInput
{
var textField:TextInput = super.createTextField();
textField.displayAsPassword = true;
return textField;
}
}
}
27 changes: 27 additions & 0 deletions src/mesh/view/helpers/form/RadioButton.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package mesh.view.helpers.form
{
import spark.components.RadioButton;

public class RadioButton extends FormField
{
private var _radioButton:spark.components.RadioButton;

public function RadioButton()
{
super();
}

/**
* @private
*/
override protected function childrenCreated():void
{
super.createChildren();

_radioButton = new spark.components.RadioButton();
_radioButton.groupName = property;
_radioButton.label = value.toString();
addElement(_radioButton);
}
}
}
10 changes: 10 additions & 0 deletions src/mesh/view/helpers/form/RadioButtonGroupField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package mesh.view.helpers.form
{
public class RadioButtonGroupField extends FormField
{
public function RadioButtonGroupField()
{
super();
}
}
}
25 changes: 25 additions & 0 deletions src/mesh/view/helpers/form/TextAreaField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mesh.view.helpers.form
{
import spark.components.TextArea;

public class TextAreaField extends FormField
{
private var _textArea:spark.components.TextArea

public function TextAreaField()
{
super();
}

/**
* @private
*/
override protected function createChildren():void
{
super.createChildren();

_textArea = new spark.components.TextArea();
addElement(_textArea);
}
}
}
34 changes: 34 additions & 0 deletions src/mesh/view/helpers/form/TextField.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package mesh.view.helpers.form
{
import spark.components.TextInput;

public class TextField extends FormField
{
/**
* Constructor.
*/
public function TextField()
{
super();
}

/**
* @private
*/
override protected function createChildren():void
{
super.createChildren();
addElement(createTextField());
}

/**
* Creates a text input field that is configured for this form field.
*
* @return A new text input.
*/
protected function createTextField():TextInput
{
return new TextInput();
}
}
}

0 comments on commit 47251fc

Please sign in to comment.