[mapguide-commits] r4815 - in trunk/Tools/Maestro/Maestro: . ResourceValidators Strings

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Apr 28 03:56:57 EDT 2010


Author: jng
Date: 2010-04-28 03:56:53 -0400 (Wed, 28 Apr 2010)
New Revision: 4815

Modified:
   trunk/Tools/Maestro/Maestro/FormMain.cs
   trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs
   trunk/Tools/Maestro/Maestro/Strings/FormMain.Designer.cs
   trunk/Tools/Maestro/Maestro/Strings/FormMain.resx
Log:
Fix #1335: Context menu issues when selected node is the root (Library://), this also fixes some commands that didn't work when the selected node was the root, as the root should've been treated as a folder resource.

Also included is a small fix for the feature source validator. It turns out a spatial context extent returned from the mapagent can be null, but can have null LL/UR coordinates (huh?)

Modified: trunk/Tools/Maestro/Maestro/FormMain.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/FormMain.cs	2010-04-27 02:35:28 UTC (rev 4814)
+++ trunk/Tools/Maestro/Maestro/FormMain.cs	2010-04-28 07:56:53 UTC (rev 4815)
@@ -1368,19 +1368,6 @@
 
 		private void TreeContextMenu_Popup(object sender, CancelEventArgs e)
 		{
-			if (ResourceTree.SelectedNode == null || ResourceTree.SelectedNode.Tag == null)
-			{
-				foreach(ToolStripItem m in TreeContextMenu.Items)
-                    if (m as ToolStripMenuItem != null)
-					    m.Enabled = false;
-			}
-			else
-			{
-                foreach (ToolStripItem m in TreeContextMenu.Items)
-                    if (m as ToolStripMenuItem != null)
-                        m.Enabled = true;
-            }
-
             var selNode = ResourceTree.SelectedNode;
 
             PropertiesMenu.Enabled =
@@ -1388,7 +1375,8 @@
             PasteMenu.Enabled = (selNode != null && m_clipboardBuffer != null);
 			NewMenu.Enabled = true;
 
-            bool isFolder = (selNode != null && selNode.Tag.GetType() == typeof(MaestroAPI.ResourceListResourceFolder));
+            bool isRoot = (selNode != null && selNode.Level == 0);
+            bool isFolder = isRoot || (selNode != null && selNode.Tag.GetType() == typeof(MaestroAPI.ResourceListResourceFolder));
 
             EditAsXmlMenu.Enabled = EditAsXmlButton.Enabled = !isFolder;
 
@@ -1401,6 +1389,9 @@
 
             FindReplaceMenu.Enabled = !isFolder;
             FindReplaceChildrenMenu.Enabled = isFolder;
+
+            DeleteMenu.Enabled = !isRoot; //Can't delete the root of the repo
+            RenameMenu.Enabled = !isRoot; //Can't rename either
 		}
 
 		private void SaveXmlAsMenu_Click(object sender, System.EventArgs e)
