[mapguide-commits] r6312 - in trunk/Tools/Maestro: Maestro.Editors/FeatureSource/Providers/Odbc Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors Maestro.Editors/Properties OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Mapping OSGeo.MapGuide.MaestroAPI/Services SDK/SamplesWeb/SamplesWeb/Tasks

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Dec 8 09:14:46 EST 2011


Author: jng
Date: 2011-12-08 06:14:46 -0800 (Thu, 08 Dec 2011)
New Revision: 6312

Modified:
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ConnectionStringCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.resx
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/IOdbcSubEditor.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/KnownDriversCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ManagedCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/UnmanagedCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs
Log:
#1708: Have ODBC child editors expose a RequestDocumentReset event. Only the DSN child editor raises this event. Thus changing the DSN will invalidate and reset the configuration document. The DSN child editor UI has been changed to allow for prompting and notification of reset configuration documents.

Also it turns out we also need to internalise the ctors of RuntimeMapGroup as well because our planned future alternate implementation of RuntimeMapLayer that wraps MgLayer needs to be associated with MgLayerGroup. So we need to be able to have derivatives of RuntimeMapGroup, thus creation also needs to be a provider specific responsibility. Thus new CreateMapGroup() methods have been added to the IMappingService interface (one overload for each previously public ctor in RuntimeMapGroup), with default implementations in PlatformConnectionBase

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -71,6 +71,11 @@
                 OnResourceChanged();
         }
 
+        void RequestedDocumentReset(object sender, EventArgs e)
+        {
+            DoDocumentReset();
+        }
+
         private bool _init = false;
 
         public override void Bind(IEditorService service)
@@ -166,13 +171,17 @@
                 catch { }
 
                 childEditor.ConnectionChanged += InternalConnectionChanged;
+                childEditor.RequestDocumentReset += RequestedDocumentReset;
                 pnlMethod.Controls.Clear();
                 childEditor.Content.Dock = DockStyle.Fill;
                 pnlMethod.Controls.Add(childEditor.Content);
             }
 
             if (this.ChildEditor != null)
+            {
                 this.ChildEditor.ConnectionChanged -= InternalConnectionChanged;
+                this.ChildEditor.RequestDocumentReset -= RequestedDocumentReset;
+            }
 
             this.ChildEditor = childEditor;
 
@@ -292,28 +301,46 @@
             mgr.AddNamespace("xlink", XmlNamespaces.XLINK);
             mgr.AddNamespace("fds", XmlNamespaces.FDS);
 
-            var desc = _fs.Describe();
-            _doc.AddSchema(desc.Schemas[0]); //Only one schema is supported by ODBC so this is ok
+            //This may have changed, so reapply
+            var props = Use64BitDriver ? this.ChildEditor.Get64BitConnectionProperties() : this.ChildEditor.ConnectionProperties;
+            _fs.ApplyConnectionProperties(props);
+            _service.SyncSessionCopy();
 
-            var scList = _fs.GetSpatialInfo(false);
-            foreach (var sc in scList.SpatialContext)
+            try
             {
-                _doc.AddSpatialContext(sc);
+                var desc = _fs.Describe();
+                if (desc.Schemas.Length == 0)
+                    throw new ApplicationException("Could not retrieve any schemas from this connection. If it is a DSN, ensure it is a valid DSN");
+                _doc.AddSchema(desc.Schemas[0]); //Only one schema is supported by ODBC so this is ok
+
+                var scList = _fs.GetSpatialInfo(false);
+                foreach (var sc in scList.SpatialContext)
+                {
+                    _doc.AddSpatialContext(sc);
+                }
             }
+            catch (Exception ex)
+            {
+                _doc = null;
+                MessageBox.Show(ex.Message);
+            }
         }
 
         private void btnReset_Click(object sender, EventArgs e)
         {
-            if (CheckValidConnection())
-            {
-                _fs.SetConfigurationContent(null);
-                _fs.ConfigurationDocument = null;
-                _service.SyncSessionCopy();
-                BuildDefaultDocument();
-                MessageBox.Show(Properties.Resources.ConfigurationDocumentReset);
-            }
+            DoDocumentReset();
         }
 
