Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs =================================================================== diff -u -ra3357275af675af3714fc89b99c554c288759ae2 -rd08c15413bbb6009c6da8ee05833a4c3531b358c --- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision a3357275af675af3714fc89b99c554c288759ae2) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c) @@ -89,44 +89,88 @@ /// The calculation group to perform all calculations for. /// The calculation group context belonging to the calculation group. /// The action that performs all calculations. - /// The func for performing additional validation checks. + /// An optional function which determines whether the item should be enabled. If the + /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip. + /// If the item should be enabled then the function should return a null or empty string. /// The itself. - /// When returns a string, the item will be disabled and the string will be shown in the tooltip. public RingtoetsContextMenuBuilder AddPerformAllCalculationsInGroupItem( CalculationGroup calculationGroup, TCalculationContext calculationGroupContext, Action calculateAllAction, - Func additionalValidationFunc) + Func enableMenuItemFunction = null) where TCalculationContext : ICalculationContext { - contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, calculateAllAction, additionalValidationFunc)); + contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, calculateAllAction, enableMenuItemFunction)); return this; } /// + /// Adds an item to the , which validates all calculations in a calculation group. + /// + /// The type of the calculation group context. + /// The calculation group to validate all calculations for. + /// The calculation group context belonging to the calculation group. + /// The action that validates all calculations. + /// An optional function which determines whether the item should be enabled. If the + /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip. + /// If the item should be enabled then the function should return a null or empty string. + /// The itself. + public RingtoetsContextMenuBuilder AddValidateAllCalculationsInGroupItem( + CalculationGroup calculationGroup, + TCalculationContext calculationGroupContext, + Action validateAllAction, + Func enableMenuItemFunction = null) + where TCalculationContext : ICalculationContext + { + contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, validateAllAction, enableMenuItemFunction)); + return this; + } + + /// /// Adds an item to the , which performs a calculation. /// /// The type of the calculation. /// The type of the calculation context. /// The calculation to perform. /// The calculation context belonging to the calculation. /// The action that performs the calculation. - /// The func for performing additional validation checks. + /// An optional function which determines whether the item should be enabled. If the + /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip. + /// If the item should be enabled then the function should return a null or empty string. /// The itself. - /// When returns a string, the item will be disabled and the string will be shown in the tooltip. public RingtoetsContextMenuBuilder AddPerformCalculationItem( TCalculation calculation, TCalculationContext calculationContext, Action calculateAction, - Func additionalValidationFunc) + Func enableMenuItemFunction = null) where TCalculationContext : ICalculationContext where TCalculation : ICalculation { - contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformCalculationItem(calculation, calculationContext, calculateAction, additionalValidationFunc)); + contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformCalculationItem(calculation, calculationContext, calculateAction, enableMenuItemFunction)); return this; } /// + /// Adds an item to the , which validates a calculation. + /// + /// The type of the calculation. + /// The calculation to validate. + /// The action that validates the calculation. + /// An optional function which determines whether the item should be enabled. If the + /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip. + /// If the item should be enabled then the function should return a null or empty string. + /// The itself. + public RingtoetsContextMenuBuilder AddValidateCalculationItem( + TCalculation calculation, + Action validateAction, + Func enableMenuItemFunction = null) + where TCalculation : ICalculation + { + contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateValidateCalculationItem(calculation, validateAction, enableMenuItemFunction)); + return this; + } + + /// /// Adds an item to the , which clears the output of a calculation. /// /// The calculation to clear the output for. @@ -154,20 +198,43 @@ /// The type of the failure mechanism context. /// The failure mechanism context belonging to the failure mechanism. /// The action that performs all calculations. - /// The func for performing additional validation checks. + /// An optional function which determines whether the item should be enabled. If the + /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip. + /// If the item should be enabled then the function should return a null or empty string. /// The itself. - /// When returns a string, the item will be disabled and the string will be shown in the tooltip. + /// When returns a string, the item will be disabled and the string will be shown in the tooltip. public RingtoetsContextMenuBuilder AddPerformAllCalculationsInFailureMechanismItem( TFailureMechanismContext failureMechanismContext, Action calculateAllAction, - Func additionalValidationFunc) + Func enableMenuItemFunction = null) where TFailureMechanismContext : IFailureMechanismContext { - contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInFailureMechanismItem(failureMechanismContext, calculateAllAction, additionalValidationFunc)); + contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInFailureMechanismItem(failureMechanismContext, calculateAllAction, enableMenuItemFunction)); return this; } /// + /// Adds an item to the , which validates all calculations in a failure mechanism. + /// + /// The type of the failure mechanism context. + /// The failure mechanism context belonging to the failure mechanism. + /// The action that validates all calculations. + /// An optional function which determines whether the item should be enabled. If the + /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip. + /// If the item should be enabled then the function should return a null or empty string. + /// The itself. + /// When returns a string, the item will be disabled and the string will be shown in the tooltip. + public RingtoetsContextMenuBuilder AddValidateAllCalculationsInFailureMechanismItem( + TFailureMechanism failureMechanism, + Action validateAllAction, + Func enableMenuItemFunction = null) + where TFailureMechanism : IFailureMechanism + { + contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInFailureMechanismItem(failureMechanism, validateAllAction, enableMenuItemFunction)); + return this; + } + + /// /// Adds an item to the , which sets if the failure mechanism is relevant. /// /// The type of the failure mechanism context.