Merge remote-tracking branch 'gravitystorm/form-layout' into form-layout
[potlatch2.git] / net / systemeD / potlatch2 / TagViewer.mxml
index bbca135b9170cd8350fc5cb32be7e6b9a8bf87a3..693bc6569cc53801775f2228a658517d1c946667 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
                                        subpanel.styleName="subcategoryPanel";
                                        subpanel.title=subcategory;
                                        subpanels[category][subcategory]=subpanel;
+                                       var form:Form = new Form();
+                                       form.name = "form";
+                                       form.layout = getFormLayout();
+                                       subpanel.addChild(form);
                                        tabComponents[tab].push(subpanel);
                                }
-                               subpanel.addChild(catEditor);
+                               Form(subpanel.getChildByName("form")).addElement(UIComponent(catEditor));
                        } else {
                                tabComponents[tab].push(catEditor);
                        }
           box.percentWidth = 100;
           box.percentHeight = 100;
           box.styleName = "dndEditorContainer";
+          var form:Form = new Form();
+          form.name = "form";
+          form.layout = getFormLayout();
+          box.addChild(form);
           return box;
       }
 
           if ( components == null || tab == null || tab.numChildren >= components.length )
               return;
           for each (var component:DisplayObject in components ) {
-              tab.addChild(component);
+              Form(tab.getChildByName("form")).addElement(UIComponent(component));
           }
       }
 
                if (rows!=Math.floor(rows)) { rows=Math.floor(rows+1); }
                event.target.height=rows*(event.target.rowHeight+1);
        }
+
+    private function getFormLayout():FormLayout {
+        var layout:FormLayout = new FormLayout();
+          // This is ugly, and should really be done with a skin. See
+          // http://stackoverflow.com/questions/5126756/flex-spark-form-item-gap
+        layout.gap = -8;
+        return layout;
+    }
   ]]></fx:Script>
 </mx:VBox>