+        private void DoDocumentReset()
+        {
+            _fs.SetConfigurationContent(null);
+            _fs.ConfigurationDocument = null;
+            _service.SyncSessionCopy();
+            _doc = null;
+            BuildDefaultDocument();
+            MessageBox.Show(Properties.Resources.ConfigurationDocumentReset);
+        }
+
         private void chkUse64Bit_CheckedChanged(object sender, EventArgs e)
         {
             OdbcConnectionMethod method = (OdbcConnectionMethod)cmbMethod.SelectedItem;

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ConnectionStringCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ConnectionStringCtrl.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ConnectionStringCtrl.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -73,5 +73,8 @@
         {
             return this.ConnectionProperties;
         }
+
+
+        public event EventHandler RequestDocumentReset;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.Designer.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.Designer.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -30,7 +30,8 @@
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DSNCtrl));
             this.label1 = new System.Windows.Forms.Label();
-            this.lstDSN = new System.Windows.Forms.ListBox();
+            this.txtDSN = new System.Windows.Forms.TextBox();
+            this.btnBrowseDsn = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // label1
@@ -38,18 +39,25 @@
             resources.ApplyResources(this.label1, "label1");
             this.label1.Name = "label1";
             // 
-            // lstDSN
+            // txtDSN
             // 
-            resources.ApplyResources(this.lstDSN, "lstDSN");
-            this.lstDSN.FormattingEnabled = true;
-            this.lstDSN.Name = "lstDSN";
-            this.lstDSN.SelectedIndexChanged += new System.EventHandler(this.lstDSN_SelectedIndexChanged);
+            resources.ApplyResources(this.txtDSN, "txtDSN");
+            this.txtDSN.Name = "txtDSN";
+            this.txtDSN.ReadOnly = true;
             // 
+            // btnBrowseDsn
+            // 
+            resources.ApplyResources(this.btnBrowseDsn, "btnBrowseDsn");
+            this.btnBrowseDsn.Name = "btnBrowseDsn";
+            this.btnBrowseDsn.UseVisualStyleBackColor = true;
+            this.btnBrowseDsn.Click += new System.EventHandler(this.btnBrowseDsn_Click);
+            // 
             // DSNCtrl
             // 
             resources.ApplyResources(this, "$this");
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.Controls.Add(this.lstDSN);
+            this.Controls.Add(this.btnBrowseDsn);
+            this.Controls.Add(this.txtDSN);
             this.Controls.Add(this.label1);
             this.Name = "DSNCtrl";
             this.ResumeLayout(false);
@@ -60,6 +68,7 @@
         #endregion
 
         private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.ListBox lstDSN;
+        private System.Windows.Forms.TextBox txtDSN;
+        private System.Windows.Forms.Button btnBrowseDsn;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -27,6 +27,7 @@
 using OSGeo.MapGuide.MaestroAPI;
 using System.Collections.Specialized;
 using OSGeo.MapGuide.ObjectModels.FeatureSource;
+using Maestro.Editors.Common;
 
 namespace Maestro.Editors.FeatureSource.Providers.Odbc.SubEditors
 {
@@ -40,11 +41,13 @@
 
         private IFeatureSource _fs;
 
+        string[] _dsnNames;
+
         public override void Bind(IEditorService service)
         {
             service.RegisterCustomNotifier(this);
             _fs = (IFeatureSource)service.GetEditedResource();
-            lstDSN.DataSource = service.FeatureService.GetConnectionPropertyValues("OSGeo.ODBC", "DataSourceName", string.Empty);
+            _dsnNames = service.FeatureService.GetConnectionPropertyValues("OSGeo.ODBC", "DataSourceName", string.Empty);
         }
 
         void OnConnectionChanged()
@@ -59,13 +62,13 @@
             get
             {
                 var values = new NameValueCollection();
-                if (lstDSN.SelectedItem != null)
-                    values["DataSourceName"] = lstDSN.SelectedItem.ToString();
+                if (!string.IsNullOrEmpty(txtDSN.Text))
+                    values["DataSourceName"] = txtDSN.Text;
                 return values;
             }
             set
             {
-                lstDSN.SelectedItem = value["DataSourceName"];
+                txtDSN.Text = value["DataSourceName"];
             }
         }
 
