[mapguide-commits] r6102 - in trunk/Tools/Maestro: Maestro.AddIn.Local Maestro.Base/UI Maestro.Editors Maestro.Editors/MapDefinition

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Aug 29 08:33:57 EDT 2011


Author: jng
Date: 2011-08-29 05:33:57 -0700 (Mon, 29 Aug 2011)
New Revision: 6102

Added:
   trunk/Tools/Maestro/Maestro.Editors/RepositoryHandle.cs
Modified:
   trunk/Tools/Maestro/Maestro.AddIn.Local/MapGuideDesktopUnmanagedApi.dll
   trunk/Tools/Maestro/Maestro.AddIn.Local/MgDesktop.dll
   trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs
   trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
Log:
 - Update MgDesktop binaries with EnumerateResources() fix
 - Fix broken drag/drop from Site Explorer in Map Definition editor. Also incorporate logic to prevent drops from connections not the same as the editor in question (though we can look at allowing this in a future revision)

Modified: trunk/Tools/Maestro/Maestro.AddIn.Local/MapGuideDesktopUnmanagedApi.dll
===================================================================
(Binary files differ)

Modified: trunk/Tools/Maestro/Maestro.AddIn.Local/MgDesktop.dll
===================================================================
(Binary files differ)

Modified: trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs	2011-08-28 17:15:37 UTC (rev 6101)
+++ trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs	2011-08-29 12:33:57 UTC (rev 6102)
@@ -35,6 +35,7 @@
 using Maestro.Base.Commands.SiteExplorer;
 using Maestro.Base.Commands;
 using System.Linq;
