140
public class ProjectFolderCommandHandler: FolderCommandHandler
140
class ProjectFolderCommandHandler: FolderCommandHandler
142
public override void ActivateItem ()
144
CurrentNode.Expanded = !CurrentNode.Expanded;
142
147
public override string GetFolderPath (object dataObject)
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);
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. ")
199
deleteOnlyQuestion.Buttons.Add (AlertButton.Cancel);
200
deleteOnlyQuestion.Buttons.Add (AlertButton.Delete);
190
202
foreach (var folder in folders) {
191
203
var project = folder.Project;
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);
208
bool isProjectFolder = files.Count == 0 && folderPf == null;
197
212
//if the parent directory has already been removed, there may be nothing to do
198
if (files.Count == 0 && folderPf == null)
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)
207
projects.Add (project);
209
//remove the files and link files in the directory
210
foreach (var f in files)
211
project.Files.Remove (f);
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)
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)
226
projects.Add (project);
228
//remove the files and link files in the directory
229
foreach (var f in files)
230
project.Files.Remove (f);
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);
218
238
if (result == AlertButton.Delete) {
229
249
folder.Remove ();
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);