[mapguide-commits] r8185 - in trunk/Tools/Maestro: Maestro.Base Maestro.Base/Services Maestro.Base/Services/DragDropHandlers Maestro.Base/UI Maestro.Editors/Common
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Jun 6 01:25:36 PDT 2014
Author: jng
Date: 2014-06-06 01:25:36 -0700 (Fri, 06 Jun 2014)
New Revision: 8185
Modified:
trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlerService.cs
trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs
trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs
trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SdfFileHandler.cs
trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/ShpFileHandler.cs
trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SltFileHandler.cs
trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/XmlResFileHandler.cs
trunk/Tools/Maestro/Maestro.Base/Strings.Designer.cs
trunk/Tools/Maestro/Maestro.Base/Strings.resx
trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorerDragDropHandler.cs
trunk/Tools/Maestro/Maestro.Editors/Common/GenericItemSelectionDialog.cs
Log:
#2454: Improve the file drag/drop handling. Where multiple handlers could be handling a given file drag/drop operation, prompt the user with the list of applicable handlers. This case was not handled until now. Also in the process, it was discovered that the GenericItemSelectionDialog.SelectItems() method that accepts and returns strings is redundant as the generic version is identical and thus has been removed in this submission as well.
Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlerService.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlerService.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlerService.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -63,9 +63,9 @@
public IList<IDragDropHandler> GetHandlersForFile(string file)
{
var matches = new List<IDragDropHandler>();
+ string ext = Path.GetExtension(file).ToUpper();
foreach (var h in _handlers)
{
- string ext = Path.GetExtension(file).ToUpper();
if (h.CanHandleFileExtension(ext))
matches.Add(h);
}
Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -80,6 +80,11 @@
}
}
+ public override string ToString()
+ {
+ return Strings.DwfHandlerAction;
+ }
+
public bool CanHandleFileExtension(string fileExtension)
{
return HandlerUtil.ExtensionInList(extensions, fileExtension);
Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/PackageFileHandler.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -71,9 +71,14 @@
}
}
+ public override string ToString()
+ {
+ return Strings.MgpHandlerAction;
+ }
+
public bool CanHandleFileExtension(string fileExtension)
{
- return Array.IndexOf(extensions, fileExtension) >= 0;
+ return HandlerUtil.ExtensionInList(extensions, fileExtension);
}
}
}
Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SdfFileHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SdfFileHandler.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SdfFileHandler.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -73,6 +73,11 @@
}
}
+ public override string ToString()
+ {
+ return Strings.SdfHandlerAction;
+ }
+
public bool CanHandleFileExtension(string fileExtension)
{
return HandlerUtil.ExtensionInList(extensions, fileExtension);
Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/ShpFileHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/ShpFileHandler.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/ShpFileHandler.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -91,6 +91,11 @@
}
}
+ public override string ToString()
+ {
+ return Strings.ShpHandlerAction;
+ }
+
public bool CanHandleFileExtension(string fileExtension)
{
return HandlerUtil.ExtensionInList(extensions, fileExtension);
Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SltFileHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SltFileHandler.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/SltFileHandler.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -73,6 +73,11 @@
}
}
+ public override string ToString()
+ {
+ return Strings.SltHandlerAction;
+ }
+
public bool CanHandleFileExtension(string fileExtension)
{
return HandlerUtil.ExtensionInList(extensions, fileExtension);
Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/XmlResFileHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/XmlResFileHandler.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/XmlResFileHandler.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -83,6 +83,11 @@
}
}
+ public override string ToString()
+ {
+ return Strings.XmlResHandlerAction;
+ }
+
public bool CanHandleFileExtension(string fileExtension)
{
return true;
Modified: trunk/Tools/Maestro/Maestro.Base/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Strings.Designer.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Strings.Designer.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -1781,6 +1781,24 @@
}
/// <summary>
+ /// Looks up a localized string similar to Select File Handler.
+ /// </summary>
+ internal static string SelectFileHandler {
+ get {
+ return ResourceManager.GetString("SelectFileHandler", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Select File Handler to handle this action.
+ /// </summary>
+ internal static string SelectFileHandlerDesc {
+ get {
+ return ResourceManager.GetString("SelectFileHandlerDesc", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Select the user template path.
/// </summary>
internal static string SelectTemplatePath {
Modified: trunk/Tools/Maestro/Maestro.Base/Strings.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Strings.resx 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/Strings.resx 2014-06-06 08:25:36 UTC (rev 8185)
@@ -1001,4 +1001,10 @@
<data name="EditedResource" xml:space="preserve">
<value>Currently Edited Resource</value>
</data>
+ <data name="SelectFileHandler" xml:space="preserve">
+ <value>Select File Handler</value>
+ </data>
+ <data name="SelectFileHandlerDesc" xml:space="preserve">
+ <value>Select File Handler to handle this action</value>
+ </data>
</root>
\ No newline at end of file
Modified: trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorerDragDropHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorerDragDropHandler.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Base/UI/SiteExplorerDragDropHandler.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -20,11 +20,13 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Linq;
using System.Windows.Forms;
using Maestro.Base.Services;
using Maestro.Shared.UI;
using Aga.Controls.Tree;
using OSGeo.MapGuide.MaestroAPI;
+using Maestro.Editors.Common;
namespace Maestro.Base.UI
{
@@ -96,6 +98,15 @@
if (handlers.Count > 1)
{
//Resolve which handler to use
+ var handler = GenericItemSelectionDialog.SelectItem<IDragDropHandler>(Strings.SelectFileHandler, Strings.SelectFileHandlerDesc, handlers.ToArray());
+ if (handler != null)
+ {
+ using (new WaitCursor(Workbench.Instance))
+ {
+ if (handler.HandleDrop(conn, file, folderId))
+ refresh = true;
+ }
+ }
}
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/GenericItemSelectionDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/GenericItemSelectionDialog.cs 2014-06-03 16:07:04 UTC (rev 8184)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/GenericItemSelectionDialog.cs 2014-06-06 08:25:36 UTC (rev 8185)
@@ -44,10 +44,8 @@
/// <param name="title"></param>
/// <param name="prompt"></param>
/// <param name="items"></param>
- /// <param name="displayMember"></param>
- /// <param name="valueMember"></param>
/// <returns></returns>
- public static T SelectItem<T>(string title, string prompt, T[] items, string displayMember, string valueMember) where T : class
+ public static T SelectItem<T>(string title, string prompt, T[] items) where T : class
{
var dlg = new GenericItemSelectionDialog();
if (!string.IsNullOrEmpty(title))
@@ -55,11 +53,6 @@
if (!string.IsNullOrEmpty(prompt))
dlg.lblPrompt.Text = prompt;
- if (!string.IsNullOrEmpty(displayMember))
- dlg.lstItems.DisplayMember = displayMember;
- if (!string.IsNullOrEmpty(valueMember))
- dlg.lstItems.ValueMember = valueMember;
-
dlg.lstItems.DataSource = items;
if (dlg.ShowDialog() == DialogResult.OK)
@@ -70,7 +63,7 @@
}
/// <summary>
- /// Displays a dialog to select items from an array of items
+ /// Displays a dialog to select an item from an array of items
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="title"></param>
@@ -79,7 +72,7 @@
/// <param name="displayMember"></param>
/// <param name="valueMember"></param>
/// <returns></returns>
- public static T[] SelectItems<T>(string title, string prompt, T[] items, string displayMember, string valueMember) where T : class
+ public static T SelectItem<T>(string title, string prompt, T[] items, string displayMember, string valueMember) where T : class
{
var dlg = new GenericItemSelectionDialog();
if (!string.IsNullOrEmpty(title))
@@ -87,33 +80,31 @@
if (!string.IsNullOrEmpty(prompt))
dlg.lblPrompt.Text = prompt;
- dlg.lstItems.SelectionMode = SelectionMode.MultiSimple;
- dlg.lstItems.DataSource = items;
if (!string.IsNullOrEmpty(displayMember))
dlg.lstItems.DisplayMember = displayMember;
if (!string.IsNullOrEmpty(valueMember))
dlg.lstItems.ValueMember = valueMember;
+ dlg.lstItems.DataSource = items;
+
if (dlg.ShowDialog() == DialogResult.OK)
{
- List<T> values = new List<T>();
- foreach (T item in dlg.lstItems.SelectedItems)
- {
- values.Add(item);
- }
- return values.ToArray();
+ return (T)dlg.lstItems.SelectedItem;
}
- return new T[0];
+ return null;
}
/// <summary>
- /// Displays a dialog to select a string from an array of strings
+ /// Displays a dialog to select items from an array of items
/// </summary>
+ /// <typeparam name="T"></typeparam>
/// <param name="title"></param>
/// <param name="prompt"></param>
/// <param name="items"></param>
+ /// <param name="displayMember"></param>
+ /// <param name="valueMember"></param>
/// <returns></returns>
- public static string SelectItem(string title, string prompt, string[] items)
+ public static T[] SelectItems<T>(string title, string prompt, T[] items, string displayMember, string valueMember) where T : class
{
var dlg = new GenericItemSelectionDialog();
if (!string.IsNullOrEmpty(title))
@@ -121,13 +112,23 @@
if (!string.IsNullOrEmpty(prompt))
dlg.lblPrompt.Text = prompt;
+ dlg.lstItems.SelectionMode = SelectionMode.MultiSimple;
dlg.lstItems.DataSource = items;
+ if (!string.IsNullOrEmpty(displayMember))
+ dlg.lstItems.DisplayMember = displayMember;
+ if (!string.IsNullOrEmpty(valueMember))
+ dlg.lstItems.ValueMember = valueMember;
if (dlg.ShowDialog() == DialogResult.OK)
{
- return dlg.lstItems.SelectedItem.ToString();
+ List<T> values = new List<T>();
+ foreach (T item in dlg.lstItems.SelectedItems)
+ {
+ values.Add(item);
+ }
+ return values.ToArray();
}
- return null;
+ return new T[0];
}
/// <summary>
More information about the mapguide-commits
mailing list