[mapguide-commits] r4924 - in sandbox/maestro-2.5: Maestro.Base Maestro.Base/Commands/Conditions Maestro.Base/UI OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon May 24 08:13:10 EDT 2010


Author: jng
Date: 2010-05-24 08:13:09 -0400 (Mon, 24 May 2010)
New Revision: 4924

Added:
   sandbox/maestro-2.5/Maestro.Base/Commands/Conditions/SelectedRootItemConditionEvaluator.cs
Modified:
   sandbox/maestro-2.5/Maestro.Base/Maestro.Base.addin
   sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj
   sandbox/maestro-2.5/Maestro.Base/UI/RepositoryTreeModel.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs
Log:
This submission includes the following changes:
 - Include root node in the SiteExplorer
 - Add new condition evaluator to determine if selected node is the root node.
 - Wrap certain commands under the selected folder context menu to be disabled if selected folder is root.

Added: sandbox/maestro-2.5/Maestro.Base/Commands/Conditions/SelectedRootItemConditionEvaluator.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/Commands/Conditions/SelectedRootItemConditionEvaluator.cs	                        (rev 0)
+++ sandbox/maestro-2.5/Maestro.Base/Commands/Conditions/SelectedRootItemConditionEvaluator.cs	2010-05-24 12:13:09 UTC (rev 4924)
@@ -0,0 +1,43 @@
+#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 SelectedRootItemConditionEvaluator : IConditionEvaluator
+    {
+        public bool IsValid(object caller, Condition condition)
+        {
+            var wb = Workbench.Instance;
+            if (wb != null)
+            {
+                var exp = wb.ActiveSiteExplorer;
+                if (exp != null && exp.SelectedItems.Length == 1)
+                {
+                    return !exp.SelectedItems[0].IsRoot;
+                }
+            }
+            return true;
+        }
+    }
+}

Modified: sandbox/maestro-2.5/Maestro.Base/Maestro.Base.addin
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/Maestro.Base.addin	2010-05-24 11:07:59 UTC (rev 4923)
+++ sandbox/maestro-2.5/Maestro.Base/Maestro.Base.addin	2010-05-24 12:13:09 UTC (rev 4924)
@@ -13,6 +13,7 @@
             <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" />
             <ConditionEvaluator name="CanClose" class="Maestro.Base.Commands.Conditions.CloseableDocumentConditionEvaluator" />
             <ConditionEvaluator name="SelectedItem" class="Maestro.Base.Commands.Conditions.SelectedItemConditionEvaluator" />
@@ -232,19 +233,23 @@
             <MenuItem id="CreatePackage"
                       label="${res:SiteExplorer_SelectedFolder_CreatePackage}"
                       class="Maestro.Base.Commands.NotImplementedCommand" />
-            <MenuItem id="Delete"
-                      label="${res:SiteExplorer_SelectedItem_Delete}"
-                      class="Maestro.Base.Commands.NotImplementedCommand" />
+            <Condition action="Disable" name="IsNotRoot">
+                <MenuItem id="Delete"
+                          label="${res:SiteExplorer_SelectedItem_Delete}"
+                          class="Maestro.Base.Commands.NotImplementedCommand" />
+            </Condition>
             <MenuItem id="LoadPackage"
                       label="${res:SiteExplorer_SelectedFolder_LoadPackage}"
                       class="Maestro.Base.Commands.NotImplementedCommand" />
             <MenuItem type="Separator" />
-            <MenuItem id="Copy"
-                      label="${res:SiteExplorer_SelectedItem_Copy}"
-                      class="Maestro.Base.Commands.NotImplementedCommand" />
-            <MenuItem id="Cut"
-                      label="${res:SiteExplorer_SelectedItem_Cut}"
-                      class="Maestro.Base.Commands.NotImplementedCommand" />
+            <Condition action="Disable" name="IsNotRoot">
+                <MenuItem id="Copy"
+                          label="${res:SiteExplorer_SelectedItem_Copy}"
+                          class="Maestro.Base.Commands.NotImplementedCommand" />
+                <MenuItem id="Cut"
+                          label="${res:SiteExplorer_SelectedItem_Cut}"
+                          class="Maestro.Base.Commands.NotImplementedCommand" />
+            </Condition>
             <MenuItem id="Paste"
                       label="${res:SiteExplorer_SelectedFolder_Paste}"
                       class="Maestro.Base.Commands.NotImplementedCommand" />

