Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2010-09-02 13:06:40 +0400
committerLluis Sanchez <lluis@novell.com>2010-09-02 13:07:10 +0400
commit43a5b0563cde8849eca1661bf8db1b7118724ba9 (patch)
tree661ebc91346d66f175b67db915f3314a7b9a97d8 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad
parent4d024082a78bf6713113654da8cc5969686a0071 (diff)
Fixed bug #636404 - Copy and paste of a file into the same folder
deletes file contents Make sure to use the provided target path name as new file name. Ask for confirmation if a file is going to be overwritten.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs56
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs2
2 files changed, 7 insertions, 51 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs
index dfbdf04a63..2dba18d629 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs
@@ -178,13 +178,10 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
Project sourceProject;
System.Collections.Generic.IEnumerable<ProjectFile> groupedChildren = null;
- bool ask;
-
if (dataObject is ProjectFolder) {
source = ((ProjectFolder) dataObject).Path;
sourceProject = ((ProjectFolder) dataObject).Project;
what = Path.GetFileName (source);
- ask = true;
}
else if (dataObject is ProjectFile) {
ProjectFile file = (ProjectFile) dataObject;
@@ -196,7 +193,6 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
}
groupedChildren = file.DependentChildren;
what = null;
- ask = false;
}
else if (dataObject is Gtk.SelectionData) {
SelectionData data = (SelectionData) dataObject;
@@ -223,9 +219,9 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
targetPath = targetPath.Combine (source.FileName);
// If copying to the same directory, make a copy with a different name
if (targetPath == source)
- targetPath = GetTargetCopyName (targetPath, dataObject is ProjectFolder);
+ targetPath = ProjectOperations.GetTargetCopyName (targetPath, dataObject is ProjectFolder);
- if (ask) {
+ if (dataObject is ProjectFolder) {
string q;
if (operation == DragOperation.Move) {
if (targetPath.ParentDirectory == targetProject.BaseDirectory)
@@ -243,7 +239,10 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
if (!MessageService.Confirm (q, AlertButton.Copy))
return;
}
-
+ } else if (dataObject is ProjectFile) {
+ 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;
}
ArrayList filesToSave = new ArrayList ();
@@ -307,49 +306,6 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
}
}
- internal static FilePath GetTargetCopyName (FilePath path, bool isFolder)
- {
- int n=1;
- // First of all try to find an existing copy tag
- string fn = path.FileNameWithoutExtension;
- for (int i=1; i<100; i++) {
- string copyTag = GetCopyTag (i);
- if (fn.EndsWith (copyTag)) {
- string newfn = fn.Substring (0, fn.Length - copyTag.Length);
- if (newfn.Trim ().Length > 0) {
- n = i + 1;
- path = path.ParentDirectory.Combine (newfn + path.Extension);
- break;
- }
- }
- }
- FilePath basePath = path;
- while ((!isFolder && File.Exists (path)) || (isFolder && Directory.Exists (path))) {
- string copyTag = GetCopyTag (n);
- path = basePath.ParentDirectory.Combine (basePath.FileNameWithoutExtension + copyTag + basePath.Extension);
- n++;
- }
- return path;
- }
-
- static string GetCopyTag (int n)
- {
- string sc;
- switch (n) {
- case 1: sc = GettextCatalog.GetString ("copy"); break;
- case 2: sc = GettextCatalog.GetString ("another copy"); break;
- case 3: sc = GettextCatalog.GetString ("3rd copy"); break;
- case 4: sc = GettextCatalog.GetString ("4th copy"); break;
- case 5: sc = GettextCatalog.GetString ("5th copy"); break;
- case 6: sc = GettextCatalog.GetString ("6th copy"); break;
- case 7: sc = GettextCatalog.GetString ("7th copy"); break;
- case 8: sc = GettextCatalog.GetString ("8th copy"); break;
- case 9: sc = GettextCatalog.GetString ("9th copy"); break;
- default: sc = GettextCatalog.GetString ("copy {0}"); break;
- }
- return " (" + string.Format (sc, n) + ")";
- }
-
[CommandHandler (ProjectCommands.AddFiles)]
public void AddFilesToProject()
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs
index d09c158dcd..b8e4b22057 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ShowAllFilesBuilderExtension.cs
@@ -343,7 +343,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
FilePath source = ((SystemFile)dataObject).Path;
targetPath = targetPath.Combine (source.FileName);
if (targetPath == source)
- targetPath = FolderCommandHandler.GetTargetCopyName (targetPath, false);
+ targetPath = ProjectOperations.GetTargetCopyName (targetPath, false);
using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString("Copying files..."), Stock.CopyIcon, true))
{