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 toolTip="{fieldDescription}"
8 direction="{fieldDirection}" styleName="titledEditor">
10 <mx:Label text="{fieldName}:"/>
11 <s:DropDownList id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
12 change="value = inputBox.selectedItem.value" labelField="label">
15 <mx:HBox toolTip="{data.description}" horizontalScrollPolicy="off">
16 <mx:Image source="{Choice(data).icon}"/>
17 <mx:Label htmlText="{data.label}"/>
24 import mx.collections.*;
26 import net.systemeD.potlatch2.mapfeatures.Feature;
28 private var _choices:ArrayCollection = null;
29 private var _unknownChoice:Choice = null;
31 [Bindable(event="factory_set")]
32 protected function get choices():ArrayCollection {
33 if ( _choices == null ) {
34 _choices = new ArrayCollection();
35 for each ( var choice:Choice in ChoiceEditorFactory(_factory).choices )
36 _choices.addItem(choice);
37 _choices.addItem(createUnsetChoice());
42 [Bindable(event="tag_changed")]
43 protected function get selectFromTag():Object {
44 var tagValue:String = value;
45 for each(var choice:Choice in choices) {
46 if ( choice.isTagMatch(tagValue) )
50 // set up the unknown choice
51 if ( _unknownChoice == null ) {
52 _unknownChoice = new Choice();
53 _unknownChoice.description = "Unknown value";
54 _choices.addItem(_unknownChoice);
56 _unknownChoice.label = "<i>Unknown:</i> "+Feature.htmlEscape(tagValue);
57 _unknownChoice.icon = null;
58 _unknownChoice.value = tagValue;
60 return _unknownChoice;
63 private function createUnsetChoice():Choice {
64 var choice:Choice = new Choice();
66 choice.description = "Field not set";
67 choice.label = "<font color='#a0a0a0'><i>Unset</i></font>";
72 </edit:SingleTagEditor>