Auto-detect filetype based on extension
authorRichard Fairhurst <richard@systemeD.net>
Wed, 15 Jun 2011 16:12:20 +0000 (17:12 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Wed, 15 Jun 2011 16:12:20 +0000 (17:12 +0100)
net/systemeD/potlatch2/VectorSourceDialog.mxml

index 42a61d0..e17c883 100644 (file)
@@ -70,7 +70,7 @@
                </mx:HBox>
                <mx:HBox>
                        <mx:Text text="URL:"/>
-                       <mx:TextInput width="100%" id="src" text="" />
+                       <mx:TextInput width="100%" id="src" text="" change="selectByExtension()" />
                        <mx:Button label="Load" click="loadFiles(src.text, filetype.selectedValue.toString(), simplify.selected, projection.selectedItem.data);" enabled="{src.text == '' ? false : true}"/>
                </mx:HBox>
        </mx:VBox>
                dispatchEvent(new Event("layers_changed"));
        }
     
+       private function selectByExtension():void {
+               if      (src.text.match(/\.shp$/i)) filetype.selectedValue='shp'
+               else if (src.text.match(/\.osm$/i)) filetype.selectedValue='osm'
+               else if (src.text.match(/\.gpx$/i)) filetype.selectedValue='gpx'
+               else if (src.text.match(/\.kml$/i)) filetype.selectedValue='kml'
+       }
+
     private function vectorDialog_close(evt:CloseEvent):void {
         PopUpManager.removePopUp(this);
     }