Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs
===================================================================
diff -u -rcf2dc4330cecec3b8c8acae9e195280323fc2a50 -r09c09d852a24510f1c63db1065a50ebc20471f55
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision cf2dc4330cecec3b8c8acae9e195280323fc2a50)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision 09c09d852a24510f1c63db1065a50ebc20471f55)
@@ -22,6 +22,7 @@
using System;
using System.Linq;
using System.Windows.Forms;
+using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
@@ -372,14 +373,15 @@
/// in the .
///
/// The calculation from which to remove all children.
+ /// The object implementing a method for closing views for the removed children.
/// The created .
- public static StrictContextMenuItem CreateRemoveAllChildrenFromGroupItem(CalculationGroup calculationGroup)
+ public static StrictContextMenuItem CreateRemoveAllChildrenFromGroupItem(CalculationGroup calculationGroup, IViewCommands viewCommands)
{
var menuItem = new StrictContextMenuItem(
Resources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all,
Resources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip,
Resources.RemoveAllIcon,
- (sender, args) => RemoveAllChildrenFromGroup(calculationGroup));
+ (sender, args) => RemoveAllChildrenFromGroup(calculationGroup, viewCommands));
var errorMessage = calculationGroup.Children.Any() ? null : Resources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove;
@@ -391,12 +393,16 @@
return menuItem;
}
- private static void RemoveAllChildrenFromGroup(CalculationGroup calculationGroup)
+ private static void RemoveAllChildrenFromGroup(CalculationGroup calculationGroup, IViewCommands viewCommands)
{
if (MessageBox.Show(Resources.CalculationGroup_RemoveAllChildrenFromGroup_Are_you_sure_you_want_to_remove_everything_from_this_group, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK)
{
return;
}
+ foreach (var calculation in calculationGroup.GetCalculations())
+ {
+ viewCommands.RemoveAllViewsForItem(calculation);
+ }
calculationGroup.Children.Clear();
calculationGroup.NotifyObservers();