@@ -76,15 +79,36 @@
             get { return this; }
         }
 
-        private void lstDSN_SelectedIndexChanged(object sender, EventArgs e)
+        public NameValueCollection Get64BitConnectionProperties()
         {
-            if (lstDSN.SelectedItem != null)
-                OnConnectionChanged();
+            return this.ConnectionProperties;
         }
 
-        public NameValueCollection Get64BitConnectionProperties()
+        private void btnBrowseDsn_Click(object sender, EventArgs e)
         {
-            return this.ConnectionProperties;
+            string dsn = GenericItemSelectionDialog.SelectItem(null, null, _dsnNames);
+            if (dsn != null)
+            {
+                if (dsn != txtDSN.Text)
+                {
+                    bool reset = MessageBox.Show(Properties.Resources.PromptResetOdbcConfigDocument, Properties.Resources.TitleQuestion, MessageBoxButtons.YesNo) == DialogResult.Yes;
+                    if (reset)
+                    {
+                        txtDSN.Text = dsn;
+                        OnRequestDocumentReset();
+                        OnConnectionChanged();
+                    }
+                }
+            }
         }
+
+        void OnRequestDocumentReset()
+        {
+            var handler = this.RequestDocumentReset;
+            if (handler != null)
+                handler(this, EventArgs.Empty);
+        }
+
+        public event EventHandler RequestDocumentReset;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.resx	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/DSNCtrl.resx	2011-12-08 14:14:46 UTC (rev 6312)
@@ -144,31 +144,61 @@
     <value>$this</value>
   </data>
   <data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
-    <value>1</value>
+    <value>2</value>
   </data>
   <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
-  <data name="lstDSN.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
-    <value>Top, Bottom, Left, Right</value>
+  <data name="txtDSN.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
+    <value>Top, Left, Right</value>
   </data>
-  <data name="lstDSN.Location" type="System.Drawing.Point, System.Drawing">
-    <value>119, 3</value>
+  <data name="txtDSN.Location" type="System.Drawing.Point, System.Drawing">
+    <value>3, 19</value>
   </data>
-  <data name="lstDSN.Size" type="System.Drawing.Size, System.Drawing">
-    <value>270, 147</value>
+  <data name="txtDSN.Size" type="System.Drawing.Size, System.Drawing">
+    <value>351, 20</value>
   </data>
-  <data name="lstDSN.TabIndex" type="System.Int32, mscorlib">
+  <data name="txtDSN.TabIndex" type="System.Int32, mscorlib">
     <value>1</value>
   </data>
-  <data name="&gt;&gt;lstDSN.Name" xml:space="preserve">
-    <value>lstDSN</value>
+  <data name="&gt;&gt;txtDSN.Name" xml:space="preserve">
+    <value>txtDSN</value>
   </data>
-  <data name="&gt;&gt;lstDSN.Type" xml:space="preserve">
-    <value>System.Windows.Forms.ListBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  <data name="&gt;&gt;txtDSN.Type" xml:space="preserve">
+    <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </data>
-  <data name="&gt;&gt;lstDSN.Parent" xml:space="preserve">
+  <data name="&gt;&gt;txtDSN.Parent" xml:space="preserve">
     <value>$this</value>
   </data>
