Start moving editors over to use a spark Form and FormLayout
authorAndy Allan <andy@gravitystorm.co.uk>
Sat, 26 Nov 2011 18:13:15 +0000 (18:13 +0000)
committerAndy Allan <andy@gravitystorm.co.uk>
Sat, 26 Nov 2011 18:13:15 +0000 (18:13 +0000)
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/mapfeatures/editors/CheckboxEditor.mxml
net/systemeD/potlatch2/mapfeatures/editors/ChoiceEditor.mxml
net/systemeD/potlatch2/mapfeatures/editors/FreeTextEditor.mxml

index 3dd633e..816242e 100644 (file)
       import net.systemeD.controls.CollapsiblePanel;
 
       import mx.collections.*;
-      import mx.containers.*;
+      import mx.containers.VBox;
+      import mx.containers.HBox;
+      import mx.containers.TabNavigator;
+      import mx.containers.Accordion;
       import mx.events.*;
       import mx.core.*;
       import mx.managers.PopUpManager;
       import mx.managers.DragManager;
       import mx.core.DragSource;
       import mx.controls.TabBar;
+      import spark.components.Form;
+      import spark.layouts.FormLayout;
 //    import flexlib.containers.SuperTabNavigator;
 
       [Bindable] [Embed(source="../../../embedded/tab_basic.png"       )] private var tabIconBasic:Class;
                        // Add to basic editor box first
                        if ( factory.presence.isEditorPresent(factory, selectedEntity, null) ) {
                                var editor:DisplayObject = factory.createEditorInstance(selectedEntity);
-                               if (editor) basicEditorBox.addChild(editor);
+                               if (editor) Form(basicEditorBox.getChildByName("form")).addElement(UIComponent(editor));
                        }
 
                        // Then prepare to add to category panel
           box.percentWidth = 100;
           box.percentHeight = 100;
           box.styleName = "dndEditorContainer";
+          var form:Form = new Form();
+          form.name = "form";
+          var layout:FormLayout = new FormLayout();
+          form.layout = layout;
+          box.addChild(form);
           return box;
       }
 
index 66b997b..35af92b 100644 (file)
@@ -2,6 +2,7 @@
 <edit:SingleTagEditor
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library://ns.adobe.com/flex/mx"
+    xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
        xmlns:flexlib="flexlib.controls.*"
        verticalGap="0"
        toolTip="{fieldDescription}"
     direction="horizontal">
 
-       <mx:Label text="{fieldName}:"/>
-       <mx:CheckBox id="inputBox" creationComplete="initCheckbox()"
-                                labelPlacement="right" label=""
-                                change="value=toYesNo()" />
+    <s:FormItem label="{fieldName}">
+      <mx:CheckBox id="inputBox" creationComplete="initCheckbox()"
+                  labelPlacement="right" label=""
+                  change="value=toYesNo()" />
+    </s:FormItem>
 
   <fx:Script><![CDATA[
   
index cd7489d..26c6151 100644 (file)
@@ -7,24 +7,25 @@
        toolTip="{fieldDescription}"
     direction="{fieldDirection}" styleName="titledEditor">
 
-  <mx:Label text="{fieldName}:"/>
-  <s:DropDownList id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
-      change="value = inputBox.selectedItem.value" labelField="label">
-      <s:itemRenderer>
-        <fx:Component>
-        <mx:HBox toolTip="{data.description}" horizontalScrollPolicy="off">
-          <mx:Image source="{Choice(data).icon}"/>
-          <mx:Label htmlText="{getStyledLabel(Choice(data))}"/>
-                       <fx:Script><![CDATA[
-                             public function getStyledLabel(choice:Choice):String {
-                                 if (choice.value==null) return "<font color='#a0a0a0'><i>"+choice.label+"</i></font>";
-                                 return choice.label;
-                                 }
-                       ]]></fx:Script>
-        </mx:HBox>
-        </fx:Component>
-      </s:itemRenderer>
-  </s:DropDownList>
+  <s:FormItem label="{fieldName}">
+    <s:DropDownList id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
+        change="value = inputBox.selectedItem.value" labelField="label">
+        <s:itemRenderer>
+          <fx:Component>
+          <mx:HBox toolTip="{data.description}" horizontalScrollPolicy="off">
+            <mx:Image source="{Choice(data).icon}"/>
+            <mx:Label htmlText="{getStyledLabel(Choice(data))}"/>
+              <fx:Script><![CDATA[
+                    public function getStyledLabel(choice:Choice):String {
+                        if (choice.value==null) return "<font color='#a0a0a0'><i>"+choice.label+"</i></font>";
+                        return choice.label;
+                    }
+              ]]></fx:Script>
+          </mx:HBox>
+          </fx:Component>
+        </s:itemRenderer>
+    </s:DropDownList>
+  </s:FormItem>
 
   <fx:Script><![CDATA[
       import mx.collections.*;
index 08ed76e..72d45e2 100644 (file)
@@ -2,6 +2,7 @@
 <edit:SingleTagEditor
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library://ns.adobe.com/flex/mx"
+    xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
        xmlns:flexlib="flexlib.controls.*"
        xmlns:controls="net.systemeD.controls.*"
        toolTip="{fieldDescription}"
     direction="{fieldDirection}" styleName="titledEditor">
 
-  <mx:Label text="{fieldName}:"/>
-  <controls:PromptingTextInputWarning id="inputBox" prompt="{prompt}" text="{value}" width="100%" 
-      focusOut="value = inputBox.text" enter="value = inputBox.text"
-      restrict="&#x0020;-&#x10FFFF;" />
-
+    <s:FormItem label="{fieldName}">
+      <controls:PromptingTextInputWarning id="inputBox" prompt="{prompt}" text="{value}" width="100%"
+        focusOut="value = inputBox.text" enter="value = inputBox.text"
+        restrict="&#x0020;-&#x10FFFF;" />
+    </s:FormItem>
   <fx:Script><![CDATA[
   
       [Bindable(event="factory_set")]