~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/MimeTypePolicyOptionsPanel.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
                
47
47
                void LoadCurrentPolicy ();
48
48
                void LoadParentPolicy ();
49
 
                void LoadSetPolicy (PolicySet pset);
 
49
                void LoadSetPolicy (PolicyContainer pset);
50
50
                void StorePolicy ();
51
51
                
52
52
                bool HasCustomPolicy { get; }
53
53
                void RemovePolicy (PolicyContainer bag);
54
54
                IEnumerable<PolicySet> GetPolicySets ();
55
 
                PolicySet GetMatchingSet ();
 
55
                PolicySet GetMatchingSet (IEnumerable<PolicySet> candidateSets);
 
56
                bool Modified { get; }
 
57
                bool HandlesPolicyType (Type type, string scope);
56
58
        }
57
59
        
58
60
        public abstract class MimeTypePolicyOptionsPanel<T>: ItemOptionsPanel, IMimeTypePolicyOptionsPanel where T : class, IEquatable<T>, new ()
128
130
                        return PolicyService.GetDefaultPolicy<T>(scopes);
129
131
                }
130
132
                
131
 
                void IMimeTypePolicyOptionsPanel.LoadSetPolicy (PolicySet pset)
 
133
                void IMimeTypePolicyOptionsPanel.LoadSetPolicy (PolicyContainer pset)
132
134
                {
133
135
                        object selected = pset.Get<T> (mimeTypeScopes);
134
136
                        if (selected == null)
157
159
                        return PolicyService.GetPolicySets<T> (mimeTypeScopes);
158
160
                }
159
161
                
160
 
                PolicySet IMimeTypePolicyOptionsPanel.GetMatchingSet ()
 
162
                PolicySet IMimeTypePolicyOptionsPanel.GetMatchingSet (IEnumerable<PolicySet> candidateSets)
161
163
                {
162
164
                        T pol = GetCurrentPolicy ();
163
 
                        return PolicyService.GetMatchingSet (pol, mimeTypeScopes);
 
165
                        if (candidateSets != null)
 
166
                                return PolicyService.GetMatchingSet (pol, candidateSets, mimeTypeScopes, false);
 
167
                        else
 
168
                                return PolicyService.GetMatchingSet (pol, mimeTypeScopes, false);
164
169
                }
165
170
                
166
171
                void IMimeTypePolicyOptionsPanel.RemovePolicy (PolicyContainer bag)
168
173
                        bag.Remove<T> (mimeType);
169
174
                }
170
175
                
 
176
                bool IMimeTypePolicyOptionsPanel.HandlesPolicyType (Type type, string scope)
 
177
                {
 
178
                        return type == typeof(T) && scope == mimeType;
 
179
                }
 
180
 
 
181
                
171
182
                T GetDirectInherited (PolicyContainer initialContainer)
172
183
                {
173
184
                        if (initialContainer == policyContainer && !loaded && hasCachedPolicy)
259
270
                        panelWidget.Show ();
260
271
                        return box;
261
272
                }
262
 
 
 
273
                
 
274
                public bool Modified {
 
275
                        get {
 
276
                                T pol = policyContainer.Get<T> (mimeTypeScopes) ?? PolicyService.GetDefaultPolicy<T> (mimeTypeScopes);
 
277
                                return !pol.Equals (GetCurrentPolicy ());
 
278
                        }
 
279
                }
263
280
                
264
281
                protected abstract void LoadFrom (T policy);
265
282