basic AutoComplete component and sample support. Needs much more work on the P2 logic...
[potlatch2.git] / net / systemeD / potlatch2 / TagViewer.mxml
index 244e1d4671fc517af57d2214d90217f8048205fc..38e526f4aca4903ab627810f840488e3a13bd53d 100644 (file)
@@ -2,6 +2,7 @@
 <mx:VBox
        xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:flexlib="flexlib.containers.*"
+       xmlns:controls="net.systemeD.controls.*"
        horizontalScrollPolicy="off"
     backgroundColor="white"
     initialize="loadFeatures()">
             doubleClickEnabled="true"
             doubleClick="if (event.target.parent==advancedTagGrid) { addNewTag(); }">
                 <mx:columns>
-                    <mx:DataGridColumn editable="true" dataField="key" headerText="Key"/>
-                    <mx:DataGridColumn editable="true" dataField="value" headerText="Value"/>
+                    <mx:DataGridColumn editable="true" dataField="key" headerText="Key">
+                                               <mx:itemEditor>
+                                                       <mx:Component>
+                                                               <controls:AutoComplete 
+                                                                 dataProvider="{autoCompleteKeys()}" 
+                                                                 labelField="name" 
+                                                                 rowCount="10"
+                                                                 typedText="{getSelectedKey()}">
+                                                                       <mx:Script><![CDATA[
+                                                                               import net.systemeD.potlatch2.mapfeatures.MapFeatures;
+                                                                               import mx.collections.ArrayCollection;
+                                                                               import mx.controls.DataGrid;
+
+                                                                               public function autoCompleteKeys():Array {
+                                                                                       var a:Array=[];
+                                                                                       for each (var k:String in MapFeatures.getInstance().getAutoCompleteKeys()) {
+                                                                                               a.push( { name: k } );
+                                                                                       }
+                                                                                       return a;
+                                                                               }
+
+                                                                               internal function getSelectedKey():String {
+                                                                                       return DataGrid(this.parent.parent).selectedItem.key;
+                                                                               }
+                                                                       ]]></mx:Script>
+                                                               </controls:AutoComplete>
+                                                       </mx:Component>
+                                               </mx:itemEditor>
+                                       </mx:DataGridColumn>
+                    <mx:DataGridColumn editable="true" dataField="value" headerText="Value" />
                 </mx:columns>
         </mx:DataGrid>
 
       private var editorStackAccordion:Accordion;
       [Bindable] private var editorStack:Container;
 
-      private var mapFeatures:MapFeatures;
+      public var mapFeatures:MapFeatures;
       private var selectedEntity:Entity;
       private var tagDataProvider:ArrayCollection;
       private var tw:CategorySelector = null;