Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -r8e8f8c83c45656f65adaa8e47600379dc5ae8f61 -r242268fc2adc055cc3ac4f28b14b4db26251b30e --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 8e8f8c83c45656f65adaa8e47600379dc5ae8f61) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 242268fc2adc055cc3ac4f28b14b4db26251b30e) @@ -59,17 +59,17 @@ where TCalculation : ICalculation where TFailureMechanism : IFailureMechanism { + private readonly ICalculationInputPropertyChangeHandler propertyChangeHandler; private readonly Dictionary propertyIndexLookup; /// /// Creates a new instance of the class. /// /// The instance to show the properties of. /// The property values required to create an instance of . + /// The handler responsible for handling effects of a property change. /// Thrown when any parameter is null. - protected StructuresInputBaseProperties( - InputContextBase data, - ConstructionProperties constructionProperties) + protected StructuresInputBaseProperties(InputContextBase data, ConstructionProperties constructionProperties, ICalculationInputPropertyChangeHandler propertyChangeHandler) { if (data == null) { @@ -79,7 +79,12 @@ { throw new ArgumentNullException(nameof(constructionProperties)); } + if (propertyChangeHandler == null) + { + throw new ArgumentNullException(nameof(propertyChangeHandler)); + } + this.propertyChangeHandler = propertyChangeHandler; Data = data; propertyIndexLookup = new Dictionary { @@ -131,26 +136,6 @@ }; } - #region Model factors - - [DynamicPropertyOrder] - [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_ModelSettings))] - [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_ModelFactorSuperCriticalFlow_DisplayName))] - [ResourcesDescription(typeof(Resources), nameof(Resources.Structure_ModelFactorSuperCriticalFlow_Description))] - public virtual NormalDistributionProperties ModelFactorSuperCriticalFlow - { - get - { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData, this) - { - Data = data.WrappedData.ModelFactorSuperCriticalFlow - }; - } - } - - #endregion - [DynamicPropertyOrderEvaluationMethod] public int DynamicPropertyOrderEvaluationMethod(string propertyName) { @@ -212,12 +197,27 @@ /// protected abstract void AfterSettingStructure(); - protected void ClearOutputAndNotifyPropertyChanged() + protected void ChangePropertyAndNotify( + SetCalculationInputPropertyValueDelegate setPropertyValue, + TValue value) { - ClearCalculationOutput(); - data.WrappedData.NotifyObservers(); + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( + data.WrappedData, + data.Calculation, + value, + setPropertyValue); + + NotifyAffectedObjects(affectedObjects); } + private static void NotifyAffectedObjects(IEnumerable affectedObjects) + { + foreach (IObservable affectedObject in affectedObjects) + { + affectedObject.NotifyObservers(); + } + } + private void ClearCalculationOutput() { IEnumerable affectedCalculation = RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(data.Calculation); @@ -320,6 +320,28 @@ #endregion } + #region Model factors + + [DynamicPropertyOrder] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_ModelFactorSuperCriticalFlow_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.Structure_ModelFactorSuperCriticalFlow_Description))] + public virtual ConfirmingNormalDistributionProperties ModelFactorSuperCriticalFlow + { + get + { + return new ConfirmingNormalDistributionProperties( + DistributionPropertiesReadOnly.StandardDeviation, + data.WrappedData.ModelFactorSuperCriticalFlow, + data.Calculation, + data.WrappedData, + propertyChangeHandler); + } + } + + #endregion + #region Schematization [DynamicPropertyOrder] @@ -335,9 +357,12 @@ } set { - data.WrappedData.Structure = value; - AfterSettingStructure(); - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyAndNotify((input, newValue) => + { + data.WrappedData.Structure = newValue; + AfterSettingStructure(); + }, + value); } } @@ -368,8 +393,8 @@ } set { - data.WrappedData.StructureNormalOrientation = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyAndNotify( + (input, newValue) => data.WrappedData.StructureNormalOrientation = newValue, value); } } @@ -474,8 +499,13 @@ } set { - SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.FailureProbabilityStructureWithErosion = parsedValue); - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyAndNotify( + (input, newValue) => + SetProbabilityValue( + newValue, + data.WrappedData, + (wrappedData, parsedValue) => wrappedData.FailureProbabilityStructureWithErosion = parsedValue) + , value); } } @@ -492,8 +522,8 @@ } set { - data.WrappedData.ForeshoreProfile = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyAndNotify( + (input, newValue) => data.WrappedData.ForeshoreProfile = newValue, value); } } @@ -502,13 +532,13 @@ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.BreakWaterProperties_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.BreakWaterProperties_Description))] - public UseBreakWaterProperties UseBreakWater + public ConfirmingUseBreakWaterProperties UseBreakWater { get { return data.WrappedData.ForeshoreProfile == null ? - new UseBreakWaterProperties() : - new UseBreakWaterProperties(data.WrappedData, this); + new ConfirmingUseBreakWaterProperties() : + new ConfirmingUseBreakWaterProperties(data.WrappedData, data.Calculation, propertyChangeHandler); } } @@ -517,11 +547,11 @@ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.ForeshoreProperties_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.ForeshoreProperties_Description))] - public UseForeshoreProperties UseForeshore + public ConfirmingUseForeshoreProperties UseForeshore { get { - return new UseForeshoreProperties(data.WrappedData, this); + return new ConfirmingUseForeshoreProperties(data.WrappedData, data.Calculation, propertyChangeHandler); } } @@ -545,8 +575,8 @@ } set { - data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyAndNotify( + (input, newValue) => data.WrappedData.HydraulicBoundaryLocation = newValue.HydraulicBoundaryLocation, value); } }