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 helpContent="{fieldDescription ? help : null}"
8 styleName="titledEditor">
10 <mx:VBox> <!-- This wrapper shouldn't be necessary, but without it the layout goes nuts -->
11 <edit:ChoiceComboBox id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
12 dropdownFactory="mx.controls.TileList"
13 change="value = inputBox.selectedItem.value"
14 itemRenderer="net.systemeD.potlatch2.mapfeatures.editors.RestrictionRenderer"
15 dropdownWidth="250" rowCount="4"
17 </edit:ChoiceComboBox>
21 import mx.collections.*;
23 import net.systemeD.potlatch2.mapfeatures.Feature;
25 private var _choices:ArrayCollection = null;
26 private var _unknownChoice:SpeedChoice = null;
28 [Bindable(event="factory_set")]
29 protected function get choices():ArrayCollection {
30 if ( _choices == null ) {
31 _choices = new ArrayCollection();
32 for each(var sp:String in
33 ["5 mph", "10 mph", "15 mph", "20 mph", "25 mph", "30 mph", "35 mph",
34 "40 mph", "45 mph", "50 mph", "55 mph", "60 mph", "65 mph", "70 mph", "75 mph",
35 "10", "20", "30", "40", "50", "60", "70", "80", "90", "100", "110", "120", "130"])
36 _choices.addItem(new SpeedChoice(sp));
37 _choices.addItem(new SpeedChoice(null));
42 [Bindable(event="tag_changed")]
43 protected function get selectFromTag():Object {
44 if ( _entity == null )
45 return new SpeedChoice(null);
47 var tagValue:String = value;
48 for each(var choice:SpeedChoice in choices) {
49 if ( choice.isTagMatch(tagValue) )
53 // set up the unknown choice
54 if ( _unknownChoice == null ) {
55 _unknownChoice = new SpeedChoice(tagValue);
56 _choices.addItem(_unknownChoice);
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 = "<i>Unset</i>";
72 </edit:SingleTagEditor>