1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
5 xmlns:flexlib="flexlib.controls.*"
8 toolTip="{fieldDescription}"
9 direction="horizontal">
11 <mx:Label text="{fieldName}:"/>
12 <mx:CheckBox id="inputBox" creationComplete="initCheckbox()"
13 labelPlacement="right" label=""
14 change="value=toYesNo()" />
18 protected function initCheckbox():void {
19 // ** FIXME - these should really be bindings (selected="{...}").
20 // 500 bonus points if you can get them to work as such, because I can't.
21 inputBox.selected=parseBoolean(value);
22 inputBox.label=checkValidity(value);
23 dispatchEvent(new Event("factory_set"));
26 [Bindable(event="factory_set")]
27 protected function checkValidity(value:String):String {
28 if (_factory==null || value==null) { return CheckboxEditorFactory(_factory).notPresentText; }
29 var cv:String=value.toLowerCase();
30 if (cv=='yes' || cv=='no' || cv=='1' || cv=='0' || cv=='true' || cv=='false') { return null; }
31 return CheckboxEditorFactory(_factory).notBooleanText;
34 [Bindable(event="factory_set")]
35 protected function parseBoolean(value:String):Boolean {
36 if (!value) { return false; }
37 var cv:String=value.toLowerCase();
38 if (cv=='yes' || cv=='1' || cv=='true') { return true; }
42 protected function toYesNo():String {
44 return inputBox.selected ? 'yes':'no';
48 </edit:SingleTagEditor>