-  <data name="&gt;&gt;lstDSN.ZOrder" xml:space="preserve">
+  <data name="&gt;&gt;txtDSN.ZOrder" xml:space="preserve">
+    <value>1</value>
+  </data>
+  <data name="btnBrowseDsn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
+    <value>Top, Right</value>
+  </data>
+  <data name="btnBrowseDsn.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
+    <value>NoControl</value>
+  </data>
+  <data name="btnBrowseDsn.Location" type="System.Drawing.Point, System.Drawing">
+    <value>360, 17</value>
+  </data>
+  <data name="btnBrowseDsn.Size" type="System.Drawing.Size, System.Drawing">
+    <value>29, 23</value>
+  </data>
+  <data name="btnBrowseDsn.TabIndex" type="System.Int32, mscorlib">
+    <value>2</value>
+  </data>
+  <data name="btnBrowseDsn.Text" xml:space="preserve">
+    <value>...</value>
+  </data>
+  <data name="&gt;&gt;btnBrowseDsn.Name" xml:space="preserve">
+    <value>btnBrowseDsn</value>
+  </data>
+  <data name="&gt;&gt;btnBrowseDsn.Type" xml:space="preserve">
+    <value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </data>
+  <data name="&gt;&gt;btnBrowseDsn.Parent" xml:space="preserve">
+    <value>$this</value>
+  </data>
+  <data name="&gt;&gt;btnBrowseDsn.ZOrder" xml:space="preserve">
     <value>0</value>
   </data>
   <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -184,6 +214,6 @@
     <value>DSNCtrl</value>
   </data>
   <data name="&gt;&gt;$this.Type" xml:space="preserve">
-    <value>Maestro.Editors.EditorBase, Maestro.Editors, Version=3.0.0.5475, Culture=neutral, PublicKeyToken=null</value>
+    <value>Maestro.Editors.EditorBase, Maestro.Editors, Version=4.0.0.6282, Culture=neutral, PublicKeyToken=f526c48929fda856</value>
   </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/IOdbcSubEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/IOdbcSubEditor.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/IOdbcSubEditor.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -31,6 +31,8 @@
 
         event EventHandler ConnectionChanged;
 
+        event EventHandler RequestDocumentReset;
+
         Control Content { get; }
 
         NameValueCollection Get64BitConnectionProperties();

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/KnownDriversCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/KnownDriversCtrl.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/KnownDriversCtrl.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -96,5 +96,8 @@
                 this.SelectedDriver = OdbcDriverMap.GetDriver(lstDriver.SelectedItem.ToString());
             }
         }
+
+
+        public event EventHandler RequestDocumentReset;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ManagedCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ManagedCtrl.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/ManagedCtrl.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -135,5 +135,8 @@
         {
             get { return this; }
         }
+
+
+        public event EventHandler RequestDocumentReset;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/UnmanagedCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/UnmanagedCtrl.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/SubEditors/UnmanagedCtrl.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -152,5 +152,8 @@
         {
             OnConnectionChanged();
         }
