[mapguide-commits] r4903 - in sandbox/maestro-2.5: Maestro.Base Maestro.Base/Editor Maestro.Base/Services Maestro.Editors Maestro.Editors/Generic Maestro.Editors/Properties Maestro.Editors/Resources OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/ObjectModels OSGeo.MapGuide.MaestroAPI/Resource OSGeo.MapGuide.MaestroAPI.Http

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue May 18 03:11:54 EDT 2010


Author: jng
Date: 2010-05-18 03:11:52 -0400 (Tue, 18 May 2010)
New Revision: 4903

Added:
   sandbox/maestro-2.5/Maestro.Base/Editor/ResourceEditorService.cs
   sandbox/maestro-2.5/Maestro.Editors/IEditorService.cs
   sandbox/maestro-2.5/Maestro.Editors/Resources/folder-horizontal.png
Modified:
   sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj
   sandbox/maestro-2.5/Maestro.Base/Services/UrlLauncher.cs
   sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.Designer.cs
   sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.cs
   sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.resx
   sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj
   sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs
   sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/IResource.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/ResourceIdentifier.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
Log:
This submission includes the following changes:
 - Add a new property ValidatingSchema to IResource
 - Add a Serialize() method to IResource
 - Implement a generic resource document/folder picker.

Added: sandbox/maestro-2.5/Maestro.Base/Editor/ResourceEditorService.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/Editor/ResourceEditorService.cs	                        (rev 0)
+++ sandbox/maestro-2.5/Maestro.Base/Editor/ResourceEditorService.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -0,0 +1,101 @@
+#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 Maestro.Editors;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using Maestro.Base.Services;
+
+namespace Maestro.Base.Editor
+{
+    public class ResourceEditorService : IEditorService
+    {
+        private IResource _resource;
+        private IUrlLauncherService _launcher;
+
+        public ResourceEditorService(IResource res, bool isNew, IUrlLauncherService launcher)
+        {
+            this.IsNew = isNew;
+            _resource = res;
+            _launcher = launcher;
+            _resource.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnResourcePropertyChanged);
+        }
+
+        void OnResourcePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+            this.IsDirty = true;
+            var handler = this.DirtyStateChanged;
+            if (handler != null)
+            {
+                handler(this, EventArgs.Empty);
+            }
+        }
+
+        public event EventHandler DirtyStateChanged;
+
+        public string EditExpression(string currentExpr, OSGeo.MapGuide.MaestroAPI.FeatureSourceDescription.FeatureSourceSchema schema, string providerName, string featureSourceId)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool IsDirty
+        {
+            get;
+            private set;
+        }
+
+        public bool IsNew
+        {
+            get;
+            private set;
+        }
+
+        public void OpenUrl(string url)
+        {
+            _launcher.OpenUrl(url);
+        }
+
+        public IResource Resource
+        {
+            get { return _resource; }
+        }
+
+        public string[] SelectMultipleResources(OSGeo.MapGuide.MaestroAPI.ResourceTypes resType)
+        {
+            throw new NotImplementedException();
+        }
+
+        public string SelectResource(OSGeo.MapGuide.MaestroAPI.ResourceTypes[] resTypes)
+        {
+            throw new NotImplementedException();
+        }
+
+        public string SelectResource(OSGeo.MapGuide.MaestroAPI.ResourceTypes resType)
+        {
+            throw new NotImplementedException();
+        }
+
+        public string SelectUnmanagedData(string startPath, System.Collections.Specialized.NameValueCollection fileTypes)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

Modified: sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj	2010-05-18 07:11:52 UTC (rev 4903)
@@ -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>
@@ -31,10 +31,6 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Maestro.Editors, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Maestro.Editors\obj\Debug\Maestro.Editors.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
     <Reference Include="System.Drawing" />
@@ -64,6 +60,7 @@
     <Compile Include="Commands\Toggle\ToggleMessagesCommand.cs" />
     <Compile Include="Commands\ValidateResourceCommand.cs" />
     <Compile Include="Commands\XmlEditCommand.cs" />
+    <Compile Include="Editor\ResourceEditorService.cs" />
     <Compile Include="Editor\EditorContentBase.cs">
       <SubType>UserControl</SubType>
     </Compile>
@@ -258,6 +255,10 @@
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\Maestro.Editors\Maestro.Editors.csproj">
+      <Project>{5AD2CDBA-952E-4148-98A1-31D2E0D540D5}</Project>
+      <Name>Maestro.Editors</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Maestro.Login\Maestro.Login.csproj">
       <Project>{07588440-5F9F-4C30-AA06-9CF30BA6DDE6}</Project>
       <Name>Maestro.Login</Name>

