~bratsche/ubuntu/maverick/monodevelop/disable-appmenu

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Projects/MonoDevelop.Projects/ProjectFileCollection.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2009-03-17 17:55:55 UTC
  • mfrom: (1.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20090317175555-2w5qbmu0l5maq6fq
Tags: 1.9.3+dfsg-1ubuntu1
* FFe for Monodevelop 2 granted by motu-release team :)
* Merge from Debian Unstable , remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
namespace MonoDevelop.Projects
35
35
{
36
36
        [Serializable()]
37
 
        public class ProjectFileCollection : Collection<ProjectFile> {
 
37
        public class ProjectFileCollection : ProjectItemCollection<ProjectFile> {
38
38
        
39
 
                Project project;
40
 
                List<ProjectFile> unresolvedDeps;
41
 
                
42
39
                public ProjectFileCollection ()
43
40
                {
44
41
                }
45
42
                
46
 
                public ProjectFileCollection (Project project)
47
 
                {
48
 
                        this.project = project;
49
 
                        DependencyResolutionEnabled = true;
50
 
                }
51
 
                
52
43
                public ProjectFile GetFile (string fileName)
53
44
                {
54
45
                        if (fileName == null) return null;
73
64
                        return list.ToArray ();
74
65
                }
75
66
                
76
 
                protected override void InsertItem (int index, ProjectFile value)
77
 
                {
78
 
                        base.InsertItem (index, value);
79
 
                        if (project != null) {
80
 
                                if (value.Project != null)
81
 
                                        throw new InvalidOperationException ("ProjectFile already belongs to a project");
82
 
                                value.SetProject (project);
83
 
                                ResolveDependencies (value);
84
 
                                project.NotifyFileAddedToProject (value);
85
 
                        }
86
 
                }
87
 
                
88
 
                internal void ResolveDependencies (ProjectFile file)
89
 
                {
90
 
                        if (!DependencyResolutionEnabled)
91
 
                                return;
92
 
                        
93
 
                        if (!file.ResolveParent ())
94
 
                                unresolvedDeps.Add (file);
95
 
                        
96
 
                        List<ProjectFile> resolved = null;
97
 
                        foreach (ProjectFile unres in unresolvedDeps) {
98
 
                                if (string.IsNullOrEmpty (unres.DependsOn )) {
99
 
                                        resolved.Add (unres);
100
 
                                }
101
 
                                if (unres.ResolveParent ()) {
102
 
                                        if (resolved == null)
103
 
                                                resolved = new List<ProjectFile> ();
104
 
                                                resolved.Add (unres);
105
 
                                }
106
 
                        }
107
 
                        if (resolved != null)
108
 
                                foreach (ProjectFile pf in resolved)
109
 
                                        unresolvedDeps.Remove (pf);
110
 
                }
111
 
                
112
 
                bool DependencyResolutionEnabled {
113
 
                        set {
114
 
                                if (value) {
115
 
                                        if (unresolvedDeps != null)
116
 
                                                return;
117
 
                                        
118
 
                                        unresolvedDeps = new List<ProjectFile> ();
119
 
                                        foreach (ProjectFile file in this)
120
 
                                                ResolveDependencies (file);
121
 
                                } else {
122
 
                                        unresolvedDeps = null;
123
 
                                }
124
 
                        }
125
 
                        get { return unresolvedDeps != null; }
126
 
                }
127
 
                        
128
 
                public void AddRange (IEnumerable<ProjectFile> files)
129
 
                {
130
 
                        foreach (ProjectFile pf in files)
131
 
                                Add (pf);
132
 
                }
133
 
                
134
 
                protected override void RemoveItem (int index)
135
 
                {
136
 
                        ProjectFile file = this [index];
137
 
                        base.RemoveItem (index);
138
 
                        if (project != null) {
139
 
                                file.SetProject (null);
140
 
                                project.NotifyFileRemovedFromProject (file);
141
 
                        }
142
 
                        
143
 
                        if (DependencyResolutionEnabled) {
144
 
                                if (unresolvedDeps.Contains (file))
145
 
                                        unresolvedDeps.Remove (file);
146
 
                                foreach (ProjectFile f in file.DependentChildren) {
147
 
                                        f.DependsOnFile = null;
148
 
                                        if (!string.IsNullOrEmpty (f.DependsOn))
149
 
                                                unresolvedDeps.Add (f);
150
 
                                }
151
 
                                file.DependsOnFile = null;
152
 
                        }
153
 
                }
154
 
                
155
67
                public void Remove (string fileName)
156
68
                {
157
69
                        fileName = FileService.GetFullPath (fileName);