[mapguide-commits] r5073 - in sandbox/maestro-3.0: Maestro.Base Maestro.Base/Commands Maestro.Editors/WebLayout

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Aug 6 01:29:48 EDT 2010


Author: jng
Date: 2010-08-06 05:29:48 +0000 (Fri, 06 Aug 2010)
New Revision: 5073

Modified:
   sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
   sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
   sandbox/maestro-3.0/Maestro.Editors/WebLayout/CommandIconCache.cs
Log:
 - Fix NullReferenceException when attempting to fetch command icon for a command that has no image url
 - Add the NewItemCommand to the site explorer context menu.


Modified: sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs	2010-08-06 05:11:06 UTC (rev 5072)
+++ sandbox/maestro-3.0/Maestro.Base/Commands/NewItemCommand.cs	2010-08-06 05:29:48 UTC (rev 5073)
@@ -31,12 +31,24 @@
         public override void Run()
         {
             var wb = Workbench.Instance;
+            var exp = wb.ActiveSiteExplorer;
             var mgr = ServiceRegistry.GetService<ServerConnectionManager>();
             var orm = ServiceRegistry.GetService<OpenResourceManager>();
-            var conn = mgr.GetConnection(wb.ActiveSiteExplorer.ConnectionName);
+            var conn = mgr.GetConnection(exp.ConnectionName);
             var nits = ServiceRegistry.GetService<NewItemTemplateService>();
 
-            var dlg = new NewResourceDialog(conn.ResourceService, nits);
+            NewResourceDialog dlg = null;
+
+            if (exp.SelectedItems.Length == 1)
+            {
+                var item = exp.SelectedItems[0];
+                if (item.IsFolder)
+                    dlg = new NewResourceDialog(conn.ResourceService, nits, item.ResourceId);
+            }
+
+            if (dlg == null)
+                dlg = new NewResourceDialog(conn.ResourceService, nits);
+
             if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 var tpl = dlg.SelectedTemplate;

Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin	2010-08-06 05:11:06 UTC (rev 5072)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin	2010-08-06 05:29:48 UTC (rev 5073)
@@ -82,7 +82,7 @@
                       icon="clipboard_paste"
                       class="Maestro.Base.Commands.NotImplementedCommand" />
         </MenuItem>
-        <!-- For testing various APIs, disable for releases -->
+        <!-- For testing various APIs, disabled for releases -->
         <Condition action="Exclude" name="DebugMode">
             <MenuItem id="Menu_Test"
                       type="Menu"
@@ -262,14 +262,15 @@
     <!-- Site Explorer Context Menu -->
     <Path name="/Maestro/Shell/SiteExplorer/SelectedFolder">
         <Condition action="Disable" name="SelectedItem" type="Folder">
+            <MenuItem id="NewItem"
+                      icon="document__plus"
+                      label="${res:Menu_File_NewResource}"
+                      tooltip="${res:Menu_File_NewResource}"
+                      class="Maestro.Base.Commands.NewItemCommand" />
+            <MenuItem type="Separator" />
             <MenuItem id="CreatePackage"
                       label="${res:SiteExplorer_SelectedFolder_CreatePackage}"
                       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" />
@@ -285,6 +286,12 @@
             <MenuItem id="Paste"
                       label="${res:SiteExplorer_SelectedFolder_Paste}"
                       class="Maestro.Base.Commands.NotImplementedCommand" />
+            <MenuItem type="Separator" />
+            <Condition action="Disable" name="IsNotRoot">
+                <MenuItem id="Delete"
+                          label="${res:SiteExplorer_SelectedItem_Delete}"
+                          class="Maestro.Base.Commands.NotImplementedCommand" />
+            </Condition>
             <MenuItem id="Validate"
                       label="${res:SiteExplorer_ValidateResources}"
                       class="Maestro.Base.Commands.SiteExplorer.ValidateCommand" />

Modified: sandbox/maestro-3.0/Maestro.Editors/WebLayout/CommandIconCache.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/WebLayout/CommandIconCache.cs	2010-08-06 05:11:06 UTC (rev 5072)
+++ sandbox/maestro-3.0/Maestro.Editors/WebLayout/CommandIconCache.cs	2010-08-06 05:29:48 UTC (rev 5073)
@@ -37,7 +37,7 @@
 
         public static Bitmap GetStandardCommandIcon(string relpath)
         {
-            if (!relpath.StartsWith("../stdicons/") && !relpath.EndsWith(".gif"))
+            if (relpath == null || !relpath.StartsWith("../stdicons/") && !relpath.EndsWith(".gif"))
                 return null;
 
             var resMgr = Properties.Resources.ResourceManager;



More information about the mapguide-commits mailing list