[mapguide-commits] r5082 - in sandbox/maestro-3.0:
Maestro.Base/Commands Maestro.Base/Properties
Maestro.Base/Templates MaestroAPITests
OSGeo.MapGuide.MaestroAPI/ObjectModels
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Aug 11 01:18:47 EDT 2010
Author: jng
Date: 2010-08-11 05:18:46 +0000 (Wed, 11 Aug 2010)
New Revision: 5082
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/ApplicationDefinitionItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/DrawingSourceItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/MapDefinitionItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/PrintLayoutItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/SdfLoadProcedureItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/ShpLoadProcedureItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/SymbolDefinitionItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/UserItemTemplate.cs
sandbox/maestro-3.0/Maestro.Base/Templates/WebLayoutItemTemplate.cs
sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
Log:
This submission includes the following changes:
- Update the new item template API to include parent folder information (should resources require it)
- Fix the invalid Load Procedure objects being created by ObjectFactory
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -23,6 +23,7 @@
using ICSharpCode.Core;
using Maestro.Base.UI;
using Maestro.Base.Services;
+using OSGeo.MapGuide.MaestroAPI.Resource;
namespace Maestro.Base.Commands
{
@@ -52,8 +53,9 @@
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var tpl = dlg.SelectedTemplate;
+ var parent = ResourceIdentifier.GetParentFolder(dlg.ResourceID);
- var res = tpl.CreateItem(conn);
+ var res = tpl.CreateItem(conn, parent);
if (res != null)
{
res.ResourceID = "Session:" + conn.SessionID + "//" + Guid.NewGuid().ToString() + "." + res.ResourceType.ToString();
Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -422,6 +422,24 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Autodesk SDF (*.sdf)|*.sdf.
+ /// </summary>
+ internal static string Filter_Sdf_Files {
+ get {
+ return ResourceManager.GetString("Filter_Sdf_Files", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to ESRI Shapefile (*.shp)|*.shp.
+ /// </summary>
+ internal static string Filter_Shp_Files {
+ get {
+ return ResourceManager.GetString("Filter_Shp_Files", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap folder_horizontal {
get {
object obj = ResourceManager.GetObject("folder_horizontal", resourceCulture);
Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx 2010-08-11 05:18:46 UTC (rev 5082)
@@ -622,4 +622,10 @@
<data name="SelectFdoProvider" xml:space="preserve">
<value>Select FDO Provider</value>
</data>
+ <data name="Filter_Sdf_Files" xml:space="preserve">
+ <value>Autodesk SDF (*.sdf)|*.sdf</value>
+ </data>
+ <data name="Filter_Shp_Files" xml:space="preserve">
+ <value>ESRI Shapefile (*.shp)|*.shp</value>
+ </data>
</root>
\ No newline at end of file
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/ApplicationDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/ApplicationDefinitionItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/ApplicationDefinitionItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -39,7 +39,7 @@
ResourceType = ResourceTypes.ApplicationDefinition.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreateFlexibleLayout(conn);
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/DrawingSourceItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/DrawingSourceItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/DrawingSourceItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -39,7 +39,7 @@
ResourceType = ResourceTypes.DrawingSource.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreateDrawingSource(conn);
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -40,7 +40,7 @@
ResourceType = ResourceTypes.FeatureSource.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
var provider = GenericItemSelectionDialog.SelectItem(
Properties.Resources.SelectFdoProvider,
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -43,8 +43,9 @@
/// <summary>
/// Creates a new item from this template
/// </summary>
- /// <param name="conn"></param>
+ /// <param name="conn">The server connection</param>
+ /// <param name="parentFolderId">The resource id of the folder this resource should be created in. Note that this is a hint for templates with regards to default values (for example, the initial folder for a load procedure)</param>
/// <returns>a new resource, null if the user cancelled during this process</returns>
- public abstract IResource CreateItem(IServerConnection conn);
+ public abstract IResource CreateItem(IServerConnection conn, string parentFolderId);
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -39,7 +39,7 @@
ResourceType = ResourceTypes.LayerDefinition.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreateLayerDefinition(conn);
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/MapDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/MapDefinitionItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/MapDefinitionItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -39,7 +39,7 @@
ResourceType = ResourceTypes.MapDefinition.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreateMapDefinition(conn);
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/PrintLayoutItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/PrintLayoutItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/PrintLayoutItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -39,7 +39,7 @@
ResourceType = ResourceTypes.PrintLayout.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreatePrintLayout(conn);
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/SdfLoadProcedureItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/SdfLoadProcedureItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/SdfLoadProcedureItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -25,6 +25,7 @@
using Res = Maestro.Base.Properties.Resources;
using OSGeo.MapGuide.MaestroAPI.Resource;
using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using Maestro.Shared.UI;
namespace Maestro.Base.Templates
{
@@ -39,9 +40,20 @@
ResourceType = ResourceTypes.LoadProcedure.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
- return ObjectFactory.CreateLoadProcedure(conn);
+ using (var dlg = DialogFactory.OpenFile())
+ {
+ dlg.Multiselect = true;
+ dlg.Filter = Properties.Resources.Filter_Sdf_Files;
+ if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ var lp = ObjectFactory.CreateSdfLoadProcedure(conn, dlg.FileNames);
+ lp.Item.RootPath = parentFolderId;
+ return lp;
+ }
+ return null;
+ }
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/ShpLoadProcedureItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/ShpLoadProcedureItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/ShpLoadProcedureItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -25,6 +25,7 @@
using Res = Maestro.Base.Properties.Resources;
using OSGeo.MapGuide.MaestroAPI.Resource;
using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using Maestro.Shared.UI;
namespace Maestro.Base.Templates
{
@@ -39,9 +40,20 @@
ResourceType = ResourceTypes.LoadProcedure.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
- return ObjectFactory.CreateLoadProcedure(conn);
+ using (var dlg = DialogFactory.OpenFile())
+ {
+ dlg.Multiselect = true;
+ dlg.Filter = Properties.Resources.Filter_Shp_Files;
+ if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ var lp = ObjectFactory.CreateShpLoadProcedure(conn, dlg.FileNames);
+ lp.Item.RootPath = parentFolderId;
+ return lp;
+ }
+ }
+ return null;
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/SymbolDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/SymbolDefinitionItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/SymbolDefinitionItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -39,7 +39,7 @@
ResourceType = ResourceTypes.SymbolDefinition.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreateSimpleSymbol(conn);
}
@@ -56,7 +56,7 @@
ResourceType = ResourceTypes.SymbolDefinition.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreateCompoundSymbol(conn);
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/UserItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/UserItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/UserItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -59,7 +59,7 @@
this.ResourceType = _res.ResourceType.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
IResource res = (IResource)_res.Clone();
res.CurrentConnection = conn;
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/WebLayoutItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/WebLayoutItemTemplate.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/WebLayoutItemTemplate.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -39,7 +39,7 @@
ResourceType = ResourceTypes.WebLayout.ToString();
}
- public override IResource CreateItem(IServerConnection conn)
+ public override IResource CreateItem(IServerConnection conn, string parentFolderId)
{
return ObjectFactory.CreateWebLayout(conn, string.Empty);
}
Modified: sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs
===================================================================
--- sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -356,7 +356,7 @@
}
#endregion
- res = ObjectFactory.CreateLoadProcedure(conn);
+ res = ObjectFactory.CreateSdfLoadProcedure(conn, null);
#region Load Procedure
try
{
@@ -389,6 +389,39 @@
}
#endregion
+ res = ObjectFactory.CreateShpLoadProcedure(conn, null);
+ #region Load Procedure
+ try
+ {
+ res.ResourceID = "dklgjlahekjedjfd";
+ Assert.Fail("Should've thrown exception on invalid resource id");
+ }
+ catch (InvalidOperationException) { }
+
+ try
+ {
+ res.ResourceID = "Library://UnitTests/";
+ Assert.Fail("Should've thrown exception on invalid resource id");
+ }
+ catch (InvalidOperationException) { }
+
+ try
+ {
+ res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+ Assert.Fail("Should've thrown exception on invalid resource id");
+ }
+ catch (InvalidOperationException) { }
+
+ try
+ {
+ res.ResourceID = "Library://UnitTests/Test.LoadProcedure";
+ }
+ catch (Exception)
+ {
+ Assert.Fail("Resource ID should've checked out");
+ }
+ #endregion
+
res = ObjectFactory.CreatePrintLayout(conn);
#region Print Layout
try
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs 2010-08-11 04:35:54 UTC (rev 5081)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs 2010-08-11 05:18:46 UTC (rev 5082)
@@ -194,6 +194,9 @@
if (owner == null)
throw new ArgumentNullException("owner");
+ //TODO: Localize these strings. Once localized we can have *translatable*
+ //web layouts!
+
var wl = new WebLayoutType()
{
CurrentConnection = owner,
@@ -561,14 +564,75 @@
return new PrintLayout() { CurrentConnection = owner };
}
- public static LoadProcedure CreateLoadProcedure(IServerConnection owner)
+ const string ARBITRARY_XYM = "LOCAL_CS[\"Non-Earth (Meter)\", LOCAL_DATUM[\"Local Datum\", 0], UNIT[\"Meter\", 1], AXIS[\"X\", EAST], AXIS[\"Y\", NORTH]]";
+
+ public static LoadProcedure CreateSdfLoadProcedure(IServerConnection owner, IEnumerable<string> sdfFiles)
{
if (owner == null)
throw new ArgumentNullException("owner");
- return new LoadProcedure() { CurrentConnection = owner };
+ IList<string> files = new List<string>();
+ if (sdfFiles != null)
+ {
+ foreach (var f in sdfFiles)
+ {
+ files.Add(f);
+ }
+ }
+ return new LoadProcedure()
+ {
+ CurrentConnection = owner,
+ Item = new SdfLoadProcedureType()
+ {
+ RootPath = "Library://",
+ CoordinateSystem = ARBITRARY_XYM,
+ SpatialDataSourcesPath = "",
+ SpatialDataSourcesFolder = "Data",
+ Generalization = 100.0,
+ LayersPath = "",
+ LayersFolder = "Layers",
+ GenerateMaps = false,
+ GenerateLayers = true,
+ GenerateSpatialDataSources = true,
+ SourceFile = new System.ComponentModel.BindingList<string>(files)
+ }
+ };
}
+ public static LoadProcedure CreateShpLoadProcedure(IServerConnection owner, IEnumerable<string> shpFiles)
+ {
+ if (owner == null)
+ throw new ArgumentNullException("owner");
+
+ IList<string> files = new List<string>();
+ if (shpFiles != null)
+ {
+ foreach (var f in shpFiles)
+ {
+ files.Add(f);
+ }
+ }
+ return new LoadProcedure()
+ {
+ CurrentConnection = owner,
+ Item = new ShpLoadProcedureType()
+ {
+ RootPath = "Library://",
+ CoordinateSystem = ARBITRARY_XYM,
+ SpatialDataSourcesPath = "",
+ SpatialDataSourcesFolder = "Data",
+ Generalization = 100.0,
+ LayersPath = "",
+ LayersFolder = "Layers",
+ GenerateMaps = false,
+ GenerateLayers = true,
+ GenerateSpatialDataSources = true,
+ ConvertToSdf = false,
+ SourceFile = new System.ComponentModel.BindingList<string>(files)
+ }
+ };
+ }
+
/// <summary>
/// Creates an empty resource document header metadata object
/// </summary>
More information about the mapguide-commits
mailing list