[mapguide-commits] r4426 - in trunk/Tools/Maestro: Maestro/ResourceEditors Maestro/ResourceValidators MaestroAPI MaestroAPI/Generated MaestroAPI/RuntimeClasses

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sat Dec 12 07:48:59 EST 2009


Author: ksgeograf
Date: 2009-12-12 07:48:58 -0500 (Sat, 12 Dec 2009)
New Revision: 4426

Modified:
   trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs
   trunk/Tools/Maestro/Maestro/ResourceValidators/MapDefinitionValidator.cs
   trunk/Tools/Maestro/MaestroAPI/Generated/MapDefinition-1.0.0.cs
   trunk/Tools/Maestro/MaestroAPI/RuntimeClasses/RuntimeMap.cs
   trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs
Log:
Maestro:
Fixed issue #1180.
Also fixed a validator bug when legenlabels are null.
Also fixed a save issue where FiniteDisplayScale is null.
Also fixed a cosmetic issue when deleting a group from a map.

Modified: trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs	2009-12-12 10:59:57 UTC (rev 4425)
+++ trunk/Tools/Maestro/Maestro/ResourceEditors/MapEditor.cs	2009-12-12 12:48:58 UTC (rev 4426)
@@ -236,14 +236,10 @@
 				}
 
 
-				lstDrawOrder.Items.Clear();
+                RefreshDrawOrderList();
+
 				foreach(OSGeo.MapGuide.MaestroAPI.MapLayerType layer in m_map.Layers)
 				{
-					ListViewItem lvi = new ListViewItem(layer.Name, m_editor.ResourceEditorMap.GetImageIndexFromResourceType("LayerDefinition"));
-					lvi.Tag = layer;
-					lvi.ImageIndex = 0;
-					lstDrawOrder.Items.Add(lvi);
-
 					TreeNode tn = new TreeNode(layer.Name, m_editor.ResourceEditorMap.GetImageIndexFromResourceType("LayerDefinition"), m_editor.ResourceEditorMap.GetImageIndexFromResourceType("LayerDefinition"));
 					tn.Tag = layer;
 					tn.ImageIndex = tn.SelectedImageIndex = 0;
@@ -311,6 +307,17 @@
 			}
 		}
 
+        private void RefreshDrawOrderList()
+        {
+			lstDrawOrder.Items.Clear();
+            foreach (OSGeo.MapGuide.MaestroAPI.MapLayerType layer in m_map.Layers)
+            {
+                ListViewItem lvi = new ListViewItem(layer.Name, m_editor.ResourceEditorMap.GetImageIndexFromResourceType("LayerDefinition"));
+                lvi.Tag = layer;
+                lvi.ImageIndex = 0;
+                lstDrawOrder.Items.Add(lvi);
+            }
+        }
 		private TreeNodeCollection FindParentNode(string fullpath)
 		{
             if (fullpath == null)
@@ -1203,6 +1210,7 @@
 
 				m_map.LayerGroups.RemoveAt(index);
 				trvLayerGroups.SelectedNode.Remove();
+                RefreshDrawOrderList();
 				m_editor.HasChanged();
 				return;
 			}

Modified: trunk/Tools/Maestro/Maestro/ResourceValidators/MapDefinitionValidator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceValidators/MapDefinitionValidator.cs	2009-12-12 10:59:57 UTC (rev 4425)
+++ trunk/Tools/Maestro/Maestro/ResourceValidators/MapDefinitionValidator.cs	2009-12-12 12:48:58 UTC (rev 4426)
@@ -37,7 +37,7 @@
             MaestroAPI.MapDefinition mdef = resource as MaestroAPI.MapDefinition;
 
             foreach(MaestroAPI.MapLayerGroupType g in mdef.LayerGroups)
-                if (g.ShowInLegend && g.LegendLabel.Trim().Length == 0)
+                if (g.ShowInLegend && (g.LegendLabel == null || g.LegendLabel.Trim().Length == 0))
                     issues.Add(new ValidationIssue(mdef, ValidationStatus.Information, string.Format(Strings.MapDefinitionValidator.GroupMissingLabelInformation, g.Name)));
                 else if (g.ShowInLegend && g.LegendLabel.Trim().ToLower() == "layer group")
                     issues.Add(new ValidationIssue(mdef, ValidationStatus.Information, string.Format(Strings.MapDefinitionValidator.GroupHasDefaultLabelInformation, g.Name)));
@@ -60,7 +60,7 @@
                 else
                     nameCounter.Add(l.Name, l);
  
-                if (l.ShowInLegend && (string.IsNullOrEmpty(l.LegendLabel) ||  l.LegendLabel.Trim().Length == 0))
+                if (l.ShowInLegend && (string.IsNullOrEmpty(l.LegendLabel) || l.LegendLabel.Trim().Length == 0))
                     issues.Add(new ValidationIssue(mdef, ValidationStatus.Information, string.Format(Strings.MapDefinitionValidator.LayerMissingLabelInformation, l.Name)));
                 
                 if (recurse)

