Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs =================================================================== diff -u -r86bb01b9f86d6a742c8d057187cc246a8d9e2c54 -r662e55f5b46d01f77a977ab0ea92acbbaddf2365 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 86bb01b9f86d6a742c8d057187cc246a8d9e2c54) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 662e55f5b46d01f77a977ab0ea92acbbaddf2365) @@ -37,7 +37,6 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.UITypeEditors; -using Ringtoets.Common.Service; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Forms.PresentationObjects; using Ringtoets.Revetment.Forms.Properties; @@ -50,8 +49,7 @@ /// public abstract class WaveConditionsInputContextProperties : ObjectProperties, IHasHydraulicBoundaryLocationProperty, - IHasForeshoreProfileProperty, - IPropertyChangeHandler + IHasForeshoreProfileProperty where T : WaveConditionsInputContext { private const int hydraulicBoundaryLocationPropertyIndex = 0; @@ -71,7 +69,7 @@ private const int foreshoreGeometryPropertyIndex = 13; private const int revetmentTypePropertyIndex = 14; - private readonly ICalculationInputPropertyChangeHandler handler; + private readonly ICalculationInputPropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . @@ -89,7 +87,7 @@ { throw new ArgumentNullException(nameof(handler)); } - this.handler = handler; + propertyChangeHandler = handler; Data = context; } @@ -129,8 +127,7 @@ } set { - data.WrappedData.UpperBoundaryRevetment = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.UpperBoundaryRevetment = d, value); } } @@ -146,8 +143,7 @@ } set { - data.WrappedData.LowerBoundaryRevetment = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.LowerBoundaryRevetment = d, value); } } @@ -163,8 +159,7 @@ } set { - data.WrappedData.UpperBoundaryWaterLevels = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.UpperBoundaryWaterLevels = d, value); } } @@ -180,8 +175,7 @@ } set { - data.WrappedData.LowerBoundaryWaterLevels = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.LowerBoundaryWaterLevels = d, value); } } @@ -198,8 +192,7 @@ } set { - data.WrappedData.StepSize = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.StepSize = d, value); } } @@ -243,8 +236,7 @@ } set { - data.WrappedData.Orientation = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.Orientation = d, value); } } @@ -253,13 +245,13 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.BreakWaterProperties_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.BreakWaterProperties_Description))] - public UseBreakWaterProperties BreakWater + public ConfirmingUseBreakWaterProperties BreakWater { get { return data.WrappedData.ForeshoreProfile == null ? - new UseBreakWaterProperties() : - new UseBreakWaterProperties(data.WrappedData, this); + new ConfirmingUseBreakWaterProperties() : + new ConfirmingUseBreakWaterProperties(data.WrappedData, data.Calculation, propertyChangeHandler); } } @@ -268,11 +260,11 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.ForeshoreProperties_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.ForeshoreProperties_Description))] - public UseForeshoreProperties ForeshoreGeometry + public ConfirmingUseForeshoreProperties ForeshoreGeometry { get { - return new UseForeshoreProperties(data.WrappedData, this); + return new ConfirmingUseForeshoreProperties(data.WrappedData, data.Calculation, propertyChangeHandler); } } @@ -295,8 +287,7 @@ } set { - data.WrappedData.ForeshoreProfile = value; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.ForeshoreProfile = d, value); } } @@ -317,16 +308,10 @@ } set { - data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; - ClearOutputAndNotifyPropertyChanged(); + ChangePropertyValueAndNotifyAffectedObjects((input, d) => input.HydraulicBoundaryLocation = d.HydraulicBoundaryLocation, value); } } - public void PropertyChanged() - { - ClearCalculationOutput(); - } - public virtual IEnumerable GetAvailableForeshoreProfiles() { return data.ForeshoreProfiles; @@ -339,18 +324,24 @@ data.HydraulicBoundaryLocations, referenceLocation); } - private void ClearOutputAndNotifyPropertyChanged() + private void ChangePropertyValueAndNotifyAffectedObjects( + SetCalculationInputPropertyValueDelegate setPropertyValue, + TValue value) { - ClearCalculationOutput(); - data.WrappedData.NotifyObservers(); + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( + data.WrappedData, + data.Calculation, + value, + setPropertyValue); + + NotifyAffectedObjects(affectedObjects); } - private void ClearCalculationOutput() + private static void NotifyAffectedObjects(IEnumerable affectedObjects) { - IEnumerable affectedCalculation = RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(data.Calculation); - foreach (var calculation in affectedCalculation) + foreach (var affectedObject in affectedObjects) { - calculation.NotifyObservers(); + affectedObject.NotifyObservers(); } } }