Index: Ringtoets/Common/src/Ringtoets.Common.Plugin/RingtoetsPluginHelper.cs =================================================================== diff -u -r37e22252b83aad49bf849a655c68e1cd22da53f1 -rda830a4d881ce21dd9091e517e60a8c05475d51d --- Ringtoets/Common/src/Ringtoets.Common.Plugin/RingtoetsPluginHelper.cs (.../RingtoetsPluginHelper.cs) (revision 37e22252b83aad49bf849a655c68e1cd22da53f1) +++ Ringtoets/Common/src/Ringtoets.Common.Plugin/RingtoetsPluginHelper.cs (.../RingtoetsPluginHelper.cs) (revision da830a4d881ce21dd9091e517e60a8c05475d51d) @@ -27,6 +27,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Forms.Views; namespace Ringtoets.Common.Plugin { @@ -66,6 +67,33 @@ return calculations.Any(c => ReferenceEquals(view.Data, c)); } + /// + /// Checks whether should be closed based on the removal of + /// . + /// + /// The view to be checked. + /// The object that is removed. + /// Whether the view should be closed. + private static bool ShouldCloseFailureMechanismSectionsView(FailureMechanismSectionsView view, object removedObject) + { + var assessmentSection = removedObject as IAssessmentSection; + var failureMechanismContext = removedObject as IFailureMechanismContext; + var failureMechanism = removedObject as IFailureMechanism; + + if (failureMechanismContext != null) + { + failureMechanism = failureMechanismContext.WrappedData; + } + + if (assessmentSection != null) + { + failureMechanism = assessmentSection.GetFailureMechanisms() + .FirstOrDefault(fm => fm == view.FailureMechanism); + } + + return failureMechanism != null && ReferenceEquals(view.FailureMechanism, failureMechanism); + } + private static IEnumerable GetCalculationsFromFailureMechanisms(object o) { var failureMechanism = o as IFailureMechanism;