[mapguide-commits] r5670 - in trunk/Tools/Maestro/Maestro.Base: . Commands/Conditions Commands/SiteExplorer Properties Resources

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Apr 4 07:40:45 EDT 2011


Author: jng
Date: 2011-04-04 04:40:45 -0700 (Mon, 04 Apr 2011)
New Revision: 5670

Added:
   trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ResourceTypeConditionEvaluator.cs
   trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/PurgeFeatureSourceCacheCommand.cs
   trunk/Tools/Maestro/Maestro.Base/Resources/arrow-circle-double.png
   trunk/Tools/Maestro/Maestro.Base/Resources/system-monitor.png
Modified:
   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
Log:
#1648: Implement a flush feature source cache command. This command only applies to Feature Sources and Layer Definitions

Added: trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ResourceTypeConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ResourceTypeConditionEvaluator.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/Conditions/ResourceTypeConditionEvaluator.cs	2011-04-04 11:40:45 UTC (rev 5670)
@@ -0,0 +1,55 @@
+#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;
+
+namespace Maestro.Base.Commands.Conditions
+{
+    internal class ResourceTypeConditionEvaluator : IConditionEvaluator
+    {
+        public bool IsValid(object caller, Condition condition)
+        {
+            var types = condition.Properties["types"];
+            if (types != null)
+            {
+                var wb = Workbench.Instance;
+                if (wb != null)
+                {
+                    if (wb.ActiveSiteExplorer != null)
+                    {
+                        var resTypes = new List<string>(types.Split(','));
+                        if (resTypes.Count > 0)
+                        {
+                            var items = wb.ActiveSiteExplorer.SelectedItems;
+                            foreach (var it in items)
+                            {
+                                if (resTypes.Contains(it.ResourceType))
+                                    return true;
+                            }
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+    }
+}

Added: trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/PurgeFeatureSourceCacheCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/PurgeFeatureSourceCacheCommand.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/SiteExplorer/PurgeFeatureSourceCacheCommand.cs	2011-04-04 11:40:45 UTC (rev 5670)
@@ -0,0 +1,70 @@
+#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;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+
+namespace Maestro.Base.Commands.SiteExplorer
+{
+    internal class PurgeFeatureSourceCacheCommand : AbstractMenuCommand
+    {
+        public override void Run()
+        {
+            var wb = Workbench.Instance;
+            if (wb != null)
+            {
+                if (wb.ActiveSiteExplorer != null)
+                {
+                    var items = wb.ActiveSiteExplorer.SelectedItems;
+                    if (items.Length == 1)
+                    {
+                        var it = items[0];
+                        if (it.ResourceType == "FeatureSource" || it.ResourceType == "LayerDefinition")
+                        {
+                            var connMgr = ServiceRegistry.GetService<ServerConnectionManager>();
+                            var conn = connMgr.GetConnection(wb.ActiveSiteExplorer.ConnectionName);
+                            var resId = it.ResourceId;
+
+                            if (it.ResourceType == "LayerDefinition")
+                            {
+                                var res = (ILayerDefinition)conn.ResourceService.GetResource(resId);
+                                resId = res.SubLayer.ResourceId;
+                            }
+
+                            //If selected item is a Layer, it must be pointing to a Feature Source and not a Drawing Source
+                            if (resId.EndsWith("FeatureSource"))
+                            {
+                                using (var st = conn.ResourceService.GetResourceXmlData(resId))
+                                {
+                                    //"Touching" the feature source is sufficient to invalidate any cached information about it
+                                    conn.ResourceService.SetResourceXmlData(resId, st);
+                                    MessageService.ShowMessage(string.Format(Properties.Resources.SchemaInformationPurged, resId));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

Modified: trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin	2011-03-31 11:19:12 UTC (rev 5669)
+++ trunk/Tools/Maestro/Maestro.Base/Maestro.Base.addin	2011-04-04 11:40:45 UTC (rev 5670)
@@ -21,6 +21,7 @@
             <ConditionEvaluator name="CanCutOrCopy" class="Maestro.Base.Commands.Conditions.CutCopyConditionEvaluator" />
             <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" />
         </Import>
     </Runtime>
 
@@ -194,6 +195,7 @@
                       class="Maestro.Base.Commands.LocalFeatureSourcePreviewCommand"/>
             <MenuItem id="ServerMonitor"
                       label="${res:ServerMonitor}"
+                      icon="system_monitor"
                       class="Maestro.Base.Commands.ServerMonitorCommand"/>
             <MenuItem id="CacheView"
                       label="${res:CacheView}"
@@ -491,6 +493,13 @@
                       label="${res:SiteExplorer_SelectedItem_Delete}"
                       class="Maestro.Base.Commands.SiteExplorer.DeleteSelectedItemsCommand" />
             <MenuItem type="Separator" />
+            <Condition action="Disable" name="ResourceType" types="FeatureSource,LayerDefinition">
+                <MenuItem id="PurgeFsCache"
+                          label="${res:SiteExplorer_PurgeFsCache}"
+                          icon="arrow_circle_double"
+                          class="Maestro.Base.Commands.SiteExplorer.PurgeFeatureSourceCacheCommand" />
+            </Condition>
+            <MenuItem type="Separator" />
             <Condition action="Disable" name="CanCutOrCopy">
                 <MenuItem id="Copy"
                           icon="document_copy"

Modified: trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2011-03-31 11:19:12 UTC (rev 5669)
+++ trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2011-04-04 11:40:45 UTC (rev 5670)
@@ -78,6 +78,7 @@
     <Compile Include="Commands\Conditions\NotConnectedConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\DebugModeConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\PasteConditionEvaluator.cs" />
+    <Compile Include="Commands\Conditions\ResourceTypeConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\SelectedItemConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\SelectedRootItemConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\NonZeroDocumentConditionEvaluator.cs" />
@@ -100,6 +101,7 @@
     <Compile Include="Commands\SaveAllCommand.cs" />
     <Compile Include="Commands\SaveResourceAsCommand.cs" />
     <Compile Include="Commands\SaveResourceCommand.cs" />
+    <Compile Include="Commands\SiteExplorer\PurgeFeatureSourceCacheCommand.cs" />
     <Compile Include="Commands\SiteExplorer\SaveResourceContentToDiskCommand.cs" />
     <Compile Include="Commands\ServerMonitorCommand.cs" />
     <Compile Include="Commands\SiteAdministratorCommand.cs" />
@@ -361,6 +363,8 @@
   </ItemGroup>
   <ItemGroup>
     <Content Include="Maestro.Base.addin" />
+    <None Include="Resources\arrow-circle-double.png" />
+    <None Include="Resources\system-monitor.png" />
     <None Include="Resources\server--arrow.png" />
     <None Include="Resources\document--arrow.png" />
     <None Include="Resources\disks.png" />

Modified: trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs	2011-03-31 11:19:12 UTC (rev 5669)
+++ trunk/Tools/Maestro/Maestro.Base/Properties/Resources.Designer.cs	2011-04-04 11:40:45 UTC (rev 5670)
@@ -136,6 +136,13 @@
             }
         }
         
+        internal static System.Drawing.Bitmap arrow_circle_double {
+            get {
+                object obj = ResourceManager.GetObject("arrow_circle_double", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         internal static System.Drawing.Bitmap blueprints {
             get {
                 object obj = ResourceManager.GetObject("blueprints", resourceCulture);
@@ -1457,6 +1464,15 @@
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Schema information for {0} purged.
+        /// </summary>
+        internal static string SchemaInformationPurged {
+            get {
+                return ResourceManager.GetString("SchemaInformationPurged", resourceCulture);
+            }
+        }
+        
         internal static System.Drawing.Bitmap scissors_blue {
             get {
                 object obj = ResourceManager.GetObject("scissors_blue", resourceCulture);
@@ -1623,6 +1639,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Purge Cached Schema Information.
+        /// </summary>
+        internal static string SiteExplorer_PurgeFsCache {
+            get {
+                return ResourceManager.GetString("SiteExplorer_PurgeFsCache", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Refresh.
         /// </summary>
         internal static string SiteExplorer_Refresh {
@@ -1748,6 +1773,13 @@
             }
         }
         
+        internal static System.Drawing.Bitmap system_monitor {
+            get {
+                object obj = ResourceManager.GetObject("system_monitor", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Close this tab.
         /// </summary>

Modified: trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx	2011-03-31 11:19:12 UTC (rev 5669)
+++ trunk/Tools/Maestro/Maestro.Base/Properties/Resources.resx	2011-04-04 11:40:45 UTC (rev 5670)
@@ -889,4 +889,16 @@
   <data name="server__arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\server--arrow.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="arrow_circle_double" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\arrow-circle-double.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="SiteExplorer_PurgeFsCache" xml:space="preserve">
+    <value>Purge Cached Schema Information</value>
+  </data>
+  <data name="system_monitor" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\system-monitor.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="SchemaInformationPurged" xml:space="preserve">
+    <value>Schema information for {0} purged</value>
+  </data>
 </root>
\ No newline at end of file

Added: trunk/Tools/Maestro/Maestro.Base/Resources/arrow-circle-double.png
===================================================================
(Binary files differ)


Property changes on: trunk/Tools/Maestro/Maestro.Base/Resources/arrow-circle-double.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/Tools/Maestro/Maestro.Base/Resources/system-monitor.png
===================================================================
(Binary files differ)


Property changes on: trunk/Tools/Maestro/Maestro.Base/Resources/system-monitor.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream



More information about the mapguide-commits mailing list