[mapguide-commits] r5626 - in trunk/Tools/Maestro/Maestro.Base/Commands: . SiteExplorer

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Mar 15 07:12:35 EDT 2011


Author: jng
Date: 2011-03-15 04:12:35 -0700 (Tue, 15 Mar 2011)
New Revision: 5626

Modified:
   trunk/Tools/Maestro/Maestro.Base/Commands/QuitCommand.cs
   trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs
   trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.cs
Log:
Fix #1625: Share the same internal logic used to abort a disconnection to abort exiting the application

Modified: trunk/Tools/Maestro/Maestro.Base/Commands/QuitCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/QuitCommand.cs	2011-03-15 10:00:19 UTC (rev 5625)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/QuitCommand.cs	2011-03-15 11:12:35 UTC (rev 5626)
@@ -21,6 +21,7 @@
 using System.Collections.Generic;
 using System.Text;
 using ICSharpCode.Core;
+using Maestro.Base.Commands.SiteExplorer;
 
 namespace Maestro.Base.Commands
 {
@@ -29,7 +30,7 @@
         public override void Run()
         {
             Workbench wb = Workbench.Instance;
-            if (wb != null)
+            if (wb != null && !DisconnectCommand.CancelDisconnect())
             {
                 wb.Close();
             }

Modified: trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs	2011-03-15 10:00:19 UTC (rev 5625)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs	2011-03-15 11:12:35 UTC (rev 5626)
@@ -31,6 +31,17 @@
         {
             var wb = Workbench.Instance;
             var svc = ServiceRegistry.GetService<ServerConnectionManager>();
+            if (!CancelDisconnect())
+            {
+                var name = wb.ActiveSiteExplorer.ConnectionName;
+                svc.RemoveConnection(name);
+            }
+        }
+
+        internal static bool CancelDisconnect()
+        {
+            var wb = Workbench.Instance;
+            var svc = ServiceRegistry.GetService<ServerConnectionManager>();
             var omgr = ServiceRegistry.GetService<OpenResourceManager>();
             if (wb.ActiveSiteExplorer != null)
             {
@@ -48,7 +59,7 @@
                     }
 
                     if (dirty && !MessageService.AskQuestion(Properties.Resources.ConfirmCloseEditors))
-                        return;
+                        return true;
                 }
 
                 var editors = omgr.OpenEditors;
@@ -56,10 +67,8 @@
                 {
                     ed.Close(true);
                 }
-
-                var name = wb.ActiveSiteExplorer.ConnectionName;
-                svc.RemoveConnection(name);
             }
+            return false;
         }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.cs	2011-03-15 10:00:19 UTC (rev 5625)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.cs	2011-03-15 11:12:35 UTC (rev 5626)
@@ -29,6 +29,7 @@
 using OSGeo.MapGuide.ObjectModels.WebLayout;
 using Props = ICSharpCode.Core.PropertyService;
 using Maestro.Base.UI.Preferences;
+using System.Windows.Forms;
 
 namespace Maestro.Base.Commands
 {
@@ -45,6 +46,7 @@
             Workbench.WorkbenchInitialized += (sender, e) =>
             {
                 var wb = Workbench.Instance;
+                wb.FormClosing += new System.Windows.Forms.FormClosingEventHandler(OnWorkbenchClosing);
                 wb.Text = "MapGuide Maestro";
 
                 var mgr = ServiceRegistry.GetService<ViewContentManager>();
@@ -56,9 +58,12 @@
                     mgr.OpenContent<OutboundRequestViewer>(ViewRegion.Bottom);
 
                 new LoginCommand().Run();
-
-                
             };
         }
+
+        void OnWorkbenchClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
+        {
+            e.Cancel = Maestro.Base.Commands.SiteExplorer.DisconnectCommand.CancelDisconnect();   
+        }
     }
 }



More information about the mapguide-commits mailing list