[mapguide-commits] r4842 - in trunk/Tools/Maestro:
Maestro/ResourceEditors MaestroAPI MaestroAPI/Generated
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed May 5 22:11:15 EDT 2010
Author: jng
Date: 2010-05-05 22:11:14 -0400 (Wed, 05 May 2010)
New Revision: 4842
Modified:
trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutEditor.cs
trunk/Tools/Maestro/MaestroAPI/Generated/WebLayout-1.0.0.cs
trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs
Log:
Adding support for WebLayout 1.1.0 schema broke the existing 1.0.0 support (as I feared). This submission restores the 1.0.0 support.
Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutEditor.cs 2010-05-05 22:56:51 UTC (rev 4841)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/LayoutEditor.cs 2010-05-06 02:11:14 UTC (rev 4842)
@@ -23,6 +23,7 @@
using System.Drawing;
using System.Data;
using System.Windows.Forms;
+using OSGeo.MapGuide.MaestroAPI;
namespace OSGeo.MapGuide.Maestro.ResourceEditors
{
@@ -156,15 +157,19 @@
: this()
{
m_editor = editor;
- m_layout = new OSGeo.MapGuide.MaestroAPI.WebLayout();
- m_tempResource = new MaestroAPI.ResourceIdentifier(Guid.NewGuid().ToString(), OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, m_editor.CurrentConnection.SessionID);
-
//HACK: There's gotta be a cleaner way
if (editor.CurrentConnection.SiteVersion >= new Version(2, 2))
{
+ m_layout = new OSGeo.MapGuide.MaestroAPI.WebLayout1_1();
chkPing.Enabled = true;
}
-
+ else
+ {
+ m_layout = new OSGeo.MapGuide.MaestroAPI.WebLayout();
+ }
+
+ m_tempResource = new MaestroAPI.ResourceIdentifier(Guid.NewGuid().ToString(), OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, m_editor.CurrentConnection.SessionID);
+
UpdateDisplay();
}
@@ -172,15 +177,32 @@
: this()
{
m_editor = editor;
- m_layout = editor.CurrentConnection.GetWebLayout(resourceID);
- m_tempResource = new MaestroAPI.ResourceIdentifier(Guid.NewGuid().ToString(), OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, m_editor.CurrentConnection.SessionID);
+ m_layout = null;
//HACK: There's gotta be a cleaner way
- if (editor.CurrentConnection.SiteVersion >= new Version(2, 2))
+ byte [] content = editor.CurrentConnection.GetResourceXmlData(resourceID);
+ using (var ms = new System.IO.MemoryStream(content))
{
- chkPing.Enabled = true;
+ try
+ {
+ m_layout = editor.CurrentConnection.DeserializeObject<WebLayout>(ms);
+ }
+ catch
+ {
+ m_layout = null;
+ }
+
+ if (m_layout == null) //Retry as 1.1.0
+ {
+ ms.Position = 0;
+ m_layout = editor.CurrentConnection.DeserializeObject<WebLayout1_1>(ms);
+ }
}
+ m_layout.ResourceId = resourceID;
+
+ m_tempResource = new MaestroAPI.ResourceIdentifier(Guid.NewGuid().ToString(), OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, m_editor.CurrentConnection.SessionID);
+
UpdateDisplay();
}
@@ -223,9 +245,10 @@
TitleText.Text = m_layout.Title;
//HACK: There's gotta be a better way
- if (m_editor.CurrentConnection.SiteVersion >= new Version(2, 2))
+ WebLayout1_1 wl = m_layout as WebLayout1_1;
+ if (wl != null)
{
- chkPing.Checked = m_layout.EnablePingServer;
+ chkPing.Checked = wl.EnablePingServer;
}
MapResource.Text = m_layout.Map.ResourceId;
@@ -1313,12 +1336,13 @@
private void chkPing_CheckedChanged(object sender, EventArgs e)
{
//HACK: Gotta be a better way
- if (m_editor.CurrentConnection.SiteVersion >= new Version(2, 2))
+ var wl = m_layout as WebLayout1_1;
+ if (wl != null)
{
if (m_isUpdating)
return;
- m_layout.EnablePingServer = chkPing.Checked;
+ wl.EnablePingServer = chkPing.Checked;
m_editor.HasChanged();
}
}
@@ -1546,12 +1570,14 @@
LoadedImageList.Images.Add(FixedImages.Images[1]);
string path = System.IO.Path.Combine(Application.StartupPath, "stdicons");
- if (System.IO.Directory.Exists(path))
- foreach(string s in System.IO.Directory.GetFiles(path, "*.gif"))
- {
- LoadedImageList.Images.Add(Image.FromFile(s));
- LoadedImages.Add("../stdicons/" + System.IO.Path.GetFileName(s), LoadedImageList.Images.Count - 1);
- }
+ if (System.IO.Directory.Exists(path))
+ {
+ foreach (string s in System.IO.Directory.GetFiles(path, "*.gif"))
+ {
+ LoadedImageList.Images.Add(System.Drawing.Image.FromFile(s));
+ LoadedImages.Add("../stdicons/" + System.IO.Path.GetFileName(s), LoadedImageList.Images.Count - 1);
+ }
+ }
}
using (System.IO.StringReader sr = new System.IO.StringReader(Properties.Resources.CommandTypesDataset))
Modified: trunk/Tools/Maestro/MaestroAPI/Generated/WebLayout-1.0.0.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/Generated/WebLayout-1.0.0.cs 2010-05-05 22:56:51 UTC (rev 4841)
+++ trunk/Tools/Maestro/MaestroAPI/Generated/WebLayout-1.0.0.cs 2010-05-06 02:11:14 UTC (rev 4842)
@@ -21,23 +21,153 @@
using System.Xml.Serialization;
namespace OSGeo.MapGuide.MaestroAPI
{
+ [System.Xml.Serialization.XmlRootAttribute("WebLayout", Namespace = "", IsNullable = false)]
+ public class WebLayout1_1 : WebLayout
+ {
+ public WebLayout1_1()
+ {
+ this.XsdSchema = "WebLayout-1.1.0.xsd";
+ }
+
+ public override string Title
+ {
+ get
+ {
+ return base.Title;
+ }
+ set
+ {
+ base.Title = value;
+ }
+ }
+
+ public override MapType Map
+ {
+ get
+ {
+ return base.Map;
+ }
+ set
+ {
+ base.Map = value;
+ }
+ }
+
+ //HACK: We can't bolt on extra properties as new schema versions are published. There's gotta be a cleaner way.
+ //Having ech version as its own class is not pretty either, but it looks like a cleaner way
+ [XmlElement]
+ public bool EnablePingServer
+ {
+ get;
+ set;
+ }
+
+ public override ToolBarType ToolBar
+ {
+ get
+ {
+ return base.ToolBar;
+ }
+ set
+ {
+ base.ToolBar = value;
+ }
+ }
+
+ public override InformationPaneType InformationPane
+ {
+ get
+ {
+ return base.InformationPane;
+ }
+ set
+ {
+ base.InformationPane = value;
+ }
+ }
+
+ public override ContextMenuType ContextMenu
+ {
+ get
+ {
+ return base.ContextMenu;
+ }
+ set
+ {
+ base.ContextMenu = value;
+ }
+ }
+
+ public override TaskPaneType TaskPane
+ {
+ get
+ {
+ return base.TaskPane;
+ }
+ set
+ {
+ base.TaskPane = value;
+ }
+ }
+
+ public override StatusBarType StatusBar
+ {
+ get
+ {
+ return base.StatusBar;
+ }
+ set
+ {
+ base.StatusBar = value;
+ }
+ }
+
+ public override ZoomControlType ZoomControl
+ {
+ get
+ {
+ return base.ZoomControl;
+ }
+ set
+ {
+ base.ZoomControl = value;
+ }
+ }
+
+ public override CommandTypeCollection CommandSet
+ {
+ get
+ {
+ return base.CommandSet;
+ }
+ set
+ {
+ base.CommandSet = value;
+ }
+ }
+ }
-
/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute("WebLayout", Namespace="", IsNullable=false)]
public class WebLayout {
- public static readonly string DefaultSchemaName = "WebLayout-1.0.0.xsd";
-
- private string SchemaName = DefaultSchemaName;
-
- [System.Xml.Serialization.XmlAttribute("noNamespaceSchemaLocation", Namespace="http://www.w3.org/2001/XMLSchema-instance")]
- public string XsdSchema
- {
- get { return SchemaName; }
- set { SchemaName = value; }
- }
+ //
+ // All top-level properties are virtual because newer versions (eg. 1.1.0) introduce new elements
+ // at certain positions in the xml document. XML documents are unfortunately sensitive to ordering/position
+ // and our classes must follow the same order.
+ public WebLayout()
+ {
+ this.XsdSchema = "WebLayout-1.0.0.xsd";
+ }
+
+ [System.Xml.Serialization.XmlAttribute("noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
+ public string XsdSchema
+ {
+ get;
+ set;
+ }
+
private string m_resourceId;
[System.Xml.Serialization.XmlIgnore()]
public string ResourceId
@@ -69,7 +199,7 @@
private CommandTypeCollection m_commandSet;
/// <remarks/>
- public string Title {
+ public virtual string Title {
get {
return this.m_title;
}
@@ -79,7 +209,7 @@
}
/// <remarks/>
- public MapType Map {
+ public virtual MapType Map {
get {
return this.m_map;
}
@@ -88,16 +218,8 @@
}
}
- //HACK: We can't bolt on extra properties as new schema versions are published. There's gotta be a cleaner way.
- [XmlElement]
- public bool EnablePingServer
- {
- get;
- set;
- }
-
/// <remarks/>
- public ToolBarType ToolBar {
+ public virtual ToolBarType ToolBar {
get {
return this.m_toolBar;
}
@@ -107,7 +229,7 @@
}
/// <remarks/>
- public InformationPaneType InformationPane {
+ public virtual InformationPaneType InformationPane {
get {
return this.m_informationPane;
}
@@ -117,7 +239,8 @@
}
/// <remarks/>
- public ContextMenuType ContextMenu {
+ public virtual ContextMenuType ContextMenu
+ {
get {
return this.m_contextMenu;
}
@@ -127,7 +250,8 @@
}
/// <remarks/>
- public TaskPaneType TaskPane {
+ public virtual TaskPaneType TaskPane
+ {
get {
return this.m_taskPane;
}
@@ -137,7 +261,8 @@
}
/// <remarks/>
- public StatusBarType StatusBar {
+ public virtual StatusBarType StatusBar
+ {
get {
return this.m_statusBar;
}
@@ -147,7 +272,8 @@
}
/// <remarks/>
- public ZoomControlType ZoomControl {
+ public virtual ZoomControlType ZoomControl
+ {
get {
return this.m_zoomControl;
}
@@ -158,7 +284,8 @@
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Command", IsNullable=false)]
- public CommandTypeCollection CommandSet {
+ public virtual CommandTypeCollection CommandSet
+ {
get {
return this.m_commandSet;
}
Modified: trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs 2010-05-05 22:56:51 UTC (rev 4841)
+++ trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs 2010-05-06 02:11:14 UTC (rev 4842)
@@ -1580,11 +1580,6 @@
WebLayout wl = resource as WebLayout;
if (wl != null)
{
- if (this.SiteVersion >= new Version(2, 2))
- {
- wl.XsdSchema = "WebLayout-1.1.0.xsd";
- }
-
if (wl.CommandSet != null)
foreach(CommandType cmd in wl.CommandSet)
{
More information about the mapguide-commits
mailing list