[mapguide-commits] r6354 - in trunk/Tools/Maestro: Maestro.AddIn.Local Maestro.Base Maestro.Base/Commands/Conditions

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Dec 22 21:27:59 EST 2011


Author: jng
Date: 2011-12-22 18:27:59 -0800 (Thu, 22 Dec 2011)
New Revision: 6354

Added:
   trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ConnectionProviderConditionEvaluator.cs
Modified:
   trunk/Tools/Maestro/Maestro.AddIn.Local/Manifest.addin
   trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin
   trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj
Log:
Guard against illegal invocation of Local Connection Pool status command as this requires a call to MgPlatform.Initialize() first

Modified: trunk/Tools/Maestro/Maestro.AddIn.Local/Manifest.addin
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Local/Manifest.addin	2011-12-22 16:18:39 UTC (rev 6353)
+++ trunk/Tools/Maestro/Maestro.AddIn.Local/Manifest.addin	2011-12-23 02:27:59 UTC (rev 6354)
@@ -20,9 +20,11 @@
 
     <!-- Main Menu Definition -->
     <Path name="/Workspace/Tools">
+      <Condition action="Disable" name="NoConnectionOfType" provider="Maestro.Local">
         <MenuItem id="LocalConnectionPoolStatus"
                   insertbefore="CacheView"
                   label="${res:LocalConnectionPoolStatus}"
                   class="Maestro.AddIn.Local.Commands.ConnectionPoolStatusCommand"/>
+      </Condition>
     </Path>
 </AddIn>

Added: trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ConnectionProviderConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ConnectionProviderConditionEvaluator.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ConnectionProviderConditionEvaluator.cs	2011-12-23 02:27:59 UTC (rev 6354)
@@ -0,0 +1,42 @@
+#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 ICSharpCode.Core;
+using Maestro.Base.Services;
+
+namespace Maestro.Base.Commands.Conditions
+{
+    internal class ConnectionProviderConditionEvaluator : IConditionEvaluator
+    {
+        public bool IsValid(object caller, Condition condition)
+        {
+            var connMgr = ServiceRegistry.GetService<ServerConnectionManager>();
+            foreach (var connName in connMgr.GetConnectionNames())
+            {
+                var conn = connMgr.GetConnection(connName);
+                if (conn.ProviderName.Equals(condition.Properties["provider"]))
+                    return true;
+            }
+            return false;
+        }
+    }
+}

Modified: trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin	2011-12-22 16:18:39 UTC (rev 6353)
+++ trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin	2011-12-23 02:27:59 UTC (rev 6354)
@@ -22,6 +22,7 @@
             <ConditionEvaluator name="MultipleSelected" class="Maestro.Base.Commands.Conditions.MultipleSelectedItemConditionEvaluator" />
             <ConditionEvaluator name="HasDocuments" class="Maestro.Base.Commands.Conditions.NonZeroDocumentConditionEvaluator" />
             <ConditionEvaluator name="ResourceType" class="Maestro.Base.Commands.Conditions.ResourceTypeConditionEvaluator" />
+            <ConditionEvaluator name="NoConnectionOfType" class="Maestro.Base.Commands.Conditions.ConnectionProviderConditionEvaluator" />
         </Import>
     </Runtime>
 

Modified: trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2011-12-22 16:18:39 UTC (rev 6353)
+++ trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2011-12-23 02:27:59 UTC (rev 6354)
@@ -57,6 +57,7 @@
     <Compile Include="Commands\Conditions\ActiveEditorConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\CloseableDocumentConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\ActiveEditorTypeConditionEvaluator.cs" />
+    <Compile Include="Commands\Conditions\ConnectionProviderConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\CutCopyConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\MultipleSelectedItemConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\NotConnectedConditionEvaluator.cs" />



More information about the mapguide-commits mailing list