Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r449b5831547d5a6391da8ad825e7c845ef7ecc1c -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) @@ -1172,33 +1172,6 @@ #region Property indices -// #region No structure indices -// -// private const int verticalWallHydraulicBoundaryLocationPropertyIndex = 0; -// private const int verticalWallStormDurationPropertyIndex = 1; -// private const int verticalWallStructurePropertyIndex = 2; -// private const int verticalWallStructureLocationPropertyIndex = 3; -// private const int verticalWallStructureNormalOrientationPropertyIndex = 4; -// private const int verticalWallInflowModelTypePropertyIndex = 5; -// private const int verticalWallWidthFlowAperturesPropertyIndex = 6; -// private const int verticalWallIdenticalAperturesPropertyIndex = 7; -// private const int verticalWallFlowWidthAtBottomProtectionPropertyIndex = 8; -// private const int verticalWallStorageStructureAreaPropertyIndex = 9; -// private const int verticalWallAllowedLevelIncreaseStoragePropertyIndex = 10; -// private const int verticalWallLevelCrestStructureNotClosingPropertyIndex = 11; -// private const int verticalWallCriticalOvertoppingDischargePropertyIndex = 12; -// private const int verticalWallProbabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex = 13; -// private const int verticalWallFailureProbabilityOpenStructurePropertyIndex = 14; -// private const int verticalWallFailureProbabilityReparationPropertyIndex = 15; -// private const int verticalWallFailureProbabilityStructureWithErosionPropertyIndex = 16; -// private const int verticalWallForeshoreProfilePropertyIndex = 17; -// private const int verticalWallUseBreakWaterPropertyIndex = 18; -// private const int verticalWallUseForeshorePropertyIndex = 19; -// private const int verticalWallModelFactorSuperCriticalFlowPropertyIndex = 20; -// private const int verticalWallFactorStormDurationOpenStructurePropertyIndex = 21; -// -// #endregion - #region VerticalWall structures indices private const int verticalWallHydraulicBoundaryLocationPropertyIndex = 0; Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -r449b5831547d5a6391da8ad825e7c845ef7ecc1c -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) @@ -456,6 +456,7 @@ } } + [DynamicReadOnly] [DynamicPropertyOrder] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_FailureProbabilityStructureWithErosion_DisplayName))] Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -r449b5831547d5a6391da8ad825e7c845ef7ecc1c -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) @@ -109,6 +109,15 @@ #endregion + public override bool IsReadOnly(string property) + { + if (property == nameof(FailureProbabilityStructureWithErosion)) + { + return !HasStructure(); + } + return base.IsReadOnly(property); + } + public override IEnumerable GetAvailableForeshoreProfiles() { return data.FailureMechanism.ForeshoreProfiles; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r449b5831547d5a6391da8ad825e7c845ef7ecc1c -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) @@ -217,8 +217,14 @@ var properties = new HeightStructuresInputContextProperties(inputContext, handler); // Assert - AssertPropertiesInState(properties.LevelCrestStructure, !hasStructure); + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + bool expectedReadOnly = !hasStructure; + PropertyDescriptor failureProbabilityStructureWithErosionProperty = dynamicProperties[failureProbabilityStructureWithErosionPropertyIndex]; + Assert.AreEqual(expectedReadOnly, failureProbabilityStructureWithErosionProperty.IsReadOnly); + + AssertPropertiesInState(properties.LevelCrestStructure, expectedReadOnly); + mockRepository.VerifyAll(); } Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs =================================================================== diff -u -rd5a0bce3d53deb3aef237c365018096e9bc83bb1 -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision d5a0bce3d53deb3aef237c365018096e9bc83bb1) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) @@ -210,7 +210,9 @@ get { return new NormalDistributionProperties( - DistributionPropertiesReadOnly.None, + HasStructure() + ? DistributionPropertiesReadOnly.None + : DistributionPropertiesReadOnly.All, data.WrappedData.InsideWaterLevelFailureConstruction, PropertyChangeHandler); } @@ -226,7 +228,9 @@ get { return new NormalDistributionProperties( - DistributionPropertiesReadOnly.None, + HasStructure() + ? DistributionPropertiesReadOnly.None + : DistributionPropertiesReadOnly.All, data.WrappedData.InsideWaterLevel, PropertyChangeHandler); } @@ -256,7 +260,9 @@ get { return new NormalDistributionProperties( - DistributionPropertiesReadOnly.StandardDeviation, + HasStructure() + ? DistributionPropertiesReadOnly.StandardDeviation + : DistributionPropertiesReadOnly.All, data.WrappedData.DrainCoefficient, PropertyChangeHandler); } @@ -291,6 +297,7 @@ } } + [DynamicReadOnly] [PropertyOrder(inflowModelTypePropertyIndex)] [TypeConverter(typeof(EnumTypeConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] @@ -308,6 +315,7 @@ } } + [DynamicReadOnly] [PropertyOrder(loadSchematizationTypePropertyIndex)] [TypeConverter(typeof(EnumTypeConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] @@ -335,7 +343,9 @@ get { return new NormalDistributionProperties( - DistributionPropertiesReadOnly.None, + HasStructure() + ? DistributionPropertiesReadOnly.None + : DistributionPropertiesReadOnly.All, data.WrappedData.LevelCrestStructure, PropertyChangeHandler); } @@ -351,23 +361,27 @@ get { return new NormalDistributionProperties( - DistributionPropertiesReadOnly.None, + HasStructure() + ? DistributionPropertiesReadOnly.None + : DistributionPropertiesReadOnly.All, data.WrappedData.ThresholdHeightOpenWeir, PropertyChangeHandler); } } [PropertyOrder(flowVelocityStructureClosablePropertyIndex)] [TypeConverter(typeof(ExpandableObjectConverter))] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] - [ResourcesDisplayName(typeof(Resources), "Structure_FlowVelocityStructureClosable_DisplayName")] - [ResourcesDescription(typeof(Resources), "Structure_FlowVelocityStructureClosable_Description")] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_FlowVelocityStructureClosable_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.Structure_FlowVelocityStructureClosable_Description))] public VariationCoefficientNormalDistributionProperties FlowVelocityStructureClosable { get { return new VariationCoefficientNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.CoefficientOfVariation, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.CoefficientOfVariation + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.FlowVelocityStructureClosable, PropertyChangeHandler); } @@ -384,7 +398,9 @@ get { return new LogNormalDistributionProperties( - DistributionPropertiesReadOnly.None, + HasStructure() + ? DistributionPropertiesReadOnly.None + : DistributionPropertiesReadOnly.All, data.WrappedData.AreaFlowApertures, PropertyChangeHandler); } @@ -401,7 +417,9 @@ get { return new VariationCoefficientLogNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.None + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.ConstructiveStrengthLinearLoadModel, PropertyChangeHandler); } @@ -418,7 +436,9 @@ get { return new VariationCoefficientLogNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.None + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.ConstructiveStrengthQuadraticLoadModel, PropertyChangeHandler); } @@ -435,7 +455,9 @@ get { return new VariationCoefficientLogNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.None + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.StabilityLinearLoadModel, PropertyChangeHandler); } @@ -452,12 +474,15 @@ get { return new VariationCoefficientLogNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.None + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.StabilityQuadraticLoadModel, PropertyChangeHandler); } } + [DynamicReadOnly] [PropertyOrder(failureProbabilityRepairClosurePropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_FailureProbabilityRepairClosure_DisplayName))] @@ -487,7 +512,9 @@ get { return new VariationCoefficientLogNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.None + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.FailureCollisionEnergy, PropertyChangeHandler); } @@ -503,7 +530,9 @@ get { return new VariationCoefficientNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.None + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.ShipMass, PropertyChangeHandler); } @@ -519,12 +548,15 @@ get { return new VariationCoefficientNormalDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, + HasStructure() + ? VariationCoefficientDistributionPropertiesReadOnly.None + : VariationCoefficientDistributionPropertiesReadOnly.All, data.WrappedData.ShipVelocity, PropertyChangeHandler); } } + [DynamicReadOnly] [PropertyOrder(levellingCountPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_LevellingCount_DisplayName))] @@ -541,6 +573,7 @@ } } + [DynamicReadOnly] [PropertyOrder(probabilityCollisionSecondaryStructurePropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_ProbabilityCollisionSecondaryStructure_DisplayName))] @@ -570,12 +603,15 @@ get { return new NormalDistributionProperties( - DistributionPropertiesReadOnly.None, + HasStructure() + ? DistributionPropertiesReadOnly.None + : DistributionPropertiesReadOnly.All, data.WrappedData.BankWidth, PropertyChangeHandler); } } + [DynamicReadOnly] [PropertyOrder(evaluationLevelPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_EvaluationLevel_DisplayName))] @@ -592,6 +628,7 @@ } } + [DynamicReadOnly] [PropertyOrder(verticalDistancePropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.Structure_VerticalDistance_DisplayName))] @@ -609,5 +646,38 @@ } #endregion + + public override bool IsReadOnly(string property) + { + if (property == nameof(InflowModelType)) + { + return !HasStructure(); + } + if (property == nameof(LoadSchematizationType)) + { + return !HasStructure(); + } + if (property == nameof(LevellingCount)) + { + return !HasStructure(); + } + if (property == nameof(EvaluationLevel)) + { + return !HasStructure(); + } + if (property == nameof(VerticalDistance)) + { + return !HasStructure(); + } + if (property == nameof(FailureProbabilityRepairClosure)) + { + return !HasStructure(); + } + if (property == nameof(ProbabilityCollisionSecondaryStructure)) + { + return !HasStructure(); + } + return base.IsReadOnly(property); + } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs =================================================================== diff -u -rf3c7ae4cc9069268dba97e9dd691bf449fa393db -r5fae8cb70dd4efeb648c5ff5ee02c837a47172db --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision f3c7ae4cc9069268dba97e9dd691bf449fa393db) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 5fae8cb70dd4efeb648c5ff5ee02c837a47172db) @@ -173,6 +173,7 @@ { InputParameters = { + Structure = new TestStabilityPointStructure(), InflowModelType = StabilityPointStructureInflowModelType.LowSill, LoadSchematizationType = LoadSchematizationType.Linear } @@ -350,6 +351,7 @@ { InputParameters = { + Structure = new TestStabilityPointStructure(), InflowModelType = StabilityPointStructureInflowModelType.LowSill, LoadSchematizationType = LoadSchematizationType.Quadratic } @@ -527,6 +529,7 @@ { InputParameters = { + Structure = new TestStabilityPointStructure(), InflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert, LoadSchematizationType = LoadSchematizationType.Linear } @@ -714,6 +717,7 @@ { InputParameters = { + Structure = new TestStabilityPointStructure(), InflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert, LoadSchematizationType = LoadSchematizationType.Quadratic } @@ -889,6 +893,69 @@ } [Test] + public void Constructor_WithoutStructure_CorrectReadOnlyForStructureDependentProperties() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var handler = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + + var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + + // Call + var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + + PropertyDescriptor structureNormalOrientation = dynamicProperties[10]; + Assert.IsTrue(structureNormalOrientation.IsReadOnly); + + PropertyDescriptor inflowModelType = dynamicProperties[11]; + Assert.IsTrue(inflowModelType.IsReadOnly); + + PropertyDescriptor loadSchematizationType = dynamicProperties[12]; + Assert.IsTrue(loadSchematizationType.IsReadOnly); + + PropertyDescriptor levellingCount = dynamicProperties[18]; + Assert.IsTrue(levellingCount.IsReadOnly); + + PropertyDescriptor evaluationLevel = dynamicProperties[25]; + Assert.IsTrue(evaluationLevel.IsReadOnly); + + PropertyDescriptor verticalDistance = dynamicProperties[26]; + Assert.IsTrue(verticalDistance.IsReadOnly); + + PropertyDescriptor failureProbabilityRepairClosure = dynamicProperties[27]; + Assert.IsTrue(failureProbabilityRepairClosure.IsReadOnly); + + PropertyDescriptor probabilityCollisionSecondaryStructure = dynamicProperties[31]; + Assert.IsTrue(probabilityCollisionSecondaryStructure.IsReadOnly); + + AssertPropertiesInState(properties.LevelCrestStructure, true); + AssertPropertiesInState(properties.ThresholdHeightOpenWeir, true); + AssertPropertiesInState(properties.AreaFlowApertures, true); + AssertPropertiesInState(properties.ConstructiveStrengthLinearLoadModel, true); + AssertPropertiesInState(properties.ConstructiveStrengthQuadraticLoadModel, true); + AssertPropertiesInState(properties.StabilityLinearLoadModel, true); + AssertPropertiesInState(properties.StabilityQuadraticLoadModel, true); + AssertPropertiesInState(properties.FailureCollisionEnergy, true); + AssertPropertiesInState(properties.ShipMass, true); + AssertPropertiesInState(properties.ShipVelocity, true); + AssertPropertiesInState(properties.BankWidth, true); + AssertPropertiesInState(properties.InsideWaterLevel, true); + AssertPropertiesInState(properties.InsideWaterLevelFailureConstruction, true); + AssertPropertiesInState(properties.FlowVelocityStructureClosable, true); + } + + [Test] public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles() { // Setup @@ -1565,6 +1632,15 @@ mockRepository.VerifyAll(); } + private static void AssertPropertiesInState(object properties, bool expectedReadOnly) + { + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + Assert.AreEqual(expectedReadOnly, dynamicProperties[1].IsReadOnly); + Assert.AreEqual(expectedReadOnly, dynamicProperties[2].IsReadOnly); + } + #region LowSill + Linear Model property Indices private const int linearLowSillHydraulicBoundaryLocationPropertyIndex = 0;