void HandlePolicyComboChanged(object sender, EventArgs e) { if (loading || synchingPoliciesCombo) { return; } selectingPolicy = true; try { if (policyCombo.Active == 0 && !isRoot) { panelData.UseParentPolicy = true; notebook.Sensitive = false; } else { string activeName = policyCombo.ActiveText; PolicySet pset = PolicyService.GetPolicySet(activeName); if (pset != null) { panelData.AssignPolicies(pset); } else { panelData.UseParentPolicy = false; } notebook.Sensitive = true; } } finally { selectingPolicy = false; } }
public async Task CSharpFormattingPolicyIndentSwitchCaseSectionChangedMultipleTimes() { string dir = Util.CreateTmpDir("IndentSwitchCaseSectionChangedMultipleTimes"); var pset = PolicyService.GetPolicySet("Mono"); var monoFormattingPolicy = pset.Get <CSharpFormattingPolicy> ("text/x-csharp"); var formattingPolicy = monoFormattingPolicy.Clone(); var solution = new Solution(); solution.Policies.Set(formattingPolicy); bool expectedSetting = !formattingPolicy.IndentSwitchCaseSection; string fileName = Path.Combine(dir, "IndentSwitchCaseSectionChangedMultipleTimes.sln"); for (int i = 0; i < 3; ++i) { formattingPolicy.IndentSwitchCaseSection = expectedSetting; await solution.SaveAsync(fileName, Util.GetMonitor()); var savedSolution = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), fileName); var savedFormattingPolicy = savedSolution.Policies.Get <CSharpFormattingPolicy> (); Assert.AreEqual(expectedSetting, savedFormattingPolicy.IndentSwitchCaseSection); expectedSetting = !expectedSetting; } solution.Dispose(); }
PolicySet GetPolicySet(bool notifyErrors) { if (radioCustom.Active) { return(PolicyService.GetPolicySet(combPolicies.ActiveText)); } else { if (string.IsNullOrEmpty(fileEntry.Path)) { if (notifyErrors) { MessageService.ShowError(GettextCatalog.GetString("File name not specified")); } return(null); } try { PolicySet pset = new PolicySet(); pset.LoadFromFile(fileEntry.Path); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = System.IO.Path.GetDirectoryName(fileEntry.Path); return(pset); } catch (Exception ex) { if (notifyErrors) { MessageService.ShowException(ex, GettextCatalog.GetString("The policy set could not be loaded")); } return(null); } } }
void HandlePolicyComboChanged(object sender, EventArgs e) { loading = true; if (policyCombo.Active == 0 && !isRoot) { panelData.UseParentPolicy = true; notebook.Sensitive = false; } else { string activeName = policyCombo.ActiveText; PolicySet pset = PolicyService.GetPolicySet(activeName); if (pset != null) { panelData.AssignPolicies(pset); } else { panelData.UseParentPolicy = false; } notebook.Sensitive = true; } loading = false; }
public async Task SaveSolutionAfterChangingCSharpFormattingPolicyForTheFirstTime() { string dir = Util.CreateTmpDir("FormattingPolicyChangedOnce"); var pset = PolicyService.GetPolicySet("Mono"); var monoFormattingPolicy = pset.Get <CSharpFormattingPolicy> ("text/x-csharp"); var formattingPolicy = monoFormattingPolicy.Clone(); var solution = new Solution(); solution.Policies.Set(formattingPolicy); bool expectedSetting = !formattingPolicy.IndentSwitchCaseSection; formattingPolicy.IndentSwitchCaseSection = expectedSetting; string fileName = Path.Combine(dir, "FormattingPolicyChangedOnce.sln"); await solution.SaveAsync(fileName, Util.GetMonitor()); var file = new SlnFile(); file.Read(fileName); var s = file.Sections.GetSection("MonoDevelopProperties", SlnSectionType.PreProcess); var missingItem = default(KeyValuePair <string, string>); Assert.AreEqual(expectedSetting.ToString(), s.Properties.SingleOrDefault(p => p.Key.Contains("IndentSwitchCaseSection")).Value); Assert.AreEqual(missingItem, s.Properties.SingleOrDefault(p => p.Key.Contains("IndentSwitchSection"))); Assert.AreEqual(missingItem, s.Properties.SingleOrDefault(p => p.Key.Contains("IndentBlock"))); Assert.AreEqual(missingItem, s.Properties.SingleOrDefault(p => p.Key.Contains("SpaceBeforeDot"))); Assert.AreEqual(missingItem, s.Properties.SingleOrDefault(p => p.Key.Contains("NewLineForElse"))); }
PolicySet GetPolicySet(bool notifyErrors) { if (radioCustom.Active) { return(PolicyService.GetPolicySet(combPolicies.ActiveText)); } var f = fileEntry.Path; if (string.IsNullOrEmpty(f) || !System.IO.File.Exists(f)) { return(null); } var pset = new PolicySet(); pset.LoadFromFile(fileEntry.Path); ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = System.IO.Path.GetDirectoryName(fileEntry.Path); return(pset); }
void OnPolicySelectionChanged(object s, ComboSelectionChangedArgs args) { Gtk.TreeIter iter; if (store.GetIter(out iter, new Gtk.TreePath(args.Path))) { MimeTypePanelData mt = (MimeTypePanelData)store.GetValue(iter, 0); if (args.Active != -1) { string sel = args.ActiveText; if (sel == (panel.IsCustomUserPolicy ? systemPolicyText : parentPolicyText)) { mt.UseParentPolicy = true; } else if (sel != customPolicyText) { PolicySet pset = PolicyService.GetPolicySet(sel); mt.AssignPolicies(pset); } } } }