[mapguide-commits] r6080 - in trunk/Tools/Maestro: Maestro.Base Maestro.Base/Commands Maestro.Base/Commands/Conditions Maestro.Base/Commands/SiteExplorer Maestro.Base/Editor Maestro.Base/Events Maestro.Base/Properties Maestro.Base/UI OSGeo.MapGuide.MaestroAPI.Http

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Aug 16 06:37:14 EDT 2011


Author: jng
Date: 2011-08-16 03:37:14 -0700 (Tue, 16 Aug 2011)
New Revision: 6080

Removed:
   trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/IsConnectedConditionEvaluator.cs
   trunk/Tools/Maestro/Maestro.Base/Commands/LogoutCommand.cs
Modified:
   trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/NotConnectedConditionEvaluator.cs
   trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs
   trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs
   trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
   trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
   trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin
   trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj
   trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx
   trunk/Tools/Maestro/Maestro.Base/UI/ISiteExplorer.cs
   trunk/Tools/Maestro/Maestro.Base/UI/RepositoryTreeModel.cs
   trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
Log:
#1784:
 - Remove unnecessary commands and condition evaluators due to multi-site support
 - Include the server version as part of the HttpServerConnection DisplayName
 - Include the originating connection (it's display name) as part of the tooltip for any open editor
 - Add a new FullRefresh() API that is called every time a connection is added or removed


Deleted: trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/IsConnectedConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/IsConnectedConditionEvaluator.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/IsConnectedConditionEvaluator.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -1,39 +0,0 @@
-#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 ICSharpCode.Core;
-
-namespace Maestro.Base.Commands.Conditions
-{
-    internal class IsConnectedConditionEvaluator : IConditionEvaluator
-    {
-        public bool IsValid(object caller, Condition condition)
-        {
-            var wb = Workbench.Instance;
-            if (wb != null)
-            {
-                return wb.ActiveSiteExplorer == null;
-            }
-            return false;
-        }
-    }
-}

Modified: trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/NotConnectedConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/NotConnectedConditionEvaluator.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/NotConnectedConditionEvaluator.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -31,7 +31,12 @@
             var wb = Workbench.Instance;
             if (wb != null)
             {
-                return wb.ActiveSiteExplorer != null;
+                if (wb.ActiveSiteExplorer != null)
+                {
+                    var items = wb.ActiveSiteExplorer.SelectedItems;
+                    if (items.Length == 1)
+                        return items[0].IsRoot;
+                }
             }
             return false;
         }

Modified: trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -48,9 +48,18 @@
                 var mgr = ServiceRegistry.GetService<ServerConnectionManager>();
                 Debug.Assert(mgr != null);
 
+                // Connection display names should be unique. A duplicate means we are connecting to the same MG server
+
                 LoggingService.Info("Connection created: " + conn.DisplayName);
-                mgr.AddConnection(conn.DisplayName, conn);
-
+                if (mgr.GetConnection(conn.DisplayName) == null)
+                {
+                    mgr.AddConnection(conn.DisplayName, conn);
+                    Workbench.Instance.ActiveSiteExplorer.FullRefresh();
+                }
+                else
+                {
+                    MessageService.ShowError(Properties.Resources.ConnectionAlreadyEstablished);
+                }
                 var vmgr = ServiceRegistry.GetService<ViewContentManager>();
             }
         }

Deleted: trunk/Tools/Maestro/Maestro.Base/Commands/LogoutCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/LogoutCommand.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/LogoutCommand.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -1,29 +0,0 @@
-#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;
-
-namespace Maestro.Base.Commands
-{
-    internal class LogoutCommand : NotImplementedCommand
-    {
-    }
-}

Modified: trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/DisconnectCommand.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -19,6 +19,7 @@
 #endregion
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 using ICSharpCode.Core;
 using Maestro.Base.Services;