Modified: trunk/Tools/Maestro/MaestroAPI/Generated/MapDefinition-1.0.0.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/Generated/MapDefinition-1.0.0.cs	2009-12-12 10:59:57 UTC (rev 4425)
+++ trunk/Tools/Maestro/MaestroAPI/Generated/MapDefinition-1.0.0.cs	2009-12-12 12:48:58 UTC (rev 4426)
@@ -19,6 +19,7 @@
 #endregion
 using System;
 using System.Collections;
+using System.Collections.Generic;
 
 namespace OSGeo.MapGuide.MaestroAPI {
     
@@ -208,6 +209,63 @@
 				this.m_baseMapDefinition = value;
 			}
 		}
+
+        /// <summary>
+        /// Sorts the group list so parent groups are listed before child groups
+        /// </summary>
+        public void SortGroupList()
+        {
+            if (m_mapLayerGroup == null || m_mapLayerGroup.Count < 2)
+                return;
+
+            List<MapLayerGroupType> remaining = new List<MapLayerGroupType>();
+            List<MapLayerGroupType> mapped = new List<MapLayerGroupType>();
+            Dictionary<string, MapLayerGroupType> mappedElements = new Dictionary<string, MapLayerGroupType>();
+
+            foreach (MapLayerGroupType g in m_mapLayerGroup)
+                if (string.IsNullOrEmpty(g.Group))
+                {
+                    mapped.Add(g);
+                    if (mappedElements.ContainsKey(g.Name))
+                        throw new Exception(string.Format("The group {0} exists more than once", g.Name));
+                    mappedElements.Add(g.Name, g);
+                }
+                else
+                    remaining.Add(g);
+
+            bool anyRemoved = true;
+            while (remaining.Count > 0 && anyRemoved)
+            {
+                anyRemoved = false;
+                for (int i = 0; i < remaining.Count; i++)
+                {
+                    if (mappedElements.ContainsKey(remaining[i].Group))
+                    {
+                        anyRemoved = true;
+                        mapped.Add(remaining[i]);
+                        if (mappedElements.ContainsKey(remaining[i].Name))
+                            throw new Exception(string.Format("The group {0} exists more than once", remaining[i].Name));
+                        mappedElements.Add(remaining[i].Name, remaining[i]);
+                        remaining.RemoveAt(i);
+                        i--;
+                    }
+                }
+            }
+
+            if (remaining.Count > 0)
+            {
+                List<string> names = new List<string>();
+                foreach (MapLayerGroupType g in remaining)
+                    names.Add(g.Name);
+                throw new Exception(string.Format("Found orphan groups: {0}", string.Join(",", names.ToArray())));
+            }
+
+            if (m_mapLayerGroup == null)
+                m_mapLayerGroup = new MapLayerGroupTypeCollection();
+            m_mapLayerGroup.Clear();
+            foreach (MapLayerGroupType g in mapped)
+                m_mapLayerGroup.Add(g);
+        }
 	}
 
 

Modified: trunk/Tools/Maestro/MaestroAPI/RuntimeClasses/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/RuntimeClasses/RuntimeMap.cs	2009-12-12 10:59:57 UTC (rev 4425)
+++ trunk/Tools/Maestro/MaestroAPI/RuntimeClasses/RuntimeMap.cs	2009-12-12 12:48:58 UTC (rev 4426)
@@ -72,6 +72,9 @@
 		{
 			if (map.CurrentConnection == null)
 				throw new Exception("Map must have a connection for construction to work");
+
+            map.SortGroupList();
+
             this.CurrentConnection = map.CurrentConnection;
 			this.m_resourceID = map.ResourceId;
 			base.m_resourceId = map.ResourceId;

Modified: trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs	2009-12-12 10:59:57 UTC (rev 4425)
+++ trunk/Tools/Maestro/MaestroAPI/ServerConnectionBase.cs	2009-12-12 12:48:58 UTC (rev 4426)
@@ -1458,7 +1458,7 @@
 						mdef.BaseMapDefinition = null;
                     else if (mdef.BaseMapDefinition.BaseMapLayerGroup == null || mdef.BaseMapDefinition.BaseMapLayerGroup.Count == 0)
                     {
-                        if (mdef.BaseMapDefinition.FiniteDisplayScale.Count == 0)
+                        if (mdef.BaseMapDefinition.FiniteDisplayScale == null || mdef.BaseMapDefinition.FiniteDisplayScale.Count == 0)
                             mdef.BaseMapDefinition = null;
                     }
 
@@ -1501,6 +1501,8 @@
                     if (mdef.BaseMapDefinition.FiniteDisplayScale.Count == 0)
                         throw new Exception("It is not allowed to have a map with base layers but no finite display scales");
                 }
+
+                mdef.SortGroupList();
             }
 
 			WebLayout wl = resource as WebLayout;



More information about the mapguide-commits mailing list