1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:fx="http://ns.adobe.com/mxml/2009"
4 xmlns:mx="library://ns.adobe.com/flex/mx"
5 xmlns:s="library://ns.adobe.com/flex/spark"
6 xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
7 xmlns:flexlib="flexlib.controls.*"
10 toolTip="{fieldDescription}"
11 direction="horizontal">
13 <s:FormItem label="{fieldName}">
14 <mx:CheckBox id="inputBox" creationComplete="initCheckbox()"
15 labelPlacement="right" label=""
16 change="value=toYesNo()" />
21 protected function initCheckbox():void {
22 // ** FIXME - these should really be bindings (selected="{...}").
23 // 500 bonus points if you can get them to work as such, because I can't.
24 inputBox.selected=parseBoolean(value);
25 inputBox.label=checkValidity(value);
26 dispatchEvent(new Event("factory_set"));
29 [Bindable(event="factory_set")]
30 protected function checkValidity(value:String):String {
31 if (_factory==null || value==null) { return CheckboxEditorFactory(_factory).notPresentText; }
32 var cv:String=value.toLowerCase();
33 if (cv=='yes' || cv=='no' || cv=='1' || cv=='0' || cv=='true' || cv=='false') { return null; }
34 return CheckboxEditorFactory(_factory).notBooleanText;
37 [Bindable(event="factory_set")]
38 protected function parseBoolean(value:String):Boolean {
39 if (!value) { return false; }
40 var cv:String=value.toLowerCase();
41 if (cv=='yes' || cv=='1' || cv=='true') { return true; }
45 protected function toYesNo():String {
47 return inputBox.selected ? 'yes':'no';
51 </edit:SingleTagEditor>