[mapguide-commits] r7034 - in trunk/Tools/Maestro: Maestro.Editors/Common OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/ObjectModels
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Sep 19 00:19:28 PDT 2012
Author: jng
Date: 2012-09-19 00:19:28 -0700 (Wed, 19 Sep 2012)
New Revision: 7034
Modified:
trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.Designer.cs
trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.cs
trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.resx
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs
Log:
#2123: Trap and attach original XML to MgDbXmlExceptions thrown on SaveResource and SaveResourceAs methods
Also fix a potential content model violation when creating a new fusion widget from a widget information instance (thanks to the work on #2123 for finding this).
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.Designer.cs 2012-09-19 00:59:47 UTC (rev 7033)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.Designer.cs 2012-09-19 07:19:28 UTC (rev 7034)
@@ -47,8 +47,8 @@
//
// groupBox1
//
+ resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.txtErrorDetails);
- resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
@@ -60,8 +60,8 @@
//
// groupBox2
//
+ resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Controls.Add(this.txtXmlContent);
- resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false;
//
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.cs 2012-09-19 00:59:47 UTC (rev 7033)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.cs 2012-09-19 07:19:28 UTC (rev 7034)
@@ -36,8 +36,6 @@
/// </summary>
public partial class XmlContentErrorDialog : Form
{
- const string EXCEPTION_KEY = "XmlError"; //NOXLATE
-
private XmlContentErrorDialog()
{
InitializeComponent();
@@ -54,7 +52,7 @@
{
if (IsDbXmlError(ex))
{
- ex.Data[EXCEPTION_KEY] = origXml;
+ ex.Data[Utility.XML_EXCEPTION_KEY] = origXml;
if (bDisplay)
Show(ex);
else
@@ -73,7 +71,7 @@
/// <returns></returns>
public static bool IsDbXmlError(Exception ex)
{
- return ex.Message.Contains("MgDbXmlException") || ex.Message.Contains("MgXmlParserException"); //NOXLATE
+ return Utility.IsDbXmlError(ex);
}
/// <summary>
@@ -83,7 +81,7 @@
/// <returns></returns>
public static bool HasOriginalXml(Exception ex)
{
- return ex.Data[EXCEPTION_KEY] != null;
+ return Utility.HasOriginalXml(ex);
}
private Exception _ex;
@@ -96,8 +94,8 @@
public static void Show(Exception ex)
{
Check.NotNull(ex, "ex"); //NOXLATE
- Check.NotNull(ex.Data[EXCEPTION_KEY], "ex.Data[EXCEPTION_KEY]"); //NOXLATE
- string origXmlContent = ex.Data[EXCEPTION_KEY].ToString();
+ Check.NotNull(ex.Data[Utility.XML_EXCEPTION_KEY], "ex.Data[Utility.XML_EXCEPTION_KEY]"); //NOXLATE
+ string origXmlContent = ex.Data[Utility.XML_EXCEPTION_KEY].ToString();
var diag = new XmlContentErrorDialog();
diag._ex = ex;
diag.txtErrorDetails.Text = ex.ToString();
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.resx 2012-09-19 00:59:47 UTC (rev 7033)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/XmlContentErrorDialog.resx 2012-09-19 07:19:28 UTC (rev 7034)
@@ -146,6 +146,28 @@
<data name=">>label1.ZOrder" xml:space="preserve">
<value>4</value>
</data>
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="groupBox1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
+ <value>Top, Left, Right</value>
+ </data>
+ <data name="txtErrorDetails.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
+ <value>Fill</value>
+ </data>
+ <data name="txtErrorDetails.Location" type="System.Drawing.Point, System.Drawing">
+ <value>3, 16</value>
+ </data>
+ <data name="txtErrorDetails.Multiline" type="System.Boolean, mscorlib">
+ <value>True</value>
+ </data>
+ <data name="txtErrorDetails.ScrollBars" type="System.Windows.Forms.ScrollBars, System.Windows.Forms">
+ <value>Both</value>
+ </data>
+ <data name="txtErrorDetails.Size" type="System.Drawing.Size, System.Drawing">
+ <value>530, 93</value>
+ </data>
+ <data name="txtErrorDetails.TabIndex" type="System.Int32, mscorlib">
+ <value>0</value>
+ </data>
<data name=">>txtErrorDetails.Name" xml:space="preserve">
<value>txtErrorDetails</value>
</data>
@@ -182,37 +204,21 @@
<data name=">>groupBox1.ZOrder" xml:space="preserve">
<value>3</value>
</data>
- <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
- <data name="txtErrorDetails.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
+ <data name="groupBox2.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
+ <value>Top, Bottom, Left, Right</value>
+ </data>
+ <data name="txtXmlContent.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
- <data name="txtErrorDetails.Location" type="System.Drawing.Point, System.Drawing">
+ <data name="txtXmlContent.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 16</value>
</data>
- <data name="txtErrorDetails.Multiline" type="System.Boolean, mscorlib">
- <value>True</value>
+ <data name="txtXmlContent.Size" type="System.Drawing.Size, System.Drawing">
+ <value>530, 239</value>
</data>
- <data name="txtErrorDetails.ScrollBars" type="System.Windows.Forms.ScrollBars, System.Windows.Forms">
- <value>Both</value>
- </data>
- <data name="txtErrorDetails.Size" type="System.Drawing.Size, System.Drawing">
- <value>530, 93</value>
- </data>
- <data name="txtErrorDetails.TabIndex" type="System.Int32, mscorlib">
+ <data name="txtXmlContent.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
- <data name=">>txtErrorDetails.Name" xml:space="preserve">
- <value>txtErrorDetails</value>
- </data>
- <data name=">>txtErrorDetails.Type" xml:space="preserve">
- <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </data>
- <data name=">>txtErrorDetails.Parent" xml:space="preserve">
- <value>groupBox1</value>
- </data>
- <data name=">>txtErrorDetails.ZOrder" xml:space="preserve">
- <value>0</value>
- </data>
<data name=">>txtXmlContent.Name" xml:space="preserve">
<value>txtXmlContent</value>
</data>
@@ -249,30 +255,9 @@
<data name=">>groupBox2.ZOrder" xml:space="preserve">
<value>2</value>
</data>
- <data name="txtXmlContent.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
- <value>Fill</value>
+ <data name="btnSave.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
+ <value>Bottom, Left</value>
</data>
- <data name="txtXmlContent.Location" type="System.Drawing.Point, System.Drawing">
- <value>3, 16</value>
- </data>
- <data name="txtXmlContent.Size" type="System.Drawing.Size, System.Drawing">
- <value>530, 239</value>
- </data>
- <data name="txtXmlContent.TabIndex" type="System.Int32, mscorlib">
- <value>0</value>
- </data>
- <data name=">>txtXmlContent.Name" xml:space="preserve">
- <value>txtXmlContent</value>
- </data>
- <data name=">>txtXmlContent.Type" xml:space="preserve">
- <value>ICSharpCode.TextEditor.TextEditorControl, ICSharpCode.TextEditor, Version=4.2.0.8783, Culture=neutral, PublicKeyToken=4d61825e8dd49f1a</value>
- </data>
- <data name=">>txtXmlContent.Parent" xml:space="preserve">
- <value>groupBox2</value>
- </data>
- <data name=">>txtXmlContent.ZOrder" xml:space="preserve">
- <value>0</value>
- </data>
<data name="btnSave.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 422</value>
</data>
@@ -297,6 +282,9 @@
<data name=">>btnSave.ZOrder" xml:space="preserve">
<value>1</value>
</data>
+ <data name="btnClose.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
+ <value>Bottom, Right</value>
+ </data>
<data name="btnClose.Location" type="System.Drawing.Point, System.Drawing">
<value>473, 422</value>
</data>
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs 2012-09-19 00:59:47 UTC (rev 7033)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs 2012-09-19 07:19:28 UTC (rev 7034)
@@ -214,13 +214,13 @@
{
Disabled = "false", //NOXLATE
Extension = new CustomContentType() { Any = new XmlElement[0] },
- ImageClass = widgetInfo.ImageClass,
- ImageUrl = widgetInfo.ImageUrl,
- Label = widgetInfo.Label,
+ ImageClass = widgetInfo.ImageClass ?? string.Empty, //Required to satisfy content model
+ ImageUrl = widgetInfo.ImageUrl ?? string.Empty, //Required to satisfy content model
+ Label = widgetInfo.Label ?? string.Empty, //Required to satisfy content model
Location = widgetInfo.Location ?? string.Empty, //Required to satisfy content model
Name = name,
StatusText = widgetInfo.StatusText ?? string.Empty, //Required to satisfy content model
- Tooltip = widgetInfo.Tooltip,
+ Tooltip = widgetInfo.Tooltip ?? string.Empty, //Required to satisfy content model
Type = widgetInfo.Type
};
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs 2012-09-19 00:59:47 UTC (rev 7033)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs 2012-09-19 07:19:28 UTC (rev 7034)
@@ -1257,7 +1257,16 @@
/// <param name="resource">The resource.</param>
public void SaveResource(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource)
{
- SaveResourceAs(resource, resource.ResourceID);
+ try
+ {
+ SaveResourceAs(resource, resource.ResourceID);
+ }
+ catch (Exception ex)
+ {
+ if (Utility.IsDbXmlError(ex))
+ ex.Data[Utility.XML_EXCEPTION_KEY] = resource.Serialize();
+ throw ex;
+ }
}
/// <summary>
@@ -1267,8 +1276,17 @@
/// <param name="resourceid">The resourceid.</param>
public void SaveResourceAs(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource, string resourceid)
{
- var stream = ResourceTypeRegistry.Serialize(resource);
- SetResourceXmlData(resourceid, stream);
+ try
+ {
+ var stream = ResourceTypeRegistry.Serialize(resource);
+ SetResourceXmlData(resourceid, stream);
+ }
+ catch (Exception ex)
+ {
+ if (Utility.IsDbXmlError(ex))
+ ex.Data[Utility.XML_EXCEPTION_KEY] = resource.Serialize();
+ throw ex;
+ }
}
/// <summary>
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs 2012-09-19 00:59:47 UTC (rev 7033)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs 2012-09-19 07:19:28 UTC (rev 7034)
@@ -35,8 +35,30 @@
/// </summary>
public class Utility
{
+ public const string XML_EXCEPTION_KEY = "XmlError"; //NOXLATE
+
+ /// <summary>
+ /// Gets whether the thrown exception is related to DBXML
+ /// </summary>
+ /// <param name="ex"></param>
+ /// <returns></returns>
+ public static bool IsDbXmlError(Exception ex)
+ {
+ return ex.Message.Contains("MgDbXmlException") || ex.Message.Contains("MgXmlParserException"); //NOXLATE
+ }
+
+ /// <summary>
+ /// Gets whether the given exception has original xml content attached
+ /// </summary>
+ /// <param name="ex"></param>
+ /// <returns></returns>
+ public static bool HasOriginalXml(Exception ex)
+ {
+ return ex.Data[XML_EXCEPTION_KEY] != null;
+ }
+
//Americans NEVER obey nationalization when outputting decimal values, so the rest of the world always have to work around their bugs :(
- private static System.Globalization.CultureInfo m_enCI = new System.Globalization.CultureInfo("en-US");
+ private static System.Globalization.CultureInfo m_enCI = new System.Globalization.CultureInfo("en-US"); //NOXLATE
/// <summary>
/// Converts the specified name value collection into a connection string
More information about the mapguide-commits
mailing list