1 | package clarin.cmdi.componentregistry.editor { |
---|
2 | import clarin.cmdi.componentregistry.common.StyleConstants; |
---|
3 | |
---|
4 | import mx.binding.utils.BindingUtils; |
---|
5 | import mx.collections.ArrayCollection; |
---|
6 | import mx.containers.FormItem; |
---|
7 | import mx.containers.FormItemDirection; |
---|
8 | import mx.controls.ComboBox; |
---|
9 | |
---|
10 | public class CardinalityInput extends FormItem { |
---|
11 | private var numericList:ComboBox = new ComboBox(); |
---|
12 | |
---|
13 | private static var cardinalityData:ArrayCollection = createCardinalityData(); |
---|
14 | |
---|
15 | private static function createCardinalityData():ArrayCollection { |
---|
16 | var result:ArrayCollection = new ArrayCollection([{label: "unbounded", data: "unbounded"}]); |
---|
17 | for (var i:int = 0; i < 10; i++) { |
---|
18 | result.addItem({label: i, data: i}); |
---|
19 | } |
---|
20 | return result; |
---|
21 | } |
---|
22 | |
---|
23 | public function CardinalityInput(name:String, value:String, bindingFunction:Function, editable:Boolean = true) { |
---|
24 | super(); |
---|
25 | label = name; |
---|
26 | direction = FormItemDirection.HORIZONTAL; |
---|
27 | styleName = StyleConstants.XMLBROWSER_FIELD; |
---|
28 | BindingUtils.bindSetter(bindingFunction, numericList, "text"); |
---|
29 | numericList.width = 300; |
---|
30 | numericList.editable = true; |
---|
31 | numericList.prompt = value; |
---|
32 | numericList.toolTip = "Pick a value or type any number"; |
---|
33 | numericList.dataProvider = cardinalityData; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | protected override function createChildren():void { |
---|
38 | super.createChildren(); |
---|
39 | addChild(numericList); |
---|
40 | } |
---|
41 | |
---|
42 | } |
---|
43 | } |
---|