~ubuntu-branches/ubuntu/natty/monodevelop/natty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-07-05 13:00:05 UTC
  • mfrom: (1.2.8 upstream) (1.3.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100705130005-d6hp4k5gcn1xkj8c
Tags: 2.4+dfsg-1ubuntu1
* debian/patches/remove_support_for_moonlight.patch,
  debian/patches/dont_add_moonlight_to_core_addins.patch,
  debian/control:
  + Enable support for Moonlight
* debian/rules:
  + Ensure Moonlight addin isn't shipped in main MonoDevelop package by
    mistake

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
using MonoDevelop.Ide.Commands;
36
36
using MonoDevelop.Ide.Gui;
37
37
using MonoDevelop.Components.Commands;
38
 
using MonoDevelop.Core.Gui;
39
38
using MonoDevelop.Core.Collections;
40
39
using MonoDevelop.Ide.Gui.Components;
 
40
using System.Linq;
41
41
 
42
42
namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
43
43
{
53
53
                
54
54
                public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
55
55
                {
56
 
                        return Path.GetFileName (((ProjectFile)dataObject).Name);
 
56
                        var file = (ProjectFile) dataObject;
 
57
                        return file.Link.IsNullOrEmpty ? file.FilePath.FileName : file.Link.FileName;
57
58
                }
58
59
                
59
60
                public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes)
72
73
                {
73
74
                        ProjectFile file = (ProjectFile) dataObject;
74
75
 
75
 
                        label = Path.GetFileName (file.FilePath);
 
76
                        label = file.Link.IsNullOrEmpty ? file.FilePath.FileName : file.Link.FileName;
76
77
                        if (!File.Exists (file.FilePath)) {
77
78
                                label = "<span foreground='red'>" + label + "</span>";
78
79
                        }
79
80
                        
80
81
                        icon = DesktopService.GetPixbufForFile (file.FilePath, Gtk.IconSize.Menu);
 
82
                        
 
83
                        if (file.IsLink && icon != null) {
 
84
                                icon = icon.Copy ();
 
85
                                using (Gdk.Pixbuf overlay = Gdk.Pixbuf.LoadFromResource ("Icons.16x16.LinkOverlay.png")) {
 
86
                                        overlay.Composite (icon,
 
87
                                                0,  0,
 
88
                                                icon.Width, icon.Width,
 
89
                                                0, 0,
 
90
                                                1, 1, Gdk.InterpType.Bilinear, 255); 
 
91
                                }
 
92
                        }
81
93
                }
82
94
                
83
95
                public override object GetParentObject (object dataObject)
93
105
                        
94
106
                        if (dir == file.Project.BaseDirectory)
95
107
                                return file.Project;
96
 
                        else if (file.IsExternalToProject)
97
 
                                return new LinkedFilesFolder (file.Project);
98
108
                        else
99
109
                            return new ProjectFolder (dir, file.Project, null);
100
110
                }
130
140
                public override void RenameItem (string newName)
131
141
                {
132
142
                        ProjectFile file = (ProjectFile) CurrentNode.DataItem;
133
 
                        string oldPath = file.Name;
134
 
                        string newPath = Path.Combine (Path.GetDirectoryName (oldPath), newName);
 
143
                        
 
144
                        FilePath oldPath, newPath, newLink = FilePath.Null, oldLink = FilePath.Null;
 
145
                        if (file.IsLink) {
 
146
                                oldLink = file.ProjectVirtualPath;
 
147
                                newLink = oldLink.ParentDirectory.Combine (newName);
 
148
                                oldPath = file.Project.BaseDirectory.Combine (oldLink);
 
149
                                newPath = file.Project.BaseDirectory.Combine (newLink);
 
150
                        } else {
 
151
                                oldPath = file.Name;
 
152
                                newPath = oldPath.ParentDirectory.Combine (newName);    
 
153
                        }
135
154
                        
136
155
                        if (oldPath != newPath) {
137
156
                                try {
138
157
                                        if (!FileService.IsValidPath (newPath)) {
139
158
                                                MessageService.ShowWarning (GettextCatalog.GetString ("The name you have chosen contains illegal characters. Please choose a different name."));
140
 
                                        } else if (File.Exists (newPath) || Directory.Exists (newPath)) {
 
159
                                        } else if (File.Exists (newPath) || Directory.Exists (newPath) ||
 
160
                                                   (file.Project != null && file.Project.Files.GetFileWithVirtualPath (newPath.ToRelative (file.Project.BaseDirectory)) != null)) {
141
161
                                                MessageService.ShowWarning (GettextCatalog.GetString ("File or directory name is already in use. Please choose a different one."));
142
162
                                        } else {
143
 
                                                FileService.RenameFile (oldPath, newName);
 
163
                                                if (file.IsLink) {
 
164
                                                        file.Link = newLink;
 
165
                                                } else {
 
166
                                                        FileService.RenameFile (oldPath, newName);
 
167
                                                }
144
168
                                                if (file.Project != null)
145
169
                                                        IdeApp.ProjectOperations.Save (file.Project);
146
170
                                        }
224
248
                           
225
249
                        foreach (ProjectFile file in files) {
226
250
                                Project project = file.Project;
227
 
                                if (!file.IsExternalToProject) {
228
 
                                        ProjectFile[] inFolder = project.Files.GetFilesInPath (Path.GetDirectoryName (file.Name));
229
 
                                        if (inFolder.Length == 1 && inFolder [0] == file) {
230
 
                                                // This is the last project file in the folder. Make sure we keep
231
 
                                                // a reference to the folder, so it is not deleted from the tree.
232
 
                                                ProjectFile folderFile = new ProjectFile (Path.GetDirectoryName (file.Name));
233
 
                                                folderFile.Subtype = Subtype.Directory;
234
 
                                                project.Files.Add (folderFile);
235
 
                                        }
 
251
                                var inFolder = project.Files.GetFilesInVirtualPath (file.ProjectVirtualPath.ParentDirectory).ToList ();
 
252
                                if (inFolder.Count == 1 && inFolder [0] == file) {
 
253
                                        // This is the last project file in the folder. Make sure we keep
 
254
                                        // a reference to the folder, so it is not deleted from the tree.
 
255
                                        ProjectFile folderFile = new ProjectFile (project.BaseDirectory.Combine (file.ProjectVirtualPath.ParentDirectory));
 
256
                                        folderFile.Subtype = Subtype.Directory;
 
257
                                        project.Files.Add (folderFile);
236
258
                                }
237
259
                                
238
260
                                if (file.HasChildren) {
244
266
                                }
245
267
                        
246
268
                                project.Files.Remove (file);
247
 
                                if (result == AlertButton.Delete)
 
269
                                if (result == AlertButton.Delete && !file.IsLink)
248
270
                                        FileService.DeleteFile (file.Name);
249
271
                        }
250
272