Skip to content

Commit

Permalink
Renamed AbstractOptionPageControl methods to be more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Mar 19, 2019
1 parent 3c1f6a1 commit 9b86bf7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
13 changes: 8 additions & 5 deletions src/VisualStudio/Core/Impl/Options/AbstractOptionPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected override void OnActivate(System.ComponentModel.CancelEventArgs e)
if (_needsLoadOnNextActivate)
{
// For pages that don't use option bindings we need to load setting changes.
pageControl.LoadSettings();
pageControl.OnLoad();

_needsLoadOnNextActivate = false;
}
Expand All @@ -89,8 +89,8 @@ public override void LoadSettingsFromStorage()
// they may have been changed programmatically. Therefore, we'll set a flag so we load
// next time

// If we are being canceled after the pageControl has already been created then
// we need to reset the option store on next load.
// When pageControl is null we know that Activation has not happened for this page.
// We only need to update the OptionStore after a cancel or close click (2).
s_needsToUpdateOptionStore = pageControl != null;

// For pages that don't use option bindings we need to load settings when it is
Expand All @@ -104,10 +104,13 @@ public override void SaveSettingsToStorage()

// Allow page controls to perist their settings to the option store before updating the
// option service.
pageControl.SaveSettings();
pageControl.OnSave();

// Save the changes that were accumulated in the option store.
s_optionService.SetOptions(s_optionStore.GetOptions());
var oldOptions = s_optionService.GetOptions();
var newOptions = s_optionStore.GetOptions();
s_optionService.SetOptions(newOptions);
OptionLogger.Log(oldOptions, newOptions);

// Make sure we load the next time a page is activated, in case that options changed
// programmatically between now and the next time the page is activated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,16 @@ protected void BindToFullSolutionAnalysisOption(CheckBox checkbox, string langua
_bindingExpressions.Add(bindingExpression);
}

internal virtual void LoadSettings()
internal virtual void OnLoad()
{
foreach (var bindingExpression in _bindingExpressions)
{
bindingExpression.UpdateTarget();
}
}

internal virtual void SaveSettings()
internal virtual void OnSave()
{

}

internal virtual void Close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void Options_PreviewKeyDown(object sender, KeyEventArgs e)
}
}

internal override void LoadSettings()
internal override void OnLoad()
{
this.ViewModel = _createViewModel(OptionStore, _serviceProvider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void Options_PreviewKeyDown(object sender, KeyEventArgs e)
}
}

internal override void LoadSettings()
internal override void OnLoad()
{
this.ViewModel = _createViewModel(this.OptionStore, _serviceProvider);

Expand Down
10 changes: 3 additions & 7 deletions src/VisualStudio/Core/Impl/Options/OptionStore.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Options;

Expand Down Expand Up @@ -28,27 +30,21 @@ public OptionStore(OptionSet optionSet, IEnumerable<IOption> registeredOptions)

public void SetOption(OptionKey optionKey, object value)
{
var oldOptions = _optionSet;
_optionSet = _optionSet.WithChangedOption(optionKey, value);
OptionLogger.Log(oldOptions, _optionSet);

OnOptionChanged(optionKey);
}

public void SetOption<T>(Option<T> option, T value)
{
var oldOptions = _optionSet;
_optionSet = _optionSet.WithChangedOption(option, value);
OptionLogger.Log(oldOptions, _optionSet);

OnOptionChanged(new OptionKey(option));
}

public void SetOption<T>(PerLanguageOption<T> option, string language, T value)
{
var oldOptionSet = _optionSet;
_optionSet = _optionSet.WithChangedOption(option, language, value);
OptionLogger.Log(oldOptionSet, _optionSet);

OnOptionChanged(new OptionKey(option, language));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal NamingStyleOptionPageControl(OptionStore optionStore, INotificationServ
_notificationService = notificationService;

InitializeComponent();
LoadSettings();
OnLoad();
}

private NamingStyleOptionPageViewModel.NamingRuleViewModel CreateItemWithNoSelections()
Expand Down Expand Up @@ -139,7 +139,7 @@ private void SetFocusToSelectedRow()
}
}

internal override void SaveSettings()
internal override void OnSave()
{
var symbolSpecifications = ArrayBuilder<SymbolSpecification>.GetInstance();
var namingRules = ArrayBuilder<SerializableNamingRule>.GetInstance();
Expand Down Expand Up @@ -180,9 +180,9 @@ internal override void SaveSettings()
OptionStore.SetOption(SimplificationOptions.NamingPreferences, _languageName, info);
}

internal override void LoadSettings()
internal override void OnLoad()
{
base.LoadSettings();
base.OnLoad();

var preferences = OptionStore.GetOption(SimplificationOptions.NamingPreferences, _languageName);
if (preferences == null)
Expand Down

0 comments on commit 9b86bf7

Please sign in to comment.