Modified: sandbox/maestro-2.5/Maestro.Base/Services/UrlLauncher.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/Services/UrlLauncher.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Base/Services/UrlLauncher.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -27,8 +27,15 @@
 
 namespace Maestro.Base.Services
 {
-    public class UrlLauncher : ServiceBase
+    public interface IUrlLauncherService
     {
+        bool CanUseEmbeddedWebBrowser { get; }
+        void OpenUrl(string url);
+        void OpenUrlEmbedded(string url, bool locked);
+    }
+
+    public class UrlLauncher : ServiceBase, IUrlLauncherService
+    {
         public override void Initialize()
         {
             base.Initialize();

Modified: sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.Designer.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.Designer.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.Designer.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -28,49 +28,97 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ResourcePicker));
             this.trvFolders = new Aga.Controls.Tree.TreeViewAdv();
+            this.nodeIcon1 = new Aga.Controls.Tree.NodeControls.NodeIcon();
+            this.nodeTextBox1 = new Aga.Controls.Tree.NodeControls.NodeTextBox();
             this.lstResources = new System.Windows.Forms.ListView();
+            this.resImageList = new System.Windows.Forms.ImageList(this.components);
             this.btnOK = new System.Windows.Forms.Button();
             this.btnCancel = new System.Windows.Forms.Button();
             this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
+            this.lblFilter = new System.Windows.Forms.Label();
             this.txtResourceId = new System.Windows.Forms.TextBox();
-            this.comboBox1 = new System.Windows.Forms.ComboBox();
+            this.cmbResourceFilter = new System.Windows.Forms.ComboBox();
             this.label3 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+            this.splitContainer1.Panel1.SuspendLayout();
+            this.splitContainer1.Panel2.SuspendLayout();
+            this.splitContainer1.SuspendLayout();
             this.SuspendLayout();
             // 
             // trvFolders
             // 
-            this.trvFolders.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-                        | System.Windows.Forms.AnchorStyles.Left)));
+            this.trvFolders.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+                        | System.Windows.Forms.AnchorStyles.Left)
+                        | System.Windows.Forms.AnchorStyles.Right)));
             this.trvFolders.BackColor = System.Drawing.SystemColors.Window;
             this.trvFolders.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
             this.trvFolders.DefaultToolTipProvider = null;
             this.trvFolders.DragDropMarkColor = System.Drawing.Color.Black;
             this.trvFolders.LineColor = System.Drawing.SystemColors.ControlDark;
-            this.trvFolders.Location = new System.Drawing.Point(12, 27);
+            this.trvFolders.LoadOnDemand = true;
+            this.trvFolders.Location = new System.Drawing.Point(12, 31);
             this.trvFolders.Model = null;
             this.trvFolders.Name = "trvFolders";
+            this.trvFolders.NodeControls.Add(this.nodeIcon1);
+            this.trvFolders.NodeControls.Add(this.nodeTextBox1);
             this.trvFolders.SelectedNode = null;
-            this.trvFolders.Size = new System.Drawing.Size(180, 257);
+            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);
             // 
+            // nodeIcon1
+            // 
+            this.nodeIcon1.DataPropertyName = "Icon";
+            this.nodeIcon1.LeftMargin = 1;
+            this.nodeIcon1.ParentColumn = null;
+            this.nodeIcon1.ScaleMode = Aga.Controls.Tree.ImageScaleMode.Clip;
+            // 
+            // nodeTextBox1
+            // 
+            this.nodeTextBox1.DataPropertyName = "Name";
+            this.nodeTextBox1.IncrementalSearchEnabled = true;
+            this.nodeTextBox1.LeftMargin = 3;
+            this.nodeTextBox1.ParentColumn = null;
+            // 
             // lstResources
             // 
             this.lstResources.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                         | System.Windows.Forms.AnchorStyles.Left)
                         | System.Windows.Forms.AnchorStyles.Right)));
-            this.lstResources.Location = new System.Drawing.Point(198, 27);
+            this.lstResources.LargeImageList = this.resImageList;
+            this.lstResources.Location = new System.Drawing.Point(3, 31);
+            this.lstResources.MultiSelect = false;
             this.lstResources.Name = "lstResources";
-            this.lstResources.Size = new System.Drawing.Size(340, 257);
+            this.lstResources.Size = new System.Drawing.Size(348, 237);
+            this.lstResources.SmallImageList = this.resImageList;
             this.lstResources.TabIndex = 1;
             this.lstResources.UseCompatibleStateImageBehavior = false;
+            this.lstResources.View = System.Windows.Forms.View.List;
+            this.lstResources.SelectedIndexChanged += new System.EventHandler(this.lstResources_SelectedIndexChanged);
             // 
+            // resImageList
+            // 
+            this.resImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("resImageList.ImageStream")));
+            this.resImageList.TransparentColor = System.Drawing.Color.Transparent;
+            this.resImageList.Images.SetKeyName(0, "document.png");
+            this.resImageList.Images.SetKeyName(1, "database-share.png");
+            this.resImageList.Images.SetKeyName(2, "layer.png");
+            this.resImageList.Images.SetKeyName(3, "map.png");
+            this.resImageList.Images.SetKeyName(4, "application-browser.png");
+            this.resImageList.Images.SetKeyName(5, "images-stack.png");
+            this.resImageList.Images.SetKeyName(6, "printer.png");
+            this.resImageList.Images.SetKeyName(7, "blueprints.png");
+            this.resImageList.Images.SetKeyName(8, "applications-stack.png");
+            // 
             // btnOK
             // 
             this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.btnOK.Enabled = false;
             this.btnOK.Location = new System.Drawing.Point(382, 317);
             this.btnOK.Name = "btnOK";
             this.btnOK.Size = new System.Drawing.Size(75, 23);
@@ -101,15 +149,15 @@
             this.label1.TabIndex = 4;
             this.label1.Text = "Resource ID";
             // 
-            // label2
+            // lblFilter
             // 
-            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
-            this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(12, 317);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(29, 13);
-            this.label2.TabIndex = 5;
-            this.label2.Text = "Filter";
+            this.lblFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.lblFilter.AutoSize = true;
+            this.lblFilter.Location = new System.Drawing.Point(12, 317);
+            this.lblFilter.Name = "lblFilter";
+            this.lblFilter.Size = new System.Drawing.Size(29, 13);
+            this.lblFilter.TabIndex = 5;
+            this.lblFilter.Text = "Filter";
             // 
             // txtResourceId
             // 
