~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFolderNodeBuilder.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
44
44
{
45
 
        public class ProjectFolderNodeBuilder: FolderNodeBuilder
 
45
        class ProjectFolderNodeBuilder: FolderNodeBuilder
46
46
        {
47
47
                Gdk.Pixbuf folderOpenIcon;
48
48
                Gdk.Pixbuf folderClosedIcon;
137
137
                }
138
138
        }
139
139
        
140
 
        public class ProjectFolderCommandHandler: FolderCommandHandler
 
140
        class ProjectFolderCommandHandler: FolderCommandHandler
141
141
        {
 
142
                public override void ActivateItem ()
 
143
                {
 
144
                        CurrentNode.Expanded = !CurrentNode.Expanded;
 
145
                }
 
146
 
142
147
                public override string GetFolderPath (object dataObject)
143
148
                {
144
149
                        return ((ProjectFolder)dataObject).Path;
186
191
                        question.Buttons.Add (AlertButton.Cancel);
187
192
                        question.Buttons.Add (AlertButton.Delete);
188
193
                        question.Buttons.Add (removeButton);
 
194
 
 
195
                        var deleteOnlyQuestion = new QuestionMessage () {
 
196
                                AllowApplyToAll = folders.Count > 1,
 
197
                                SecondaryText = GettextCatalog.GetString ("The directory and any files it contains will be permanintly removed from your hard disk. ")
 
198
                        };
 
199
                        deleteOnlyQuestion.Buttons.Add (AlertButton.Cancel);
 
200
                        deleteOnlyQuestion.Buttons.Add (AlertButton.Delete);
189
201
                        
190
202
                        foreach (var folder in folders) {
191
203
                                var project = folder.Project;
192
 
                                
 
204
 
193
205
                                var folderRelativePath = folder.Path.ToRelative (project.BaseDirectory);
194
206
                                var files = project.Files.GetFilesInVirtualPath (folderRelativePath).ToList ();
195
207
                                var folderPf = project.Files.GetFileWithVirtualPath (folderRelativePath);
196
 
                                
 
208
                                bool isProjectFolder = files.Count == 0 && folderPf == null;
 
209
 
 
210
                                AlertButton result;
 
211
 
197
212
                                //if the parent directory has already been removed, there may be nothing to do
198
 
                                if (files.Count == 0 && folderPf == null)
199
 
                                        continue;
200
 
                                
201
 
                                question.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0} from project {1}?",
202
 
                                        folder.Name, project.Name);
203
 
                                var result = MessageService.AskQuestion (question);
204
 
                                if (result != removeButton && result != AlertButton.Delete) 
205
 
                                        break;
206
 
                                
207
 
                                projects.Add (project);
208
 
                                
209
 
                                //remove the files and link files in the directory
210
 
                                foreach (var f in files)
211
 
                                        project.Files.Remove (f);
212
 
                                
213
 
                                // also remove the folder's own ProjectFile, if it exists 
214
 
                                // FIXME: it probably was already in the files list
215
 
                                if (folderPf != null)
216
 
                                        project.Files.Remove (folderPf);
 
213
                                if (isProjectFolder) {
 
214
                                        deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
 
215
                                        result = MessageService.AskQuestion (deleteOnlyQuestion);
 
216
                                        if (result != AlertButton.Delete) 
 
217
                                                break;
 
218
                                }
 
219
                                else {
 
220
                                        question.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0} from project {1}?",
 
221
                                                folder.Name, project.Name);
 
222
                                        result = MessageService.AskQuestion (question);
 
223
                                        if (result != removeButton && result != AlertButton.Delete) 
 
224
                                                break;
 
225
                                        
 
226
                                        projects.Add (project);
 
227
                                        
 
228
                                        //remove the files and link files in the directory
 
229
                                        foreach (var f in files)
 
230
                                                project.Files.Remove (f);
 
231
                                        
 
232
                                        // also remove the folder's own ProjectFile, if it exists 
 
233
                                        // FIXME: it probably was already in the files list
 
234
                                        if (folderPf != null)
 
235
                                                project.Files.Remove (folderPf);
 
236
                                }
217
237
                                
218
238
                                if (result == AlertButton.Delete) {
219
239
                                        try {
229
249
                                        folder.Remove ();
230
250
                                }
231
251
                                
232
 
                                if (folder.Path.ParentDirectory != project.BaseDirectory) {
 
252
                                if (isProjectFolder && folder.Path.ParentDirectory != project.BaseDirectory) {
233
253
                                        // If it's the last item in the parent folder, make sure we keep a reference to the parent 
234
254
                                        // folder, so it is not deleted from the tree.
235
255
                                        var inParentFolder = project.Files.GetFilesInVirtualPath (folderRelativePath.ParentDirectory);