Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismProperties.cs =================================================================== diff -u -rdb6e1eda8b29e446c5ca5ba7aabce982faf585ce -r4b4b8a9607ac669b026a57a90cbd6b9c1d1856b2 --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismProperties.cs (.../WaveImpactAsphaltCoverFailureMechanismProperties.cs) (revision db6e1eda8b29e446c5ca5ba7aabce982faf585ce) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismProperties.cs (.../WaveImpactAsphaltCoverFailureMechanismProperties.cs) (revision 4b4b8a9607ac669b026a57a90cbd6b9c1d1856b2) @@ -20,9 +20,12 @@ // All rights reserved. using System; +using System.Collections.Generic; +using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Util.Attributes; using Core.Gui.Attributes; +using Riskeer.Common.Forms.PropertyClasses; using Riskeer.WaveImpactAsphaltCover.Data; using Riskeer.WaveImpactAsphaltCover.Forms.Properties; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; @@ -41,17 +44,28 @@ private const int bPropertyIndex = 4; private const int cPropertyIndex = 5; + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; + /// /// Creates a new instance of . /// /// The instance to show the properties of. - /// Thrown when is null. - public WaveImpactAsphaltCoverFailureMechanismProperties(WaveImpactAsphaltCoverFailureMechanism data) : base(data, new ConstructionProperties + /// Handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. + public WaveImpactAsphaltCoverFailureMechanismProperties(WaveImpactAsphaltCoverFailureMechanism data, IFailureMechanismPropertyChangeHandler handler) : base(data, new ConstructionProperties { NamePropertyIndex = namePropertyIndex, CodePropertyIndex = codePropertyIndex - }) {} + }) + { + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + propertyChangeHandler = handler; + } + #region Model settings [PropertyOrder(aPropertyIndex)] @@ -94,7 +108,12 @@ ValidateParamC(newC); - data.GeneralInput.C = newC; + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( + data, + newC, + (f, v) => f.GeneralInput.C = v); + + NotifyAffectedObjects(affectedObjects); } } @@ -107,6 +126,15 @@ } } + private static void NotifyAffectedObjects(IEnumerable affectedObjects) + { + foreach (IObservable affectedObject in affectedObjects) + { + affectedObject.NotifyObservers(); + } + } + + #endregion } } \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r9339a780307cdb21ebe38cbd3aa8811e2c98d980 -r4b4b8a9607ac669b026a57a90cbd6b9c1d1856b2 --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 9339a780307cdb21ebe38cbd3aa8811e2c98d980) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 4b4b8a9607ac669b026a57a90cbd6b9c1d1856b2) @@ -6,7 +6,7 @@ // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -80,7 +80,7 @@ { yield return new PropertyInfo { - CreateInstance = context => new HydraulicLoadsStateFailureMechanismProperties(context.WrappedData) + CreateInstance = context => new HydraulicLoadsStateFailureMechanismProperties(context.WrappedData, new FailureMechanismPropertyChangeHandler()) }; yield return new PropertyInfo { Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs =================================================================== diff -u -r6ba841ede2bfbe9685aafac513cac423d3a705e0 -r4b4b8a9607ac669b026a57a90cbd6b9c1d1856b2 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs (.../WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs) (revision 6ba841ede2bfbe9685aafac513cac423d3a705e0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs (.../WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs) (revision 4b4b8a9607ac669b026a57a90cbd6b9c1d1856b2) @@ -24,6 +24,7 @@ using Core.Common.Base.Data; using Core.Gui.TestUtil; using NUnit.Framework; +using Riskeer.Common.Forms.ChangeHandlers; using Riskeer.WaveImpactAsphaltCover.Data; using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses; using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.HydraulicLoadsState; @@ -46,7 +47,7 @@ var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); // Call - var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism); + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism, new FailureMechanismPropertyChangeHandler()); // Assert Assert.IsInstanceOf(properties); @@ -64,7 +65,7 @@ public void Constructor_Always_PropertiesHaveExpectedAttributeValues() { // Call - var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(new WaveImpactAsphaltCoverFailureMechanism()); + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(new WaveImpactAsphaltCoverFailureMechanism(), new FailureMechanismPropertyChangeHandler()); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -119,7 +120,7 @@ private void SetToOutOfBounds() { var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism); + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism, new FailureMechanismPropertyChangeHandler()); // C must be in range [0, ... , 2] properties.C = new RoundedDouble(2, 3.14); }