[mapguide-commits] r6038 - in trunk/Tools/Maestro/Maestro.Base: Editor Properties

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Aug 5 07:48:22 EDT 2011


Author: jng
Date: 2011-08-05 04:48:21 -0700 (Fri, 05 Aug 2011)
New Revision: 6038

Modified:
   trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
   trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.resx
   trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx
Log:
#1769: Implement in-place upgrade of edited resources. This was easier than I thought it would be!


Modified: trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2011-08-05 11:28:25 UTC (rev 6037)
+++ trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2011-08-05 11:48:21 UTC (rev 6038)
@@ -32,6 +32,8 @@
 using Maestro.Base.UI;
 using Maestro.Base.UI.Preferences;
 using Maestro.Shared.UI;
+using OSGeo.MapGuide.MaestroAPI.Resource.Conversion;
+using System.IO;
 
 namespace Maestro.Base.Editor
 {
@@ -289,7 +291,29 @@
 
         private void btnUpgrade_Click(object sender, EventArgs e)
         {
+            var res = _svc.GetEditedResource();
+            var conn = res.CurrentConnection;
+            var ver = conn.Capabilities.GetMaxSupportedResourceVersion(res.ResourceType);
 
+            using (new WaitCursor(this))
+            {
+                var conv = new ResourceObjectConverter();
+                var res2 = conv.Convert(res, ver);
+                
+                using (var stream = ResourceTypeRegistry.Serialize(res2))
+                {
+                    using (var sr =new StreamReader(stream))
+                    {
+                        _svc.UpdateResourceContent(sr.ReadToEnd());
+                        ((ResourceEditorService)_svc).ReReadSessionResource();
+                    }
+                }
+                
+                //This will re-init everything
+                this.EditorService = this.EditorService;
+                MessageBox.Show(string.Format(Properties.Resources.ResourceUpgraded, ver.Major, ver.Minor, ver.Build));
+                this.EditorService.MarkDirty(); //It gets re-init with a clean slate, but an in-place upgrade is a dirty operation
+            }
         }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.resx	2011-08-05 11:28:25 UTC (rev 6037)
+++ trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.resx	2011-08-05 11:48:21 UTC (rev 6038)
@@ -150,9 +150,6 @@
   <data name="btnUpgrade.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
     <value>Top, Right</value>
   </data>
-  <data name="btnUpgrade.Enabled" type="System.Boolean, mscorlib">
-    <value>False</value>
-  </data>
   <data name="btnUpgrade.Location" type="System.Drawing.Point, System.Drawing">
     <value>526, 8</value>
   </data>
@@ -235,6 +232,6 @@
     <value>EditorContentBase</value>
   </data>
   <data name="&gt;&gt;$this.Type" xml:space="preserve">
-    <value>Maestro.Base.ViewContentBase, Maestro.Base, Version=3.0.0.5610, Culture=neutral, PublicKeyToken=null</value>
+    <value>Maestro.Base.ViewContentBase, Maestro.Base, Version=3.5.0.5977, Culture=neutral, PublicKeyToken=null</value>
   </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs	2011-08-05 11:28:25 UTC (rev 6037)
+++ trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs	2011-08-05 11:48:21 UTC (rev 6038)
@@ -1622,6 +1622,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Resource upgraded to schema version {0}.{1}.{2}.
+        /// </summary>
+        internal static string ResourceUpgraded {
+            get {
+                return ResourceManager.GetString("ResourceUpgraded", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Failed to decode the current bounds,
         ///you must re-enter the epsg code in the SRS tag manually.
         ///Error message: {0}..

Modified: trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx	2011-08-05 11:28:25 UTC (rev 6037)
+++ trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx	2011-08-05 11:48:21 UTC (rev 6038)
@@ -1049,4 +1049,7 @@
   <data name="SiteExplorer_CreateFolderStructure" xml:space="preserve">
     <value>Create Standard Folder Structure</value>
   </data>
+  <data name="ResourceUpgraded" xml:space="preserve">
+    <value>Resource upgraded to schema version {0}.{1}.{2}</value>
+  </data>
 </root>
\ No newline at end of file



More information about the mapguide-commits mailing list