dial B for source tag
authorRichard Fairhurst <richard@systemed.net>
Sun, 14 Nov 2010 17:40:38 +0000 (17:40 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 14 Nov 2010 17:40:38 +0000 (17:40 +0000)
net/systemeD/potlatch2/BackgroundSelector.mxml
net/systemeD/potlatch2/EditController.as
net/systemeD/potlatch2/StyleSelector.mxml
net/systemeD/potlatch2/controller/ControllerState.as
potlatch2.mxml

index cac03f7..3bb05b7 100644 (file)
@@ -6,14 +6,14 @@
        
        <mx:List width="100%" height="100%" id="background" verticalScrollPolicy="on" 
                        labelField="name"
-                       change="Application.application.setBackground(background.selectedItem.name, background.selectedItem.url);"                      
+                       change="Application.application.bgButton.close(); Application.application.setBackground(background.selectedItem);"                      
                dataProvider="{Application.application.theController.imagery}" />
        <mx:CheckBox width="100%" label="Dim background" selected="true" id="dim"
            change="Application.application.theMap.setDimming(dim.selected); Application.application.yahoo.alpha = dim.selected ? 0.5 : 1" />
 
        <mx:HBox>
-       <mx:Button label="Edit..." click="new BackgroundDialog().init('Background imagery',background,Application.application.theController.imagery);" />
-       <mx:Button label="Vector file..." click="new VectorSourceDialog().init();" />
+       <mx:Button label="Edit..." click="Application.application.bgButton.close(); new BackgroundDialog().init('Background imagery',background,Application.application.theController.imagery);" />
+       <mx:Button label="Vector file..." click="Application.application.bgButton.close(); new VectorSourceDialog().init();" />
        </mx:HBox>
 
        <mx:Script><![CDATA[
index e27b05d..e799046 100644 (file)
@@ -19,6 +19,7 @@ package net.systemeD.potlatch2 {
                private var keys:Object={};
                public var clipboards:Object={};
                public var imagery:Array=[];
+               public var imagerySelected:Object={};
                public var stylesheets:Array=[];
                public var cursorsEnabled:Boolean=true;
 
index 9e6ff10..04566cd 100644 (file)
@@ -6,7 +6,7 @@
        
        <mx:List width="100%" height="100%" id="mapStyle" 
                labelField="name"
-               change="Application.application.setStylesheet(mapStyle.selectedItem.name, mapStyle.selectedItem.url);"
+               change="Application.application.styleButton.close(); Application.application.setStylesheet(mapStyle.selectedItem.name, mapStyle.selectedItem.url);"
                dataProvider="{Application.application.theController.stylesheets}" />
 
        <mx:Button label="Edit..." click="new BackgroundDialog().init('Map style',mapStyle,Application.application.theController.stylesheets);" />
index 28ae847..f40ecb1 100644 (file)
@@ -51,6 +51,7 @@ package net.systemeD.potlatch2.controller {
                
                protected function sharedKeyboardEvents(event:KeyboardEvent):ControllerState {
                        switch (event.keyCode) {
+                               case 66:        setSourceTag(); break;                                                                                                  // B - set source tag for current object
                                case 67:        controller.connection.closeChangeset(); break;                                                  // C - close changeset
                                case 68:        controller.map.paint.alpha=1.3-controller.map.paint.alpha; return null; // D - dim
                                case 83:        SaveManager.saveChanges(); break;                                                                               // S - save
@@ -152,6 +153,13 @@ package net.systemeD.potlatch2.controller {
                        object.resume();
                }
                
+               protected function setSourceTag():void {
+                       if (selectCount!=1) { return; }
+                       if (controller.imagerySelected && controller.imagerySelected.sourcetag) {
+                               firstSelected.setTag('source',controller.imagerySelected.sourcetag, MainUndoStack.getGlobalStack().addAction);
+                       }
+               }
+               
                // Selection getters
                
                public function get selectCount():uint {
index 8376124..2b6aad5 100644 (file)
                
         private function onImageryLoad(event:Event):void {
                        var xml:XML = new XML(URLLoader(event.target).data);
-                       var saved_url:String = SharedObject.getLocal("user_state").data['background_url'];
-                       var saved_name:String= SharedObject.getLocal("user_state").data['background_name'];
+                       var saved:Object;
+                       if (SharedObject.getLocal("user_state").data['background_url']) {
+                               saved={ name: SharedObject.getLocal("user_state").data['background_name'],
+                                               url:  SharedObject.getLocal("user_state").data['background_url' ] };
+                       } else {
+                               saved={};
+                       }
+
                        var isSet:Boolean=false;
             var backgroundSet:Boolean = false;
 
             theController.imagery=new Array(
                                { name: "None", url: "" },
-                               { name: "Yahoo", url: "yahoo" } );
+                               { name: "Yahoo", url: "yahoo", sourcetag: "Yahoo" } );
                        for each(var set:XML in xml.set) {
                                var obj:Object={};
                                for (var a:String in set.children()) {
                                        obj[set.child(a).name()]=set.child(a);
                                }
                 theController.imagery.push(obj);
-                               if (obj['url']==saved_url || (obj['name']==saved_name && obj['name']!='Custom')) { isSet=true; }
+                               if ((obj.url ==saved.url) ||
+                                   (obj.name==saved.name && obj.name!='Custom')) { isSet=true; }
                        }
 
-            if (!isSet && saved_name != null && saved_url != null && saved_url != '' && saved_url != 'yahoo') {
-                theController.imagery.push({ name:saved_name, url:saved_url });
+            if (!isSet && saved.name && saved.url && saved.url!='' && saved.url!='yahoo') {
+                theController.imagery.push(saved);
                 isSet=true;
             }
 
                        for each (var bg:Object in theController.imagery) {
-                               if (bg['name']==saved_name || bg['url']==saved_url) {
-                                       setBackground(bg['name'], bg['url']);
+                               if (bg.name==saved.name || bg.url==saved.url) {
+                                       setBackground(bg);
                     backgroundSet = true;
                                }
                        }
 
             // For most contributors it's useful to set the background to yahoo by default, I reckon, but lets make it a config
             if (!backgroundSet && loaderInfo.parameters['yahoo_default'] == 'true') {
-                setBackground("Yahoo", "yahoo");
+                setBackground(theController.imagery[1]);
             }
                }
                
-               public function setBackground(name:String,url:String):void {
-                       // ** this should take an object with all parameters (source tag, etc.)
-                       if (url=='yahoo') { theMap.setBackground('') ; yahoo.show(); }
-                                    else { theMap.setBackground(url); yahoo.hide(); }
+               public function setBackground(bg:Object):void {
+                       if (bg.url=='yahoo') { theMap.setBackground(''    ); yahoo.show(); }
+                                       else { theMap.setBackground(bg.url); yahoo.hide(); }
+                       theController.imagerySelected=bg;
                        var obj:SharedObject = SharedObject.getLocal("user_state");
-                       obj.setProperty("background_url",url );
-                       obj.setProperty("background_name",name);
+                       obj.setProperty('background_url' ,String(bg.url));
+                       obj.setProperty('background_name',String(bg.name));
                        obj.flush();
                }
 
                                        obj[set.child(a).name()]=set.child(a);
                                }
                 theController.stylesheets.push(obj);
-                               if (obj['url']==saved_url || (obj['name']==saved_name && obj['name']!='Custom')) { isInMenu=true; }
+                               if (obj.url==saved_url || (obj.name==saved_name && obj.name!='Custom')) { isInMenu=true; }
                        }
                        if (saved_url && !isInMenu) { theController.stylesheets.push({ name:saved_name, url:saved_url }); }
 
             // or alternatively the first one on the menu,
             // or finally try 'potlatch.css'
                        for each (var ss:Object in theController.stylesheets) {
-                               if (ss['name']==saved_name || ss['url']==saved_url) {
-                                       setStylesheet(ss['name'], ss['url']);
+                               if (ss.name==saved_name || ss.url==saved_url) {
+                                       setStylesheet(ss.name, ss.url);
                     isSet = true;
                     break;
                                }
             if (!isSet) {
               if(theController.stylesheets.length > 0) {
                 var s:Object = theController.stylesheets[0];
-                setStylesheet(s['name'], s['url']);
+                setStylesheet(s.name, s.url);
               } else {
                 //hit and hope. FIXME should this be an error state?
                 theController.stylesheets.push({ name:'Potlatch', url:'potlatch.css'});