categories of additional tags for roads
[potlatch2.git] / net / systemeD / potlatch2 / TagViewer.mxml
index 70a0061..bdcf17e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <mx:VBox
-       xmlns:mx="http://www.adobe.com/2006/mxml" 
-       xmlns:halcyon="net.systemeD.halcyon.*"
+       xmlns:mx="http://www.adobe.com/2006/mxml"
+       xmlns:flexlib="flexlib.containers.*"
     backgroundColor="white"
     creationComplete="loadFeatures()">
 
@@ -15,6 +15,9 @@
         </mx:VBox>
         <mx:LinkButton label="?" click="openDescription()" id="helpLabel"/>
     </mx:HBox>
+    <flexlib:SuperTabNavigator id="editorStack" width="100%" height="100%" paddingLeft="2" paddingRight="2"
+        allowTabSqueezing="false" minTabWidth="10" closePolicy="close_never"
+        scrollSpeed="20"/>
   </mx:VBox>
 
   <mx:VBox width="100%" height="100%" label="Advanced" initialize="checkAdvanced()" verticalGap="1">
       }
 
       private function refreshFeatureIcon():void {
+          var oldFeature:Feature = feature;
           feature = selectedEntity == null ? null : mapFeatures.findMatchingFeature(selectedEntity);
+          if ( feature != oldFeature )
+              initialiseEditors();
+
           if ( feature != null )
               setFeatureIcon(selectedEntity, feature);
           else
@@ -80,7 +87,7 @@
       }
 
       private function setFeatureIcon(entity:Entity, feature:Feature):void {
-          blankFeatureIcon(entity);
+          //blankFeatureIcon(entity);
           
           iconImage.source = feature.image;
 
           tw.setSelectedFeature(null);
       }
 
+      private function initialiseEditors():void {
+          editorStack.removeAllChildren();
+          if ( selectedEntity == null || feature == null )
+              return;
+          
+          var editorBox:VBox = createEditorBox();
+          editorBox.label = "Basic";
+          editorStack.addChild(editorBox);
+          
+          var tabs:Object = {};
+          
+          for each (var factory:EditorFactory in feature.editors) {
+              if ( factory.presence.isEditorPresent(factory, selectedEntity, null) ) {
+                  var editor:DisplayObject = factory.createEditorInstance(selectedEntity);
+                  if ( editor != null )
+                      editorBox.addChild(editor);
+              }
+              var category:String = factory.category;
+              var tab:VBox = tabs[category];
+              if ( tab == null ) {
+                  tab = createEditorBox();
+                  tab.label = category;
+                  editorStack.addChild(tab);
+                  tabs[category] = tab;
+              }
+              var catEditor:DisplayObject = factory.createEditorInstance(selectedEntity);
+              if ( catEditor != null )
+                  tab.addChild(catEditor);
+          }
+      }
+      
+      private function createEditorBox():VBox {
+          var box:VBox = new VBox();
+          box.percentWidth = 100;
+          box.percentHeight = 100;
+          return box;
+      }
+
       private function checkAdvanced():void {
           if ( selectedEntity != null )
              setupAdvanced(selectedEntity);
                   if ( event.newValue == null ) {
                       collection.removeItemAt(i-1);
                       collection.refresh();
+                  } else {
+                      collection.itemUpdated(tag, "value");
                   }
               }
           }