[mapguide-commits] r5453 - in sandbox/maestro-3.0: Maestro.Base Maestro.Base/Properties Maestro.Base/Services/DragDropHandlers Maestro.Editors/Common Maestro.Editors/Properties

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Dec 9 05:57:00 EST 2010


Author: jng
Date: 2010-12-09 02:57:00 -0800 (Thu, 09 Dec 2010)
New Revision: 5453

Added:
   sandbox/maestro-3.0/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs
Modified:
   sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
   sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
   sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
   sandbox/maestro-3.0/Maestro.Editors/Common/ResourceDataCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx
Log:
3.0 sandbox changes:
 - #1564: Implement drag/drop package loading
 - #1565: Resource Data UI improvements

Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin	2010-12-09 08:31:01 UTC (rev 5452)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin	2010-12-09 10:57:00 UTC (rev 5453)
@@ -31,6 +31,7 @@
 
     <!-- Registered drop handlers -->
     <Path name="/Maestro/DragDropHandlers">
+        <Class id="MgpHandler" class="Maestro.Base.Services.DragDropHandlers.PackageFileHandler" />
         <Class id="SdfHandler" class="Maestro.Base.Services.DragDropHandlers.SdfFileHandler" />
         <Class id="ShpHandler" class="Maestro.Base.Services.DragDropHandlers.ShpFileHandler" />
         <Class id="SltHandler" class="Maestro.Base.Services.DragDropHandlers.SltFileHandler" />

Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj	2010-12-09 08:31:01 UTC (rev 5452)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj	2010-12-09 10:57:00 UTC (rev 5453)
@@ -212,6 +212,7 @@
     </Compile>
     <Compile Include="Services\ClipboardService.cs" />
     <Compile Include="Services\DragDropHandlerService.cs" />