@@ -35,6 +36,7 @@
             {
                 var name = wb.ActiveSiteExplorer.ConnectionName;
                 svc.RemoveConnection(name);
+                wb.ActiveSiteExplorer.FullRefresh();
             }
         }
 

Modified: trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -168,10 +168,15 @@
             UpdateTitle();
         }
 
+        private string GetTooltip(string item)
+        {
+            return string.Format(Properties.Resources.EditorTitleTemplate, item, Environment.NewLine, this.Resource.CurrentConnection.DisplayName);
+        }
+
         private void UpdateTitle()
         {
             this.Title = this.IsNew ? Properties.Resources.NewResource : ResourceIdentifier.GetName(_svc.ResourceID);
-            this.Description = this.IsNew ? Properties.Resources.NewResource : _svc.ResourceID;
+            this.Description = GetTooltip(this.IsNew ? Properties.Resources.NewResource : _svc.ResourceID);
         }
 
         const string DIRTY_PREFIX = "* ";

Modified: trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -88,24 +88,35 @@
         {
             Workbench wb = Workbench.Instance;
             Debug.Assert(wb.ActiveSiteExplorer != null);
-            Debug.Assert(wb.ActiveSiteExplorer.ConnectionName == name);
+            var svc = ServiceRegistry.GetService<ServerConnectionManager>();
+            LoggingService.Info("There are now " + svc.GetConnectionNames().Count + " active connections"); //LOCALIZEME
+            //Debug.Assert(wb.ActiveSiteExplorer.ConnectionName == name);
 
-            wb.ActiveSiteExplorer = null;
-
+            /*
             //TODO: Review this API design when we do decide to support multiple
             //site connections
             ServerStatusMonitor.Init(null);
+             */
         }
 
         static void OnConnectionAdded(object sender, string name)
         {
-            var exp = new SiteExplorer(name);
             var wb = Workbench.Instance;
-            wb.ShowContent(exp);
+            if (wb.ActiveSiteExplorer == null)
+            {
+                var siteExp = new SiteExplorer();
+                wb.ShowContent(siteExp);
+            }
 
+            wb.ActiveSiteExplorer.RefreshModel(name);
+            
+
             var svc = ServiceRegistry.GetService<ServerConnectionManager>();
             var conn = svc.GetConnection(name);
-            
+
+            LoggingService.Info("There are now " + svc.GetConnectionNames().Count + " active connections"); //LOCALIZEME
+
+            /*
             ISiteService siteSvc = null;
             var svcTypes = conn.Capabilities.SupportedServices;
             if (Array.IndexOf(svcTypes, (int)ServiceType.Site) >= 0)
@@ -115,6 +126,7 @@
             //TODO: Review this API design when we do decide to support multiple
             //site connections
             ServerStatusMonitor.Init(siteSvc);
+             */
         }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin	2011-08-16 10:37:14 UTC (rev 6080)
@@ -11,7 +11,6 @@
     <Runtime>
         <Import assembly="../Maestro.Base.dll">
             <ConditionEvaluator name="DebugMode" class="Maestro.Base.Commands.Conditions.DebugModeConditionEvaluator" />
-            <ConditionEvaluator name="IsConnected" class="Maestro.Base.Commands.Conditions.IsConnectedConditionEvaluator" />
             <ConditionEvaluator name="NotConnected" class="Maestro.Base.Commands.Conditions.NotConnectedConditionEvaluator" />
             <ConditionEvaluator name="IsNotRoot" class="Maestro.Base.Commands.Conditions.SelectedRootItemConditionEvaluator" />
             <ConditionEvaluator name="EditorFunction" class="Maestro.Base.Commands.Conditions.ActiveEditorConditionEvaluator" />
@@ -76,12 +75,10 @@
         <MenuItem id="Menu_File"
                   type="Menu"
                   label="${res:Menu_File}">
