From 4efdafdcc6e407c91c92798428954de6718e72d8 Mon Sep 17 00:00:00 2001 From: Lluis Sanchez Date: Wed, 26 Aug 2015 17:57:29 +0200 Subject: [Ide] Don't allow dropping files into other files It is a very unusual operation which is very easy to trigger and which is a source of confusion to users. --- .../ProjectFileNodeBuilder.cs | 54 ---------------------- 1 file changed, 54 deletions(-) (limited to 'main/src/core/MonoDevelop.Ide') diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs index ca2204543b..57608e02bb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs @@ -224,60 +224,6 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad return DragOperation.Copy | DragOperation.Move; } - public override bool CanDropNode (object dataObject, DragOperation operation) - { - var target = (ProjectFile) CurrentNode.DataItem; - var pf = dataObject as ProjectFile; - - return pf != null && pf != target && !pf.HasChildren && target.DependsOn == null; - } - - void Drop (ProjectFile pf, DragOperation operation, HashSet projectsToSave) - { - var target = (ProjectFile) CurrentNode.DataItem; - var targetDirectory = target.FilePath.ParentDirectory; - - // file dependencies only work if they are in the same physical folder - if (pf.FilePath.ParentDirectory != targetDirectory) { - var targetPath = targetDirectory.Combine (pf.FilePath.FileName); - - // if copying to the same directory, make a copy with a different name - if (targetPath == pf.FilePath) - targetPath = ProjectOperations.GetTargetCopyName (targetPath, false); - - if (File.Exists (targetPath)) - if (!MessageService.Confirm (GettextCatalog.GetString ("The file '{0}' already exists. Do you want to overwrite it?", targetPath.FileName), AlertButton.OverwriteFile)) - return; - - // unlink the project file from its current parent - pf.DependsOn = null; - - projectsToSave.Add (pf.Project); - - bool move = operation == DragOperation.Move; - var opText = move ? GettextCatalog.GetString ("Moving file...") : GettextCatalog.GetString ("Copying file..."); - - using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (opText, Stock.StatusWorking, true)) - IdeApp.ProjectOperations.TransferFiles (monitor, pf.Project, pf.FilePath, target.Project, targetPath, move, true); - - pf = target.Project.Files.GetFile (targetPath); - } - - // the dropped project file now depends on the file it was just dropped onto - pf.DependsOn = target.FilePath.FileName; - projectsToSave.Add (pf.Project); - } - - public override void OnMultipleNodeDrop (object[] dataObjects, DragOperation operation) - { - var projectsToSave = new HashSet (); - - foreach (var dataObject in dataObjects) - Drop ((ProjectFile) dataObject, operation, projectsToSave); - - IdeApp.ProjectOperations.Save (projectsToSave); - } - public override bool CanDeleteItem () { return true; -- cgit v1.2.3