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="{getStyledLabel(Choice(data))}"/>
19 public function getStyledLabel(choice:Choice):String {
20 if (choice.value==null) return "<font color='#a0a0a0'><i>"+choice.label+"</i></font>";
30 import mx.collections.*;
32 import net.systemeD.potlatch2.mapfeatures.Feature;
34 private var _choices:ArrayCollection = null;
35 private var _unknownChoice:Choice = null;
37 [Bindable(event="factory_set")]
38 protected function get choices():ArrayCollection {
39 var dummy:String=_factory.key; // otherwise _factory is null, for some not yet discovered reason.
40 if ( _choices == null ) {
41 _choices = new ArrayCollection();
42 for each ( var choice:Choice in ChoiceEditorFactory(_factory).choices ) {
43 _choices.addItem(choice);
45 _choices.addItem(createUnsetChoice());
50 [Bindable(event="tag_changed")]
51 protected function get selectFromTag():Object {
52 var tagValue:String = value;
53 for each(var choice:Choice in choices) {
54 if ( choice.isTagMatch(tagValue) )
58 // set up the unknown choice
59 if ( _unknownChoice == null ) {
60 _unknownChoice = new Choice();
61 _unknownChoice.description = "Unknown value";
62 _choices.addItem(_unknownChoice);
64 _unknownChoice.label = "<i>Unknown:</i> "+Feature.htmlEscape(tagValue);
65 _unknownChoice.icon = null;
66 _unknownChoice.value = tagValue;
68 return _unknownChoice;
71 private function createUnsetChoice():Choice {
72 var choice:Choice = new Choice();
74 choice.description = "Field not set";
75 choice.label = "Unset";
80 </edit:SingleTagEditor>