@@ -2136,55 +2127,87 @@
 			{
 				try
 				{
-					if (ResourceTree.SelectedNode != null && ResourceTree.SelectedNode.Tag != null)
+                    bool isRoot = (ResourceTree.SelectedNode != null && ResourceTree.SelectedNode.Level == 0);
+					if (ResourceTree.SelectedNode != null && (ResourceTree.SelectedNode.Tag != null || isRoot))
 					{
-						if (ResourceTree.SelectedNode.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument))
-						{
-							OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument document = (OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument)ResourceTree.SelectedNode.Tag;
-							if (m_userControls.ContainsKey(document.ResourceId))
-							{
-								EditorInterface edi = (EditorInterface)m_userControls[document.ResourceId];
-								if (!edi.Close(true))
-									return;
-							}
+                        if (!isRoot)
+                        {
+                            if (ResourceTree.SelectedNode.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument))
+                            {
+                                OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument document = (OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument)ResourceTree.SelectedNode.Tag;
+                                if (m_userControls.ContainsKey(document.ResourceId))
+                                {
+                                    EditorInterface edi = (EditorInterface)m_userControls[document.ResourceId];
+                                    if (!edi.Close(true))
+                                        return;
+                                }
 
-							if (!String.IsNullOrEmpty(szFind))
-								OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl), szFind, szReplace);
-							else
-								OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl));
-						}
-						else
-						{
-							if (ResourceTree.SelectedNode.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceFolder))
-							{
-								if (!ResourceTree.SelectedNode.IsExpanded)
-									ResourceTree.SelectedNode.Expand();
+                                if (!String.IsNullOrEmpty(szFind))
+                                    OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl), szFind, szReplace);
+                                else
+                                    OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl));
+                            }
+                            else
+                            {
+                                if (ResourceTree.SelectedNode.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceFolder))
+                                {
+                                    if (!ResourceTree.SelectedNode.IsExpanded)
+                                        ResourceTree.SelectedNode.Expand();
 
-								int iCount = ResourceTree.SelectedNode.Nodes.Count;
-								if (DialogResult.Yes != MessageBox.Show(this, "Are You Sure You Want to Open " + iCount + " Items?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
-									return;
+                                    int iCount = GetDocumentNodeCount(ResourceTree.SelectedNode);
+                                    string msg = string.Format(Strings.FormMain.ConfirmMultipleOpen, iCount);
+                                    if (DialogResult.Yes != MessageBox.Show(this, msg, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
+                                        return;
 
-								foreach (TreeNode tnThis in ResourceTree.SelectedNode.Nodes)
-								{
-									// only deal with documents
-									if (tnThis.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument))
-									{
-										OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument document = (OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument)tnThis.Tag;
-										if (m_userControls.ContainsKey(document.ResourceId))
-										{
-											EditorInterface edi = (EditorInterface)m_userControls[document.ResourceId];
-											if (!edi.Close(true))
-												return;
-										}
+                                    foreach (TreeNode tnThis in ResourceTree.SelectedNode.Nodes)
+                                    {
+                                        // Document nodes are tagged with the ResourceListResourceDocument class
+                                        if (tnThis.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument))
+                                        {
+                                            OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument document = (OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument)tnThis.Tag;
+                                            if (m_userControls.ContainsKey(document.ResourceId))
+                                            {
+                                                EditorInterface edi = (EditorInterface)m_userControls[document.ResourceId];
+                                                if (!edi.Close(true))
+                                                    return;
+                                            }
 
-										if (!String.IsNullOrEmpty(szFind))
-											OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl), szFind, szReplace);
-										else
-											OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl));
-									}
-								}
-							}
-						}
+                                            if (!String.IsNullOrEmpty(szFind))
+                                                OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl), szFind, szReplace);
+                                            else
+                                                OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl));
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        else
+                        {
+                            int iCount = GetDocumentNodeCount(ResourceTree.SelectedNode);
+                            string msg = string.Format(Strings.FormMain.ConfirmMultipleOpen, iCount);
+                            if (DialogResult.Yes != MessageBox.Show(this, msg, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
+                                return;
+
+                            foreach (TreeNode tnThis in ResourceTree.SelectedNode.Nodes)
+                            {
+                                // only deal with documents
+                                if (tnThis.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument))
+                                {
+                                    OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument document = (OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument)tnThis.Tag;
+                                    if (m_userControls.ContainsKey(document.ResourceId))
+                                    {
+                                        EditorInterface edi = (EditorInterface)m_userControls[document.ResourceId];
+                                        if (!edi.Close(true))
+                                            return;
+                                    }
+
+                                    if (!String.IsNullOrEmpty(szFind))
+                                        OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl), szFind, szReplace);
+                                    else
+                                        OpenResource(document.ResourceId, typeof(OSGeo.MapGuide.Maestro.ResourceEditors.XmlEditorControl));
+                                }
+                            }
+                        }
 					}
 				}
 				catch (Exception ex)
@@ -2195,6 +2218,20 @@
 			}
 		}
 
