[mapguide-commits] r5044 - in sandbox/maestro-3.0: Maestro.Base
Maestro.Base/Commands Maestro.Base/Editor
Maestro.Base/Properties Maestro.Base/Services
Maestro.Base/Templates Maestro.Base/UI Maestro.Editors/Common
OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Properties
OSGeo.MapGuide.MaestroAPI/Resource
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 21 03:04:30 EDT 2010
Author: jng
Date: 2010-07-21 07:04:30 +0000 (Wed, 21 Jul 2010)
New Revision: 5044
Added:
sandbox/maestro-3.0/Maestro.Base/Editor/IEditorFactory.cs
Modified:
sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
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/Services/NewItemTemplateService.cs
sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs
sandbox/maestro-3.0/Maestro.Base/Services/ViewContentManager.cs
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/Maestro.Base/UI/RepositoryTreeModel.cs
sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.Designer.cs
sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs
sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.Designer.cs
sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.cs
sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.resx
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/ResourceContentVersionChecker.cs
sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
Log:
This submission includes the following changes:
- Added busy cursors to the Site Explorer and Folder browser
- Use the more efficient resource service API for Site Explorer and Folder browser
- Make the new item templates driven from the addin registry
- Make the editors driven from the addin registry. If no registered editor is found for a given resource, it defaults to the XML editor.
Modified: sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -40,9 +40,12 @@
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var tpl = dlg.SelectedTemplate;
- tpl.CreateItem(conn.ResourceService, dlg.ResourceID);
- var ri = new IRepositoryItemImpl(dlg.ResourceID);
- orm.Open(new RepositoryItem(ri), conn, false);
+
+ var res = tpl.CreateItem(conn);
+ res.ResourceID = "Session:" + conn.SessionID + "//" + Guid.NewGuid().ToString() + "." + res.ResourceType.ToString();
+ conn.ResourceService.SaveResource(res);
+
+ orm.Open(res.ResourceID, conn, false);
}
}
}
Added: sandbox/maestro-3.0/Maestro.Base/Editor/IEditorFactory.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/IEditorFactory.cs (rev 0)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/IEditorFactory.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -0,0 +1,160 @@
+#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.Text;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+
+namespace Maestro.Base.Editor
+{
+ public interface IEditorFactory
+ {
+ /// <summary>
+ /// Gets the type of resource (and version) this editor can edit
+ /// </summary>
+ ResourceTypeDescriptor ResourceTypeAndVersion { get; }
+
+ /// <summary>
+ /// Creates an instance of this resource editor
+ /// </summary>
+ /// <returns></returns>
+ IEditorViewContent Create();
+ }
+
+ internal class DrawingSourceEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public DrawingSourceEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.DrawingSource, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new DrawingSourceEditor();
+ }
+ }
+
+ internal class FeatureSourceEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public FeatureSourceEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.FeatureSource, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new FeatureSourceEditor();
+ }
+ }
+
+ internal class LayerDefinitionEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public LayerDefinitionEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new LayerDefinitionEditor();
+ }
+ }
+
+ internal class LoadProcedureEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public LoadProcedureEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.LoadProcedure, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new LoadProcedureEditor();
+ }
+ }
+
+ internal class MapDefinitionEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public MapDefinitionEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.MapDefinition, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new MapDefinitionEditor();
+ }
+ }
+
+ internal class PrintLayoutEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public PrintLayoutEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.PrintLayout, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new PrintLayoutEditor();
+ }
+ }
+
+ internal class SymbolDefinitionEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public SymbolDefinitionEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.SymbolDefinition, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new SymbolDefinitionEditor();
+ }
+ }
+
+ internal class WebLayoutEditorFactory : IEditorFactory
+ {
+ public ResourceTypeDescriptor ResourceTypeAndVersion { get; private set; }
+
+ public WebLayoutEditorFactory()
+ {
+ this.ResourceTypeAndVersion = new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, "1.0.0");
+ }
+
+ public IEditorViewContent Create()
+ {
+ return new WebLayoutEditor();
+ }
+ }
+}
Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin 2010-07-21 07:04:30 UTC (rev 5044)
@@ -20,6 +20,33 @@
<ConditionEvaluator name="MultipleSelected" class="Maestro.Base.Commands.Conditions.MultipleSelectedItemConditionEvaluator" />
</Import>
</Runtime>
+
+ <!-- Registered editors -->
+ <Path name="/Maestro/Editors">
+ <Class id="DrawingSourceEditor100" class="Maestro.Base.Editor.DrawingSourceEditorFactory" />
+ <Class id="FeatureSourceEditor100" class="Maestro.Base.Editor.FeatureSourceEditorFactory" />
+ <Class id="LayerDefinitionEditor100" class="Maestro.Base.Editor.LayerDefinitionEditorFactory" />
+ <Class id="LoadProcedureEditor100" class="Maestro.Base.Editor.LoadProcedureEditorFactory" />
+ <Class id="MapDefinitionEditor100" class="Maestro.Base.Editor.MapDefinitionEditorFactory" />
+ <Class id="PrintLayoutEditor100" class="Maestro.Base.Editor.PrintLayoutEditorFactory" />
+ <Class id="SymbolDefinitionEditor100" class="Maestro.Base.Editor.SymbolDefinitionEditorFactory" />
+ <Class id="WebLayoutEditor100" class="Maestro.Base.Editor.WebLayoutEditorFactory" />
+ </Path>
+
+ <!-- Registered System Templates -->
+ <Path name="/Maestro/NewItemTemplates">
+ <Class id="FlexLayout100" class="Maestro.Base.Templates.ApplicationDefinitionItemTemplate" />
+ <Class id="DrawingSource100" class="Maestro.Base.Templates.DrawingSourceItemTemplate" />
+ <Class id="FeatureSource100" class="Maestro.Base.Templates.FeatureSourceItemTemplate" />
+ <Class id="LayerDefinition100" class="Maestro.Base.Templates.LayerDefinitionItemTemplate" />
+ <Class id="MapDefinition100" class="Maestro.Base.Templates.MapDefinitionItemTemplate" />
+ <Class id="PrintLayout100" class="Maestro.Base.Templates.PrintLayoutItemTemplate" />
+ <Class id="SdfLoadProcedure100" class="Maestro.Base.Templates.SdfLoadProcedureItemTemplate" />
+ <Class id="ShpLoadProcedure100" class="Maestro.Base.Templates.ShpLoadProcedureItemTemplate" />
+ <Class id="SimpleSymbol100" class="Maestro.Base.Templates.SimpleSymbolDefinitionItemTemplate" />
+ <Class id="CompoundSymbol100" class="Maestro.Base.Templates.CompoundSymbolDefinitionItemTemplate" />
+ <Class id="WebLayout100" class="Maestro.Base.Templates.WebLayoutItemTemplate" />
+ </Path>
<!-- Main Menu Definition -->
<Path name="/Maestro/Shell/MainMenu">
Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj 2010-07-21 07:04:30 UTC (rev 5044)
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F1E2F468-5030-4DBA-968C-9620284AFAA1}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -87,6 +87,7 @@
<Compile Include="Editor\FeatureSourceEditor.Designer.cs">
<DependentUpon>FeatureSourceEditor.cs</DependentUpon>
</Compile>
+ <Compile Include="Editor\IEditorFactory.cs" />
<Compile Include="Editor\LayerDefinitionEditor.cs">
<SubType>UserControl</SubType>
</Compile>
Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.3053
+// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -387,6 +387,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to Registered Editor: {0}.
+ /// </summary>
+ internal static string EditorRegistered {
+ get {
+ return ResourceManager.GetString("EditorRegistered", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Singleton view content cannot be closed by users. The AllowUserClose property must return false.
/// </summary>
internal static string Error_Closeable_Singleton_Content {
@@ -699,6 +708,15 @@
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Skipping registration of editor: {0} because an existing editor is already registered to handle {1} v{2}.
+ /// </summary>
+ internal static string OpenResourceManager_SkipEditorRegistration {
+ get {
+ return ResourceManager.GetString("OpenResourceManager_SkipEditorRegistration", resourceCulture);
+ }
+ }
+
internal static System.Drawing.Bitmap plug__arrow {
get {
object obj = ResourceManager.GetObject("plug__arrow", resourceCulture);
@@ -1066,6 +1084,24 @@
}
/// <summary>
+ /// Looks up a localized string similar to Create a new Compund Symbol Definition.
+ /// </summary>
+ internal static string TPL_CSD_DESC {
+ get {
+ return ResourceManager.GetString("TPL_CSD_DESC", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Compound Symbol Definition.
+ /// </summary>
+ internal static string TPL_CSD_NAME {
+ get {
+ return ResourceManager.GetString("TPL_CSD_NAME", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Create a new Drawing Source.
/// </summary>
internal static string TPL_DS_DESC {
@@ -1192,24 +1228,33 @@
}
/// <summary>
- /// Looks up a localized string similar to Create a new Symbol Definition.
+ /// Looks up a localized string similar to Create a new Simple Symbol Definition.
/// </summary>
- internal static string TPL_SDF_DESC {
+ internal static string TPL_SSD_DESC {
get {
- return ResourceManager.GetString("TPL_SDF_DESC", resourceCulture);
+ return ResourceManager.GetString("TPL_SSD_DESC", resourceCulture);
}
}
/// <summary>
- /// Looks up a localized string similar to Symbol Definition.
+ /// Looks up a localized string similar to Simple Symbol Definition.
/// </summary>
- internal static string TPL_SDF_NAME {
+ internal static string TPL_SSD_NAME {
get {
- return ResourceManager.GetString("TPL_SDF_NAME", resourceCulture);
+ return ResourceManager.GetString("TPL_SSD_NAME", resourceCulture);
}
}
/// <summary>
+ /// Looks up a localized string similar to User Defined Resource Template.
+ /// </summary>
+ internal static string TPL_USER_DEFINED {
+ get {
+ return ResourceManager.GetString("TPL_USER_DEFINED", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Create a new Web Layout.
/// </summary>
internal static string TPL_WL_DESC {
Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx 2010-07-21 07:04:30 UTC (rev 5044)
@@ -448,11 +448,11 @@
<data name="TPL_PL_NAME" xml:space="preserve">
<value>Print Layout</value>
</data>
- <data name="TPL_SDF_DESC" xml:space="preserve">
- <value>Create a new Symbol Definition</value>
+ <data name="TPL_SSD_DESC" xml:space="preserve">
+ <value>Create a new Simple Symbol Definition</value>
</data>
- <data name="TPL_SDF_NAME" xml:space="preserve">
- <value>Symbol Definition</value>
+ <data name="TPL_SSD_NAME" xml:space="preserve">
+ <value>Simple Symbol Definition</value>
</data>
<data name="TPL_WL_DESC" xml:space="preserve">
<value>Create a new Web Layout</value>
@@ -565,4 +565,19 @@
<data name="SiteExplorer_SelectedItem_Properties" xml:space="preserve">
<value>Properties</value>
</data>
+ <data name="EditorRegistered" xml:space="preserve">
+ <value>Registered Editor: {0}</value>
+ </data>
+ <data name="OpenResourceManager_SkipEditorRegistration" xml:space="preserve">
+ <value>Skipping registration of editor: {0} because an existing editor is already registered to handle {1} v{2}</value>
+ </data>
+ <data name="TPL_USER_DEFINED" xml:space="preserve">
+ <value>User Defined Resource Template</value>
+ </data>
+ <data name="TPL_CSD_DESC" xml:space="preserve">
+ <value>Create a new Compund Symbol Definition</value>
+ </data>
+ <data name="TPL_CSD_NAME" xml:space="preserve">
+ <value>Compound Symbol Definition</value>
+ </data>
</root>
\ No newline at end of file
Modified: sandbox/maestro-3.0/Maestro.Base/Services/NewItemTemplateService.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/NewItemTemplateService.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Services/NewItemTemplateService.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -29,15 +29,59 @@
{
using Res = Properties.Resources;
using Maestro.Base.Templates;
+using System.IO;
public class NewItemTemplateService : ServiceBase
{
+ private List<ItemTemplate> _systemTemplates;
+ private List<ItemTemplate> _userTemplates;
+
public override void Initialize()
{
base.Initialize();
+ _systemTemplates = new List<ItemTemplate>();
+ _userTemplates = new List<ItemTemplate>();
+
+ var tpls = AddInTree.BuildItems<ItemTemplate>("/Maestro/NewItemTemplates", this);
+ foreach (var tp in tpls)
+ {
+ _systemTemplates.Add(tp);
+ LoggingService.Info("Registered default template: " + tp.GetType()); //LOCALIZE
+ }
+
+ UserItemTemplate [] utpls = ScanUserTemplates();
+ foreach (var ut in utpls)
+ {
+ _userTemplates.Add(ut);
+ LoggingService.Info("Adding user template: " + ut.TemplatePath);
+ }
LoggingService.Info("Initialized: New Item Template Service"); //LOCALIZE
}
+ private UserItemTemplate[] ScanUserTemplates()
+ {
+ List<UserItemTemplate> tpls = new List<UserItemTemplate>();
+
+ //TODO: Store path in preferences
+ string userTplPath = Path.Combine(FileUtility.ApplicationRootPath, "UserTemplates");
+ if (Directory.Exists(userTplPath))
+ {
+ foreach (string file in Directory.GetFiles(userTplPath))
+ {
+ try
+ {
+ var tpl = new UserItemTemplate(file);
+ tpls.Add(tpl);
+ }
+ catch (Exception ex)
+ {
+ LoggingService.Info("Could not load user template: " + file); //LOCALIZE
+ }
+ }
+ }
+ return tpls.ToArray();
+ }
+
public string[] GetCategories()
{
return new string[] {
@@ -50,22 +94,11 @@
{
if (category == Res.TPL_CATEGORY_DEFAULT)
{
- return new ItemTemplate[]
- {
- new SdfLoadProcedureItemTemplate(),
- new ShpLoadProcedureItemTemplate(),
- new FeatureSourceItemTemplate(),
- new LayerDefinitionItemTemplate(),
- new MapDefinitionItemTemplate(),
- new WebLayoutItemTemplate(),
- new ApplicationDefinitionItemTemplate(),
- new PrintLayoutItemTemplate(),
- new SymbolDefinitionItemTemplate()
- };
+ return _systemTemplates.ToArray();
}
else
{
- return new ItemTemplate[0];
+ return _userTemplates.ToArray();
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Services/OpenResourceManager.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -32,41 +32,51 @@
{
private Dictionary<string, IEditorViewContent> _openItems;
+ private Dictionary<ResourceTypeDescriptor, IEditorFactory> _factories;
+
public override void Initialize()
{
base.Initialize();
_openItems = new Dictionary<string, IEditorViewContent>();
- LoggingService.Info(Properties.Resources.Service_Init_Open_Resource_Manager);
- }
+ _factories = new Dictionary<ResourceTypeDescriptor, IEditorFactory>();
- /// <summary>
- /// Opens the specified resource using its assigned editor. If the resource is already
- /// open, the the existing editor view is activated instead. If the resource has no assigned
- /// editor or <see cref="useXmlEditor"/> is true, the resource will be opened in the default
- /// XML editor.
- /// </summary>
- /// <param name="item"></param>
- /// <param name="conn"></param>
- /// <param name="useXmlEditor"></param>
- public void Open(RepositoryItem item, IServerConnection conn, bool useXmlEditor)
- {
- if (item.IsFolder)
- return;
-
- if (!_openItems.ContainsKey(item.ResourceId))
+ var facts = AddInTree.BuildItems<IEditorFactory>("/Maestro/Editors", this);
+ foreach (var fact in facts)
{
- var svc = ServiceRegistry.GetService<ViewContentManager>();
- IResource res = null;
- try
+ if (_factories.ContainsKey(fact.ResourceTypeAndVersion))
{
- res = (IResource)conn.ResourceService.GetResource(item.ResourceId);
+ LoggingService.Info(string.Format(Properties.Resources.OpenResourceManager_SkipEditorRegistration, fact.ResourceTypeAndVersion.ResourceType, fact.ResourceTypeAndVersion.Version));
}
- catch (Exception ex)
+ else
{
- MessageService.ShowError(ex);
- return;
+ _factories.Add(fact.ResourceTypeAndVersion, fact);
+ LoggingService.Info(string.Format(Properties.Resources.EditorRegistered, fact.GetType()));
}
+ }
+ LoggingService.Info(Properties.Resources.Service_Init_Open_Resource_Manager);
+ }
+
+ private IEditorFactory GetRegisteredEditor(ResourceTypeDescriptor rtd)
+ {
+ if (_factories.ContainsKey(rtd))
+ return _factories[rtd];
+ else
+ return null;
+ }
+
+ private IEditorFactory GetRegisteredEditor(ResourceTypes type, string version)
+ {
+ var rtd = new ResourceTypeDescriptor(type, version);
+ return GetRegisteredEditor(rtd);
+ }
+
+ public void Open(IResource res, IServerConnection conn, bool useXmlEditor)
+ {
+ string resourceId = res.ResourceID;
+ if (!_openItems.ContainsKey(resourceId))
+ {
+ var svc = ServiceRegistry.GetService<ViewContentManager>();
IEditorViewContent ed = null;
if (useXmlEditor || !res.IsStronglyTyped)
{
@@ -77,64 +87,55 @@
ed = FindEditor(svc, res.GetResourceTypeDescriptor());
}
var launcher = ServiceRegistry.GetService<UrlLauncher>();
- var editorSvc = new ResourceEditorService(item.ResourceId, conn, launcher);
+ var editorSvc = new ResourceEditorService(resourceId, conn, launcher);
ed.EditorService = editorSvc;
- _openItems[item.ResourceId] = ed;
+ _openItems[resourceId] = ed;
ed.ViewContentClosing += (sender, e) =>
{
- _openItems.Remove(item.ResourceId);
+ _openItems.Remove(resourceId);
};
}
- _openItems[item.ResourceId].Activate();
+ _openItems[resourceId].Activate();
}
+ /// <summary>
+ /// Opens the specified resource using its assigned editor. If the resource is already
+ /// open, the the existing editor view is activated instead. If the resource has no assigned
+ /// editor or <see cref="useXmlEditor"/> is true, the resource will be opened in the default
+ /// XML editor.
+ /// </summary>
+ /// <param name="resourceId"></param>
+ /// <param name="conn"></param>
+ /// <param name="useXmlEditor"></param>
+ public void Open(string resourceId, IServerConnection conn, bool useXmlEditor)
+ {
+ IResource res = null;
+ try
+ {
+ res = (IResource)conn.ResourceService.GetResource(resourceId);
+ Open(res, conn, useXmlEditor);
+ }
+ catch (Exception ex)
+ {
+ MessageService.ShowError(ex);
+ return;
+ }
+ }
+
private IEditorViewContent FindEditor(ViewContentManager svc, ResourceTypeDescriptor rtd)
{
IEditorViewContent ed = null;
- //TODO: Editors should be registered in the addin registry and we should be
- //interrogate from that.
- Version rv = new Version(rtd.Version);
- if (rv > new Version(1, 0, 0))
+ IEditorFactory fact = GetRegisteredEditor(rtd);
+
+ //No registered editor, use the xml editor fallback
+ if (fact == null)
{
ed = svc.OpenContent<XmlEditor>(ViewRegion.Document);
}
- else //Is a 1.0.0 resource
+ else
{
- ResourceTypes rt = (ResourceTypes)Enum.Parse(typeof(ResourceTypes), rtd.ResourceType);
- switch (rt)
- {
- case ResourceTypes.ApplicationDefinition:
- break;
- case ResourceTypes.DrawingSource:
- ed = svc.OpenContent<DrawingSourceEditor>(ViewRegion.Document);
- break;
- case ResourceTypes.FeatureSource:
- ed = svc.OpenContent<FeatureSourceEditor>(ViewRegion.Document);
- break;
- case ResourceTypes.LayerDefinition:
- ed = svc.OpenContent<LayerDefinitionEditor>(ViewRegion.Document);
- break;
- case ResourceTypes.LoadProcedure:
- ed = svc.OpenContent<LoadProcedureEditor>(ViewRegion.Document);
- break;
- case ResourceTypes.MapDefinition:
- ed = svc.OpenContent<MapDefinitionEditor>(ViewRegion.Document);
- break;
- case ResourceTypes.PrintLayout:
- //ed = svc.OpenContent<PrintLayoutEditor>(ViewRegion.Document);
- break;
- case ResourceTypes.SymbolDefinition:
- //ed = svc.OpenContent<SymbolDefinitionEditor>(ViewRegion.Document);
- break;
- case ResourceTypes.SymbolLibrary:
- break;
- case ResourceTypes.WebLayout:
- //ed = svc.OpenContent<WebLayoutEditor>(ViewRegion.Document);
- break;
- default:
- ed = svc.OpenContent<XmlEditor>(ViewRegion.Document);
- break;
- }
+ //I LOVE ANONYMOUS DELEGATES!
+ ed = svc.OpenContent(ViewRegion.Document, () => { return fact.Create(); });
}
if (ed == null)
@@ -142,14 +143,5 @@
return ed;
}
-
- public void Open(RepositoryItem[] items, IServerConnection conn)
- {
- foreach (var item in items)
- {
- if (!item.IsFolder)
- Open(item, conn, false);
- }
- }
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Services/ViewContentManager.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/ViewContentManager.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Services/ViewContentManager.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -128,6 +128,11 @@
}
}
+ public T OpenContent<T>(ViewRegion region, CreateFunc<T> method) where T : IViewContent
+ {
+ return OpenContent<T>(null, null, region, method);
+ }
+
public T OpenContent<T>(ViewRegion region) where T : IViewContent
{
return OpenContent<T>(null, null, region);
@@ -135,6 +140,11 @@
public T OpenContent<T>(string title, string description, ViewRegion region) where T : IViewContent
{
+ return OpenContent<T>(title, description, region, () => { return (T)Activator.CreateInstance(typeof(T), true); });
+ }
+
+ public T OpenContent<T>(string title, string description, ViewRegion region, CreateFunc<T> method) where T : IViewContent
+ {
var type = typeof(T);
var wb = Workbench.Instance;
if (_singletonViewContentTypes.ContainsKey(type.Name))
@@ -149,7 +159,7 @@
}
}
- T obj = (T)Activator.CreateInstance(type, true);
+ T obj = method(); //(T)Activator.CreateInstance(type, true);
SingletonViewContent svc = obj as SingletonViewContent;
if (svc != null)
throw new InvalidOperationException(string.Format(Properties.Resources.Error_ViewContent_Not_Registered, type.Name));
@@ -160,4 +170,6 @@
return obj;
}
}
+
+ public delegate T CreateFunc<T>();
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/ApplicationDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/ApplicationDefinitionItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/ApplicationDefinitionItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using OSGeo.MapGuide.MaestroAPI.Resource;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.ApplicationDefinition.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateFlexibleLayout(conn);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/DrawingSourceItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/DrawingSourceItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/DrawingSourceItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.DrawingSource.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateDrawingSource(conn);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/FeatureSourceItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,10 @@
ResourceType = ResourceTypes.FeatureSource.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ string provider = "";
+ return ObjectFactory.CreateFeatureSource(conn, provider);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/ItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
using System.Drawing;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI;
namespace Maestro.Base.Templates
{
@@ -38,6 +40,6 @@
public Image Icon { get; protected set; }
- public abstract void CreateItem(IResourceService resSvc, string resourceID);
+ public abstract IResource CreateItem(IServerConnection conn);
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.LayerDefinition.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateLayerDefinition(conn);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/MapDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/MapDefinitionItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/MapDefinitionItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.MapDefinition.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateMapDefinition(conn);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/PrintLayoutItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/PrintLayoutItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/PrintLayoutItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.PrintLayout.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreatePrintLayout(conn);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/SdfLoadProcedureItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/SdfLoadProcedureItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/SdfLoadProcedureItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.LoadProcedure.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateLoadProcedure(conn);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/ShpLoadProcedureItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/ShpLoadProcedureItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/ShpLoadProcedureItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.LoadProcedure.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateLoadProcedure(conn);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/SymbolDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/SymbolDefinitionItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/SymbolDefinitionItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,23 +23,42 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
- public class SymbolDefinitionItemTemplate : ItemTemplate
+ public class SimpleSymbolDefinitionItemTemplate : ItemTemplate
{
- public SymbolDefinitionItemTemplate()
+ public SimpleSymbolDefinitionItemTemplate()
{
Category = Res.TPL_CATEGORY_DEFAULT;
Icon = Res.images_stack;
- Description = Res.TPL_SDF_DESC;
- Name = Res.TPL_SDF_NAME;
+ Description = Res.TPL_SSD_DESC;
+ Name = Res.TPL_SSD_NAME;
ResourceType = ResourceTypes.SymbolDefinition.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateSimpleSymbol(conn);
}
}
+
+ public class CompoundSymbolDefinitionItemTemplate : ItemTemplate
+ {
+ public CompoundSymbolDefinitionItemTemplate()
+ {
+ Category = Res.TPL_CATEGORY_DEFAULT;
+ Icon = Res.images_stack;
+ Description = Res.TPL_CSD_DESC;
+ Name = Res.TPL_CSD_NAME;
+ ResourceType = ResourceTypes.SymbolDefinition.ToString();
+ }
+
+ public override IResource CreateItem(IServerConnection conn)
+ {
+ return ObjectFactory.CreateCompoundSymbol(conn);
+ }
+ }
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/UserItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/UserItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/UserItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,14 +23,47 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using System.IO;
+using OSGeo.MapGuide.MaestroAPI.Resource;
namespace Maestro.Base.Templates
{
public class UserItemTemplate : ItemTemplate
{
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ private IResource _res;
+
+ public UserItemTemplate(string templatePath)
+ : this(Res.TPL_USER_DEFINED, templatePath)
+ { }
+
+ public UserItemTemplate(string description, string templatePath)
+ : this(Path.GetFileNameWithoutExtension(templatePath), description, templatePath)
+ { }
+
+ public string TemplatePath
{
- throw new NotImplementedException();
+ get;
+ private set;
}
+
+ public UserItemTemplate(string name, string description, string templatePath)
+ {
+ this.Description = description;
+
+ this.Category = Res.TPL_CATEGORY_DEFAULT;
+ this.Icon = Res.document;
+ this.Name = name;
+ this.TemplatePath = templatePath;
+
+ _res = ResourceTypeRegistry.Deserialize(File.ReadAllText(templatePath));
+ this.ResourceType = _res.ResourceType.ToString();
+ }
+
+ public override IResource CreateItem(IServerConnection conn)
+ {
+ IResource res = (IResource)_res.Clone();
+ res.CurrentConnection = conn;
+ return res;
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/Templates/WebLayoutItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/WebLayoutItemTemplate.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/WebLayoutItemTemplate.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -23,6 +23,8 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.MaestroAPI.Services;
using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace Maestro.Base.Templates
{
@@ -37,9 +39,9 @@
ResourceType = ResourceTypes.WebLayout.ToString();
}
- public override void CreateItem(IResourceService resSvc, string resourceID)
+ public override IResource CreateItem(IServerConnection conn)
{
- throw new NotImplementedException();
+ return ObjectFactory.CreateWebLayout(conn, string.Empty);
}
}
}
Modified: sandbox/maestro-3.0/Maestro.Base/UI/RepositoryTreeModel.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/UI/RepositoryTreeModel.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/UI/RepositoryTreeModel.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -30,61 +30,6 @@
namespace Maestro.Base.UI
{
/// <summary>
- /// Stub implementation
- /// </summary>
- internal class IRepositoryItemImpl : IRepositoryItem
- {
- private ResourceIdentifier _rid;
-
- public IRepositoryItemImpl(string resourceid)
- {
- this.ResourceId = resourceid;
- _rid = new ResourceIdentifier(resourceid);
- }
-
- public string Name
- {
- get { return _rid.Name; }
- }
-
- public string ResourceId
- {
- get;
- private set;
- }
-
- public ResourceTypes ResourceType
- {
- get { return _rid.ResourceType; }
- }
-
- public bool IsFolder
- {
- get { return _rid.IsFolder; }
- }
-
- public bool HasChildren
- {
- get { return false; }
- }
-
- public string Owner
- {
- get { return string.Empty; }
- }
-
- public DateTime CreatedDate
- {
- get { return DateTime.Now; }
- }
-
- public DateTime ModifiedDate
- {
- get { return DateTime.Now; }
- }
- }
-
- /// <summary>
/// Models an object in the repository
/// </summary>
public class RepositoryItem
@@ -235,7 +180,7 @@
var node = treePath.LastNode as RepositoryItem;
if (node != null && node.IsFolder) //Can't enumerate children of documents
{
- var list = _conn.ResourceService.GetRepositoryResources(node.ResourceId, 1);
+ var list = _conn.ResourceService.GetRepositoryResources(node.ResourceId, "", 1, false);
return GetSorted(list);
}
else
Modified: sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.Designer.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.Designer.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -64,6 +64,8 @@
this.trvResources.TabIndex = 2;
this.trvResources.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.trvResources_MouseDoubleClick);
this.trvResources.MouseClick += new System.Windows.Forms.MouseEventHandler(this.trvResources_MouseClick);
+ this.trvResources.Expanding += new System.EventHandler<Aga.Controls.Tree.TreeViewAdvEventArgs>(this.trvResources_Expanding);
+ this.trvResources.Expanded += new System.EventHandler<Aga.Controls.Tree.TreeViewAdvEventArgs>(this.trvResources_Expanded);
//
// rdResourceIcon
//
Modified: sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Base/UI/SiteExplorer.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -110,7 +110,7 @@
if (item != null && !item.IsFolder)
{
var resMgr = ServiceRegistry.GetService<OpenResourceManager>();
- resMgr.Open(item, _conn, false);
+ resMgr.Open(item.ResourceId, _conn, false);
}
}
}
@@ -174,5 +174,35 @@
return items.ToArray();
}
}
+
+ private void trvResources_Expanding(object sender, TreeViewAdvEventArgs e)
+ {
+ if (this.InvokeRequired)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.Cursor = Cursors.WaitCursor;
+ }));
+ }
+ else
+ {
+ this.Cursor = Cursors.WaitCursor;
+ }
+ }
+
+ private void trvResources_Expanded(object sender, TreeViewAdvEventArgs e)
+ {
+ if (this.InvokeRequired)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.Cursor = Cursors.Default;
+ }));
+ }
+ else
+ {
+ this.Cursor = Cursors.Default;
+ }
+ }
}
}
Modified: sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.Designer.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.Designer.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -68,8 +68,9 @@
this.trvFolders.SelectedNode = null;
this.trvFolders.Size = new System.Drawing.Size(168, 237);
this.trvFolders.TabIndex = 0;
- this.trvFolders.Text = "treeViewAdv1";
this.trvFolders.SelectionChanged += new System.EventHandler(this.trvFolders_SelectionChanged);
+ this.trvFolders.Expanding += new System.EventHandler<Aga.Controls.Tree.TreeViewAdvEventArgs>(this.trvFolders_Expanding);
+ this.trvFolders.Expanded += new System.EventHandler<Aga.Controls.Tree.TreeViewAdvEventArgs>(this.trvFolders_Expanded);
//
// nodeIcon1
//
Modified: sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -267,6 +267,36 @@
}
}
}
+
+ private void trvFolders_Expanding(object sender, TreeViewAdvEventArgs e)
+ {
+ if (this.InvokeRequired)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.Cursor = Cursors.WaitCursor;
+ }));
+ }
+ else
+ {
+ this.Cursor = Cursors.WaitCursor;
+ }
+ }
+
+ private void trvFolders_Expanded(object sender, TreeViewAdvEventArgs e)
+ {
+ if (this.InvokeRequired)
+ {
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.Cursor = Cursors.Default;
+ }));
+ }
+ else
+ {
+ this.Cursor = Cursors.Default;
+ }
+ }
}
internal class RepositoryFolder
@@ -341,7 +371,7 @@
var node = treePath.LastNode as RepositoryFolder;
if (node.HasChildren)
{
- var list = _resSvc.GetRepositoryResources(node.ResourceId, 1);
+ var list = _resSvc.GetRepositoryResources(node.ResourceId, ResourceTypes.Folder.ToString(), 1, true);
return GetSorted(list);
}
else
Modified: sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.resx 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/Maestro.Editors/Common/ResourcePicker.resx 2010-07-21 07:04:30 UTC (rev 5044)
@@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADQ
- EQAAAk1TRnQBSQFMAgEBCQEAAWABAAFgAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+ EQAAAk1TRnQBSQFMAgEBCQEAAWgBAAFoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.3053
+// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -61,6 +61,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to Bad Document: Expected attributes at the root level node.
+ /// </summary>
+ internal static string ERR_BAD_DOCUMENT_NO_ROOT_ATTRIBUTES {
+ get {
+ return ResourceManager.GetString("ERR_BAD_DOCUMENT_NO_ROOT_ATTRIBUTES", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Resource cannot be downgraded. It is already older than the version this converter can downgrade to.
/// </summary>
internal static string ERR_CANNOT_DOWNGRADE_OLDER_RESOURCE {
@@ -115,6 +124,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to Could not find matching serializer for this resource: .
+ /// </summary>
+ internal static string ERR_NO_SERIALIZER {
+ get {
+ return ResourceManager.GetString("ERR_NO_SERIALIZER", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to There is no upgrade path to the desired resource version.
/// </summary>
internal static string ERR_NO_UPGRADE_PATH {
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx 2010-07-21 07:04:30 UTC (rev 5044)
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="ERR_BAD_DOCUMENT_NO_ROOT_ATTRIBUTES" xml:space="preserve">
+ <value>Bad Document: Expected attributes at the root level node</value>
+ </data>
<data name="ERR_CANNOT_DOWNGRADE_OLDER_RESOURCE" xml:space="preserve">
<value>Resource cannot be downgraded. It is already older than the version this converter can downgrade to</value>
</data>
@@ -135,6 +138,9 @@
<data name="ERR_NO_DOWNGRADE_PATH" xml:space="preserve">
<value>There is no downgrade path to the desired resource version</value>
</data>
+ <data name="ERR_NO_SERIALIZER" xml:space="preserve">
+ <value>Could not find matching serializer for this resource: </value>
+ </data>
<data name="ERR_NO_UPGRADE_PATH" xml:space="preserve">
<value>There is no upgrade path to the desired resource version</value>
</data>
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/ResourceContentVersionChecker.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/ResourceContentVersionChecker.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/ResourceContentVersionChecker.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -47,17 +47,35 @@
}
/// <summary>
+ /// Alternate constructor
+ /// </summary>
+ /// <param name="xmlContent"></param>
+ public ResourceContentVersionChecker(string xmlContent)
+ {
+ _reader = new XmlTextReader(new StringReader(xmlContent));
+ }
+
+ private ResourceTypeDescriptor _rtd;
+
+ /// <summary>
/// Gets the resource content version
/// </summary>
/// <returns></returns>
- public Version GetVersion()
+ public ResourceTypeDescriptor GetVersion()
{
- Version v = new Version(1, 0, 0);
+ if (_rtd == null)
+ {
+ _reader.Read();
- //Inspect the stream up to the version attribute
- //Parse this attribute and return it
+ if (!_reader.HasAttributes)
+ throw new XmlException(Properties.Resources.ERR_BAD_DOCUMENT_NO_ROOT_ATTRIBUTES);
- return v;
+ ResourceTypes rt = (ResourceTypes)Enum.Parse(typeof(ResourceTypes), _reader.Name);
+ string version = _reader.GetAttribute("version");
+
+ _rtd = new ResourceTypeDescriptor(rt, version);
+ }
+ return _rtd;
}
/// <summary>
@@ -65,8 +83,11 @@
/// </summary>
public void Dispose()
{
- _reader.Close();
- _stream.Dispose();
+ if (_stream != null)
+ _stream.Dispose();
+
+ if (_reader != null)
+ _reader.Close();
}
}
}
Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs 2010-07-20 16:45:02 UTC (rev 5043)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs 2010-07-21 07:04:30 UTC (rev 5044)
@@ -185,7 +185,7 @@
{
xr.MoveToContent();
if (!xr.HasAttributes)
- throw new SerializationException("Bad Document: Expected attributes at the root level node");
+ throw new SerializationException();
//Resources post-1.0.0 have a version attribute, those without are assumed to be 1.0.0 version
try
@@ -222,9 +222,19 @@
{
var rd = res.GetResourceTypeDescriptor();
if (!_serializers.ContainsKey(rd))
- throw new SerializationException("Could not find matching serializer for this resource: " + rd.ToString()); //LOCALIZE
+ throw new SerializationException(Properties.Resources.ERR_NO_SERIALIZER + rd.ToString());
return _serializers[rd].Serialize(res);
}
+
+ public static IResource Deserialize(string xml)
+ {
+ var checker = new ResourceContentVersionChecker(xml);
+ var rd = checker.GetVersion();
+ if (!_serializers.ContainsKey(rd))
+ throw new SerializationException(Properties.Resources.ERR_NO_SERIALIZER + rd.ToString());
+
+ return _serializers[rd].Deserialize(xml);
+ }
}
}
More information about the mapguide-commits
mailing list