Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs =================================================================== diff -u -rf3c7ae4cc9069268dba97e9dd691bf449fa393db -r449b5831547d5a6391da8ad825e7c845ef7ecc1c --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision f3c7ae4cc9069268dba97e9dd691bf449fa393db) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) @@ -258,6 +258,7 @@ } } + [DynamicReadOnly] [PropertyOrder(inflowModelTypePropertyIndex)] [TypeConverter(typeof(EnumTypeConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] @@ -313,6 +314,7 @@ } } + [DynamicReadOnly] [PropertyOrder(failureProbabilityOpenStructurePropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.FailureProbabilityOpenStructure_DisplayName))] @@ -332,6 +334,7 @@ } } + [DynamicReadOnly] [PropertyOrder(failureProbabilityReparationPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.FailureProbabilityReparation_DisplayName))] @@ -351,6 +354,7 @@ } } + [DynamicReadOnly] [PropertyOrder(identicalAperturesPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.IdenticalApertures_DisplayName))] @@ -386,6 +390,7 @@ } } + [DynamicReadOnly] [PropertyOrder(probabilityOrFrequencyOpenStructureBeforeFloodingPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_Schematization))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.ProbabilityOrFrequencyOpenStructureBeforeFlooding_DisplayName))] @@ -406,5 +411,31 @@ } #endregion + + public override bool IsReadOnly(string property) + { + if (property == nameof(InflowModelType)) + { + return !HasStructure(); + } + if (property == nameof(IdenticalApertures)) + { + return !HasStructure(); + } + if (property == nameof(ProbabilityOrFrequencyOpenStructureBeforeFlooding)) + { + return !HasStructure(); + } + if (property == nameof(FailureProbabilityOpenStructure)) + { + return !HasStructure(); + } + if (property == nameof(FailureProbabilityReparation)) + { + return !HasStructure(); + } + + return base.IsReadOnly(property); + } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs =================================================================== diff -u -rf3c7ae4cc9069268dba97e9dd691bf449fa393db -r449b5831547d5a6391da8ad825e7c845ef7ecc1c --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision f3c7ae4cc9069268dba97e9dd691bf449fa393db) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) @@ -471,19 +471,19 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - PropertyDescriptor inflowModelType = dynamicProperties[5]; + PropertyDescriptor inflowModelType = dynamicProperties[6]; Assert.IsTrue(inflowModelType.IsReadOnly); - PropertyDescriptor identicalApertures = dynamicProperties[8]; + PropertyDescriptor identicalApertures = dynamicProperties[9]; Assert.IsTrue(identicalApertures.IsReadOnly); - PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFlooding = dynamicProperties[15]; + PropertyDescriptor probabilityOrFrequencyOpenStructureBeforeFlooding = dynamicProperties[16]; Assert.IsTrue(probabilityOrFrequencyOpenStructureBeforeFlooding.IsReadOnly); - PropertyDescriptor failureProbabilityOpenStructure = dynamicProperties[16]; + PropertyDescriptor failureProbabilityOpenStructure = dynamicProperties[17]; Assert.IsTrue(failureProbabilityOpenStructure.IsReadOnly); - PropertyDescriptor failureProbabilityReparation = dynamicProperties[17]; + PropertyDescriptor failureProbabilityReparation = dynamicProperties[18]; Assert.IsTrue(failureProbabilityReparation.IsReadOnly); AssertPropertiesInState(properties.ThresholdHeightOpenWeir, true); Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -rf3c7ae4cc9069268dba97e9dd691bf449fa393db -r449b5831547d5a6391da8ad825e7c845ef7ecc1c --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision f3c7ae4cc9069268dba97e9dd691bf449fa393db) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) @@ -568,7 +568,7 @@ } [DynamicReadOnlyValidationMethod] - public bool IsReadOnly(string property) + public virtual bool IsReadOnly(string property) { if (property == nameof(StructureNormalOrientation)) { Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -rf861839e975251253e2ffd7bc3f0a1839b85534e -r449b5831547d5a6391da8ad825e7c845ef7ecc1c --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision f861839e975251253e2ffd7bc3f0a1839b85534e) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) @@ -99,7 +99,9 @@ get { return new NormalDistributionProperties( - DistributionPropertiesReadOnly.None, + HasStructure() + ? DistributionPropertiesReadOnly.None + : DistributionPropertiesReadOnly.All, data.WrappedData.LevelCrestStructure, PropertyChangeHandler); } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 -r449b5831547d5a6391da8ad825e7c845ef7ecc1c --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 449b5831547d5a6391da8ad825e7c845ef7ecc1c) @@ -193,6 +193,45 @@ } [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_WithOrWithoutStructure_CorrectReadOnlyForStructureDependentProperties(bool hasStructure) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var handler = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var inputContext = new HeightStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + if (hasStructure) + { + calculation.InputParameters.Structure = new TestHeightStructure(); + } + + // Call + var properties = new HeightStructuresInputContextProperties(inputContext, handler); + + // Assert + AssertPropertiesInState(properties.LevelCrestStructure, !hasStructure); + + 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); + } + + [Test] public void GetAvailableForeshoreProfiles_SetInputContextInstanceWithForeshoreProfiles_ReturnForeshoreProfiles() { // Setup @@ -305,6 +344,7 @@ var calculation = new StructuresCalculation(); HeightStructuresInput input = calculation.InputParameters; input.ForeshoreProfile = new TestForeshoreProfile(); + input.Structure = new TestHeightStructure(); var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] {