-            <Condition action="Disable" name="IsConnected">
-                <MenuItem id="Connect"
-                          label="${res:Menu_File_Connect}"
-                          icon="plug__plus"
-                          class="Maestro.Base.Commands.LoginCommand" />
-            </Condition>
+            <MenuItem id="Connect"
+                      label="${res:Menu_File_Connect}"
+                      icon="plug__plus"
+                      class="Maestro.Base.Commands.LoginCommand" />
             <Condition action="Disable" name="NotConnected">
                 <MenuItem id="NewItem"
                           label="${res:Menu_File_NewResource}"
@@ -280,13 +277,11 @@
     
     <!-- Toolbar Definition -->
     <Path name="/Maestro/Shell/Toolbars/Main">
-        <Condition action="Disable" name="IsConnected">
-            <ToolbarItem id="Connect"
-                         icon="plug__plus"
-                         label="${res:Menu_File_Connect}"
-                         tooltip="${res:Menu_File_Connect}"
-                         class="Maestro.Base.Commands.LoginCommand" />
-        </Condition>
+        <ToolbarItem id="Connect"
+                     icon="plug__plus"
+                     label="${res:Menu_File_Connect}"
+                     tooltip="${res:Menu_File_Connect}"
+                     class="Maestro.Base.Commands.LoginCommand" />
         <Condition action="Disable" name="NotConnected">
             <ToolbarItem id="NewItem"
                          icon="document__plus"

Modified: trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2011-08-16 10:37:14 UTC (rev 6080)
@@ -78,7 +78,6 @@
     <Compile Include="Commands\Conditions\ActiveEditorConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\CloseableDocumentConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\CutCopyConditionEvaluator.cs" />
-    <Compile Include="Commands\Conditions\IsConnectedConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\MultipleSelectedItemConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\NotConnectedConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\DebugModeConditionEvaluator.cs" />
@@ -94,7 +93,6 @@
     <Compile Include="Commands\LoadPackageCommand.cs" />
     <Compile Include="Commands\LocalFeatureSourcePreviewCommand.cs" />
     <Compile Include="Commands\LoginCommand.cs" />
-    <Compile Include="Commands\LogoutCommand.cs" />
     <Compile Include="Commands\MgCookerCommand.cs" />
     <Compile Include="Commands\NewItemCommand.cs" />
     <Compile Include="Commands\NotImplementedCommand.cs" />

