Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs
===================================================================
diff -u -r36b6f1f7c1ddf585689512eb61256d41a1e0ca64 -re2991a38a1982398a6cbb35e38e534e26ba8930d
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision 36b6f1f7c1ddf585689512eb61256d41a1e0ca64)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision e2991a38a1982398a6cbb35e38e534e26ba8930d)
@@ -36,48 +36,46 @@
///
/// This class represents a factory for creating .
///
- public static class RingtoetsContextMenuItemFactory
+ public class RingtoetsContextMenuItemFactory
{
///
- /// This method adds a context menu item for creating new calculation groups.
+ /// Creates a which is bound to the action of adding new calculation groups.
///
- /// The builder to add the context menu item to.
/// The calculation group involved.
- public static void AddCreateCalculationGroupItem(IContextMenuBuilder builder, CalculationGroup calculationGroup)
+ /// The created .
+ public StrictContextMenuItem CreateAddCalculationGroupItem(CalculationGroup calculationGroup)
{
- var createCalculationGroupItem = new StrictContextMenuItem(
+ return new StrictContextMenuItem(
Resources.CalculationGroup_Add_CalculationGroup,
Resources.CalculationGroup_Add_CalculationGroup_Tooltip,
Resources.AddFolderIcon,
(o, args) => CreateCalculationGroup(calculationGroup));
-
- builder.AddCustomItem(createCalculationGroupItem);
}
///
- /// This method adds a context menu item for creating new calculations.
+ /// Creates a which is bound to the action of adding new calculations.
///
- /// The builder to add the context menu item to.
/// The calculation group context involved.
/// The action for adding a calculation to the calculation group.
- public static void AddCreateCalculationItem(IContextMenuBuilder builder, TCalculationGroupContext calculationGroupContext, Action addCalculation)
- where TCalculationGroupContext : ICalculationContext
+ /// The created .
+ public StrictContextMenuItem CreateAddCalculationItem(
+ TCalculationContext calculationGroupContext,
+ Action addCalculation)
+ where TCalculationContext : ICalculationContext
{
- var createCalculationItem = new StrictContextMenuItem(
+ return new StrictContextMenuItem(
Resources.CalculationGroup_Add_Calculation,
Resources.CalculationGroup_Add_Calculation_Tooltip,
Resources.FailureMechanismIcon,
(o, args) => addCalculation(calculationGroupContext));
-
- builder.AddCustomItem(createCalculationItem);
}
///
- /// This method adds a context menu item for clearing the output of all calculations in the calculation group.
+ /// Creates a which is bound to the action of clearing the output of all calculations in the calculation group.
///
- /// The builder to add the context menu item to.
/// The calculation group involved.
- public static void AddClearAllCalculationOutputInGroupItem(IContextMenuBuilder builder, CalculationGroup calculationGroup)
+ /// The created .
+ public StrictContextMenuItem CreateClearAllCalculationOutputInGroupItem(CalculationGroup calculationGroup)
{
var clearAllItem = new StrictContextMenuItem(
Resources.Clear_all_output,
@@ -91,19 +89,21 @@
clearAllItem.ToolTipText = Resources.CalculationGroup_ClearOutput_No_calculation_with_output_to_clear;
}
- builder.AddCustomItem(clearAllItem);
+ return clearAllItem;
}
///
- /// This method adds a context menu item for performing all calculations in the calculation group.
+ /// Creates a which is bound to the action of performing all calculations in a calculation group.
///
- /// The builder to add the context menu item to.
/// The calculation group involved.
/// The calculation group context belonging to the calculation group.
/// The action that performs all calculations.
- public static void AddPerformAllCalculationsInGroupItem
- (IContextMenuBuilder builder, CalculationGroup calculationGroup, TCalculationGroupContext context, Action calculateAll)
- where TCalculationGroupContext : ICalculationContext
+ /// The created .
+ public StrictContextMenuItem CreatePerformAllCalculationsInGroupItem(
+ CalculationGroup calculationGroup,
+ TCalculationContext context,
+ Action calculateAll)
+ where TCalculationContext : ICalculationContext
{
var performAllItem = new StrictContextMenuItem(
Resources.Calculate_all,
@@ -117,36 +117,36 @@
performAllItem.ToolTipText = Resources.CalculationGroup_CalculateAll_No_calculations_to_run;
}
- builder.AddCustomItem(performAllItem);
+ return performAllItem;
}
///
- /// This method adds a context menu item for performing a calculation.
+ /// Creates a which is bound to the action of performing a calculation.
///
- /// The builder to add the context menu item to.
/// The calculation involved.
/// The calculation context belonging to the calculation.
/// The action that performs the calculation.
- public static void AddPerformCalculationItem(
- IContextMenuBuilder builder, TCalculation calculation, TCalculationContext context, Action calculate)
+ /// The created .
+ public StrictContextMenuItem CreatePerformCalculationItem(
+ TCalculation calculation,
+ TCalculationContext context,
+ Action calculate)
+ where TCalculationContext : ICalculationContext
where TCalculation : ICalculation
- where TCalculationContext : ICalculationContext
{
- var calculateItem = new StrictContextMenuItem(
+ return new StrictContextMenuItem(
Resources.Calculate,
Resources.Calculate_ToolTip,
Resources.CalculateIcon,
(o, args) => calculate(calculation, context));
-
- builder.AddCustomItem(calculateItem);
}
///
- /// This method adds a context menu item for clearing the output of a calculation.
+ /// Creates a which is bound to the action of clearing the output of a calculation.
///
- /// The builder to add the context menu item to.
/// The calculation involved.
- public static void AddClearCalculationOutputItem(IContextMenuBuilder builder, ICalculation calculation)
+ /// The created .
+ public StrictContextMenuItem CreateClearCalculationOutputItem(ICalculation calculation)
{
var clearOutputItem = new StrictContextMenuItem(
Resources.Clear_output,
@@ -160,18 +160,17 @@
clearOutputItem.ToolTipText = Resources.ClearOutput_No_output_to_clear;
}
- builder.AddCustomItem(clearOutputItem);
+ return clearOutputItem;
}
///
- /// This method adds a context menu item for changing the relevancy state of a disabled failure mechanism.
+ /// Creates a which is bound to the action of changing the relevancy state of a disabled failure mechanism.
///
- /// The builder to add the context menu item to.
/// The failure mechanism context involved.
- public static void AddDisabledChangeRelevancyItem(IContextMenuBuilder builder, TFailureMechanismContext failureMechanismContext)
- where TFailureMechanismContext : IFailureMechanismContext
+ /// The created .
+ public StrictContextMenuItem CreateDisabledChangeRelevancyItem(IFailureMechanismContext failureMechanismContext)
{
- var changeRelevancyItem = new StrictContextMenuItem(
+ return new StrictContextMenuItem(
Resources.FailureMechanismContextMenuStrip_Is_relevant,
Resources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip,
Resources.Checkbox_empty,
@@ -180,8 +179,6 @@
failureMechanismContext.WrappedData.IsRelevant = true;
failureMechanismContext.WrappedData.NotifyObservers();
});
-
- builder.AddCustomItem(changeRelevancyItem);
}
private static void CreateCalculationGroup(CalculationGroup calculationGroup)