case "checkbox": return new CheckboxEditorFactory(inputXML);
case "choice": return new ChoiceEditorFactory(inputXML);
case "slider": return new SliderEditorFactory(inputXML);
+ case "number": return new NumberEditorFactory(inputXML);
case "speed": return new SpeedEditorFactory(inputXML);
case "route": return new RouteEditorFactory(inputXML);
case "turn": return new TurnRestrictionEditorFactory(inputXML);
xmlns:flexlib="flexlib.controls.*"
verticalGap="0"
width="100%"
- toolTip="{fieldDescription}">
+ toolTip="{fieldDescription}"
+ direction="horizontal">
- <mx:HBox>
<mx:Label text="{fieldName}:"/>
<mx:CheckBox id="inputBox" creationComplete="initCheckbox()"
labelPlacement="right" label=""
change="value=toYesNo()" />
- </mx:HBox>
+
<mx:Script><![CDATA[
protected function initCheckbox():void {
public function CheckboxEditorFactory(inputXML:XML) {
super(inputXML);
_notPresentText = inputXML.hasOwnProperty("@absenceText") ? String(inputXML.@absenceText) : "Unset";
- _notBooleanText = inputXML.hasOwnProperty("@invalidText") ? String(inputXML.@absenceText) : "Not yes/no";
+ _notBooleanText = inputXML.hasOwnProperty("@invalidText") ? String(inputXML.@invalidText) : "Not yes/no";
}
override protected function createSingleTagEditor():SingleTagEditor {
<edit:SingleTagEditor
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
- verticalGap="0"
- toolTip="{fieldDescription}">
+ toolTip="{fieldDescription}"
+ direction="{fieldDirection}" styleName="titledEditor">
-<mx:Box direction="{fieldDirection}" styleName="titledEditor">
<mx:Label text="{fieldName}:"/>
<edit:ChoiceComboBox id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
change="value = inputBox.selectedItem.value"
</mx:Component>
</edit:itemRenderer>
</edit:ChoiceComboBox>
-</mx:Box>
<mx:Script><![CDATA[
import mx.collections.*;
xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
xmlns:flexlib="flexlib.controls.*"
width="100%"
- toolTip="{fieldDescription}">
+ toolTip="{fieldDescription}"
+ direction="{fieldDirection}" styleName="titledEditor">
- <mx:Box direction="{fieldDirection}" styleName="titledEditor">
<mx:Label text="{fieldName}:"/>
<flexlib:PromptingTextInput id="inputBox" prompt="{prompt}" text="{value}" width="100%" change="value = inputBox.text"/>
- </mx:Box>
<mx:Script><![CDATA[
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<edit:SingleTagEditor
+ xmlns:mx="http://www.adobe.com/2006/mxml"
+ xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
+ xmlns:flexlib="flexlib.controls.*"
+ verticalGap="0"
+ width="100%"
+ toolTip="{fieldDescription}"
+ direction="{fieldDirection}" styleName="titledEditor">
+
+ <mx:Label text="{fieldName}:"/>
+ <mx:HBox horizontalGap="3" verticalAlign="middle">
+ <mx:NumericStepper id="input"
+ minimum="{minimum}" maximum="{maximum}"
+ stepSize="{stepSize}"
+ value="{translatedValue}"
+ enabled="{isValueValid}"
+ change="value = input.value.toString()" />
+ <mx:Label text="{prompt}" visible="{value == null || value == ''}"/>
+ </mx:HBox>
+
+ <mx:Script><![CDATA[
+ [Bindable(event="factory_set")]
+ protected function get prompt():String {
+ return _factory == null ? null : NumberEditorFactory(_factory).notPresentText;
+ }
+
+ [Bindable(event="factory_set")]
+ public function get minimum():Number {
+ return NumberEditorFactory(_factory) == null ? 0 : NumberEditorFactory(_factory).minimum;
+ }
+
+ [Bindable(event="factory_set")]
+ public function get maximum():Number {
+ return NumberEditorFactory(_factory) == null ? 100 : NumberEditorFactory(_factory).maximum;
+ }
+
+ [Bindable(event="factory_set")]
+ public function get stepSize():Number {
+ return NumberEditorFactory(_factory) == null ? 1 : NumberEditorFactory(_factory).stepSize;
+ }
+
+ [Bindable(event="tag_changed")]
+ private function get translatedValue():Number {
+ var validatedValue:Number = getValidatedValue();
+ return validatedValue;
+ }
+
+ [Bindable(event="tag_changed")]
+ private function get isValueValid():Boolean {
+ var validatedValue:Number = getValidatedValue();
+ return !(isNaN(validatedValue) && value != null && value != "");
+ }
+
+ private function getValidatedValue():Number {
+ var valueStr:String = value;
+ if ( valueStr == null || valueStr == "" )
+ return Number.NaN;
+
+ var parsed:Number = parseFloat(value);
+ if ( isNaN(parsed) || parsed < minimum || parsed > maximum )
+ return Number.NaN;
+ return parsed;
+ }
+
+ ]]></mx:Script>
+</edit:SingleTagEditor>
+
--- /dev/null
+package net.systemeD.potlatch2.mapfeatures.editors {
+
+ import net.systemeD.halcyon.connection.*;
+ import net.systemeD.potlatch2.mapfeatures.*;
+ import flash.display.*;
+
+ public class NumberEditorFactory extends SingleTagEditorFactory {
+ private var _minimum:Number;
+ private var _maximum:Number;
+ private var _stepSize:Number;
+ private var _notPresentText:String;
+
+ public function NumberEditorFactory(inputXML:XML) {
+ super(inputXML);
+ _minimum = parseFloat(inputXML.hasOwnProperty("@minimum") ? String(inputXML.@minimum) : "0");
+ _maximum = parseFloat(inputXML.hasOwnProperty("@maximum") ? String(inputXML.@maximum) : "100");
+ _stepSize = parseFloat(inputXML.hasOwnProperty("@stepSize") ? String(inputXML.@stepSize) : "1");
+ _notPresentText = inputXML.hasOwnProperty("@absenceText") ? String(inputXML.@absenceText) : "Unset";
+ }
+
+ override protected function createSingleTagEditor():SingleTagEditor {
+ return new NumberEditor();
+ }
+
+ public function get minimum():Number { return _minimum; }
+ public function get maximum():Number { return _maximum; }
+ public function get stepSize():Number { return _stepSize; }
+ public function get notPresentText():String { return _notPresentText; }
+ }
+
+}
+
+
import net.systemeD.halcyon.connection.*;
import net.systemeD.potlatch2.mapfeatures.*;
- import mx.containers.VBox;
+ import mx.containers.Box;
import flash.events.*;
- public class SingleTagEditor extends VBox {
+ public class SingleTagEditor extends Box {
protected var _factory:SingleTagEditorFactory;
protected var _entity:Entity;
xmlns:flexlib="flexlib.controls.*"
verticalGap="0"
width="100%"
- toolTip="{fieldDescription}">
+ toolTip="{fieldDescription}"
+ direction="horizontal" styleName="titledEditor">
- <mx:HBox styleName="titledEditor">
<mx:Label text="{fieldName}:"/>
<mx:HSlider id="inputSlider"
minimum="{sliderMinimum}" maximum="{sliderMaximum}"
enabled="{isValueValid}"
liveDragging="true"
change="setTagValueFromSlider()" />
- </mx:HBox>
+
<mx:Script><![CDATA[
private function setTagValueFromSlider():void {
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
toolTip="{fieldDescription}"
- verticalGap="0">
+ direction="horizontal" styleName="titledEditor">
<mx:Label text="{fieldName}:"/>
<edit:ChoiceComboBox id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
</inputSet>
<inputSet id="roadPhysical">
- <input type="slider" presence="onTagMatch"
- name="Layer" category="Physical" description="Relative vertical positions (-5 lowest, +5 highest)"
- key="layer" minimum="-5" maximum="5" default="0" snapInterval="1" labels="Lowest,Ground,Highest"
- defaultName="Ground"/>
<input type="freetext" presence="onTagMatch"
name="Width" category="Physical"
key="width" description="Width of the road" layout="horizontal"/>
</inputSet>
<inputSet id="roadLanes">
- <!-- slider not implemented...-->
- <!-- <input presence="always" type="slider" name="Lanes" category="Physical" description="Total number of lanes, counting both directions"
- key="lanes" min="1" max="10" default="2"/>-->
-
- <input presence="onTagMatch" type="choice" name="Lanes" category="Physical" description="Total number of lanes, counting both directions"
- key="lanes" default="2">
- <choice value="1" text="1" />
- <choice value="2" text="2" />
- <choice value="3" text="3" />
- <choice value="4" text="4" />
- <choice value="5" text="5" />
- <choice value="6" text="6" />
- <choice value="7" text="7" />
- <choice value="8" text="8" />
- <choice value="9" text="9" />
- <choice value="10" text="10" />
- </input>
-
+ <input presence="onTagMatch" type="number" name="Lanes" category="Physical" description="Total number of lanes, counting both directions"
+ key="lanes" minimum="1" maximum="10" layout="horizontal"/>
</inputSet>
<inputSet id="bridge">
<choice value="viaduct" text="Viaduct" description="Viaduct"/>
<choice value="suspension" text="Suspension bridge"/>
</input>
- </inputSet>
+ <input type="slider" presence="onTagMatch"
+ name="Layer" category="Physical" description="Relative vertical positions (-5 lowest, +5 highest)"
+ key="layer" minimum="-5" maximum="5" default="0" snapInterval="1" labels="Lowest,Ground,Highest"
+ defaultName="Ground"/>
+ </inputSet>
<inputSet id="tunnel">
<input type="choice" presence="onTagMatch"
name="Tunnel" category="Physical" description="Road goes into a tunnel"
<tag k="amenity" v="parking"/>
<inputSet ref="names"/>
<input type="freetext" presence="onTagMatch" category="Naming" name="Operator" key="operator" description="The provider of the postal service" priority="low"/>
- <input type="freetext" presence="always" category="Parking" name="Capacity" key="capacity" description="The number of bicycles that can be parked in the group of bicycle parking racks"/>
+ <input type="number" minimum="0" maximum="99999" stepSize="1" presence="always" category="Parking" name="Capacity" key="capacity" description="The number of cars that can be parked in the car park"/>
<inputSet ref="fee"/>
</feature>
<tag k="amenity" v="bicycle_parking"/>
<inputSet ref="names"/>
<input type="freetext" presence="onTagMatch" category="Naming" name="Operator" key="operator" description="The provider of the postal service" priority="low"/>
- <input type="freetext" presence="always" category="Cycle" name="Capacity" key="capacity" description="The number of bicycles that can be parked in the group of bicycle parking racks"/>
+ <input type="number" minimum="0" maximum="99999" stepSize="1"
+ presence="always" category="Cycle" name="Capacity" key="capacity"
+ description="The number of bicycles that can be parked in the group of bicycle parking racks"/>
<inputSet ref="fee"/>
<input type="choice" presence="always" category="Cycle" name="Covered" key="covered" description="Is the cycle parking covered, so that the bikes are kept dry?">
<choice value="yes" text="Yes"/>