@@ -117,23 +165,25 @@
                         | System.Windows.Forms.AnchorStyles.Right)));
             this.txtResourceId.Location = new System.Drawing.Point(85, 288);
             this.txtResourceId.Name = "txtResourceId";
+            this.txtResourceId.ReadOnly = true;
             this.txtResourceId.Size = new System.Drawing.Size(453, 20);
             this.txtResourceId.TabIndex = 6;
             // 
-            // comboBox1
+            // cmbResourceFilter
             // 
-            this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+            this.cmbResourceFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                         | System.Windows.Forms.AnchorStyles.Right)));
-            this.comboBox1.FormattingEnabled = true;
-            this.comboBox1.Location = new System.Drawing.Point(85, 314);
-            this.comboBox1.Name = "comboBox1";
-            this.comboBox1.Size = new System.Drawing.Size(255, 21);
-            this.comboBox1.TabIndex = 7;
+            this.cmbResourceFilter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.cmbResourceFilter.FormattingEnabled = true;
+            this.cmbResourceFilter.Location = new System.Drawing.Point(85, 314);
+            this.cmbResourceFilter.Name = "cmbResourceFilter";
+            this.cmbResourceFilter.Size = new System.Drawing.Size(255, 21);
+            this.cmbResourceFilter.TabIndex = 7;
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(12, 9);
+            this.label3.Location = new System.Drawing.Point(9, 9);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(41, 13);
             this.label3.TabIndex = 8;
@@ -142,12 +192,31 @@
             // label4
             // 
             this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(198, 8);
+            this.label4.Location = new System.Drawing.Point(3, 9);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(98, 13);
             this.label4.TabIndex = 9;
             this.label4.Text = "Resources in folder";
             // 
+            // splitContainer1
+            // 
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Top;
+            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer1.Name = "splitContainer1";
+            // 
+            // splitContainer1.Panel1
+            // 
+            this.splitContainer1.Panel1.Controls.Add(this.label3);
+            this.splitContainer1.Panel1.Controls.Add(this.trvFolders);
+            // 
+            // splitContainer1.Panel2
+            // 
+            this.splitContainer1.Panel2.Controls.Add(this.lstResources);
+            this.splitContainer1.Panel2.Controls.Add(this.label4);
+            this.splitContainer1.Size = new System.Drawing.Size(550, 282);
+            this.splitContainer1.SplitterDistance = 183;
+            this.splitContainer1.TabIndex = 10;
+            // 
             // ResourcePicker
             // 
             this.AcceptButton = this.btnOK;
@@ -156,19 +225,21 @@
             this.CancelButton = this.btnCancel;
             this.ClientSize = new System.Drawing.Size(550, 352);
             this.ControlBox = false;
-            this.Controls.Add(this.label4);
-            this.Controls.Add(this.label3);
-            this.Controls.Add(this.comboBox1);
+            this.Controls.Add(this.splitContainer1);
+            this.Controls.Add(this.cmbResourceFilter);
             this.Controls.Add(this.txtResourceId);
-            this.Controls.Add(this.label2);
+            this.Controls.Add(this.lblFilter);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.btnCancel);
             this.Controls.Add(this.btnOK);
-            this.Controls.Add(this.lstResources);
-            this.Controls.Add(this.trvFolders);
             this.Name = "ResourcePicker";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
             this.Text = "Select Resource";
+            this.splitContainer1.Panel1.ResumeLayout(false);
+            this.splitContainer1.Panel1.PerformLayout();
+            this.splitContainer1.Panel2.ResumeLayout(false);
+            this.splitContainer1.Panel2.PerformLayout();
+            this.splitContainer1.ResumeLayout(false);
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -181,10 +252,14 @@
         private System.Windows.Forms.Button btnOK;
         private System.Windows.Forms.Button btnCancel;
         private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label lblFilter;
         private System.Windows.Forms.TextBox txtResourceId;
-        private System.Windows.Forms.ComboBox comboBox1;
+        private System.Windows.Forms.ComboBox cmbResourceFilter;
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Label label4;
+        private Aga.Controls.Tree.NodeControls.NodeIcon nodeIcon1;
+        private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBox1;
+        private System.Windows.Forms.ImageList resImageList;
+        private System.Windows.Forms.SplitContainer splitContainer1;
     }
 }
\ No newline at end of file

