Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs
===================================================================
diff -u -r09e76611c2a789b6f015368968a18ea5b9b138cc -ra3357275af675af3714fc89b99c554c288759ae2
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision 09e76611c2a789b6f015368968a18ea5b9b138cc)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision a3357275af675af3714fc89b99c554c288759ae2)
@@ -100,33 +100,33 @@
/// 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 that checks if the item is enabled.
+ /// The func for performing additional validation checks.
/// The created .
+ /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public static StrictContextMenuItem CreatePerformAllCalculationsInGroupItem(
CalculationGroup calculationGroup,
TCalculationContext calculationGroupContext,
Action calculateAllAction,
- Func isEnabledFunc)
+ Func additionalValidationFunc)
where TCalculationContext : ICalculationContext
{
+ var validationText = additionalValidationFunc(calculationGroupContext);
+
var performAllItem = new StrictContextMenuItem(
Resources.Calculate_all,
Resources.CalculationGroup_CalculateAll_ToolTip,
Resources.CalculateAllIcon,
- (o, args) => calculateAllAction(calculationGroup, calculationGroupContext))
- {
- Enabled = isEnabledFunc(calculationGroupContext)
- };
+ (o, args) => calculateAllAction(calculationGroup, calculationGroupContext));
- if (!performAllItem.Enabled)
+ if (!calculationGroupContext.WrappedData.Children.Any())
{
- return performAllItem;
+ performAllItem.Enabled = false;
+ performAllItem.ToolTipText = Resources.CalculationGroup_CalculateAll_No_calculations_to_run;
}
-
- if (!calculationGroup.GetCalculations().Any())
+ else if (!string.IsNullOrEmpty(validationText))
{
performAllItem.Enabled = false;
- performAllItem.ToolTipText = Resources.CalculationGroup_CalculateAll_No_calculations_to_run;
+ performAllItem.ToolTipText = validationText;
}
return performAllItem;
@@ -140,23 +140,28 @@
/// The calculation to perform.
/// The calculation context belonging to the calculation.
/// The action that performs the calculation.
- /// The func that checks if the item is enabled.
+ /// The func for performing additional validation checks.
/// The created .
+ /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public static StrictContextMenuItem CreatePerformCalculationItem(
TCalculation calculation,
TCalculationContext calculationContext,
Action calculateAction,
- Func isEnabledFunc)
+ Func additionalValidationFunc)
where TCalculationContext : ICalculationContext
where TCalculation : ICalculation
{
+ var validationText = additionalValidationFunc(calculationContext);
+ var nodeEnabled = string.IsNullOrEmpty(validationText);
+
return new StrictContextMenuItem(
Resources.Calculate,
Resources.Calculate_ToolTip,
Resources.CalculateIcon,
(o, args) => calculateAction(calculation, calculationContext))
{
- Enabled = isEnabledFunc(calculationContext)
+ Enabled = nodeEnabled,
+ ToolTipText = nodeEnabled ? Resources.Calculate_ToolTip : validationText
};
}
@@ -209,33 +214,33 @@
/// The type of the failure mechanism context.
/// The failure mechanism context belonging to the failure mechanism.
/// The action that performs all calculations.
- /// The func that checks if the item is enabled.
+ /// The func for performing additional validation checks.
/// The created .
+ /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public static StrictContextMenuItem CreatePerformAllCalculationsInFailureMechanismItem(
TFailureMechanismContext failureMechanismContext,
Action calculateAllAction,
- Func isEnabledFunc)
+ Func additionalValidationFunc)
where TFailureMechanismContext : IFailureMechanismContext
{
+ var validationText = additionalValidationFunc(failureMechanismContext);
+
var performAllItem = new StrictContextMenuItem(
Resources.Calculate_all,
Resources.Calculate_all_ToolTip,
Resources.CalculateAllIcon,
- (o, args) => calculateAllAction(failureMechanismContext))
- {
- Enabled = isEnabledFunc(failureMechanismContext)
- };
+ (o, args) => calculateAllAction(failureMechanismContext));
- if (!performAllItem.Enabled)
- {
- return performAllItem;
- }
-
if (!failureMechanismContext.WrappedData.Calculations.Any())
{
performAllItem.Enabled = false;
performAllItem.ToolTipText = Resources.FailureMechanism_CreateCalculateAllItem_No_calculations_to_run;
}
+ else if (!string.IsNullOrEmpty(validationText))
+ {
+ performAllItem.Enabled = false;
+ performAllItem.ToolTipText = validationText;
+ }
return performAllItem;
}