Modified: sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj	2010-05-24 11:07:59 UTC (rev 4923)
+++ sandbox/maestro-2.5/Maestro.Base/Maestro.Base.csproj	2010-05-24 12:13:09 UTC (rev 4924)
@@ -47,6 +47,7 @@
     <Compile Include="Commands\Conditions\NotConnectedConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\DebugModeConditionEvaluator.cs" />
     <Compile Include="Commands\Conditions\SelectedItemConditionEvaluator.cs" />
+    <Compile Include="Commands\Conditions\SelectedRootItemConditionEvaluator.cs" />
     <Compile Include="Commands\CopyCommand.cs" />
     <Compile Include="Commands\CutCommand.cs" />
     <Compile Include="Commands\LoginCommand.cs" />

Modified: sandbox/maestro-2.5/Maestro.Base/UI/RepositoryTreeModel.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/UI/RepositoryTreeModel.cs	2010-05-24 11:07:59 UTC (rev 4923)
+++ sandbox/maestro-2.5/Maestro.Base/UI/RepositoryTreeModel.cs	2010-05-24 12:13:09 UTC (rev 4924)
@@ -24,6 +24,7 @@
 using OSGeo.MapGuide.MaestroAPI;
 using OSGeo.MapGuide.ObjectModels.Common;
 using System.Drawing;
+using System.Diagnostics;
 
 namespace Maestro.Base.UI
 {
@@ -39,6 +40,11 @@
             _item = item;
         }
 
+        public bool IsRoot
+        {
+            get { return this.ResourceId == "Library://"; }
+        }
+
         public string ResourceId
         {
             get { return _item.ResourceId; }
@@ -78,29 +84,36 @@
         {
             get
             {
-                switch (_item.ResourceType)
+                if (IsRoot)
                 {
-                    case ResourceTypes.DrawingSource:
-                        return Properties.Resources.blueprints;
-                    case ResourceTypes.FeatureSource:
-                        return Properties.Resources.database_share;
-                    case ResourceTypes.Folder:
-                        return Properties.Resources.folder_horizontal;
-                    case ResourceTypes.LayerDefinition:
-                        return Properties.Resources.layer;
-                    case ResourceTypes.MapDefinition:
-                        return Properties.Resources.map;
-                    case ResourceTypes.WebLayout:
-                        return Properties.Resources.application_browser;
-                    case ResourceTypes.ApplicationDefinition:
-                        return Properties.Resources.applications_stack;
-                    case ResourceTypes.SymbolLibrary:
-                        return Properties.Resources.images_stack;
-                    case ResourceTypes.PrintLayout:
-                        return Properties.Resources.printer;
-                    default:
-                        return Properties.Resources.document;
+                    return Properties.Resources.server;
                 }
+                else
+                {
+                    switch (_item.ResourceType)
+                    {
+                        case ResourceTypes.DrawingSource:
+                            return Properties.Resources.blueprints;
+                        case ResourceTypes.FeatureSource:
+                            return Properties.Resources.database_share;
+                        case ResourceTypes.Folder:
+                            return Properties.Resources.folder_horizontal;
+                        case ResourceTypes.LayerDefinition:
+                            return Properties.Resources.layer;
+                        case ResourceTypes.MapDefinition:
+                            return Properties.Resources.map;
+                        case ResourceTypes.WebLayout:
+                            return Properties.Resources.application_browser;
+                        case ResourceTypes.ApplicationDefinition:
+                            return Properties.Resources.applications_stack;
+                        case ResourceTypes.SymbolLibrary:
+                            return Properties.Resources.images_stack;
+                        case ResourceTypes.PrintLayout:
+                            return Properties.Resources.printer;
+                        default:
+                            return Properties.Resources.document;
+                    }
+                }
             }
         }
     }
@@ -158,7 +171,7 @@
         {
             if (treePath.IsEmpty())
             {
-                var list = _conn.ResourceService.GetRepositoryResources("Library://", 1);
+                var list = _conn.ResourceService.GetRepositoryResources("Library://", 0);
                 return GetSorted(list);
             }
             else

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs	2010-05-24 11:07:59 UTC (rev 4923)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ResourceItems.cs	2010-05-24 12:13:09 UTC (rev 4924)
@@ -83,7 +83,13 @@
         [XmlIgnore]
         public string Name
         {
-            get { return ResourceIdentifier.GetName(this.ResourceId); }
+            get 
+            {
+                if (this.ResourceId != "Library://")
+                    return ResourceIdentifier.GetName(this.ResourceId);
+                else
+                    return "Root"; //LOCALIZE
+            }
         }
 
         [XmlIgnore]



More information about the mapguide-commits mailing list