+using Maestro.Editors;
 
 namespace Maestro.Base.UI
 {
@@ -358,12 +359,16 @@
         private void trvResources_ItemDrag(object sender, ItemDragEventArgs e)
         {
             var nodes = e.Item as TreeNodeAdv[];
-            if (nodes != null)
+            if (nodes != null && nodes.Length > 0)
             {
-                List<RepositoryItem> rids = new List<RepositoryItem>();
+                IServerConnection conn = null;
+                List<RepositoryHandle> rids = new List<RepositoryHandle>();
                 foreach (var n in nodes)
                 {
-                    rids.Add((RepositoryItem)n.Tag);
+                    var ri = (RepositoryItem)n.Tag;
+                    conn = _connManager.GetConnection(ri.ConnectionName);
+                    rids.Add(new RepositoryHandle(new ResourceIdentifier(ri.ResourceId), conn));
+
                 }
                 trvResources.DoDragDrop(rids.ToArray(), DragDropEffects.All);
             }

Modified: trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2011-08-28 17:15:37 UTC (rev 6101)
+++ trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2011-08-29 12:33:57 UTC (rev 6102)
@@ -924,6 +924,7 @@
       <DesignTime>True</DesignTime>
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
+    <Compile Include="RepositoryHandle.cs" />
     <Compile Include="ResourceEditorServiceBase.cs" />
     <Compile Include="SymbolDefinition\AdvancedSettingsCtrl.cs">
       <SubType>UserControl</SubType>

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2011-08-28 17:15:37 UTC (rev 6101)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2011-08-29 12:33:57 UTC (rev 6102)
@@ -892,7 +892,7 @@
         private static void HandleDragEnter(DragEventArgs e)
         {
             //Accepting all resource id drops
-            var rids = e.Data.GetData(typeof(ResourceIdentifier[])) as ResourceIdentifier[];
+            var rids = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[];
             if (rids == null || rids.Length == 0)
             {
                 e.Effect = DragDropEffects.None;
@@ -900,7 +900,7 @@
             }
 
             //But only of the Layer Definition kind
-            if (rids.Length == 1 && rids[0].ResourceType != ResourceTypes.LayerDefinition)
+            if (rids.Length == 1 && rids[0].ResourceId.ResourceType != ResourceTypes.LayerDefinition)
             {
                 e.Effect = DragDropEffects.None;
                 return;
@@ -909,7 +909,7 @@
             //Even in multiples
             foreach (var r in rids)
             {
-                if (r.ResourceType != ResourceTypes.LayerDefinition)
+                if (r.ResourceId.ResourceType != ResourceTypes.LayerDefinition)
                 {
                     e.Effect = DragDropEffects.None;
                     return;
@@ -919,7 +919,7 @@
 
         private void trvLayersGroup_DragDrop(object sender, DragEventArgs e)
         {
-            var rids = e.Data.GetData(typeof(ResourceIdentifier[])) as ResourceIdentifier[];
+            var rids = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[];
             var nodes = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
             if (rids != null && rids.Length > 0)
             {
@@ -936,10 +936,10 @@
                 int added = 0;
                 foreach (var rid in rids)
                 {
-                    if (rid.ResourceType == ResourceTypes.LayerDefinition)
+                    if (rid.ResourceId.ResourceType == ResourceTypes.LayerDefinition)
                     {
-                        var name = GenerateLayerName(rid.ToString(), _map);
-                        var layer = _map.AddLayer(parent == null ? null : parent.Name, name, rid.ToString());
+                        var name = GenerateLayerName(rid.ResourceId.ToString(), _map);
+                        var layer = _map.AddLayer(parent == null ? null : parent.Name, name, rid.ResourceId.ToString());
                         added++;
                     }
                 }
@@ -1021,14 +1021,24 @@
             }
         }
 
-        private static void HandleDragOver(DragEventArgs e)
+        private void HandleDragOver(DragEventArgs e)
         {
-            var rids = e.Data.GetData(typeof(ResourceIdentifier[])) as ResourceIdentifier[];
+            var rids = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[];
             if (rids == null || rids.Length == 0)
             {
                 e.Effect = DragDropEffects.None;
                 return;
             }
+            else
+            {
+                //All handles should have the same connection, so sample the first
+                //Must be the same connection as this current editor
+                if (rids[0].Connection != _edSvc.GetEditedResource().CurrentConnection)
+                {
+                    e.Effect = DragDropEffects.None;
+                    return;
+                }
+            }
 
             e.Effect = DragDropEffects.Copy;
         }
@@ -1036,7 +1046,7 @@
         private void trvLayerDrawingOrder_DragDrop(object sender, DragEventArgs e)
         {
             //TODO: Handle drag/drop re-ordering
-            var rids = e.Data.GetData(typeof(ResourceIdentifier[])) as ResourceIdentifier[];
+            var rids = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[];
             if (rids != null && rids.Length > 0)
             {
                 IMapLayer layer = null;
@@ -1051,11 +1061,11 @@
                 int added = 0;
                 foreach (var rid in rids)
                 {
-                    if (rid.ResourceType == ResourceTypes.LayerDefinition)
+                    if (rid.ResourceId.ResourceType == ResourceTypes.LayerDefinition)
                     {
-                        var name = GenerateLayerName(rid.ToString(), _map);
+                        var name = GenerateLayerName(rid.ResourceId.ToString(), _map);
                         //var layer = _map.AddLayer(parent == null ? null : parent.Name, name, rid.ToString());
-                        var lyr = _map.AddLayer(layer, null, name, rid.ToString());
+                        var lyr = _map.AddLayer(layer, null, name, rid.ResourceId.ToString());
                         added++;
                     }
                 }
@@ -1151,7 +1161,7 @@
 
         private void trvBaseLayers_DragDrop(object sender, DragEventArgs e)
         {
-            var rids = e.Data.GetData(typeof(ResourceIdentifier[])) as ResourceIdentifier[];
+            var rids = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[];
             var data = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
             if (rids != null && rids.Length > 0)
             {
@@ -1173,9 +1183,9 @@
 
                 foreach (var rid in rids)
                 {
-                    if (rid.ResourceType == ResourceTypes.LayerDefinition)
+                    if (rid.ResourceId.ResourceType == ResourceTypes.LayerDefinition)
                     {
-                        group.AddLayer(GenerateBaseLayerName(rid.ToString(), _map.BaseMap), rid.ToString());
+                        group.AddLayer(GenerateBaseLayerName(rid.ResourceId.ToString(), _map.BaseMap), rid.ResourceId.ToString());
                         added++;
                     }
                 }

Added: trunk/Tools/Maestro/Maestro.Editors/RepositoryHandle.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/RepositoryHandle.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/RepositoryHandle.cs	2011-08-29 12:33:57 UTC (rev 6102)
@@ -0,0 +1,40 @@
+#region Disclaimer / License
+// Copyright (C) 2011, 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;
+using OSGeo.MapGuide.MaestroAPI;
+
+namespace Maestro.Editors
+{
+    public class RepositoryHandle
+    {
+        public ResourceIdentifier ResourceId { get; private set; }
+
+        public IServerConnection Connection { get; private set; }
+
+        public RepositoryHandle(ResourceIdentifier resId, IServerConnection conn)
+        {
+            this.ResourceId = resId;
+            this.Connection = conn;
+        }
+    }
+}



More information about the mapguide-commits mailing list