[mapguide-commits] r6141 - in trunk/Tools/Maestro/Maestro.Editors: LayerDefinition LayerDefinition/Vector Properties

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Sep 21 10:27:26 EDT 2011


Author: jng
Date: 2011-09-21 07:27:26 -0700 (Wed, 21 Sep 2011)
New Revision: 6141

Modified:
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
Log:
#1811: Fix an exception rendering a null Brush. Also implement a graceful way to recover when opening a broken Layer Definition

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs	2011-09-21 09:56:04 UTC (rev 6140)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs	2011-09-21 14:27:26 UTC (rev 6141)
@@ -9,6 +9,8 @@
 using System.Diagnostics;
 using OSGeo.MapGuide.ObjectModels.LayerDefinition;
 using Maestro.Editors.Common;
+using Maestro.Editors.Generic;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace Maestro.Editors.LayerDefinition
 {
@@ -77,30 +79,44 @@
             if (_vl == null || string.IsNullOrEmpty(_vl.FeatureName))
                 return;
 
-            //TODO: Should just fetch the class definition
-            var desc = _edsvc.FeatureService.DescribeFeatureSource(_vl.ResourceId);
-            var cls = desc.GetClass(_vl.FeatureName);
-            if (cls != null)
+            if (_edsvc.ResourceService.ResourceExists(_vl.ResourceId))
             {
-                grdProperties.Rows.Clear();
-                foreach (var col in cls.Properties)
+                //TODO: Should just fetch the class definition
+                var desc = _edsvc.FeatureService.DescribeFeatureSource(_vl.ResourceId);
+                var cls = desc.GetClass(_vl.FeatureName);
+                if (cls != null)
                 {
-                    if (col.Type == OSGeo.MapGuide.MaestroAPI.Schema.PropertyDefinitionType.Data)
+                    grdProperties.Rows.Clear();
+                    foreach (var col in cls.Properties)
                     {
-                        bool visible = false;
-                        string disp = col.Name;
-                        foreach (var item in _vl.PropertyMapping)
+                        if (col.Type == OSGeo.MapGuide.MaestroAPI.Schema.PropertyDefinitionType.Data)
                         {
-                            if (item.Name == col.Name)
+                            bool visible = false;
+                            string disp = col.Name;
+                            foreach (var item in _vl.PropertyMapping)
                             {
-                                visible = true;
-                                disp = item.Value;
+                                if (item.Name == col.Name)
+                                {
+                                    visible = true;
+                                    disp = item.Value;
+                                }
                             }
+                            grdProperties.Rows.Add(visible, col.Name, disp);
                         }
-                        grdProperties.Rows.Add(visible, col.Name, disp);
                     }
                 }
             }
+            else
+            {
+                MessageBox.Show(string.Format(Properties.Resources.PromptRepairBrokenFeatureSource, _vl.ResourceId));
+                using (var picker = new ResourcePicker(_edsvc.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
+                {
+                    if (picker.ShowDialog() == DialogResult.OK)
+                    {
+                        _vl.ResourceId = picker.ResourceID;
+                    }
+                }
+            }
         }
 
         private void btnCheckAll_Click(object sender, EventArgs e)

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs	2011-09-21 09:56:04 UTC (rev 6140)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs	2011-09-21 14:27:26 UTC (rev 6141)
@@ -58,7 +58,7 @@
 
 			if (item.Fill != null)
 			{
-				Brush b;
+                Brush b = null;
 			
 				Image texture = null;
                 foreach (ImageStylePicker.NamedImage img in FillImages)
@@ -112,7 +112,7 @@
                 catch { }
                 if (texture == null && bgColor.HasValue)
                     b = new SolidBrush(bgColor.Value);
-				else
+				else if (texture != null)
 					b = new TextureBrush(texture);
 
                 if (b != null)

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-09-21 09:56:04 UTC (rev 6140)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-09-21 14:27:26 UTC (rev 6141)
@@ -2315,6 +2315,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to The resource id {0} could not be found. You will now be prompted to select the correct feature source.
+        /// </summary>
+        internal static string PromptRepairBrokenFeatureSource {
+            get {
+                return ResourceManager.GetString("PromptRepairBrokenFeatureSource", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Use Office 2010 Drivers? (these are 64-bit compatible).
         /// </summary>
         internal static string PromptUseOffice2010Drivers {

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-09-21 09:56:04 UTC (rev 6140)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-09-21 14:27:26 UTC (rev 6141)
@@ -1265,4 +1265,7 @@
   <data name="color" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\color.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="PromptRepairBrokenFeatureSource" xml:space="preserve">
+    <value>The resource id {0} could not be found. You will now be prompted to select the correct feature source</value>
+  </data>
 </root>
\ No newline at end of file



More information about the mapguide-commits mailing list