-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from ManticSic/fix/75/settings-not-saved
Create new options page
- Loading branch information
Showing
10 changed files
with
467 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using JetBrains.Application.Settings; | ||
using JetBrains.Application.UI.Options; | ||
using JetBrains.Application.UI.Options.OptionsDialog; | ||
using JetBrains.DataFlow; | ||
using JetBrains.IDE.UI.Extensions; | ||
using JetBrains.IDE.UI.Options; | ||
using JetBrains.Lifetimes; | ||
using JetBrains.Rd.Base; | ||
using JetBrains.Util; | ||
|
||
namespace ReSharper.Exceptional.Options | ||
{ | ||
[OptionsPage(Pid, Name, typeof(UnnamedThemedIcons.ExceptionalSettings), ParentId = ExceptionalOptionsPage.Pid, Sequence = 4.0)] | ||
public class AccessorOverridesOptionsPage : BeSimpleOptionsPage | ||
{ | ||
public const string Pid = "Exceptional::AccessorOverrides"; | ||
public const string Name = "Accessor Overrides"; | ||
|
||
public AccessorOverridesOptionsPage(Lifetime lifetime, OptionsPageContext optionsPageContext, OptionsSettingsSmartContext optionsSettingsSmartContext, bool wrapInScrollablePanel = true) : base(lifetime, optionsPageContext, optionsSettingsSmartContext, wrapInScrollablePanel) | ||
{ | ||
AddText(OptionsLabels.AccessorOverrides.Description); | ||
|
||
CreateCheckboxUsePredefined(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
|
||
AddButton(OptionsLabels.AccessorOverrides.ShowPredefined, ShowPredefined); | ||
|
||
AddSpacer(); | ||
|
||
AddText(OptionsLabels.AccessorOverrides.Note); | ||
CreateRichTextAccessorOverrides(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
} | ||
|
||
private void ShowPredefined() | ||
{ | ||
string content = ReSharper.Exceptional.Settings.ExceptionalSettings.DefaultAccessorOverrides; | ||
|
||
MessageBox.ShowInfo(content); | ||
} | ||
|
||
private void CreateCheckboxUsePredefined(in Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<bool> property = new Property<bool>(lifetime, "Exceptional::AccessorOverrides::UsePredefined"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.UseDefaultAccessorOverrides2)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.UseDefaultAccessorOverrides2, a.New); | ||
}); | ||
|
||
AddBoolOption((Settings.ExceptionalSettings key) => key.UseDefaultAccessorOverrides2, OptionsLabels.AccessorOverrides.UsePredefined); | ||
} | ||
|
||
private void CreateRichTextAccessorOverrides(in Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<string> property = new Property<string>(lifetime, "Exceptional::AccessorOverrides::AccessorOverrides"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.AccessorOverrides2)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.AccessorOverrides2, a.New); | ||
}); | ||
|
||
var textControl = BeControls.GetTextControl(isReadonly:false); | ||
|
||
textControl.Text.SetValue(property.GetValue()); | ||
textControl.Text.Change.Advise(lifetime, str => | ||
{ | ||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.AccessorOverrides2, str); | ||
}); | ||
|
||
AddControl(textControl); | ||
} | ||
|
||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/Exceptional/Options/ExceptionTypesAsHintForMethodOrPropertyOptionsPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using JetBrains.Application.Settings; | ||
using JetBrains.Application.UI.Options; | ||
using JetBrains.Application.UI.Options.OptionsDialog; | ||
using JetBrains.DataFlow; | ||
using JetBrains.IDE.UI.Extensions; | ||
using JetBrains.IDE.UI.Options; | ||
using JetBrains.Lifetimes; | ||
using JetBrains.Rd.Base; | ||
using JetBrains.Util; | ||
|
||
namespace ReSharper.Exceptional.Options | ||
{ | ||
[OptionsPage(Pid, Name, typeof(UnnamedThemedIcons.ExceptionalSettings), ParentId = ExceptionalOptionsPage.Pid, Sequence = 3.0)] | ||
public class ExceptionTypesAsHintForMethodOrPropertyOptionsPage : BeSimpleOptionsPage | ||
{ | ||
public const string Pid = "Exceptional::ExceptionTypesAsHintForMethodsOrProperties"; | ||
public const string Name = "Optional Exceptions (Methods or Properties)"; | ||
|
||
public ExceptionTypesAsHintForMethodOrPropertyOptionsPage(Lifetime lifetime, OptionsPageContext optionsPageContext, OptionsSettingsSmartContext optionsSettingsSmartContext, bool wrapInScrollablePanel = true) : base(lifetime, optionsPageContext, optionsSettingsSmartContext, wrapInScrollablePanel) | ||
{ | ||
AddText(OptionsLabels.ExceptionTypesAsHintForMethodOrProperty.Description); | ||
|
||
CreateCheckboxUsePredefined(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
|
||
AddButton(OptionsLabels.ExceptionTypesAsHintForMethodOrProperty.ShowPredefined, ShowPredefined); | ||
|
||
AddSpacer(); | ||
|
||
AddText(OptionsLabels.ExceptionTypesAsHintForMethodOrProperty.Note); | ||
CreateRichTextExceptionTypesAsHint(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
} | ||
|
||
private void ShowPredefined() | ||
{ | ||
string content = ReSharper.Exceptional.Settings.ExceptionalSettings.DefaultOptionalMethodExceptions; | ||
|
||
MessageBox.ShowInfo(content); | ||
} | ||
|
||
private void CreateCheckboxUsePredefined(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<bool> property = new Property<bool>(lifetime, "Exceptional::ExceptionTypesAsHintForMethodsOrProperties::UsePredefined"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.UseDefaultOptionalMethodExceptions2)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.UseDefaultOptionalMethodExceptions2, a.New); | ||
}); | ||
|
||
AddBoolOption((Settings.ExceptionalSettings key) => key.UseDefaultOptionalMethodExceptions2, OptionsLabels.ExceptionTypesAsHintForMethodOrProperty.UsePredefined); | ||
} | ||
|
||
private void CreateRichTextExceptionTypesAsHint(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<string> property = new Property<string>(lifetime, "Exceptional::ExceptionTypesAsHintForMethodsOrProperties::ExceptionTypes"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.OptionalMethodExceptions2)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.OptionalMethodExceptions2, a.New); | ||
}); | ||
|
||
var textControl = BeControls.GetTextControl(isReadonly:false); | ||
|
||
textControl.Text.SetValue(property.GetValue()); | ||
textControl.Text.Change.Advise(lifetime, str => | ||
{ | ||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.OptionalMethodExceptions2, str); | ||
}); | ||
|
||
AddControl(textControl); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/Exceptional/Options/ExceptionTypesAsHintOptionsPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using JetBrains.Application.Settings; | ||
using JetBrains.Application.UI.Options; | ||
using JetBrains.Application.UI.Options.OptionsDialog; | ||
using JetBrains.DataFlow; | ||
using JetBrains.IDE.UI.Extensions; | ||
using JetBrains.IDE.UI.Options; | ||
using JetBrains.Lifetimes; | ||
using JetBrains.Rd.Base; | ||
using JetBrains.Util; | ||
|
||
namespace ReSharper.Exceptional.Options | ||
{ | ||
[OptionsPage(Pid, Name, typeof(UnnamedThemedIcons.ExceptionalSettings), ParentId = ExceptionalOptionsPage.Pid, Sequence = 2.0)] | ||
public class ExceptionTypesAsHintOptionsPage : BeSimpleOptionsPage | ||
{ | ||
public const string Pid = "Exceptional::ExceptionTypesAsHint"; | ||
public const string Name = "Optional Exceptions (Global)"; | ||
|
||
public ExceptionTypesAsHintOptionsPage(Lifetime lifetime, OptionsPageContext optionsPageContext, OptionsSettingsSmartContext optionsSettingsSmartContext) : base(lifetime, optionsPageContext, optionsSettingsSmartContext, true) | ||
{ | ||
AddText(OptionsLabels.ExceptionTypesAsHint.Description); | ||
|
||
CreateCheckboxUsePredefined(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
|
||
AddButton(OptionsLabels.ExceptionTypesAsHint.ShowPredefined, ShowPredefined); | ||
|
||
AddSpacer(); | ||
|
||
AddText(OptionsLabels.ExceptionTypesAsHint.Note); | ||
CreateRichTextExceptionTypesAsHint(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
} | ||
|
||
private void ShowPredefined() | ||
{ | ||
string content = ReSharper.Exceptional.Settings.ExceptionalSettings.DefaultOptionalExceptions; | ||
|
||
MessageBox.ShowInfo(content); | ||
} | ||
|
||
private void CreateCheckboxUsePredefined(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<bool> property = new Property<bool>(lifetime, "Exceptional::ExceptionTypesAsHint::UsePredefined"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.UseDefaultOptionalExceptions2)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.UseDefaultOptionalExceptions2, a.New); | ||
}); | ||
|
||
AddBoolOption((Settings.ExceptionalSettings key) => key.UseDefaultOptionalExceptions2, OptionsLabels.ExceptionTypesAsHint.UsePredefined); | ||
} | ||
|
||
private void CreateRichTextExceptionTypesAsHint(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<string> property = new Property<string>(lifetime, "Exceptional::ExceptionTypesAsHint::ExceptionTypes"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.OptionalExceptions2)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.OptionalExceptions2, a.New); | ||
}); | ||
|
||
var textControl = BeControls.GetTextControl(isReadonly:false); | ||
|
||
textControl.Text.SetValue(property.GetValue()); | ||
textControl.Text.Change.Advise(lifetime, str => | ||
{ | ||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.OptionalExceptions2, str); | ||
}); | ||
|
||
AddControl(textControl); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using JetBrains.Application.UI.Options; | ||
using JetBrains.Application.UI.Options.OptionsDialog; | ||
|
||
namespace ReSharper.Exceptional.Options | ||
{ | ||
[OptionsPage(Pid, Name, null, Sequence = 5.0)] | ||
public class ExceptionalOptionsPage : AEmptyOptionsPage | ||
{ | ||
public const string Pid = "Exceptional"; | ||
public const string Name = "Exceptional"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using JetBrains.Application.Settings; | ||
using JetBrains.Application.UI.Options; | ||
using JetBrains.Application.UI.Options.OptionsDialog; | ||
using JetBrains.DataFlow; | ||
using JetBrains.IDE.UI.Options; | ||
using JetBrains.Lifetimes; | ||
|
||
namespace ReSharper.Exceptional.Options | ||
{ | ||
[OptionsPage(Pid, Name, typeof(UnnamedThemedIcons.ExceptionalSettings), ParentId = ExceptionalOptionsPage.Pid, Sequence = 0.0)] | ||
public class GeneralOptionsPage : BeSimpleOptionsPage | ||
{ | ||
public const string Pid = "Exceptional::General"; | ||
public const string Name = "General"; | ||
|
||
public GeneralOptionsPage(Lifetime lifetime, OptionsPageContext optionsPageContext, OptionsSettingsSmartContext optionsSettingsSmartContext, bool wrapInScrollablePanel = false) : base(lifetime, optionsPageContext, optionsSettingsSmartContext, wrapInScrollablePanel) | ||
{ | ||
CreateCheckboxInspectPublic(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
|
||
CreateDocumentationSection(lifetime, optionsSettingsSmartContext.StoreOptionsTransactionContext); | ||
} | ||
|
||
private void CreateCheckboxInspectPublic(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<bool> property = new Property<bool>(lifetime, "Exceptional::General::DelegateInvocationsMayThrowSystemException"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.DelegateInvocationsMayThrowExceptions)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.DelegateInvocationsMayThrowExceptions, a.New); | ||
}); | ||
|
||
AddBoolOption((Settings.ExceptionalSettings key) => key.DelegateInvocationsMayThrowExceptions, OptionsLabels.General.DelegateInvocationsMayThrowSystemException); | ||
} | ||
|
||
private void CreateDocumentationSection(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
AddHeader(OptionsLabels.General.DocumentationOfThrownExceptionsSubtypeHeader); | ||
|
||
CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForThrowStatements(lifetime, storeOptionsTransactionContext); | ||
CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions(lifetime, storeOptionsTransactionContext); | ||
} | ||
|
||
private void CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForThrowStatements(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<bool> property = new Property<bool>(lifetime, "Exceptional::General::IsDocumentationOfExceptionSubtypeSufficientForThrowStatements"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.IsDocumentationOfExceptionSubtypeSufficientForThrowStatements)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.IsDocumentationOfExceptionSubtypeSufficientForThrowStatements, a.New); | ||
}); | ||
|
||
AddBoolOption((Settings.ExceptionalSettings key) => key.IsDocumentationOfExceptionSubtypeSufficientForThrowStatements, OptionsLabels.General.IsDocumentationOfExceptionSubtypeSufficientForThrowStatements); | ||
} | ||
|
||
private void CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions(Lifetime lifetime, IContextBoundSettingsStoreLive storeOptionsTransactionContext) | ||
{ | ||
IProperty<bool> property = new Property<bool>(lifetime, "Exceptional::General::IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions"); | ||
property.SetValue(storeOptionsTransactionContext.GetValue((Settings.ExceptionalSettings key) => key.IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions)); | ||
|
||
property.Change.Advise(lifetime, a => | ||
{ | ||
if (!a.HasNew) return; | ||
|
||
storeOptionsTransactionContext.SetValue((Settings.ExceptionalSettings key) => key.IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions, a.New); | ||
}); | ||
|
||
AddBoolOption((Settings.ExceptionalSettings key) => key.IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions, OptionsLabels.General.IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions); | ||
} | ||
} | ||
} |
Oops, something went wrong.