Modified: sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -24,22 +24,136 @@
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
+using Aga.Controls.Tree;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.ObjectModels.Common;
+using System.Security.AccessControl;
+using OSGeo.MapGuide.MaestroAPI.Resource;
 
 namespace Maestro.Editors.Generic
 {
+    /// <summary>
+    /// A generic dialog for selecting folders or resource documents
+    /// </summary>
     public partial class ResourcePicker : Form
     {
-        public ResourcePicker()
+        const int RES_UNKNOWN = 0;
+        const int RES_FEATURESOURCE = 1;
+        const int RES_LAYERDEFINITION = 2;
+        const int RES_MAPDEFINITION = 3;
+        const int RES_WEBLAYOUT = 4;
+        const int RES_SYMBOLLIBRARY = 5;
+        const int RES_PRINTLAYOUT = 6;
+        const int RES_DRAWINGSOURCE = 7;
+        const int RES_APPLICATIONDEFINITION = 8;
+
+        private ResourceTypes[] _resTypes;
+
+        private ResourcePicker()
         {
             InitializeComponent();
+            _resTypes = new ResourceTypes[] 
+            {
+                ResourceTypes.ApplicationDefinition,
+                ResourceTypes.DrawingSource,
+                ResourceTypes.FeatureSource,
+                ResourceTypes.Folder,
+                ResourceTypes.LayerDefinition,
+                ResourceTypes.LoadProcedure,
+                ResourceTypes.MapDefinition,
+                ResourceTypes.PrintLayout,
+                ResourceTypes.SymbolDefinition,
+                ResourceTypes.SymbolLibrary,
+                ResourceTypes.WebLayout
+            };
+            cmbResourceFilter.DataSource = _resTypes;
         }
 
+        private IResourceService _resSvc;
+
+        private bool _resourceMode = false;
+
+        /// <summary>
+        /// Constructs a new instance. Use this overload to select any resource type. If only
+        /// folder selection is desired, set <see cref="SelectFoldersOnly"/> to true before
+        /// showing the dialog
+        /// </summary>
+        /// <param name="resSvc"></param>
+        public ResourcePicker(IResourceService resSvc)
+            : this()
+        {
+            _resSvc = resSvc;
+            trvFolders.Model = new RepositoryFolderTreeModel(_resSvc);
+            this.UseFilter = false;
+        }
+
+        /// <summary>
+        /// Constructs a new instance. Use this overload to select only resources of a specific type.
+        /// You cannot select folders in this mode. Attempting to set <see cref="SelectFoldersOnly"/> to
+        /// true will throw an <see cref="InvalidOperationException"/>
+        /// </summary>
+        /// <param name="resSvc"></param>
+        /// <param name="resFilter"></param>
+        public ResourcePicker(IResourceService resSvc, ResourceTypes resFilter)
+            : this(resSvc)
+        {
+            this.Filter = resFilter;
+            this.UseFilter = true;
+
+            _resourceMode = true;
+            cmbResourceFilter.Enabled = false;
+        }
+
+        /// <summary>
+        /// Gets or sets the resource filter. If a filter value is specified, browsing
+        /// is locked to that particular resource type, otherwise al 
+        /// </summary>
+        public ResourceTypes Filter
+        {
+            get { return (ResourceTypes)cmbResourceFilter.SelectedItem; }
+            set
+            {
+                if (Array.IndexOf<ResourceTypes>(_resTypes, value) < 0)
+                    throw new InvalidOperationException("Cannot use specified resource type as filter: " + value); //LOCALIZE
+
+                cmbResourceFilter.SelectedItem = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets whether to use a resource filter. If set to false, when selecting a folder
+        /// all resource types are returned, otherwise only children of the specified type are returned
+        /// </summary>
+        internal bool UseFilter
+        {
+            get { return cmbResourceFilter.Visible; }
+            set 
+            {
+                if (value && this.SelectFoldersOnly)
+                    throw new InvalidOperationException("Cannot specify a filter when SelectFoldersOnly is true"); //LOCALIZE
+                cmbResourceFilter.Visible = value; lblFilter.Visible = value; 
+            }
+        }
+        
+        /// <summary>
+        /// Gets or sets whether to select folders only. If true, the document view is disabled.
+        /// </summary>
         public bool SelectFoldersOnly
         {
-            get { return !lstResources.Enabled; }
-            set { lstResources.Enabled = !value; }
+            get { return splitContainer1.Panel2Collapsed; }
+            set 
+            {
+                if (_resourceMode && value)
+                    throw new InvalidOperationException("Cannot specify to select folders when dialog is initialized with a resource filter"); //LOCALIZE
+
+                splitContainer1.Panel2Collapsed = value;
+            }
         }
 
+        /// <summary>
+        /// Gets the resource id of the selected item
+        /// </summary>
         public string ResourceID
         {
             get { return txtResourceId.Text; }
@@ -54,5 +168,182 @@
         {
             this.DialogResult = DialogResult.OK;
         }
+
+        private void trvFolders_SelectionChanged(object sender, EventArgs e)
+        {
+            var node = trvFolders.SelectedNode;
+            if (node != null)
+            {
+                RepositoryFolder folder = node.Tag as RepositoryFolder;
+                btnOK.Enabled = false;
+                if (this.SelectFoldersOnly)
+                {
+                    txtResourceId.Text = folder.ResourceId;
+                    btnOK.Enabled = true;
+                }
+                else
+                {
+                    ResourceList list = null;
+                    if (!this.UseFilter)
+                        list = _resSvc.GetRepositoryResources(folder.ResourceId, 1);
+                    else
+                        list = _resSvc.GetRepositoryResources(folder.ResourceId, this.Filter.ToString(), 1);
+
+                    PopulateDocumentList(list);
+                }
+            }
+        }
+
+        private void PopulateDocumentList(ResourceList list)
+        {
+            lstResources.Clear();
+            foreach (var item in list.Items)
+            {
+                var doc = item as ResourceListResourceDocument;
+                if (doc != null)
+                {
+                    var li = new ListViewItem(doc.Name);
+                    li.Tag = doc;
+
+                    try
+                    {
+                        var rt = ResourceIdentifier.GetResourceType(doc.ResourceId);
+                        switch (rt)
+                        {
+                            case ResourceTypes.ApplicationDefinition:
+                                li.ImageIndex = RES_APPLICATIONDEFINITION;
+                                break;
+                            case ResourceTypes.DrawingSource:
+                                li.ImageIndex = RES_DRAWINGSOURCE;
+                                break;
+                            case ResourceTypes.FeatureSource:
+                                li.ImageIndex = RES_FEATURESOURCE;
+                                break;
+                            case ResourceTypes.LayerDefinition:
+                                li.ImageIndex = RES_LAYERDEFINITION;
+                                break;
+                            case ResourceTypes.MapDefinition:
+                                li.ImageIndex = RES_MAPDEFINITION;
+                                break;
+                            case ResourceTypes .PrintLayout:
+                                li.ImageIndex = RES_PRINTLAYOUT;
+                                break;
+                            case ResourceTypes.SymbolLibrary:
+                                li.ImageIndex = RES_SYMBOLLIBRARY;
+                                break;
+                            case ResourceTypes.WebLayout:
+                                li.ImageIndex = RES_WEBLAYOUT;
+                                break;
+                            default:
+                                li.ImageIndex = RES_UNKNOWN;
+                                break;
+                        }
+                    }
+                    catch
+                    {
+                        li.ImageIndex = RES_UNKNOWN;
+                    }
+
+                    lstResources.Items.Add(li);
+                }
+            }
+        }
+
+        private void lstResources_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            btnOK.Enabled = false;
+            if (lstResources.SelectedItems.Count == 1)
+            {
+                var item = lstResources.SelectedItems[0];
+                var doc = item.Tag as ResourceListResourceDocument;
+                if (doc != null)
+                {
+                    txtResourceId.Text = doc.ResourceId;
+                    btnOK.Enabled = true;
+                }
+            }
+        }
     }
+
+    internal class RepositoryFolder
+    {
+        private IRepositoryItem _item;
+
+        public RepositoryFolder(IRepositoryItem item)
+        {
+            _item = item;
+        }
+
+        public string Name { get { return _item.Name; } }
+
+        public string ResourceId { get { return _item.ResourceId; } }
+
+        public bool HasChildren { get { return _item.HasChildren; } }
+
+        public Image Icon
+        {
+            get { return Properties.Resources.folder_horizontal; }
+        }
+    }
+
+    internal class RepositoryFolderTreeModel : ITreeModel
+    {
+        private IResourceService _resSvc;
+
+        public RepositoryFolderTreeModel(IResourceService resSvc)
+        {
+            _resSvc = resSvc;
+        }
+
+        private System.Collections.IEnumerable GetSorted(ResourceList list)
+        {
+            //Sort them before returning them
+            SortedList<string, RepositoryFolder> folders = new SortedList<string, RepositoryFolder>();
+            foreach (var item in list.Children)
+            {
+                if (item.IsFolder)
+                    folders.Add(item.Name, new RepositoryFolder(item));
+            }
+            foreach (var folder in folders.Values)
+            {
+                yield return folder;
+            }
+        }
+
+        public System.Collections.IEnumerable GetChildren(TreePath treePath)
+        {
+            if (treePath.IsEmpty())
+            {
+                var list = _resSvc.GetRepositoryResources("Library://", ResourceTypes.Folder.ToString(), 1);
+                return GetSorted(list);
+            }
+            else
+            {
+                var node = treePath.LastNode as RepositoryFolder;
+                if (node.HasChildren)
+                {
+                    var list = _resSvc.GetRepositoryResources(node.ResourceId, 1);
+                    return GetSorted(list);
+                }
+                else
+                {
+                    return new RepositoryFolder[0];
+                }
+            }
+        }
+
+        public bool IsLeaf(TreePath treePath)
+        {
+            return !((RepositoryFolder)treePath.LastNode).HasChildren;
+        }
+
+        public event EventHandler<TreeModelEventArgs> NodesChanged;
+
+        public event EventHandler<TreeModelEventArgs> NodesInserted;
+
+        public event EventHandler<TreeModelEventArgs> NodesRemoved;
+
+        public event EventHandler<TreePathEventArgs> StructureChanged;
+    }
+
 }

Modified: sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.resx
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.resx	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Editors/Generic/ResourcePicker.resx	2010-05-18 07:11:52 UTC (rev 4903)
@@ -117,4 +117,91 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="resImageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <data name="resImageList.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
+    <value>
+        AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
+        LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
+        ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADQ
+        EQAAAk1TRnQBSQFMAgEBCQEAAVgBAAFYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+        AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
+        AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
+        AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
+        AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
+        AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
+        AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
+        ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
+        AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
+        AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
+        AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
+        AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
+        AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
+        AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
+        AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
+        AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
+        ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
+        Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
+        AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
+        AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
+        AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
+        ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
+        Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
+        AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
+        AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
+        AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
+        AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
+        AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
+        AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wEAAfAIBwG8Af81AAG8
+        CPMBvAH/NQAB8AH0BvMB9AHwNgAB8AH/BvQB/wG8A/8zAAHxCP8BkgIHAfAzAAHwAgcD7wL3AZIB7ALz
+        AbwzAAHxAfAB8QHwAbwBBwO8Ae8B8wH0AfAzAAH0AfIB8QXvAQcB8gH0Af8BvAP/MwAB8Qj/AZICBwHw
+        MwAB8AIHA+8C9wGSAewC8wG8MwAB8QHwAfEB8AG8AQcDvAHvAfMB9AHwMwAB9AHyAfEF7wEHAfIB9AH/
+        AfA2AAHxCP8B8TYAAfACBwPvAvcBkgG8NgAB8QHwAfEB8AG8AQcDvAHxNgAB9AHyBvEB8gH0QAAM/wcA
+        AbwIBwG8AwAB9AG1CLQBtQH0BAAQ/wG8CgcBvAQAA/8BBwj/AQcE/wG0AdwBGQTbAQkB3AG0Af8EAAG8
+        Au8MrgG1AbwB/wj0Af8BBwL/AgABBwPvAfIBswEJAbsCbAGLAfID7wEHAQABtAIZAQkBGQIJARkBCQG0
+        Bf8BBwHzAfIBiwmzAdUBrQGRAbwB9AQqATABNwEwASoB9AHsAQcBvAIAAwcK6gMHAQABtAHbAgkB2wEJ
+        AdsBCQHbAa0DtAG1AfQBvAHzAfIBiwHbBrMBtALbAbMBtAG8AfQFMQFYATcBMQH0AfcB/wEHAv8BvAEH
+        Ae8BbQLtBuwB6wIHAbwBAAG0AdsBCQHbAdwB2wIJAdsBswHbAQkB3AG0AQABvAHzAfICtAOzArQBugG0
+        AbMB3AHbAbQBvAH/AREBFQFLAVEBeQGgAeUBWAH/AbQB9AHsAQcBvAHwAQcB9wEQCBIBEAGSAe8B8AEA
+        AbQB2wEZAtsB3AHbAQkB2wGzAQkBGQEJAbQBAAG8AfQB8wEJAbMBtAG6AQkBuwG6AQkBGQG6AQkB4QG0
+        AfAB/wFEAUsCWAFZAeUBWQFYAf8BtAH0AfcB/wG8AfEB8AEHAUMBEgcUAUMB5AEHAfEBAAG0AdsCCQPb
+        AQkB2wGzAdsBCQHbAbQBAAHwAfQC8wG0AboBuwIZAgkEGQG0AfAB/wFSB1gB/wHvAf8BSgH0AbwB8wK8
+        ARQBbQIUBBUCFAHvAQcB8wEAAboB2wEZAdsB3ALbAQkB2wGzAgkB2wG0AQAB8AP0AfIBtAG7AQkBGQIJ
+        ARkC4gHcAbsB8AH/CDEB/wEHAf8BUQH0AbwB9AG8AfEB6gHrAW0B6gESARQBFQFDARMB6gIHAfQBAAG6
+        AdsCCQHbAdwB2wEJAdsBswHbAQkB2wG0AQAB8AT/AfMCugMJAhkB2wG6AvAK/wG7Af8BUQH/AbwB/wHw
+        AfMBbQjsAW0B8gHwAf8BAAG6AdsBCQHbAQkB2wOzAa0B2wEJAdsBtAEAAfAG/wEZAtsB1ALbARkB/wHw
+        AfMB8QHvAbwCswG0AbMDtAG7Af8BUQH/AfAB/wHyAfEB9wjrAfcB8QHyAf8BAAG6AQkBGQMJAbQB/wK0
+        AdsBCQHbAboBAAHxDv8B8QIAAfAK/wFRAf8B8AMAAfAB/wL0AvMC8QH0AfAEAALbAQkD2wO0AdwB2wEJ
+        AdsBugEAAfADBwbvA/cCkgG8AgAB8wHxAe8BvAhRAf8B8AMAAfAB/wH0AvMB8QP3AbwEAAEJA9sC1AHV
+        AbQBCQHbA7MBtAEAAfEB8ALxAvACvAIHBbwB8QQAAfAK/wHwAwAB8AH/AvMC8QHvAf8B8AH/CAABugEJ
+        ARkDCQG0Af8B8AH0AQAB9AHyDPEB8gH0BAAB8wrxAfMDAAHxAf8E9AEHAfEB9AkAAtsBCQPbAbQB8AH0
+        JQAB8wbyAfQKAAEJBtsB9AMAAf8B9AG8CgcBvAH0Af8F9AHzAfABHANuARwB8iL/AQAC/wEHCv8BBwL/
+        AhEB7wEHAfABHAFzAXQDmgJ0AZkB8wEAAf8B8wy8AfMB/wG8DQcBvAMAAbwK/wG8AgACZgHyAQcBcwF0
+        AXkCdAJLAXQBmQJ0ARsBAAHxAfAK8gHwAfEBAAEHAf8L9AH/AQcDAAG8CP8B9AH/AbwCAAFmARUB8QGS
+        AZoEdAKaAUsBdAKaAZkBAAHwDPIB8AEAAbwB9AZzAngBHAKZAfQBvAMAAbwH/wL0Af8BvAIAARIBZgHz
+        AfcFmgF0AUsBcwEcAnQBGgEAAfAM8gHwAQABvAH0AXMBHAF4AXMCeAGZARwBnwHDAQgB9AG8AwABvAb/
+        A/QB/wG8AgABrgHqAf8B7wOaAZkBdAFzAZIB7wEHAfABvAIAAfEM8gHxAQABvAH0AXMBHAF4AXMBeAKZ
+        AZgBnwEbAQcB9AG8AwABvAX/BPQB/wG8AgAC6gLxA3QBkwG8AQcB7wEHAbwB8QHwAgAB8QHzC/IB8QEA
+        AbwB9ANzA3gBmAKZAQgBuwH0AbwDAAG8BP8G9AG8BgAB9AHvApIE7AHtAe8B9AIAAfEB8wvyAfEBAAG8
+        Af8BcwN4ApkBnwGZARsBGQG7Af8BvAMAAfAD/wX0AfMB9AHwBgAB8QHyAbwBBwHvAvcB7wG8AfEB8AIA
+        AfED8wnyAfEBAAG8Af8BcwN4ApkBnwGZAfEB3AG6Af8BvAMAAfAC/wX0AvMB9AHwBgAB8QHyAbwBBwHv
+        AvcB7wG8AfIB8AIAAfIG8wfyAQAB8AH/AXMBeAGZAXgBmQGfAcMBCAEJAdwBugH/AfADAAHwAf8F9ALz
+        AfEB9AHwBgAB8QHzAfEB8AG8AgcBvAHwAfMB8AIAAfIB9ArzAfQB8gEAAfAB/wN4A5kBCAK7AroB/wHw
+        AwAB8AH/BPQC8wLxAfQB8AYAAfQB7wKSBOwB7QHvAfQCAAHyAfQK8wH0AfIBAAHwAf8BeAOZAcMBGwHx
+        AbsC3AG6Af8B8AMAAfAB/wP0AvMB8QP3AbwGAAHxAfIBvAEHAe8C9wEHAbwB8gHwAgAB8gH0CvMB9AHy
+        AQAB8AH/AXgDmQHDAcIBCQG6AdwB2wG6Af8B8AMAAfAB/wL0AvMC8QHvAf8B8AH0BgAB8QHyAbwBBwHv
+        AvcBBwG8AfMB8AIAAfMB8gr0AfIB8wEAAfAB/wF4AZgCmQEIArsDugG0Af8B8AMAAfEC/wX0AQcB8QH0
+        BwAB8QHzAfEB8AG8AgcBvAHwAfMB8AIAAf8B8wryAfMB/wEAAfEN/wHxAwAB8wjyAfQIAAHyCfEB8hEA
+        AfMN8gHzAQABQgFNAT4HAAE+AwABKAMAAUADAAEwAwABAQEAAQEFAAGAAQEWAAP/AgABHwcAAR8HAAE/
+        BwABBwcAAQcHAAEHBwABBw4AAeAHAAHgBwAB4AcAAeAHAAH8BwAB/AcAAfwHAAH8BwAC/wEAAQ8B4AEH
+        AQABDwMAAQ8DAAEPAwABAwIAAYAEAAEDAgABgAcAAYABAQYAAYABAQYAAYABAQYAAYABAQYAAYABAQYA
+        AYABAQYAAYABAQIAAcABAAHgAQcBgAEBAgABwAEAAeABBwGAAQECAAHwAQAB4AEHAfgBAQIAAfABAAHg
+        AQ8B+AEDBP8B4AEfAfgBBwcAAQEDAAEBAwABAQHAAQMCAAGAAQEBAAEBAcABAwIAAYABAQEAAQEBwAED
+        AgABgAEBAQABAQHAAQMBAAEBAYABAQEAAQEBwAEDAQABAQGAAQEBAAEBAcABAwHwAQEBgAEBAQABAQHA
+        AQMB8AEBAYABAQEAAQEBwAEDAfABAQGAAQEBAAEBAcABAwHwAQEBgAEBAQABAQHAAQMB8AEBAYABAQEA
+        AQEBwAEDAfABAQGAAQEBAAEBAcABAwHwAQEBgAEBAQABAQHAAQcB8AEBAYABAQEAAQEBwAEPAfABAQL/
+        AQABAQs=
+</value>
+  </data>
 </root>
\ No newline at end of file

Added: sandbox/maestro-2.5/Maestro.Editors/IEditorService.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/IEditorService.cs	                        (rev 0)
+++ sandbox/maestro-2.5/Maestro.Editors/IEditorService.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -0,0 +1,51 @@
+#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;
+using System.Collections.Specialized;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+
+namespace Maestro.Editors
+{
+    public interface IEditorService
+    {
+        string SelectResource(ResourceTypes resType);
+
+        string SelectResource(ResourceTypes[] resTypes);
+
+        string[] SelectMultipleResources(ResourceTypes resType);
+
+        string SelectUnmanagedData(string startPath, NameValueCollection fileTypes);
+
+        string EditExpression(string currentExpr, FeatureSourceDescription.FeatureSourceSchema schema, string providerName, string featureSourceId);
+
+        IResource Resource { get; }
+
+        void OpenUrl(string url);
+
+        bool IsNew { get; }
+
+        bool IsDirty { get; }
+
+        event EventHandler DirtyStateChanged;
+    }
+}

Modified: sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj	2010-05-18 07:11:52 UTC (rev 4903)
@@ -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>{5AD2CDBA-952E-4148-98A1-31D2E0D540D5}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -173,6 +173,7 @@
     <Compile Include="Generic\XmlEditorCtrl.Designer.cs">
       <DependentUpon>XmlEditorCtrl.cs</DependentUpon>
     </Compile>
+    <Compile Include="IEditorService.cs" />
     <Compile Include="LayerDefinition\LayerPropertiesSectionCtrl.cs">
       <SubType>UserControl</SubType>
     </Compile>
@@ -680,6 +681,9 @@
     <None Include="Resources\document--pencil.png" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="Resources\folder-horizontal.png" />
+  </ItemGroup>
+  <ItemGroup>
     <Folder Include="DrawingSource\Preview\" />
     <Folder Include="LayerDefinition\Drawing\" />
     <Folder Include="LayerDefinition\Geometry\" />

Modified: sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -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.
@@ -221,6 +221,13 @@
             }
         }
         