+
+
+        public event EventHandler RequestDocumentReset;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -2432,6 +2432,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Changing the DSN will reset the current configuration document. Proceed?.
+        /// </summary>
+        internal static string PromptResetOdbcConfigDocument {
+            get {
+                return ResourceManager.GetString("PromptResetOdbcConfigDocument", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Select Map.
         /// </summary>
         internal static string PromptSelectMap {

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-12-08 14:14:46 UTC (rev 6312)
@@ -1316,4 +1316,7 @@
   <data name="PromptUpdateMapWidgetReference" xml:space="preserve">
     <value>Update Map Widget to point to</value>
   </data>
+  <data name="PromptResetOdbcConfigDocument" xml:space="preserve">
+    <value>Changing the DSN will reset the current configuration document. Proceed?</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -245,11 +245,6 @@
             this.BackgroundColor = mdf.BackgroundColor;
             this.CoordinateSystem = mdf.CoordinateSystem;
 
-            if (Array.IndexOf(this.CurrentConnection.Capabilities.SupportedServices, (int)ServiceType.Mapping) < 0)
-                throw new InvalidOperationException("The Map Definition originates from an incompatible IServerConnection implementation");
-
-            IMappingService mappingSvc = (IMappingService)this.CurrentConnection.GetService((int)ServiceType.Mapping);
-
             //TODO: infer real mpu from coordinate system
 
             //If a setup helper exists, use it to get required layers in a single
@@ -272,14 +267,14 @@
             //Load map layers
             foreach (var layer in mdf.MapLayer)
             {
-                var rtl = mappingSvc.CreateMapLayer(this, layer);
+                var rtl = _mapSvc.CreateMapLayer(this, layer);
                 this.Layers.Add(rtl);
             }
 
             //Load map groups
             foreach (var group in mdf.MapLayerGroup)
             {
-                var grp = new RuntimeMapGroup(this, group);
+                var grp = _mapSvc.CreateMapGroup(this, group);
                 this.Groups.Add(grp);
             }
 
@@ -293,13 +288,13 @@
                     {
                         foreach (var layer in group.BaseMapLayer)
                         {
-                            var rtl = mappingSvc.CreateMapLayer(this, layer);
+                            var rtl = _mapSvc.CreateMapLayer(this, layer);
                             rtl.Visible = true;
                             rtl.Type = RuntimeMapLayer.kBaseMap;
                             this.Layers.Add(rtl);
                         }
                     }
-                    var rtg = new RuntimeMapGroup(this, group);
+                    var rtg = _mapSvc.CreateMapGroup(this, group);
                     this.Groups.Add(rtg);
                 }
 
@@ -914,6 +909,7 @@
 
             for (int i = 0; i < groupCount; i++)
             {
+                //TODO: Review when we split to specific implementations
                 RuntimeMapGroup g = new RuntimeMapGroup();
                 g.Deserialize(d);
                 this.Groups.Add(g);
@@ -1105,7 +1101,7 @@
         /// <returns></returns>
         internal RuntimeMapGroup AddGroup(string name)
         {
-            var group = new RuntimeMapGroup(this, name);
+            var group = _mapSvc.CreateMapGroup(this, name);
             this.Groups.Add(group);
             return group;
         }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -48,7 +48,7 @@
         /// </summary>
         /// <param name="map">The map.</param>
         /// <param name="name">The name.</param>
-        public RuntimeMapGroup(RuntimeMap map, string name) 
+        internal RuntimeMapGroup(RuntimeMap map, string name) 
             : this()
         {
             this.Parent = map;
@@ -62,7 +62,7 @@
         /// </summary>
         /// <param name="map">The map.</param>
         /// <param name="group">The group.</param>
-        public RuntimeMapGroup(RuntimeMap map, IMapLayerGroup group)
+        internal RuntimeMapGroup(RuntimeMap map, IMapLayerGroup group)
             : this(map, group.Name)
         {
             _disableChangeTracking = true;

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -1722,6 +1722,39 @@
         }
 
         /// <summary>
+        /// Creates the map group.
+        /// </summary>
+        /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        public virtual RuntimeMapGroup CreateMapGroup(RuntimeMap parent, string name)
+        {
+            return new RuntimeMapGroup(parent, name);
+        }
+
+        /// <summary>
+        /// Creates a new runtime map group
+        /// </summary>
+        /// <param name="parent">The map.</param>
+        /// <param name="group">The group.</param>
+        /// <returns></returns>
+        public virtual RuntimeMapGroup CreateMapGroup(RuntimeMap parent, IBaseMapGroup group)
+        {
+            return new RuntimeMapGroup(parent, group);
+        }
+
+        /// <summary>
+        /// Creates a new runtime map group
+        /// </summary>
+        /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
+        /// <param name="group">The group.</param>
+        /// <returns></returns>
+        public virtual RuntimeMapGroup CreateMapGroup(RuntimeMap parent, IMapLayerGroup group)
+        {
+            return new RuntimeMapGroup(parent, group);
+        }
+
+        /// <summary>
         /// Creates a new runtime map layer from the specified Layer Definition
         /// </summary>
         /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
@@ -1755,6 +1788,23 @@
         }
 
         /// <summary>
+        /// Creates a new runtime map layer from the specified <see cref="T:OSGeo.MapGuide.ObjectModels.MapDefinition.IBaseMapLayer"/> instance
+        /// </summary>
+        /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
+        /// <param name="source">The map definition layer</param>
+        /// <returns></returns>
+        public RuntimeMapLayer CreateMapLayer(RuntimeMap parent, IMapLayer source)
+        {
+            var rtLayer = CreateMapLayer(parent, (IBaseMapLayer)source);
+
+            //These may not match, so set them here
+            rtLayer.Group = source.Group;
+            rtLayer.Visible = source.Visible;
+            
+            return rtLayer;
+        }
+
+        /// <summary>
         /// Creates a new runtime map instance from an existing map definition. Meters per unit
         /// is calculated from the Coordinate System WKT of the map definition.
         /// </summary>

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Services/IMappingService.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -44,6 +44,30 @@
     public interface IMappingService : IService
     {
         /// <summary>
+        /// Creates the map group.
+        /// </summary>
+        /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
+        /// <param name="name">The name.</param>
+        /// <returns></returns>
+        RuntimeMapGroup CreateMapGroup(RuntimeMap parent, string name);
+
+        /// <summary>
+        /// Creates a new runtime map group
+        /// </summary>
+        /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
+        /// <param name="group">The group.</param>
+        /// <returns></returns>
+        RuntimeMapGroup CreateMapGroup(RuntimeMap parent, IBaseMapGroup group);
+
+        /// <summary>
+        /// Creates a new runtime map group
+        /// </summary>
+        /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
+        /// <param name="group">The group.</param>
+        /// <returns></returns>
+        RuntimeMapGroup CreateMapGroup(RuntimeMap parent, IMapLayerGroup group);
+
+        /// <summary>
         /// Creates a new runtime map layer from the specified Layer Definition
         /// </summary>
         /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
@@ -60,6 +84,14 @@
         RuntimeMapLayer CreateMapLayer(RuntimeMap parent, IBaseMapLayer source);
 
         /// <summary>
+        /// Creates a new runtime map layer from the specified <see cref="T:OSGeo.MapGuide.ObjectModels.MapDefinition.IMapLayer"/> instance
+        /// </summary>
+        /// <param name="parent">The parent runtime map. The runtime map must have been created or opened from this same service instance</param>
+        /// <param name="source">The map definition layer</param>
+        /// <returns></returns>
+        RuntimeMapLayer CreateMapLayer(RuntimeMap parent, IMapLayer source);
+
+        /// <summary>
         /// Creates a new runtime map instance from an existing map definition.
         /// </summary>
         /// <param name="mapDef"></param>

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -64,7 +64,7 @@
                 RuntimeMapGroup group = rtMap.Groups[groupName];
                 if (group == null)
                 {
-                    group = new RuntimeMapGroup(rtMap, groupName);
+                    group = mpSvc.CreateMapGroup(rtMap, groupName);
                     rtMap.Groups.Add(group);
                 }
 

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs	2011-12-08 12:39:23 UTC (rev 6311)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/ToggleParcelsLayer.aspx.cs	2011-12-08 14:14:46 UTC (rev 6312)
@@ -71,7 +71,7 @@
                 RuntimeMapGroup group = rtMap.Groups[groupName];
                 if (group == null)
                 {
-                    group = new RuntimeMapGroup(rtMap, groupName);
+                    group = mpSvc.CreateMapGroup(rtMap, groupName);
                     rtMap.Groups.Add(group);
                     throw new Exception("Layer group not found");
                 }



More information about the mapguide-commits mailing list