+    <Compile Include="Services\DragDropHandlers\PackageFileHandler.cs" />
     <Compile Include="Services\DragDropHandlers\SltFileHandler.cs" />
     <Compile Include="Services\DragDropHandlers\SdfFileHandler.cs" />
     <Compile Include="Services\DragDropHandlers\ShpFileHandler.cs" />

Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs	2010-12-09 08:31:01 UTC (rev 5452)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs	2010-12-09 10:57:00 UTC (rev 5453)
@@ -292,6 +292,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Confirm.
+        /// </summary>
+        internal static string Confirm {
+            get {
+                return ResourceManager.GetString("Confirm", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to You have open editors with unsaved changes. Continue anyway?.
         /// </summary>
         internal static string ConfirmCloseEditors {
@@ -319,6 +328,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Are you sure you want to load this package file?.
+        /// </summary>
+        internal static string ConfirmLoadPackage {
+            get {
+                return ResourceManager.GetString("ConfirmLoadPackage", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Are you sure you want to move the following resources?.
         /// </summary>
         internal static string ConfirmMove {
@@ -961,6 +979,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Load this package file.
+        /// </summary>
+        internal static string MgpHandlerAction {
+            get {
+                return ResourceManager.GetString("MgpHandlerAction", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Failed to move {0} to {1}.
         /// </summary>
         internal static string MoveFailure {

Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx	2010-12-09 08:31:01 UTC (rev 5452)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx	2010-12-09 10:57:00 UTC (rev 5453)
@@ -799,4 +799,13 @@
   <data name="Menu_Window" xml:space="preserve">
     <value>Window</value>
   </data>
+  <data name="MgpHandlerAction" xml:space="preserve">
+    <value>Load this package file</value>
+  </data>
+  <data name="Confirm" xml:space="preserve">
+    <value>Confirm</value>
+  </data>
+  <data name="ConfirmLoadPackage" xml:space="preserve">
+    <value>Are you sure you want to load this package file?</value>
+  </data>
 </root>
\ No newline at end of file

Added: sandbox/maestro-3.0/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs	                        (rev 0)
+++ sandbox/maestro-3.0/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs	2010-12-09 10:57:00 UTC (rev 5453)
@@ -0,0 +1,72 @@
+#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 System.IO;
+using ICSharpCode.Core;
+using Maestro.Packaging;
+
+namespace Maestro.Base.Services.DragDropHandlers
+{
+    public class PackageFileHandler : IDragDropHandler
+    {
+        public string HandlerAction
+        {
+            get { return Properties.Resources.MgpHandlerAction; }
+        }
+
+        string[] extensions = { ".mgp" };
+
+        public string[] FileExtensions
+        {
+            get { return extensions; }
+        }
+
+        public bool HandleDrop(string file, string folderId)
+        {
+            try
+            {
+                if (!MessageService.AskQuestion(Properties.Resources.ConfirmLoadPackage, Properties.Resources.Confirm))
+                    return false;
+
+                var wb = Workbench.Instance;
+                var exp = wb.ActiveSiteExplorer;
+                var mgr = ServiceRegistry.GetService<ServerConnectionManager>();
+                var conn = mgr.GetConnection(exp.ConnectionName);
+                var res = PackageProgress.UploadPackage(
+                        wb,
+                        conn,
+                        file);
+
+                if (res == System.Windows.Forms.DialogResult.OK)
+                {
+                    exp.RefreshModel();
+                }
+                return false; //Already refreshed if successful
+            }
+            catch (Exception ex)
+            {
+                MessageService.ShowError(ex);
+                return false;
+            }
+        }
+    }
+}

Modified: sandbox/maestro-3.0/Maestro.Editors/Common/ResourceDataCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Common/ResourceDataCtrl.cs	2010-12-09 08:31:01 UTC (rev 5452)
+++ sandbox/maestro-3.0/Maestro.Editors/Common/ResourceDataCtrl.cs	2010-12-09 10:57:00 UTC (rev 5453)
@@ -197,6 +197,9 @@
             var item = this.SelectedItem;
             if (item != null)
             {
+                if (MessageBox.Show(Properties.Resources.ConfirmDeleteResourceData, Properties.Resources.Confirm, MessageBoxButtons.YesNo) == DialogResult.No)
+                    return;
+
                 try
                 {
                     using (new WaitCursor(this))
@@ -225,6 +228,7 @@
             {
                 using (var save = DialogFactory.SaveFile())
                 {
+                    save.FileName = item.Name;
                     if (save.ShowDialog() == DialogResult.OK)
                     {
                         try
@@ -239,7 +243,7 @@
                                     Utility.CopyStream(stream, fs);
                                 }
                             }
-                            MessageBox.Show(Properties.Resources.FileDownloaded);
+                            MessageBox.Show(string.Format(Properties.Resources.FileDownloaded, save.FileName));
                         }
                         catch (Exception ex)
                         {

Modified: sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs	2010-12-09 08:31:01 UTC (rev 5452)
+++ sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.Designer.cs	2010-12-09 10:57:00 UTC (rev 5453)
@@ -319,6 +319,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Are you sure you want to delete this resource data?.
+        /// </summary>
+        internal static string ConfirmDeleteResourceData {
+            get {
+                return ResourceManager.GetString("ConfirmDeleteResourceData", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to The content file does not exist.
         /// </summary>
         internal static string ContentFileMissing {
@@ -550,7 +559,7 @@
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to File Downloaded.
+        ///   Looks up a localized string similar to File Downloaded to {0}.
         /// </summary>
         internal static string FileDownloaded {
             get {

Modified: sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx	2010-12-09 08:31:01 UTC (rev 5452)
+++ sandbox/maestro-3.0/Maestro.Editors/Properties/Resources.resx	2010-12-09 10:57:00 UTC (rev 5453)
@@ -517,7 +517,7 @@
     <value>..\Resources\icon_copy_disabled.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
   <data name="FileDownloaded" xml:space="preserve">
-    <value>File Downloaded</value>
+    <value>File Downloaded to {0}</value>
   </data>
   <data name="ColumnHasNoValidDataError" xml:space="preserve">
     <value>The selected column had no non-null values and cannot be used.</value>
@@ -1061,4 +1061,7 @@
   <data name="FilterXml" xml:space="preserve">
     <value>XML Files (.xml)|*.xml</value>
   </data>
+  <data name="ConfirmDeleteResourceData" xml:space="preserve">
+    <value>Are you sure you want to delete this resource data?</value>
+  </data>
 </root>
\ No newline at end of file



More information about the mapguide-commits mailing list