[mapguide-commits] r5202 - in sandbox/maestro-3.0: Generated
Maestro.Base Maestro.Base/Commands
Maestro.Base/Commands/SiteExplorer Maestro.Base/Editor
Maestro.Base/Services Maestro.Base/UI Maestro.Editors
Maestro.Editors/LayerDefinition/Vector/Thematics
Maestro.Editors/LoadProcedure Maestro.Editors/Properties
MaestroAPITests OSGeo.MapGuide.MaestroAPI
OSGeo.MapGuide.MaestroAPI/Commands OSGeo.MapGuide.MaestroAPI/Feature
OSGeo.MapGuide.MaestroAPI/ObjectModels
OSGeo.MapGuide.MaestroAPI.Http
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Sep 28 10:33:11 EDT 2010
Author: jng
Date: 2010-09-28 14:33:11 +0000 (Tue, 28 Sep 2010)
New Revision: 5202
Added:
sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.Designer.cs
sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.cs
sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.resx
Modified:
sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs
sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/NewFolderCommand.cs
sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenResourceCommand.cs
sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenWithXmlEditorCommand.cs
sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/RenameCommand.cs
sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs
sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs
sandbox/maestro-3.0/Maestro.Base/UI/ISiteExplorer.cs
sandbox/maestro-3.0/Maestro.Base/UI/RepositoryTreeModel.cs
sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs
sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs
sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.Designer.cs
sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.cs
sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/LoadProcedureEditorCtrl.cs
sandbox/maestro-3.0/Maestro.Editors/Maestro.Editors.csproj
sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs
sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx
sandbox/maestro-3.0/MaestroAPITests/SerializationTests.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureSetReader.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/CommandType.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
Log:
This submission includes the following changes:
- Add missing version attribute to LayerDefinition resource class
- Implement Load Procedure support. This should be functionally equivalent to what is currently in the 2.x stream
- Implement the following Site Explorer changes:
- Allow refreshing of the model at certain nodes
- Add extra Site Explorer APIs to refresh at a certain node and to expand at a certain node
- Adding a new folder will select the folder node and expand its parent
- Deleting a resource node will refresh its parent node
- Update the model on item rename
- Forward-port geometry type detection code and other fixes from 2.x stream
- Implement Add/Delete file buttons of Load Procedure Editor
Modified: sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs
===================================================================
--- sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -25,27 +25,29 @@
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class LayerDefinition : LayerDefinitionType, System.ComponentModel.INotifyPropertyChanged {
- [EditorBrowsable(EditorBrowsableState.Never)]
- private string versionField;
+ //[EditorBrowsable(EditorBrowsableState.Never)]
+ //private string versionField;
private static System.Xml.Serialization.XmlSerializer serializer;
[System.Xml.Serialization.XmlAttributeAttribute()]
public string version {
get {
- return this.versionField;
+ //return this.versionField;
+ return "1.0.0";
}
set {
- if ((this.versionField != null)) {
- if ((versionField.Equals(value) != true)) {
- this.versionField = value;
- this.OnPropertyChanged("version");
- }
- }
- else {
- this.versionField = value;
- this.OnPropertyChanged("version");
- }
+
+ //if ((this.versionField != null)) {
+ // if ((versionField.Equals(value) != true)) {
+ // this.versionField = value;
+ // this.OnPropertyChanged("version");
+ // }
+ //}
+ //else {
+ // this.versionField = value;
+ // this.OnPropertyChanged("version");
+ //}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -61,7 +61,7 @@
res.ResourceID = "Session:" + conn.SessionID + "//" + Guid.NewGuid().ToString() + "." + res.ResourceType.ToString();
conn.ResourceService.SaveResource(res);
- orm.Open(res.ResourceID, conn, false);
+ orm.Open(res.ResourceID, conn, false, exp);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/NewFolderCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/NewFolderCommand.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/NewFolderCommand.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -49,6 +49,10 @@
conn.ResourceService.CreateFolder(item.ResourceId + name);
var path = item.Model.GetPath(item);
item.Model.RaiseStructureChanged(new Aga.Controls.Tree.TreeModelEventArgs(path, new object[0]));
+
+ //Expand so user can see this new folder
+ exp.ExpandNode(item.ResourceId);
+ exp.SelectNode(item.ResourceId + name + "/");
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenResourceCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenResourceCommand.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenResourceCommand.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -33,6 +33,7 @@
public override void Run()
{
var wb = Workbench.Instance;
+ var exp = wb.ActiveSiteExplorer;
var items = wb.ActiveSiteExplorer.SelectedItems;
var openMgr = ServiceRegistry.GetService<OpenResourceManager>();
var connMgr = ServiceRegistry.GetService<ServerConnectionManager>();
@@ -49,7 +50,7 @@
}
else
{
- openMgr.Open(item.ResourceId, _conn, false);
+ openMgr.Open(item.ResourceId, _conn, false, exp);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenWithXmlEditorCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenWithXmlEditorCommand.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/OpenWithXmlEditorCommand.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -34,6 +34,7 @@
public override void Run()
{
var wb = Workbench.Instance;
+ var exp = wb.ActiveSiteExplorer;
var items = wb.ActiveSiteExplorer.SelectedItems;
var openMgr = ServiceRegistry.GetService<OpenResourceManager>();
var connMgr = ServiceRegistry.GetService<ServerConnectionManager>();
@@ -59,7 +60,7 @@
}
else
{
- openMgr.Open(item.ResourceId, _conn, true);
+ openMgr.Open(item.ResourceId, _conn, true, exp);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/RenameCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/RenameCommand.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/SiteExplorer/RenameCommand.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -78,10 +78,15 @@
else
conn.ResourceService.MoveResource(oldid, newid, dlg.Overwrite);
}
-
+
current.Name = dlg.NewName;
if (dlg.Overwrite)
parent.RemoveChild(parent[dlg.NewName]);
+
+ //Need to refresh the model because it still is called by the old name
+ var rid = new OSGeo.MapGuide.MaestroAPI.Resource.ResourceIdentifier(oldid);
+ var folder = rid.ParentFolder;
+ exp.RefreshModel(folder);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/ResourceEditorService.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -29,6 +29,7 @@
using System.ComponentModel;
using System.IO;
using Maestro.Editors.Common;
+using Maestro.Base.UI;
namespace Maestro.Base.Editor
{
@@ -36,13 +37,15 @@
{
private IUrlLauncherService _launcher;
private IServerConnection _conn;
+ private ISiteExplorer _siteExp;
private IResource _editCopy;
- public ResourceEditorService(string resourceID, IServerConnection conn, IUrlLauncherService launcher)
+ public ResourceEditorService(string resourceID, IServerConnection conn, IUrlLauncherService launcher, ISiteExplorer siteExp)
{
this.IsNew = ResourceIdentifier.IsSessionBased(resourceID);
this.ResourceID = resourceID;
+ _siteExp = siteExp;
_conn = conn;
_launcher = launcher;
}
@@ -275,5 +278,25 @@
{
get { return _conn.SessionID; }
}
+
+ public bool SupportsCommand(OSGeo.MapGuide.MaestroAPI.Commands.CommandType cmdType)
+ {
+ return Array.IndexOf(_conn.Capabilities.SupportedCommands, (int)cmdType) >= 0;
+ }
+
+ public OSGeo.MapGuide.MaestroAPI.Commands.ICommand CreateCommand(OSGeo.MapGuide.MaestroAPI.Commands.CommandType cmdType)
+ {
+ return _conn.CreateCommand((int)cmdType);
+ }
+
+ public void RequestRefresh()
+ {
+ _siteExp.RefreshModel();
+ }
+
+ public void RequestRefresh(string folderId)
+ {
+ _siteExp.RefreshModel(folderId);
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin 2010-09-28 14:33:11 UTC (rev 5202)
@@ -317,7 +317,7 @@
class="Maestro.Base.Commands.NotImplementedCommand" />
<MenuItem id="Delete"
label="${res:SiteExplorer_SelectedItem_Delete}"
- class="Maestro.Base.Commands.NotImplementedCommand" />
+ class="Maestro.Base.Commands.SiteExplorer.DeleteSelectedItemsCommand" />
<MenuItem type="Separator" />
<MenuItem id="Copy"
label="${res:SiteExplorer_SelectedItem_Copy}"
@@ -345,7 +345,7 @@
class="Maestro.Base.Commands.SiteExplorer.RenameCommand" />
<MenuItem id="Delete"
label="${res:SiteExplorer_SelectedItem_Delete}"
- class="Maestro.Base.Commands.NotImplementedCommand" />
+ class="Maestro.Base.Commands.SiteExplorer.DeleteSelectedItemsCommand" />
<MenuItem type="Separator" />
<MenuItem id="Copy"
label="${res:SiteExplorer_SelectedItem_Copy}"
Modified: sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -80,7 +80,7 @@
/// <param name="res"></param>
/// <param name="conn"></param>
/// <param name="useXmlEditor"></param>
- public void Open(IResource res, IServerConnection conn, bool useXmlEditor)
+ public void Open(IResource res, IServerConnection conn, bool useXmlEditor, ISiteExplorer siteExp)
{
string resourceId = res.ResourceID;
if (!_openItems.ContainsKey(resourceId))
@@ -96,7 +96,7 @@
ed = FindEditor(svc, res.GetResourceTypeDescriptor());
}
var launcher = ServiceRegistry.GetService<UrlLauncherService>();
- var editorSvc = new ResourceEditorService(resourceId, conn, launcher);
+ var editorSvc = new ResourceEditorService(resourceId, conn, launcher, siteExp);
ed.EditorService = editorSvc;
_openItems[resourceId] = ed;
ed.ViewContentClosing += (sender, e) =>
@@ -116,13 +116,13 @@
/// <param name="resourceId"></param>
/// <param name="conn"></param>
/// <param name="useXmlEditor"></param>
- public void Open(string resourceId, IServerConnection conn, bool useXmlEditor)
+ public void Open(string resourceId, IServerConnection conn, bool useXmlEditor, ISiteExplorer siteExp)
{
IResource res = null;
try
{
res = (IResource)conn.ResourceService.GetResource(resourceId);
- Open(res, conn, useXmlEditor);
+ Open(res, conn, useXmlEditor, siteExp);
}
catch (Exception ex)
{
Modified: sandbox/maestro-3.0/Maestro.Base/UI/ISiteExplorer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/UI/ISiteExplorer.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/UI/ISiteExplorer.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -25,11 +25,35 @@
{
public interface ISiteExplorer : IViewContent
{
+ /// <summary>
+ /// The name of the <see cref="IServerConnection"/> associated with this site explorer
+ /// </summary>
string ConnectionName { get; }
+ /// <summary>
+ /// Refreshes the tree model
+ /// </summary>
void RefreshModel();
/// <summary>
+ /// Refreshes the tree model from the specified resource id
+ /// </summary>
+ /// <param name="resId"></param>
+ void RefreshModel(string resId);
+
+ /// <summary>
+ /// Expands the node indicated by the specified id
+ /// </summary>
+ /// <param name="folderId"></param>
+ void ExpandNode(string folderId);
+
+ /// <summary>
+ /// Selects the node indicated by the specified id
+ /// </summary>
+ /// <param name="resourceId"></param>
+ void SelectNode(string resourceId);
+
+ /// <summary>
/// Gets the items currently selected
/// </summary>
RepositoryItem[] SelectedItems { get; }
Modified: sandbox/maestro-3.0/Maestro.Base/UI/RepositoryTreeModel.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/UI/RepositoryTreeModel.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/UI/RepositoryTreeModel.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -155,7 +155,7 @@
{
item.Parent = this;
_children.Add(item.NameQualified, item);
- NotifyStructureChanged();
+ NotifyStructureChanged(this);
}
public void RemoveChild(RepositoryItem item)
@@ -165,11 +165,28 @@
if (_children.Remove(item.NameQualified))
{
item.Parent = null;
- NotifyStructureChanged();
+ NotifyStructureChanged(this);
}
}
}
+ private void NotifyStructureChanged(RepositoryItem repositoryItem)
+ {
+ if (!_notify)
+ return;
+
+ var model = FindModel();
+ if (model != null && this.Parent != null)
+ {
+ TreePath path = model.GetPath(repositoryItem);
+ if (path != null)
+ {
+ var args = new TreePathEventArgs(path);
+ model.RaiseStructureChanged(args);
+ }
+ }
+ }
+
public bool IsRoot
{
get { return this.ResourceId == "Library://"; }
@@ -235,23 +252,6 @@
}
}
- private void NotifyStructureChanged()
- {
- if (!_notify)
- return;
-
- var model = FindModel();
- if (model != null && this.Parent != null)
- {
- TreePath path = model.GetPath(this.Parent);
- if (path != null)
- {
- var args = new TreeModelEventArgs(path, new object[] { this });
- model.RaiseStructureChanged(args);
- }
- }
- }
-
public string ResourceType
{
get;
@@ -319,12 +319,14 @@
public class RepositoryTreeModel : TreeModelBase
{
private RepositoryItem _rootNode;
+ private TreeViewAdv _tree;
private IServerConnection _conn;
- public RepositoryTreeModel(IServerConnection conn)
+ public RepositoryTreeModel(IServerConnection conn, TreeViewAdv tree)
{
_conn = conn;
+ _tree = tree;
}
private System.Collections.IEnumerable GetSorted(ResourceList list)
@@ -384,6 +386,18 @@
}
}
+ public override void Refresh()
+ {
+ //We have to override this because the base impl does not
+ //preserve the tree path of the selected node (and thus expand
+ //all the nodes from the root to this node)
+ //
+ //Which is also why we need to pass a reference to
+ //the TreeViewAdv in the ctor
+ var selected = _tree.GetPath(_tree.SelectedNode);
+ OnStructureChanged(new TreePathEventArgs(selected));
+ }
+
public override bool IsLeaf(TreePath treePath)
{
return !((RepositoryItem)treePath.LastNode).IsFolder;
@@ -413,7 +427,7 @@
}
}
- internal void RaiseStructureChanged(TreeModelEventArgs args)
+ internal void RaiseStructureChanged(TreePathEventArgs args)
{
base.OnStructureChanged(args);
}
@@ -429,7 +443,10 @@
RepositoryItem current = _rootNode;
for (int i = 0; i < components.Length; i++)
{
- current = current[components[i]];
+ if (current.Contains(components[i]))
+ current = current[components[i]];
+ else
+ return null;
}
return GetPath(current);
}
Modified: sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -28,6 +28,7 @@
using Aga.Controls.Tree;
using Maestro.Base.Services;
using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Resource;
namespace Maestro.Base.UI
{
@@ -78,7 +79,7 @@
var mgr = ServiceRegistry.GetService<ServerConnectionManager>();
_conn = mgr.GetConnection(this.ConnectionName);
- _model = new RepositoryTreeModel(_conn);
+ _model = new RepositoryTreeModel(_conn, trvResources);
trvResources.Model = _model;
}
@@ -100,41 +101,30 @@
public void RefreshModel()
{
- string resId = null;
- if (this.SelectedItems.Length == 1)
+ RefreshModel(null);
+ }
+
+ public void RefreshModel(string resId)
+ {
+ if (!string.IsNullOrEmpty(resId))
{
- resId = this.SelectedItems[0].ResourceId;
+ var rid = new ResourceIdentifier(resId);
+ if (!rid.IsFolder)
+ resId = rid.ParentFolder;
+
+ var path = _model.GetPathFromResourceId(resId);
+ var node = trvResources.FindNode(path, true);
+ if (node != null)
+ {
+ //Walk back up until node has children. We want to refresh from this node down
+ while (node.Children.Count == 0 && node != trvResources.Root)
+ node = node.Parent;
+ }
+ trvResources.SelectedNode = node;
}
_model.Refresh();
- ExpandRoot();
-
- //This doesn't actually work yet :(
-
- //if (!string.IsNullOrEmpty(resId))
- //{
- // var path = _model.GetPathFromResourceId(resId);
- // if (path != TreePath.Empty)
- // {
- // var node = trvResources.FindNode(path);
- // if (node != null)
- // {
- // while (node.Parent != null)
- // {
- // node = node.Parent;
- // if (!node.IsExpanded)
- // node.Expand();
- // }
- // }
- // }
- //}
}
- private void ExpandRoot()
- {
- //"Root" of the model is actually the child of the tree root
- trvResources.Root.Children[0].Expand();
- }
-
private void trvResources_MouseDoubleClick(object sender, MouseEventArgs e)
{
TreeNodeAdv node = trvResources.GetNodeAt(new Point(e.X, e.Y));
@@ -144,7 +134,7 @@
if (item != null && !item.IsFolder)
{
var resMgr = ServiceRegistry.GetService<OpenResourceManager>();
- resMgr.Open(item.ResourceId, _conn, false);
+ resMgr.Open(item.ResourceId, _conn, false, this);
}
}
}
@@ -238,5 +228,32 @@
this.Cursor = Cursors.Default;
}
}
+
+
+ public void ExpandNode(string folderId)
+ {
+ var path = _model.GetPathFromResourceId(folderId);
+ if (path != null)
+ {
+ var node = trvResources.FindNode(path, true);
+ if (node != null)
+ {
+ node.IsExpanded = true;
+ }
+ }
+ }
+
+ public void SelectNode(string resourceId)
+ {
+ var path = _model.GetPathFromResourceId(resourceId);
+ if (path != null)
+ {
+ var node = trvResources.FindNode(path, true);
+ if (node != null)
+ {
+ trvResources.SelectedNode = node;
+ }
+ }
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/IEditorService.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -27,6 +27,7 @@
using OSGeo.MapGuide.ObjectModels.Common;
using System.ComponentModel;
using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI.Commands;
namespace Maestro.Editors
{
@@ -36,6 +37,18 @@
public interface IEditorService
{
/// <summary>
+ /// Indicates if a specified custom command is supported and can be created
+ /// </summary>
+ /// <param name="cmdType"></param>
+ /// <returns></returns>
+ bool SupportsCommand(CommandType cmdType);
+ /// <summary>
+ /// Create a custom command
+ /// </summary>
+ /// <param name="cmdType"></param>
+ /// <returns></returns>
+ ICommand CreateCommand(CommandType cmdType);
+ /// <summary>
/// Gets the associated feature service
/// </summary>
IFeatureService FeatureService { get; }
@@ -170,5 +183,16 @@
/// databinding system.
/// </summary>
void HasChanged();
+
+ /// <summary>
+ /// Raises a request to refresh the Site Explorer
+ /// </summary>
+ void RequestRefresh();
+
+ /// <summary>
+ /// Raises a request to refresh the Site Explorer at the specified folder id
+ /// </summary>
+ /// <param name="folderId"></param>
+ void RequestRefresh(string folderId);
}
}
Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -228,7 +228,7 @@
try
{
IVectorLayerDefinition vl = (IVectorLayerDefinition)m_layer.SubLayer;
- using (FeatureSetReader rd = m_editor.FeatureService.QueryFeatureSource(vl.FeatureSourceID, m_schema.Fullname, filter, new string[] { col.Name }))
+ using (FeatureSetReader rd = m_editor.FeatureService.QueryFeatureSource(vl.FeatureSourceID, m_schema.FullnameDecoded, filter, new string[] { col.Name }))
{
while (rd.Read() && m_values.Count < 100000) //No more than 100.000 records in memory
{
Added: sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.Designer.cs (rev 0)
+++ sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.Designer.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -0,0 +1,60 @@
+namespace Maestro.Editors.LoadProcedure
+{
+ partial class ExecuteCtrl
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.btnExecute = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // btnExecute
+ //
+ this.btnExecute.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.btnExecute.Location = new System.Drawing.Point(15, 13);
+ this.btnExecute.Name = "btnExecute";
+ this.btnExecute.Size = new System.Drawing.Size(104, 23);
+ this.btnExecute.TabIndex = 0;
+ this.btnExecute.Text = "Load Resources";
+ this.btnExecute.UseVisualStyleBackColor = true;
+ this.btnExecute.Click += new System.EventHandler(this.btnExecute_Click);
+ //
+ // ExecuteCtrl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.btnExecute);
+ this.Name = "ExecuteCtrl";
+ this.Size = new System.Drawing.Size(655, 50);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button btnExecute;
+ }
+}
Added: sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.cs (rev 0)
+++ sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -0,0 +1,46 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#endregion
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Maestro.Editors.LoadProcedure
+{
+ public partial class ExecuteCtrl : UserControl
+ {
+ internal event EventHandler Execute;
+
+ public ExecuteCtrl()
+ {
+ InitializeComponent();
+ }
+
+ private void btnExecute_Click(object sender, EventArgs e)
+ {
+ var handler = this.Execute;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+ }
+}
Added: sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.resx (rev 0)
+++ sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/ExecuteCtrl.resx 2010-09-28 14:33:11 UTC (rev 5202)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Modified: sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.Designer.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.Designer.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -59,6 +59,7 @@
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(75, 22);
this.btnAdd.Text = "Add Files";
+ this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// btnDelete
//
@@ -67,6 +68,7 @@
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(86, 22);
this.btnDelete.Text = "Delete Files";
+ this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// lstInputFiles
//
@@ -76,6 +78,7 @@
this.lstInputFiles.Name = "lstInputFiles";
this.lstInputFiles.Size = new System.Drawing.Size(449, 264);
this.lstInputFiles.TabIndex = 1;
+ this.lstInputFiles.SelectedIndexChanged += new System.EventHandler(this.lstInputFiles_SelectedIndexChanged);
//
// InputFilesCtrl
//
Modified: sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/InputFilesCtrl.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -37,13 +37,63 @@
InitializeComponent();
}
+ private OSGeo.MapGuide.ObjectModels.LoadProcedure.LoadProcedureType _lpt;
+
public override void Bind(IEditorService service)
{
var lp = service.GetEditedResource() as OSGeo.MapGuide.ObjectModels.LoadProcedure.LoadProcedure;
Debug.Assert(lp != null);
+ _lpt = lp.Item;
+
service.RegisterCustomNotifier(this);
- lstInputFiles.DataSource = lp.Item.SourceFile;
+ lstInputFiles.DataSource = _lpt.SourceFile;
}
+
+ private void lstInputFiles_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ btnDelete.Enabled = (lstInputFiles.SelectedItems.Count > 0);
+ }
+
+ private void btnAdd_Click(object sender, EventArgs e)
+ {
+ string filter = GetFilter();
+ using (var dlg = DialogFactory.OpenFile())
+ {
+ dlg.Filter = filter;
+ dlg.Multiselect = true;
+ if (dlg.ShowDialog() == DialogResult.OK)
+ {
+ _lpt.AddFiles(dlg.FileNames);
+ }
+ }
+ }
+
+ private string GetFilter()
+ {
+ string filter = Properties.Resources.FilterAll;
+ if (_lpt is OSGeo.MapGuide.ObjectModels.LoadProcedure.SdfLoadProcedureType)
+ filter = Properties.Resources.FilterSdf;
+ else if (_lpt is OSGeo.MapGuide.ObjectModels.LoadProcedure.ShpLoadProcedureType)
+ filter = Properties.Resources.FilterShp;
+
+ return filter;
+ }
+
+ private void btnDelete_Click(object sender, EventArgs e)
+ {
+ if (lstInputFiles.SelectedItems.Count > 0)
+ {
+ var files = new List<string>();
+ foreach (var obj in lstInputFiles.SelectedItems)
+ {
+ files.Add(obj.ToString());
+ }
+ foreach (var f in files)
+ {
+ _lpt.RemoveFile(f);
+ }
+ }
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/LoadProcedureEditorCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/LoadProcedureEditorCtrl.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/LoadProcedure/LoadProcedureEditorCtrl.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -21,16 +21,16 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
-using System.Data;
using System.Text;
using System.Windows.Forms;
using OSGeo.MapGuide.ObjectModels.LoadProcedure;
using System.Diagnostics;
using Maestro.Shared.UI;
+using OSGeo.MapGuide.MaestroAPI.Commands;
namespace Maestro.Editors.LoadProcedure
{
- public partial class LoadProcedureEditorCtrl : UserControl, IEditorBindable
+ public partial class LoadProcedureEditorCtrl : EditorBase
{
public LoadProcedureEditorCtrl()
{
@@ -39,9 +39,12 @@
private OSGeo.MapGuide.ObjectModels.LoadProcedure.LoadProcedure _lp;
- public void Bind(IEditorService service)
+ private IEditorService _ed;
+
+ public override void Bind(IEditorService service)
{
- _lp = service.GetEditedResource() as OSGeo.MapGuide.ObjectModels.LoadProcedure.LoadProcedure;
+ _ed = service;
+ _lp = _ed.GetEditedResource() as OSGeo.MapGuide.ObjectModels.LoadProcedure.LoadProcedure;
Debug.Assert(_lp != null);
service.RegisterCustomNotifier(this);
@@ -75,11 +78,56 @@
input.Dock = DockStyle.Top;
target.Dock = DockStyle.Top;
+ var exec = new ExecuteCtrl();
+ exec.Dock = DockStyle.Bottom;
+ exec.Execute += new EventHandler(OnExecute);
+
+ this.Controls.Add(exec);
this.Controls.Add(target);
this.Controls.Add(tp);
this.Controls.Add(input);
}
+ void OnExecute(object sender, EventArgs e)
+ {
+ if (_ed.SupportsCommand(CommandType.ExecuteLoadProcedure))
+ {
+ var pdlg = new ProgressDialog();
+ pdlg.CancelAbortsThread = true;
+
+ var worker = new ProgressDialog.DoBackgroundWork(ExecuteLoadProcedure);
+ try
+ {
+ var result = pdlg.RunOperationAsync(this.ParentForm, worker, _ed, _lp);
+ MessageBox.Show(Properties.Resources.OperationCompleted);
+ _ed.RequestRefresh(_lp.Item.RootPath);
+ }
+ catch (CancelException)
+ {
+ MessageBox.Show(Properties.Resources.OperationCancelled);
+ }
+ }
+ else
+ {
+ MessageBox.Show(Properties.Resources.LoadProcedureVersionExecutionNotSupported);
+ }
+ }
+
+ object ExecuteLoadProcedure(BackgroundWorker worker, DoWorkEventArgs e, params object[] args)
+ {
+ OSGeo.MapGuide.MaestroAPI.LengthyOperationProgressCallBack cb = (s, cbArgs) =>
+ {
+ worker.ReportProgress(cbArgs.Progress, cbArgs.StatusMessage);
+ };
+
+ IEditorService ed = (IEditorService)args[0];
+ var proc = (OSGeo.MapGuide.ObjectModels.LoadProcedure.LoadProcedure)args[1];
+
+ var cmd = (IExecuteLoadProcedure)_ed.CreateCommand(CommandType.ExecuteLoadProcedure);
+
+ return cmd.Execute(proc, cb);
+ }
+
public event EventHandler ResourceChanged;
}
}
Modified: sandbox/maestro-3.0/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Maestro.Editors.csproj 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/Maestro.Editors.csproj 2010-09-28 14:33:11 UTC (rev 5202)
@@ -359,6 +359,12 @@
<Compile Include="LayerDefinition\Vector\VectorLayerStyleSectionCtrl.Designer.cs">
<DependentUpon>VectorLayerStyleSectionCtrl.cs</DependentUpon>
</Compile>
+ <Compile Include="LoadProcedure\ExecuteCtrl.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="LoadProcedure\ExecuteCtrl.Designer.cs">
+ <DependentUpon>ExecuteCtrl.cs</DependentUpon>
+ </Compile>
<Compile Include="LoadProcedure\InputFilesCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -713,6 +719,9 @@
<DependentUpon>VectorLayerStyleSectionCtrl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="LoadProcedure\ExecuteCtrl.resx">
+ <DependentUpon>ExecuteCtrl.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="LoadProcedure\InputFilesCtrl.resx">
<DependentUpon>InputFilesCtrl.cs</DependentUpon>
<SubType>Designer</SubType>
Modified: sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.3053
+// Runtime Version:2.0.50727.4952
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -415,6 +415,33 @@
}
/// <summary>
+ /// Looks up a localized string similar to All File Types (*.*)|*.*.
+ /// </summary>
+ internal static string FilterAll {
+ get {
+ return ResourceManager.GetString("FilterAll", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Autodesk SDF (*.sdf)|*.*.
+ /// </summary>
+ internal static string FilterSdf {
+ get {
+ return ResourceManager.GetString("FilterSdf", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to ESRI Shape File (*.shp)|*.*.
+ /// </summary>
+ internal static string FilterShp {
+ get {
+ return ResourceManager.GetString("FilterShp", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Cannot Find an Empty String.
/// </summary>
internal static string FindEmptyString {
@@ -1238,6 +1265,15 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to This connection does not support executing this type of Load Procedure.
+ /// </summary>
+ internal static string LoadProcedureVersionExecutionNotSupported {
+ get {
+ return ResourceManager.GetString("LoadProcedureVersionExecutionNotSupported", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap magnifier {
get {
object obj = ResourceManager.GetObject("magnifier", resourceCulture);
@@ -1295,6 +1331,24 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Operation Cancelled.
+ /// </summary>
+ internal static string OperationCancelled {
+ get {
+ return ResourceManager.GetString("OperationCancelled", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Operation Completed.
+ /// </summary>
+ internal static string OperationCompleted {
+ get {
+ return ResourceManager.GetString("OperationCompleted", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap plus_circle {
get {
object obj = ResourceManager.GetObject("plus-circle", resourceCulture);
Modified: sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx 2010-09-28 14:33:11 UTC (rev 5202)
@@ -751,4 +751,22 @@
<data name="question" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\question.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
+ <data name="LoadProcedureVersionExecutionNotSupported" xml:space="preserve">
+ <value>This connection does not support executing this type of Load Procedure</value>
+ </data>
+ <data name="OperationCancelled" xml:space="preserve">
+ <value>Operation Cancelled</value>
+ </data>
+ <data name="OperationCompleted" xml:space="preserve">
+ <value>Operation Completed</value>
+ </data>
+ <data name="FilterAll" xml:space="preserve">
+ <value>All File Types (*.*)|*.*</value>
+ </data>
+ <data name="FilterSdf" xml:space="preserve">
+ <value>Autodesk SDF (*.sdf)|*.*</value>
+ </data>
+ <data name="FilterShp" xml:space="preserve">
+ <value>ESRI Shape File (*.shp)|*.*</value>
+ </data>
</root>
\ No newline at end of file
Modified: sandbox/maestro-3.0/MaestroAPITests/SerializationTests.cs
===================================================================
--- sandbox/maestro-3.0/MaestroAPITests/SerializationTests.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/MaestroAPITests/SerializationTests.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -21,6 +21,9 @@
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using NMock2;
+using OSGeo.MapGuide.MaestroAPI;
namespace MaestroAPITests
{
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/CommandType.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/CommandType.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/CommandType.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -25,8 +25,17 @@
{
public enum CommandType : int
{
+ /// <summary>
+ /// Execute v1.0.0 Load Procedure resources
+ /// </summary>
ExecuteLoadProcedure = 1,
+ /// <summary>
+ /// Get v1.0.0 Capabilites document
+ /// </summary>
GetCapabilities = 2,
+ /// <summary>
+ /// Get v1.1.0 Capabilites document
+ /// </summary>
GetCapabilities2 = 3,
}
}
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -35,9 +35,9 @@
/// </summary>
public interface IExecuteLoadProcedure : ICommand
{
- string[] Execute(OSGeo.MapGuide.MaestroAPI.LengthyOperationProgressCallBack callback);
+ string[] Execute(LP.LoadProcedure loadProc, OSGeo.MapGuide.MaestroAPI.LengthyOperationProgressCallBack callback);
+ string[] Execute(string resourceID, OSGeo.MapGuide.MaestroAPI.LengthyOperationProgressCallBack callback);
bool IgnoreUnsupportedFeatures { get; set; }
- string ResourceID { get; set; }
}
internal class ExecuteLoadProcedure : IExecuteLoadProcedure
@@ -72,6 +72,18 @@
set;
}
+ public string[] Execute(string resourceID, OSGeo.MapGuide.MaestroAPI.LengthyOperationProgressCallBack callback)
+ {
+ if (!ResourceIdentifier.Validate(this.ResourceID))
+ throw new ArgumentException("Invalid resource id: " + this.ResourceID);
+
+ if (ResourceIdentifier.GetResourceType(this.ResourceID) != ResourceTypes.LoadProcedure)
+ throw new ArgumentException("Not a load procedure resource id: " + this.ResourceID);
+
+ LP.LoadProcedure proc = (LP.LoadProcedure)this.Parent.ResourceService.GetResource(resourceID);
+ return Execute(proc, callback);
+ }
+
/// <summary>
/// Executes the specified load procedure. Only SDF and SHP load procedures are supported.
/// Also note that the following load procedure features are ignored during execution:
@@ -84,7 +96,7 @@
/// <param name="ignoreUnsupportedFeatures">If false, will throw exceptions when executing a load procedure containing unsupported features.</param>
/// <param name="callback"></param>
/// <returns>A list of resource IDs that were created from the execution of this load procedure</returns>
- public string[] Execute(LengthyOperationProgressCallBack callback)
+ public string[] Execute(LP.LoadProcedure proc, LengthyOperationProgressCallBack callback)
{
//TODO: Localize callback messages
//TODO: Localize exception messages
@@ -96,19 +108,12 @@
string[] resourcesCreatedOrUpdated = null;
- if (!ResourceIdentifier.Validate(this.ResourceID))
- throw new ArgumentException("Invalid resource id: " + this.ResourceID);
-
- if (ResourceIdentifier.GetResourceType(this.ResourceID) != ResourceTypes.LoadProcedure)
- throw new ArgumentException("Not a load procedure resource id: " + this.ResourceID);
-
LengthyOperationProgressCallBack cb = callback;
//Assign dummy callback if none specified
if (cb == null)
cb = delegate { };
- LP.LoadProcedure proc = (LP.LoadProcedure)this.Parent.ResourceService.GetResource(this.ResourceID);
//bool loadProcedureUpdated = false;
//bool updateGeneratedResourceIds = false;
@@ -315,6 +320,9 @@
bool skip = (resToUpdate.Count > 0 && !resToUpdate.Contains(lyrId));
if (!skip)
{
+ //NOTE: Because we are working against 1.0.0 object types this will always create 1.0.0 Layer Definition
+ //resources
+
//Process is as follows
//
// 1. Describe the schema of the feature source
@@ -355,21 +363,61 @@
if (clsDef != null && geom != null)
{
- OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition ld = ObjectFactory.CreateLayerDefinition(this.Parent);
+ OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition ld = ObjectFactory.CreateMonoChromaticVectorLayer(this.Parent);
//Step 3: Assign default properties
ld.ResourceID = lyrId;
VectorLayerDefinitionType vld = ld.Item as VectorLayerDefinitionType;
vld.ResourceId = fsId;
- vld.FeatureName = clsDef.Fullname;
+ vld.FeatureName = clsDef.FullnameDecoded;
vld.Geometry = geom.Name;
+ //Step 4: Infer geometry storage support and remove unsupported styles
+ object obj = geom.GetMetadata(GeometryMetadata.GEOM_TYPES);
+ if (obj != null)
+ {
+ List<string> geomTypes = new List<string>();
+ geomTypes.AddRange(obj.ToString().Trim().Split(' '));
+
+ var scale = vld.VectorScaleRange[0];
+
+ if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_POINT))
+ {
+ for (int i = scale.Items.Count - 1; i >= 0; i--)
+ {
+ if (typeof(PointTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
+ {
+ scale.Items.RemoveAt(i);
+ }
+ }
+ }
+ if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_CURVE))
+ {
+ for (int i = scale.Items.Count - 1; i >= 0; i--)
+ {
+ if (typeof(LineTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
+ {
+ scale.Items.RemoveAt(i);
+ }
+ }
+ }
+ if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_SURFACE))
+ {
+ for (int i = scale.Items.Count - 1; i >= 0; i--)
+ {
+ if (typeof(AreaTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
+ {
+ scale.Items.RemoveAt(i);
+ }
+ }
+ }
+ }
+
this.Parent.ResourceService.SaveResource(ld);
resCreatedOrUpdated.Add(lyrId);
cb(this, new LengthyOperationProgressArgs("Created: " + lyrId, current));
- //Step 4: Infer geometry storage support and remove unsupported styles
- //TODO: There doesn't seem to be a MaestroAPI way to figure out geometry storage types atm
+
}
}
}
@@ -514,6 +562,9 @@
bool skip = (resToUpdate.Count > 0 && !resToUpdate.Contains(lyrId));
if (!skip)
{
+ //NOTE: Because we are working against 1.0.0 object types this will always create 1.0.0 Layer Definition
+ //resources
+
//Process is as follows
//
// 1. Describe the schema of the feature source
@@ -554,7 +605,7 @@
if (clsDef != null && geom != null)
{
- LayerDefinition ld = ObjectFactory.CreateLayerDefinition(this.Parent);
+ LayerDefinition ld = ObjectFactory.CreateMonoChromaticVectorLayer(this.Parent);
//Step 3: Assign default properties
ld.ResourceID = lyrId;
@@ -563,12 +614,50 @@
vld.FeatureName = clsDef.Fullname;
vld.Geometry = geom.Name;
+ //Step 4: Infer geometry storage support and remove unsupported styles
+ object obj = geom.GetMetadata(GeometryMetadata.GEOM_TYPES);
+ if (obj != null)
+ {
+ List<string> geomTypes = new List<string>();
+ geomTypes.AddRange(obj.ToString().Trim().Split(' '));
+
+ var scale = vld.VectorScaleRange[0];
+
+ if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_POINT))
+ {
+ for (int i = scale.Items.Count - 1; i >= 0; i--)
+ {
+ if (typeof(PointTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
+ {
+ scale.Items.RemoveAt(i);
+ }
+ }
+ }
+ if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_CURVE))
+ {
+ for (int i = scale.Items.Count - 1; i >= 0; i--)
+ {
+ if (typeof(LineTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
+ {
+ scale.Items.RemoveAt(i);
+ }
+ }
+ }
+ if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_SURFACE))
+ {
+ for (int i = scale.Items.Count - 1; i >= 0; i--)
+ {
+ if (typeof(AreaTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
+ {
+ scale.Items.RemoveAt(i);
+ }
+ }
+ }
+ }
+
this.Parent.ResourceService.SaveResource(ld);
resCreatedOrUpdated.Add(lyrId);
cb(this, new LengthyOperationProgressArgs("Created: " + lyrId, current));
-
- //Step 4: Infer geometry storage support and remove unsupported styles
- //TODO: There doesn't seem to be a MaestroAPI way to figure out geometry storage types atm
}
}
}
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Feature/FeatureSetReader.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -271,6 +271,8 @@
public abstract class FeatureSetColumn
{
+ protected System.Collections.Hashtable m_metadata = new System.Collections.Hashtable();
+
protected string m_name;
protected Type m_type;
protected bool m_allowNull;
@@ -278,6 +280,8 @@
public string Name { get { return m_name; } }
public Type Type { get { return m_type; } }
+ public System.Collections.ICollection MetadataKeys { get { return m_metadata.Keys; } }
+
public bool IsGeometry
{
get
@@ -285,8 +289,28 @@
return typeof(IGeometry).IsAssignableFrom(this.Type);
}
}
+
+ public object GetMetadata(string key)
+ {
+ return m_metadata[key];
+ }
+
+ public void SetMetadata(string key, object value)
+ {
+ m_metadata[key] = value;
+ }
}
+ public class GeometryMetadata
+ {
+ public const string GEOM_TYPES = "GEOM_TYPES";
+
+ public const string GEOM_TYPE_POINT = "point";
+ public const string GEOM_TYPE_CURVE = "curve";
+ public const string GEOM_TYPE_SURFACE = "surface";
+ public const string GEOM_TYPE_SOLID = "solid";
+ }
+
public abstract class FeatureSetRow : IDataRecord
{
private Topology.IO.WKTReader m_reader = null;
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -98,4 +98,29 @@
get { return true; }
}
}
+
+ partial class LoadProcedureType
+ {
+ public void AddFiles(IEnumerable<string> files)
+ {
+ Check.NotNull(files, "files");
+
+ var _files = this.sourceFileField;
+ foreach (var f in files)
+ {
+ if (!_files.Contains(f))
+ _files.Add(f);
+ }
+ }
+
+ public void RemoveFile(string file)
+ {
+ Check.NotEmpty(file, "file");
+
+ if (this.sourceFileField.Contains(file))
+ {
+ this.sourceFileField.Remove(file);
+ }
+ }
+ }
}
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -43,6 +43,33 @@
/// </summary>
public static class ObjectFactory
{
+ public static LayerDefinition CreateMonoChromaticVectorLayer(IServerConnection owner)
+ {
+ Check.NotNull(owner, "owner");
+
+ var layer = new LayerDefinition();
+ layer.CurrentConnection = owner;
+
+ var vl = new VectorLayerDefinitionType();
+ layer.Item = vl;
+
+ vl.VectorScaleRange = new System.ComponentModel.BindingList<VectorScaleRangeType>();
+ var defaultRange = new VectorScaleRangeType()
+ {
+ Items = new System.ComponentModel.BindingList<object>(),
+ AreaStyle = CreateDefaultAreaStyle(),
+ LineStyle = CreateDefaultLineStyle(),
+ PointStyle = CreateDefaultPointStyle()
+ };
+ defaultRange.AreaStyle.AreaRule.Add(CreateAreaRule());
+ defaultRange.LineStyle.LineRule.Add(CreateLineRule());
+ defaultRange.PointStyle.PointRule.Add(CreatePointRule());
+ vl.VectorScaleRange.Add(defaultRange);
+
+ return layer;
+ }
+
+ //TODO: Split into CreateVector/CreateRaster/CreateDrawing ?
public static LayerDefinition CreateLayerDefinition(IServerConnection owner)
{
Check.NotNull(owner, "owner");
@@ -779,6 +806,7 @@
Fill = CreateDefaultFill(),
SizeContext = SizeContextType.DeviceUnits,
MaintainAspect = true,
+ Shape = ShapeType.Square,
Rotation = "0",
SizeX = "10",
SizeY = "10",
@@ -798,6 +826,7 @@
{
return new PointRuleType()
{
+ LegendLabel = "",
Item = CreateDefaultPointSymbolization2D()
};
}
@@ -806,6 +835,7 @@
{
return new AreaRuleType()
{
+ LegendLabel = "",
Item = new AreaSymbolizationFillType()
{
Fill = CreateDefaultFill(),
@@ -818,6 +848,7 @@
{
return new LineRuleType()
{
+ LegendLabel = "",
Items = new System.ComponentModel.BindingList<StrokeType>()
{
CreateDefaultStroke()
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -28,6 +28,7 @@
using AppDef = OSGeo.MapGuide.ObjectModels.ApplicationDefinition;
using OSGeo.MapGuide.ObjectModels.Capabilities;
using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.Commands;
namespace OSGeo.MapGuide.MaestroAPI
{
@@ -1614,5 +1615,17 @@
public abstract void SetCustomProperty(string name, object value);
public abstract object GetCustomProperty(string name);
+
+ public virtual ICommand CreateCommand(int cmdType)
+ {
+ CommandType ct = (CommandType)cmdType;
+ switch (ct)
+ {
+ case CommandType.ExecuteLoadProcedure:
+ return new ExecuteLoadProcedure(GetInterface());
+ default:
+ return null;
+ }
+ }
}
}
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -114,7 +114,10 @@
get
{
//TODO: Work out what this can/can't do
- return new int[0];
+ return new int[]
+ {
+ (int)OSGeo.MapGuide.MaestroAPI.Commands.CommandType.ExecuteLoadProcedure
+ };
}
}
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -1597,11 +1597,6 @@
get { return this; }
}
- public ICommand CreateCommand(int commandType)
- {
- throw new NotImplementedException();
- }
-
public IConnectionCapabilities Capabilities
{
get { return new HttpCapabilities(this); }
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureSetReader.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureSetReader.cs 2010-09-28 10:57:10 UTC (rev 5201)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI.Http/XmlFeatureSetReader.cs 2010-09-28 14:33:11 UTC (rev 5202)
@@ -224,10 +224,16 @@
m_name = node.Attributes["name"].Value;
m_allowNull = node.Attributes["minOccurs"] != null && node.Attributes["minOccurs"].Value == "0";
if (node.Attributes["type"] != null && node.Attributes["type"].Value == "gml:AbstractGeometryType")
+ {
m_type = Utility.GeometryType;
+ this.SetMetadata(GeometryMetadata.GEOM_TYPES, node.Attributes["fdo:geometricTypes"].Value);
+ }
else if (node["xs:simpleType"] == null)
+ {
m_type = Utility.RasterType;
+ }
else
+ {
switch (node["xs:simpleType"]["xs:restriction"].Attributes["base"].Value.ToLower())
{
case "xs:string":
@@ -265,6 +271,7 @@
m_type = Utility.UnmappedType;
break;
}
+ }
}
}
}
More information about the mapguide-commits
mailing list