diff --git a/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/ServerBrowserTool.csproj b/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/ServerBrowserTool.csproj index edc5877645..b0e46ec65f 100644 --- a/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/ServerBrowserTool.csproj +++ b/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/ServerBrowserTool.csproj @@ -40,6 +40,7 @@ + diff --git a/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/Src/Forms/ISupportsDragDrop.cs b/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/Src/Forms/ISupportsDragDrop.cs new file mode 100644 index 0000000000..6e6429ed4e --- /dev/null +++ b/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/Src/Forms/ISupportsDragDrop.cs @@ -0,0 +1,23 @@ +/* + * Created by SharpDevelop. + * User: dickon + * Date: 04/03/2007 + * Time: 09:14 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Windows.Forms; + +namespace SharpServerTools.Forms +{ + /// + /// This interface is implemented by any plugin to ServerExplorer that supports drag and drop + /// of some of its data + /// + public interface ISupportsDragDrop + { + void HandleMouseDownEvent(object sender, MouseEventArgs e); + } +} diff --git a/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/Src/Forms/ServerToolTreeView.cs b/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/Src/Forms/ServerToolTreeView.cs index f68864d5f6..c1ae2fd0c6 100644 --- a/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/Src/Forms/ServerToolTreeView.cs +++ b/src/AddIns/Misc/SharpServerTools/ServerBrowserTool/Src/Forms/ServerToolTreeView.cs @@ -34,14 +34,25 @@ namespace SharpServerTools.Forms // create an instance of the relevant ServerTool TreeNode string id = codon.Id; TreeNode treeNode = (TreeNode)node.BuildChildItem(id, null, null); - IRequiresRebuildSource s = treeNode as IRequiresRebuildSource; - + // a ServerTool plugin can register to be refreshed by the ServerToolTreeView // control by implementing the IRequiresRebuildSource interface + IRequiresRebuildSource s = treeNode as IRequiresRebuildSource; + if (s != null) { s.RebuildRequiredEvent += new RebuildRequiredEventHandler(RebuildRequiredNotify); } + + // a ServerTool plugin can also register to handle drag-n-drop if it implements + // the required interface + + ISupportsDragDrop d = treeNode as ISupportsDragDrop; + + if (d != null) { + this.MouseDown += new MouseEventHandler(d.HandleMouseDownEvent); + } + this.Nodes.Add(treeNode); } @@ -91,7 +102,7 @@ namespace SharpServerTools.Forms } } - } public delegate void RebuildChildrenDelegate(IEnumerable children); + } diff --git a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/DatabaseExplorerTreeNode.cs b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/DatabaseExplorerTreeNode.cs index 6717a5d1fb..7e91f72f3d 100644 --- a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/DatabaseExplorerTreeNode.cs +++ b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/DatabaseExplorerTreeNode.cs @@ -22,7 +22,7 @@ namespace SharpDbTools.Forms /// Description of DatabaseExplorerNode. /// Hold minimal state - access state through the DbModelInfoService /// - public class DatabaseExplorerTreeNode: TreeNode, IRebuildable, IRequiresRebuildSource + public class DatabaseExplorerTreeNode: TreeNode, IRebuildable, IRequiresRebuildSource, ISupportsDragDrop { public DatabaseExplorerTreeNode(): base("Database Explorer") { @@ -143,5 +143,31 @@ namespace SharpDbTools.Forms } } } + + /// + /// If a DbModelInfoTreeNode is selected then the desired drag and drop behaviour + /// is to pass the ConnectionString to drop target. + /// + /// + /// + public void HandleMouseDownEvent(object sender, MouseEventArgs e) + { + LoggingService.Debug(this.GetType().Name + " handling MouseDownEvent"); + TreeView parent = this.TreeView; + TreeNode currentlySelected = parent.SelectedNode; + + // If the user has selected a TreeNode for a specific connection, and has the right + // mouse button down, then initiate a drag drop operation + DbModelInfoTreeNode infoNode = currentlySelected as DbModelInfoTreeNode; + if (infoNode != null) { + string logicalConnectionName = infoNode.LogicalConnectionName; + DbModelInfo info = DbModelInfoService.GetDbModelInfo(logicalConnectionName); + string connectionString = info.ConnectionString; + LoggingService.Debug("drag drop operation initiated for ConnectionString: " + connectionString); + if (connectionString != null) { + parent.DoDragDrop(connectionString, DragDropEffects.Copy); + } + } + } } }