37
37
using MonoDevelop.Ide.Gui;
38
38
using MonoDevelop.Components.Commands;
39
39
using MonoDevelop.Ide.Gui.Components;
40
using System.Collections.Generic;
41
43
namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
118
120
IdeApp.Workbench.OpenDocument (file.Path);
121
public override void DeleteItem ()
123
public override void DeleteMultipleItems ()
123
SystemFile file = CurrentNode.DataItem as SystemFile;
125
bool yes = MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to permanently delete the file {0}?", file.Path), AlertButton.Delete);
129
FileService.DeleteFile (file.Path);
131
MessageService.ShowError (GettextCatalog.GetString ("The file {0} could not be deleted", file.Path));
125
if (CurrentNodes.Length == 1) {
126
SystemFile file = (SystemFile)CurrentNodes[0].DataItem;
127
if (!MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to permanently delete the file {0}?", file.Path), AlertButton.Delete))
130
if (!MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to permanently delete all selected files?"), AlertButton.Delete))
133
foreach (SystemFile file in CurrentNodes.Select (n => (SystemFile)n.DataItem)) {
135
FileService.DeleteFile (file.Path);
137
MessageService.ShowError (GettextCatalog.GetString ("The file {0} could not be deleted", file.Path));
144
151
Set<SolutionEntityItem> projects = new Set<SolutionEntityItem> ();
145
152
Set<Solution> solutions = new Set<Solution> ();
146
foreach (ITreeNavigator node in CurrentNodes) {
147
SystemFile file = (SystemFile) node.DataItem;
148
Project project = node.GetParentDataItem (typeof(Project), true) as Project;
149
if (project != null) {
150
project.AddFile (file.Path);
151
projects.Add (project);
154
SolutionFolder folder = node.GetParentDataItem (typeof(SolutionFolder), true) as SolutionFolder;
155
if (folder != null) {
156
folder.Files.Add (file.Path);
157
solutions.Add (folder.ParentSolution);
153
var nodesByProject = CurrentNodes.GroupBy (n => n.GetParentDataItem (typeof(Project), true) as Project);
155
foreach (var projectGroup in nodesByProject) {
156
Project project = projectGroup.Key;
157
List<FilePath> newFiles = new List<FilePath> ();
158
foreach (ITreeNavigator node in projectGroup) {
159
SystemFile file = (SystemFile) node.DataItem;
160
if (project != null) {
161
newFiles.Add (file.Path);
162
projects.Add (project);
160
Solution sol = node.GetParentDataItem (typeof(Solution), true) as Solution;
161
sol.RootFolder.Files.Add (file.Path);
165
SolutionFolder folder = node.GetParentDataItem (typeof(SolutionFolder), true) as SolutionFolder;
166
if (folder != null) {
167
folder.Files.Add (file.Path);
168
solutions.Add (folder.ParentSolution);
171
Solution sol = node.GetParentDataItem (typeof(Solution), true) as Solution;
172
sol.RootFolder.Files.Add (file.Path);
177
if (newFiles.Count > 0)
178
project.AddFiles (newFiles);
166
180
IdeApp.ProjectOperations.Save (projects);
167
181
foreach (Solution sol in solutions)
191
205
[CommandUpdateHandler (ViewCommands.OpenWithList)]
192
206
public void OnOpenWithUpdate (CommandArrayInfo info)
194
SystemFile file = CurrentNode.DataItem as SystemFile;
195
FileViewer prev = null;
196
foreach (FileViewer fv in IdeApp.Workbench.GetFileViewers (file.Path)) {
197
if (prev != null && fv.IsExternal != prev.IsExternal)
198
info.AddSeparator ();
199
info.Add (fv.Title, fv);
208
ProjectFileNodeCommandHandler.PopulateOpenWithViewers (info, null, ((SystemFile) CurrentNode.DataItem).Path);