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:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
6 xmlns:flexlib="flexlib.controls.*"
9 toolTip="{fieldDescription}"
10 direction="horizontal">
12 <mx:Label text="{fieldName}:"/>
13 <mx:CheckBox id="inputBox" creationComplete="initCheckbox()"
14 labelPlacement="right" label=""
15 change="value=toYesNo()" />
19 protected function initCheckbox():void {
20 // ** FIXME - these should really be bindings (selected="{...}").
21 // 500 bonus points if you can get them to work as such, because I can't.
22 inputBox.selected=parseBoolean(value);
23 inputBox.label=checkValidity(value);
24 dispatchEvent(new Event("factory_set"));
27 [Bindable(event="factory_set")]
28 protected function checkValidity(value:String):String {
29 if (_factory==null || value==null) { return CheckboxEditorFactory(_factory).notPresentText; }
30 var cv:String=value.toLowerCase();
31 if (cv=='yes' || cv=='no' || cv=='1' || cv=='0' || cv=='true' || cv=='false') { return null; }
32 return CheckboxEditorFactory(_factory).notBooleanText;
35 [Bindable(event="factory_set")]
36 protected function parseBoolean(value:String):Boolean {
37 if (!value) { return false; }
38 var cv:String=value.toLowerCase();
39 if (cv=='yes' || cv=='1' || cv=='true') { return true; }
43 protected function toYesNo():String {
45 return inputBox.selected ? 'yes':'no';
49 </edit:SingleTagEditor>