Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/StrengthStabilityLengthwiseConstructionSectionResultRow.cs
===================================================================
diff -u -r802d3cd39b925ac9873ea277588ecd1933e374f6 -r9b261d1aecde88dc1a0d996a274c040302cca40a
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/StrengthStabilityLengthwiseConstructionSectionResultRow.cs (.../StrengthStabilityLengthwiseConstructionSectionResultRow.cs) (revision 802d3cd39b925ac9873ea277588ecd1933e374f6)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/StrengthStabilityLengthwiseConstructionSectionResultRow.cs (.../StrengthStabilityLengthwiseConstructionSectionResultRow.cs) (revision 9b261d1aecde88dc1a0d996a274c040302cca40a)
@@ -20,33 +20,71 @@
// All rights reserved.
using System;
-using System.ComponentModel;
-using Core.Common.Base.Data;
-using Ringtoets.Common.Forms.TypeConverters;
+using Core.Common.Controls.DataGrid;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.Forms;
+using Ringtoets.Common.Data.Exceptions;
+using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Common.Primitives;
+using Ringtoets.Integration.Data.StandAlone.AssemblyFactories;
using Ringtoets.Integration.Data.StandAlone.SectionResults;
namespace Ringtoets.Integration.Forms.Views.SectionResultRows
{
///
/// Class for displaying as a row in a grid view.
///
- public class StrengthStabilityLengthwiseConstructionSectionResultRow
+ public class StrengthStabilityLengthwiseConstructionSectionResultRow
: FailureMechanismSectionResultRow
{
+ private readonly int simpleAssessmentResultIndex;
+ private readonly int tailorMadeAssessmentResultIndex;
+ private readonly int simpleAssemblyCategoryGroupIndex;
+ private readonly int tailorMadeAssemblyCategoryGroupIndex;
+ private readonly int combinedAssemblyCategoryGroupIndex;
+ private readonly int manualAssemblyCategoryGroupIndex;
+
+ private FailureMechanismSectionAssemblyCategoryGroup simpleAssemblyCategoryGroup;
+ private FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssemblyCategoryGroup;
+ private FailureMechanismSectionAssemblyCategoryGroup combinedAssemblyCategoryGroup;
+
///
/// Creates a new instance of .
///
/// The to wrap
/// so that it can be displayed as a row.
- /// Thrown when is null.
- public StrengthStabilityLengthwiseConstructionSectionResultRow(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult sectionResult)
- : base(sectionResult) {}
+ /// The property values required to create an instance of
+ /// .
+ /// Thrown when any parameter is null.
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ internal StrengthStabilityLengthwiseConstructionSectionResultRow(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult sectionResult,
+ ConstructionProperties constructionProperties)
+ : base(sectionResult)
+ {
+ if (constructionProperties == null)
+ {
+ throw new ArgumentNullException(nameof(constructionProperties));
+ }
+ simpleAssessmentResultIndex = constructionProperties.SimpleAssessmentResultIndex;
+ tailorMadeAssessmentResultIndex = constructionProperties.TailorMadeAssessmentResultIndex;
+ simpleAssemblyCategoryGroupIndex = constructionProperties.SimpleAssemblyCategoryGroupIndex;
+ tailorMadeAssemblyCategoryGroupIndex = constructionProperties.TailorMadeAssemblyCategoryGroupIndex;
+ combinedAssemblyCategoryGroupIndex = constructionProperties.CombinedAssemblyCategoryGroupIndex;
+ manualAssemblyCategoryGroupIndex = constructionProperties.ManualAssemblyCategoryGroupIndex;
+
+ CreateColumnStateDefinitions();
+
+ Update();
+ }
+
///
/// Gets or sets the value representing the simple assessment result.
///
+ /// Thrown when
+ /// is a valid value, but unsupported.
public SimpleAssessmentResultType SimpleAssessmentResult
{
get
@@ -56,10 +94,245 @@
set
{
SectionResult.SimpleAssessmentResult = value;
- SectionResult.NotifyObservers();
+ UpdateInternalData();
}
}
- public override void Update() {}
+ ///
+ /// Gets or sets the value representing the tailor made assessment result.
+ ///
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ public TailorMadeAssessmentResultType TailorMadeAssessmentResult
+ {
+ get
+ {
+ return SectionResult.TailorMadeAssessmentResult;
+ }
+ set
+ {
+ SectionResult.TailorMadeAssessmentResult = value;
+ UpdateInternalData();
+ }
+ }
+
+ ///
+ /// Gets the simple assembly category group.
+ ///
+ public string SimpleAssemblyCategoryGroup
+ {
+ get
+ {
+ return FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(simpleAssemblyCategoryGroup);
+ }
+ }
+
+ ///
+ /// Gets the tailor made assembly category group.
+ ///
+ public string TailorMadeAssemblyCategoryGroup
+ {
+ get
+ {
+ return FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(tailorMadeAssemblyCategoryGroup);
+ }
+ }
+
+ ///
+ /// Gets the combined assembly category group.
+ ///
+ public string CombinedAssemblyCategoryGroup
+ {
+ get
+ {
+ return FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(combinedAssemblyCategoryGroup);
+ }
+ }
+
+ ///
+ /// Gets or sets the indicator whether the combined assembly should be overwritten by .
+ ///
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ public bool UseManualAssemblyCategoryGroup
+ {
+ get
+ {
+ return SectionResult.UseManualAssemblyCategoryGroup;
+ }
+ set
+ {
+ SectionResult.UseManualAssemblyCategoryGroup = value;
+ UpdateInternalData();
+ }
+ }
+
+ ///
+ /// Gets or sets the manually selected assembly category group.
+ ///
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ public SelectableFailureMechanismSectionAssemblyCategoryGroup ManualAssemblyCategoryGroup
+ {
+ get
+ {
+ return SelectableFailureMechanismSectionAssemblyCategoryGroupConverter.ConvertTo(SectionResult.ManualAssemblyCategoryGroup);
+ }
+ set
+ {
+ SectionResult.ManualAssemblyCategoryGroup = SelectableFailureMechanismSectionAssemblyCategoryGroupConverter.ConvertFrom(value);
+ UpdateInternalData();
+ }
+ }
+
+ ///
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ public override void Update()
+ {
+ UpdateDerivedData();
+ UpdateColumnStateDefinitionStates();
+ }
+
+ private void CreateColumnStateDefinitions()
+ {
+ ColumnStateDefinitions.Add(simpleAssessmentResultIndex, new DataGridViewColumnStateDefinition());
+ ColumnStateDefinitions.Add(tailorMadeAssessmentResultIndex, new DataGridViewColumnStateDefinition());
+ ColumnStateDefinitions.Add(simpleAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition
+ {
+ ReadOnly = true
+ });
+ ColumnStateDefinitions.Add(tailorMadeAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition
+ {
+ ReadOnly = true
+ });
+ ColumnStateDefinitions.Add(combinedAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition
+ {
+ ReadOnly = true
+ });
+ ColumnStateDefinitions.Add(manualAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition());
+ }
+
+ private void UpdateDerivedData()
+ {
+ ResetErrorTexts();
+ TryGetSimpleAssemblyCategoryGroup();
+ TryGetTailorMadeAssemblyCategoryGroup();
+ TryGetCombinedAssemblyCategoryGroup();
+ }
+
+ private void ResetErrorTexts()
+ {
+ ColumnStateDefinitions[simpleAssemblyCategoryGroupIndex].ErrorText = string.Empty;
+ ColumnStateDefinitions[tailorMadeAssemblyCategoryGroupIndex].ErrorText = string.Empty;
+ ColumnStateDefinitions[combinedAssemblyCategoryGroupIndex].ErrorText = string.Empty;
+ }
+
+ private void TryGetSimpleAssemblyCategoryGroup()
+ {
+ try
+ {
+ simpleAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult);
+ }
+ catch (AssemblyException e)
+ {
+ simpleAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.None;
+ ColumnStateDefinitions[simpleAssemblyCategoryGroupIndex].ErrorText = e.Message;
+ }
+ }
+
+ private void TryGetTailorMadeAssemblyCategoryGroup()
+ {
+ try
+ {
+ tailorMadeAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult);
+ }
+ catch (AssemblyException e)
+ {
+ tailorMadeAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.None;
+ ColumnStateDefinitions[tailorMadeAssemblyCategoryGroupIndex].ErrorText = e.Message;
+ }
+ }
+
+ private void TryGetCombinedAssemblyCategoryGroup()
+ {
+ try
+ {
+ combinedAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult);
+ }
+ catch (AssemblyException e)
+ {
+ combinedAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.None;
+ ColumnStateDefinitions[combinedAssemblyCategoryGroupIndex].ErrorText = e.Message;
+ }
+ }
+
+ ///
+ /// Updates the column state definitions.
+ ///
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ private void UpdateColumnStateDefinitionStates()
+ {
+ bool simpleAssessmentSufficient = FailureMechanismSectionResultRowHelper.SimpleAssessmentIsSufficient(SimpleAssessmentResult);
+
+ FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[simpleAssessmentResultIndex], UseManualAssemblyCategoryGroup);
+ FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[tailorMadeAssessmentResultIndex],
+ simpleAssessmentSufficient || UseManualAssemblyCategoryGroup);
+
+ if (UseManualAssemblyCategoryGroup)
+ {
+ FailureMechanismSectionResultRowHelper.DisableColumn(ColumnStateDefinitions[simpleAssemblyCategoryGroupIndex]);
+ FailureMechanismSectionResultRowHelper.DisableColumn(ColumnStateDefinitions[tailorMadeAssemblyCategoryGroupIndex]);
+ FailureMechanismSectionResultRowHelper.DisableColumn(ColumnStateDefinitions[combinedAssemblyCategoryGroupIndex]);
+ }
+ else
+ {
+ FailureMechanismSectionResultRowHelper.SetAssemblyCategoryGroupStyle(ColumnStateDefinitions[simpleAssemblyCategoryGroupIndex],
+ simpleAssemblyCategoryGroup);
+ FailureMechanismSectionResultRowHelper.SetAssemblyCategoryGroupStyle(ColumnStateDefinitions[tailorMadeAssemblyCategoryGroupIndex],
+ tailorMadeAssemblyCategoryGroup);
+ FailureMechanismSectionResultRowHelper.SetAssemblyCategoryGroupStyle(ColumnStateDefinitions[combinedAssemblyCategoryGroupIndex],
+ combinedAssemblyCategoryGroup);
+ }
+
+ FailureMechanismSectionResultRowHelper.SetColumnState(ColumnStateDefinitions[manualAssemblyCategoryGroupIndex], !UseManualAssemblyCategoryGroup);
+ }
+
+ ///
+ /// Class holding the various construction parameters for .
+ ///
+ public class ConstructionProperties
+ {
+ ///
+ /// Sets the simple assessment result index.
+ ///
+ public int SimpleAssessmentResultIndex { internal get; set; }
+
+ ///
+ /// Sets the tailor made assessment result index.
+ ///
+ public int TailorMadeAssessmentResultIndex { internal get; set; }
+
+ ///
+ /// Sets the simple assembly category group index.
+ ///
+ public int SimpleAssemblyCategoryGroupIndex { internal get; set; }
+
+ ///
+ /// Sets the tailor made assembly category group index.
+ ///
+ public int TailorMadeAssemblyCategoryGroupIndex { internal get; set; }
+
+ ///
+ /// Sets the combined assembly category group index.
+ ///
+ public int CombinedAssemblyCategoryGroupIndex { internal get; set; }
+
+ ///
+ /// Sets the manual assembly category group index.
+ ///
+ public int ManualAssemblyCategoryGroupIndex { internal get; set; }
+ }
}
}
\ No newline at end of file