[mapguide-commits] r5075 - in sandbox/maestro-3.0/Maestro.Base: Commands Properties Templates

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Aug 6 01:49:03 EDT 2010


Author: jng
Date: 2010-08-06 05:49:03 +0000 (Fri, 06 Aug 2010)
New Revision: 5075

Modified:
   sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
   sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
   sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs
   sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs
Log:
Alter the new feature source template to prompt for FDO provider


Modified: sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs	2010-08-06 05:43:53 UTC (rev 5074)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs	2010-08-06 05:49:03 UTC (rev 5075)
@@ -54,10 +54,13 @@
                 var tpl = dlg.SelectedTemplate;
 
                 var res = tpl.CreateItem(conn);
-                res.ResourceID = "Session:" + conn.SessionID + "//" + Guid.NewGuid().ToString() + "." + res.ResourceType.ToString();
-                conn.ResourceService.SaveResource(res);
+                if (res != null)
+                {
+                    res.ResourceID = "Session:" + conn.SessionID + "//" + Guid.NewGuid().ToString() + "." + res.ResourceType.ToString();
+                    conn.ResourceService.SaveResource(res);
 
-                orm.Open(res.ResourceID, conn, false);
+                    orm.Open(res.ResourceID, conn, false);
+                }
             }
         }
     }

Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs	2010-08-06 05:43:53 UTC (rev 5074)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs	2010-08-06 05:49:03 UTC (rev 5075)
@@ -898,6 +898,15 @@
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Select FDO Provider.
+        /// </summary>
+        internal static string SelectFdoProvider {
+            get {
+                return ResourceManager.GetString("SelectFdoProvider", resourceCulture);
+            }
+        }
+        
         internal static System.Drawing.Bitmap server {
             get {
                 object obj = ResourceManager.GetObject("server", resourceCulture);

Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx	2010-08-06 05:43:53 UTC (rev 5074)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx	2010-08-06 05:49:03 UTC (rev 5075)
@@ -619,4 +619,7 @@
   <data name="SiteExplorer_SelectedItem_OpenWithXmlEditor" xml:space="preserve">
     <value>Open Resource with XML Editor</value>
   </data>
+  <data name="SelectFdoProvider" xml:space="preserve">
+    <value>Select FDO Provider</value>
+  </data>
 </root>
\ No newline at end of file

Modified: sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs	2010-08-06 05:43:53 UTC (rev 5074)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs	2010-08-06 05:49:03 UTC (rev 5075)
@@ -25,6 +25,7 @@
 using Res = Maestro.Base.Properties.Resources;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using Maestro.Editors.Common;
 
 namespace Maestro.Base.Templates
 {
@@ -41,8 +42,18 @@
 
         public override IResource CreateItem(IServerConnection conn)
         {
-            string provider = "";
-            return ObjectFactory.CreateFeatureSource(conn, provider);
+            var provider = GenericItemSelectionDialog.SelectItem(
+                Properties.Resources.SelectFdoProvider,
+                Properties.Resources.SelectFdoProvider,
+                conn.FeatureService.FeatureProviders,
+                "DisplayName",
+                "Name");
+
+            if (provider != null)
+            {
+                return ObjectFactory.CreateFeatureSource(conn, provider.Name);
+            }
+            return null;
         }
     }
 }

Modified: sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs	2010-08-06 05:43:53 UTC (rev 5074)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs	2010-08-06 05:49:03 UTC (rev 5075)
@@ -40,6 +40,11 @@
 
         public Image Icon { get; protected set; }
 
+        /// <summary>
+        /// Creates a new item from this template
+        /// </summary>
+        /// <param name="conn"></param>
+        /// <returns>a new resource, null if the user cancelled during this process</returns>
         public abstract IResource CreateItem(IServerConnection conn);
     }
 }



More information about the mapguide-commits mailing list