+        private static int GetDocumentNodeCount(TreeNode treeNode)
+        {
+            int i = 0;
+            foreach (TreeNode tnThis in treeNode.Nodes)
+            {
+                // Document nodes are tagged with the ResourceListResourceDocument class
+                if (tnThis.Tag != null && tnThis.Tag.GetType() == typeof(OSGeo.MapGuide.MaestroAPI.ResourceListResourceDocument))
+                {
+                    i++;
+                }
+            }
+            return i;
+        }
+
 		private void LoadFromXmlMenu_Click(object sender, System.EventArgs e)
 		{
 			using(new WaitCursor(this))
@@ -2924,6 +2961,8 @@
                 resid = (ResourceTree.SelectedNode.Tag as MaestroAPI.ResourceListResourceDocument).ResourceId;
             else if (ResourceTree.SelectedNode.Tag as MaestroAPI.ResourceListResourceFolder != null)
                 resid = (ResourceTree.SelectedNode.Tag as MaestroAPI.ResourceListResourceFolder).ResourceId;
+            else if (ResourceTree.SelectedNode.Level == 0)
+                resid = "Library://";
 
             if (resid == null)
                 return;
@@ -2971,10 +3010,12 @@
 				return;
 
 			string resid = null;
-			if (nodeSel.Tag as MaestroAPI.ResourceListResourceDocument != null)
-				resid = (nodeSel.Tag as MaestroAPI.ResourceListResourceDocument).ResourceId;
-			else if (nodeSel.Tag as MaestroAPI.ResourceListResourceFolder != null)
-				resid = (nodeSel.Tag as MaestroAPI.ResourceListResourceFolder).ResourceId;
+            if (nodeSel.Tag as MaestroAPI.ResourceListResourceDocument != null)
+                resid = (nodeSel.Tag as MaestroAPI.ResourceListResourceDocument).ResourceId;
+            else if (nodeSel.Tag as MaestroAPI.ResourceListResourceFolder != null)
+                resid = (nodeSel.Tag as MaestroAPI.ResourceListResourceFolder).ResourceId;
+            else if (nodeSel.Level == 0)
+                resid = "Library://";
 
 			if (null == resid)
 				return;

Modified: trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs	2010-04-27 02:35:28 UTC (rev 4814)
+++ trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs	2010-04-28 07:56:53 UTC (rev 4815)
@@ -49,7 +49,7 @@
                     issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, Strings.FeatureSourceValidator.NoSpatialContextWarning));
                 else
                     foreach (MaestroAPI.FdoSpatialContextListSpatialContext c in lst.SpatialContext)
-                        if (c.Extent == null)
+                        if (c.Extent == null || c.Extent.LowerLeftCoordinate == null || c.Extent.UpperRightCoordinate == null)
                             issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, Strings.FeatureSourceValidator.EmptySpatialContextWarning));
                         else if (double.Parse(c.Extent.LowerLeftCoordinate.X, ci) <= -1000000 && double.Parse(c.Extent.LowerLeftCoordinate.Y, ci) <= -1000000 && double.Parse(c.Extent.UpperRightCoordinate.X, ci) >= 1000000 && double.Parse(c.Extent.UpperRightCoordinate.Y, ci) >= 1000000)
                             issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, Strings.FeatureSourceValidator.DefaultSpatialContextWarning));

Modified: trunk/Tools/Maestro/Maestro/Strings/FormMain.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/Strings/FormMain.Designer.cs	2010-04-27 02:35:28 UTC (rev 4814)
+++ trunk/Tools/Maestro/Maestro/Strings/FormMain.Designer.cs	2010-04-28 07:56:53 UTC (rev 4815)
@@ -61,6 +61,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Are you sure you want to open {0} items?.
+        /// </summary>
+        internal static string ConfirmMultipleOpen {
+            get {
+                return ResourceManager.GetString("ConfirmMultipleOpen", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Copy {0} of {1}.
         /// </summary>
         internal static string CopyOfName {

Modified: trunk/Tools/Maestro/Maestro/Strings/FormMain.resx
===================================================================
--- trunk/Tools/Maestro/Maestro/Strings/FormMain.resx	2010-04-27 02:35:28 UTC (rev 4814)
+++ trunk/Tools/Maestro/Maestro/Strings/FormMain.resx	2010-04-28 07:56:53 UTC (rev 4815)
@@ -117,6 +117,10 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <data name="ConfirmMultipleOpen" xml:space="preserve">
+    <value>Are you sure you want to open {0} items?</value>
+    <comment>A confirmation message that is displayed when opening multiple items for editing</comment>
+  </data>
   <data name="CopyOfName" xml:space="preserve">
     <value>Copy {0} of {1}</value>
     <comment>The name of a new item that is a copy of an existing item</comment>



More information about the mapguide-commits mailing list