+        internal static System.Drawing.Bitmap folder_horizontal {
+            get {
+                object obj = ResourceManager.GetObject("folder_horizontal", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         internal static System.Drawing.Bitmap function {
             get {
                 object obj = ResourceManager.GetObject("function", resourceCulture);

Modified: sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx	2010-05-18 07:11:52 UTC (rev 4903)
@@ -246,4 +246,7 @@
   <data name="TransparentName" xml:space="preserve">
     <value>Transparent</value>
   </data>
+  <data name="folder_horizontal" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\folder-horizontal.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>
\ No newline at end of file

Added: sandbox/maestro-2.5/Maestro.Editors/Resources/folder-horizontal.png
===================================================================
(Binary files differ)


Property changes on: sandbox/maestro-2.5/Maestro.Editors/Resources/folder-horizontal.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "ApplicationDefinition-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "DrawingSource-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "FeatureSource-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "LayerDefinition-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "LoadProcedure-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -84,6 +84,8 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "MapDefinition-1.0.0.xsd"; } }
     }
 
     partial class MapLayerType

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "PrintLayout-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -35,6 +35,8 @@
 
         bool IsFolder { get; }
 
+        bool HasChildren { get; }
+
         string Owner { get; }
 
         DateTime CreatedDate { get; }
@@ -66,6 +68,9 @@
         }
 
         [XmlIgnore]
+        public bool HasChildren { get { return false; } } //Documents don't have child resources
+
+        [XmlIgnore]
         public string ResourceType { get { return ResourceIdentifier.GetExtension(this.ResourceId); } }
 
         [XmlIgnore]
@@ -81,6 +86,9 @@
         }
 
         [XmlIgnore]
+        public bool HasChildren { get { return int.Parse(this.NumberOfDocuments) > 0 || int.Parse(this.NumberOfFolders) > 0; } }
+
+        [XmlIgnore]
         public string ResourceType { get { return "Folder"; } }
 
         [XmlIgnore]

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "SymbolDefinition-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "SymbolLibrary-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -82,5 +82,7 @@
         {
             return this.Clone();
         }
+
+        public string ValidatingSchema { get { return "WebLayout-1.0.0.xsd"; } }
     }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/IResource.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/IResource.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/IResource.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -21,15 +21,30 @@
 using System.Collections.Generic;
 using System.Text;
 using System.Xml.Serialization;
+using System.IO;
+using System.ComponentModel;
 
 namespace OSGeo.MapGuide.MaestroAPI.Resource
 {
-    public interface IResource : IVersionedEntity, ICloneable
+    public interface IResource : IVersionedEntity, ICloneable, INotifyPropertyChanged
     {
         IServerConnection CurrentConnection { get; set; }
 
+        string ValidatingSchema { get; }
+
         string ResourceID { get; set; }
 
         string ResourceType { get; }
+
+        string Serialize();
     }
+
+    public static class ResourceExtensions
+    {
+        public static Stream SerializeToStream(this IResource res)
+        {
+            string str = res.Serialize();
+            return new MemoryStream(Encoding.UTF8.GetBytes(str));
+        }
+    }
 }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/ResourceIdentifier.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/ResourceIdentifier.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Resource/ResourceIdentifier.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -372,6 +372,11 @@
             return identifier.Substring(GetRepository(identifier).Length, identifier.Length - GetExtension(identifier).Length - GetRepository(identifier).Length - 1);
         }
 
