keep changesets open throughout subsequent uploads, unless we go past the timeout
authorRichard Fairhurst <richard@systemed.net>
Thu, 2 Sep 2010 16:52:11 +0000 (16:52 +0000)
committerRichard Fairhurst <richard@systemed.net>
Thu, 2 Sep 2010 16:52:11 +0000 (16:52 +0000)
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/save/SaveDialog.mxml
net/systemeD/potlatch2/save/SaveManager.as

index 8cbb080..c1e87aa 100755 (executable)
@@ -90,6 +90,7 @@ package net.systemeD.halcyon.connection {
         private var relations:Object = {};
         private var pois:Array = [];
         private var changeset:Changeset = null;
+               private var changesetUpdated:Number;
                private var modified:Boolean = false;
                public var nodecount:int=0;
                public var waycount:int=0;
@@ -157,8 +158,13 @@ package net.systemeD.halcyon.connection {
 
         protected function setActiveChangeset(changeset:Changeset):void {
             this.changeset = changeset;
+                       changesetUpdated = new Date().getTime();
             sendEvent(new EntityEvent(NEW_CHANGESET, changeset),false);
         }
+
+               protected function freshenActiveChangeset():void {
+                       changesetUpdated = new Date().getTime();
+               }
         
         public function getNode(id:Number):Node {
             return nodes[id];
@@ -297,6 +303,10 @@ package net.systemeD.halcyon.connection {
                }
 
         public function getActiveChangeset():Changeset {
+                       // ** FIXME - should be able to manually close changesets
+                       if (changeset && (new Date().getTime()) > (changesetUpdated+58*60*1000)) {
+                               changeset=null;
+                       }
             return changeset;
         }
         
index f003cfe..3ffb664 100644 (file)
@@ -175,6 +175,7 @@ package net.systemeD.halcyon.connection {
             }
 
             dispatchEvent(new SaveCompleteEvent(SAVE_COMPLETED, true));
+                       freshenActiveChangeset();
             markClean(); // marks the connection clean. Pressing undo from this point on leads to unexpected results
             MainUndoStack.getGlobalStack().breakUndo(); // so, for now, break the undo stack
         }
index c8ab631..8407a06 100644 (file)
@@ -11,7 +11,8 @@
     <mx:Object k="comment" v=""/>
   </mx:ArrayCollection>
   
-  <mx:ViewStack id="processSequence" width="100%" height="100%">
+  <mx:ViewStack id="processSequence" width="100%" height="100%" 
+      creationPolicy="all" creationComplete="if (doSkip) skipInput();">
   
     <!-- section for entering tags -->
     <mx:VBox width="100%" height="100%" verticalGap="0">
     import net.systemeD.halcyon.connection.*;
     
     private var conn:Connection = Connection.getConnectionInstance();
+       private var doSkip:Boolean = false;
     
     [Bindable]
     private var failureText:String = "";
 
+       public function dontPrompt():void {
+               if (processSequence.initialized) { skipInput(); } else { doSkip=true; }
+       }
+
+       private function skipInput():void {
+               processSequence.selectedChild = createChangesetTab;
+               saveButton.enabled = false;
+               changesetCreated();
+       }
+
        private function commentChanged(event:Event):void {
                for (var i:int=changesetTags.length-1; i>0; i--) {
                        if (changesetTags[i]['k']=='comment') { changesetTags.removeItemAt(i); }
         }
     }
 
-    private function changesetCreated(event:EntityEvent):void {
+    private function changesetCreated(event:EntityEvent=null):void {
         var changeset:Changeset = conn.getActiveChangeset();
-        addStatus("Changeset created (id: "+changeset.id+")");
+        addStatus("Saving to changeset "+changeset.id);
         
         saveProgress.label = "Uploading changes";
         conn.addEventListener(Connection.SAVE_COMPLETED, saveCompleted);
index e3fcee3..1d90ab7 100644 (file)
@@ -75,12 +75,16 @@ package net.systemeD.potlatch2.save {
         }
         
         private function saveData():void {
-            Connection.getConnectionInstance().setAppID(consumer);
-            Connection.getConnectionInstance().setAuthToken(accessToken);
-            
             var saveDialog:SaveDialog = SaveDialog(
                 PopUpManager.createPopUp(Application(Application.application), SaveDialog, true));
             PopUpManager.centerPopUp(saveDialog);
+
+                       if (Connection.getConnectionInstance().getActiveChangeset()) {
+                               saveDialog.dontPrompt();
+                       } else {
+                   Connection.getConnectionInstance().setAppID(consumer);
+                   Connection.getConnectionInstance().setAuthToken(accessToken);
+                       }
         }
     }