Modified: trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -443,6 +443,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to You have already established such a connection.
+        /// </summary>
+        internal static string ConnectionAlreadyEstablished {
+            get {
+                return ResourceManager.GetString("ConnectionAlreadyEstablished", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Messages.
         /// </summary>
         internal static string Content_Messages {
@@ -654,6 +663,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Resource ID: {0}{1}Connection: {2}.
+        /// </summary>
+        internal static string EditorTitleTemplate {
+            get {
+                return ResourceManager.GetString("EditorTitleTemplate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Singleton view content cannot be closed by users. The AllowUserClose property must return false.
         /// </summary>
         internal static string Error_Closeable_Singleton_Content {

Modified: trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx	2011-08-16 10:37:14 UTC (rev 6080)
@@ -1058,4 +1058,10 @@
   <data name="SiteExplorer_CopyResourceIds" xml:space="preserve">
     <value>Copy Resource IDs to clipboard</value>
   </data>
+  <data name="ConnectionAlreadyEstablished" xml:space="preserve">
+    <value>You have already established such a connection</value>
+  </data>
+  <data name="EditorTitleTemplate" xml:space="preserve">
+    <value>Resource ID: {0}{1}Connection: {2}</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Base/UI/ISiteExplorer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/ISiteExplorer.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/UI/ISiteExplorer.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -38,6 +38,11 @@
         string[] ConnectionNames { get; }
 
         /// <summary>
+        /// Performs a full refresh of the tree model
+        /// </summary>
+        void FullRefresh();
+
+        /// <summary>
         /// Refreshes the tree model
         /// </summary>
         void RefreshModel(string connectionName);

Modified: trunk/Tools/Maestro/Maestro.Base/UI/RepositoryTreeModel.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/RepositoryTreeModel.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/UI/RepositoryTreeModel.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -523,6 +523,11 @@
             OnStructureChanged(new TreePathEventArgs(selected));
         }
 
+        internal void FullRefresh()
+        {
+            OnStructureChanged(new TreePathEventArgs());
+        }
+
         public override bool IsLeaf(TreePath treePath)
         {
             return !((RepositoryItem)treePath.LastNode).IsFolder;

Modified: trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorer.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -49,6 +49,19 @@
             Application.Idle += new EventHandler(OnIdle);
             ndResource.ToolTipProvider = new RepositoryItemToolTipProvider();
             ndResource.DrawText += new EventHandler<Aga.Controls.Tree.NodeControls.DrawEventArgs>(OnNodeDrawText);
+
+            this.Title = Properties.Resources.Content_SiteExplorer;
+            this.Description = Properties.Resources.Content_SiteExplorer;
+
+            var ts = ToolbarService.CreateToolStripItems("/Maestro/Shell/SiteExplorer/Toolbar", this, true);
+            tsSiteExplorer.Items.AddRange(ts);
+
+            _connManager = ServiceRegistry.GetService<ServerConnectionManager>();
+
+            var omgr = ServiceRegistry.GetService<OpenResourceManager>();
+            var clip = ServiceRegistry.GetService<ClipboardService>();
+            _model = new RepositoryTreeModel(_connManager, trvResources, omgr, clip);
+            trvResources.Model = _model;
         }
 
         void OnIdle(object sender, EventArgs e)
@@ -62,32 +75,28 @@
 
         public string ConnectionName
         {
-            get;
-            private set;
+            get
+            {
+                if (trvResources.SelectedNode != null)
+                {
+                    var item = (RepositoryItem)trvResources.SelectedNode.Tag;
+                    return item.ConnectionName;
+                }
+                else if (trvResources.SelectedNodes != null && trvResources.SelectedNodes.Count > 0)
+                {
+                    var item = (RepositoryItem)trvResources.SelectedNodes[0].Tag;
+                    return item.ConnectionName;
+                }
+                return null;
+            }
         }
 
-        public SiteExplorer(string name) : this()
-        {
-            this.ConnectionName = name;
-        }
-
         private RepositoryTreeModel _model;
         private ServerConnectionManager _connManager;
 
         protected override void OnLoad(EventArgs e)
         {
-            this.Title = Properties.Resources.Content_SiteExplorer;
-            this.Description = string.Format("{0}: {1}", Properties.Resources.Content_SiteExplorer, this.ConnectionName);
-
-            var ts = ToolbarService.CreateToolStripItems("/Maestro/Shell/SiteExplorer/Toolbar", this, true);
-            tsSiteExplorer.Items.AddRange(ts);
-
-            _connManager = ServiceRegistry.GetService<ServerConnectionManager>();
-
-            var omgr = ServiceRegistry.GetService<OpenResourceManager>();
-            var clip = ServiceRegistry.GetService<ClipboardService>();
-            _model = new RepositoryTreeModel(_connManager, trvResources, omgr, clip);
-            trvResources.Model = _model;
+            
         }
 
         public override bool AllowUserClose
@@ -106,6 +115,15 @@
             }
         }
 
+        public void FullRefresh()
+        {
+            _model.FullRefresh();
+            foreach(var node in trvResources.Root.Children)
+            {
+                node.Expand();
+            }
+        }
+
         public void RefreshModel(string connectionName)
         {
             RefreshModel(connectionName, null);

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2011-08-16 09:52:31 UTC (rev 6079)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2011-08-16 10:37:14 UTC (rev 6080)
@@ -795,7 +795,7 @@
 				/*if (m_wc.Credentials as NetworkCredential != null)
 					s += " [" + (m_wc.Credentials as NetworkCredential).UserName + "]"; */
 
-				return s;
+				return s + " (v" + this.SiteVersion.ToString() + ")";
 			}
 		}
 



More information about the mapguide-commits mailing list