+        public static ResourceTypes GetResourceType(string identifier)
+        {
+            return (ResourceTypes)Enum.Parse(typeof(ResourceTypes), GetExtension(identifier));
+        }
+
         /// <summary>
         /// Returns the extension of a resource identifier
         /// </summary>

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -1199,7 +1199,18 @@
 		/// <param name="stream">A stream containing the new content of the resource data</param>
         abstract public void SetResourceData(string resourceid, string dataname, ObjCommon.ResourceDataType datatype, System.IO.Stream stream, Utility.StreamCopyProgressDelegate callback);
 
+        public void SaveResource(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource)
+        {
+            SaveResourceAs(resource, resource.ResourceID);   
+        }
+
+        public void SaveResourceAs(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource, string resourceid)
+        {
+            var stream = resource.SerializeToStream();
+            SetResourceXmlData(resourceid, stream);
+        }
 		
+        /*
 		/// <summary>
 		/// Saves an object into the repository
 		/// </summary>
@@ -1212,6 +1223,7 @@
 			System.IO.MemoryStream ms = SerializeObject(resource);
 			SetResourceXmlData(resourceid, ms);
 		}
+         */
 
 		/// <summary>
 		/// Gets a list of installed feature providers

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2010-05-18 01:33:35 UTC (rev 4902)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2010-05-18 07:11:52 UTC (rev 4903)
@@ -1561,16 +1561,6 @@
             throw new UnsupportedServiceTypeException(st);
         }
 
-        public void SaveResource(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource)
-        {
-            throw new NotImplementedException();
-        }
-
-        public void SaveResourceAs(OSGeo.MapGuide.MaestroAPI.Resource.IResource resource, string resourceid)
-        {
-            throw new NotImplementedException();
-        }
-
         const string PROP_USER_AGENT = "UserAgent";
 
         public override string[] GetCustomPropertyNames()



More information about the mapguide-commits mailing list