Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs =================================================================== diff -u -rbd29bacc20bc58cc67f27dd33fa4fa6b41db873c -r4435a35be229b12da5859395985ad38c9c5d4729 --- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision bd29bacc20bc58cc67f27dd33fa4fa6b41db873c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) @@ -34,7 +34,6 @@ public class RingtoetsContextMenuBuilder { private readonly IContextMenuBuilder contextMenuBuilder; - private readonly RingtoetsContextMenuItemFactory ringtoetsContextMenuItemFactory; /// /// Creates a new instance of the class. @@ -43,8 +42,6 @@ public RingtoetsContextMenuBuilder(IContextMenuBuilder contextMenuBuilder) { this.contextMenuBuilder = contextMenuBuilder; - - ringtoetsContextMenuItemFactory = new RingtoetsContextMenuItemFactory(); } /// @@ -139,17 +136,6 @@ } /// - /// Adds an item to the , which enables a disabled failure mechanism. - /// - /// The failure mechanism context belonging to the failure mechanism. - /// The itself. - public RingtoetsContextMenuBuilder AddDisabledChangeRelevancyItem(IFailureMechanismContext failureMechanismContext) - { - contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateDisabledChangeRelevancyItem(failureMechanismContext)); - return this; - } - - /// /// Adds an item to the , which clears the output of all calculations in the failure mechanism. /// /// The failure mechanism to clear the output for. @@ -164,7 +150,7 @@ /// Adds an item to the , which performs all calculations in a failure mechanism. /// /// The type of the failure mechanism context. - /// The failure mechanism to perform all calculations for. + /// 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 itself. @@ -179,10 +165,21 @@ } /// + /// Adds an item to the , which enables a disabled failure mechanism. + /// + /// The failure mechanism context belonging to the failure mechanism. + /// The itself. + public RingtoetsContextMenuBuilder AddDisabledChangeRelevancyItem(IFailureMechanismContext failureMechanismContext) + { + contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateDisabledChangeRelevancyItem(failureMechanismContext)); + return this; + } + + /// /// Adds an item to the , which sets if the failure mechanism is relevant. /// /// The type of the failure mechanism context. - /// The failure mechanism to change if it is relevant. + /// The failure mechanism context belonging to the failure mechanism. /// The action that removes all views. /// The itself. public RingtoetsContextMenuBuilder AddChangeRelevancyOfFailureMechanismItem( Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs =================================================================== diff -u -rbd29bacc20bc58cc67f27dd33fa4fa6b41db873c -r4435a35be229b12da5859395985ad38c9c5d4729 --- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision bd29bacc20bc58cc67f27dd33fa4fa6b41db873c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) @@ -36,7 +36,7 @@ /// /// This class represents a factory for creating . /// - public class RingtoetsContextMenuItemFactory + public static class RingtoetsContextMenuItemFactory { /// /// Creates a which is bound to the action of adding new calculation groups. @@ -201,7 +201,7 @@ } /// - /// Creates a which is bound to the action of clearing the output of all calculations in the failure mechanism. + /// Creates a which is bound to the action of clearing the output of all calculations in a failure mechanism. /// /// The failure mechanism to clear the output for. /// The created . @@ -225,7 +225,7 @@ /// Creates a which is bound to the action of performing all calculations in a failure mechanism. /// /// The type of the failure mechanism context. - /// The failure mechanism to perform all calculations for. + /// 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 created . @@ -259,18 +259,18 @@ } /// - /// Creates a which is bound to the action of changing the relevance of the failure mechanism. + /// Creates a which is bound to the action of changing the relevance of a failure mechanism. /// /// The type of the failure mechanism context. - /// The failure mechanism to set the relevance of. + /// The failure mechanism context belonging to the failure mechanism. /// The action that removes all views. /// The created . public static StrictContextMenuItem CreateChangeRelevancyOfFailureMechanismItem( TFailureMechanismContext failureMechanismContext, Action removeAllViewsForItemAction) where TFailureMechanismContext : IFailureMechanismContext { - var changeRelevancyItem = new StrictContextMenuItem( + return new StrictContextMenuItem( Resources.FailureMechanismContextMenuStrip_Is_relevant, Resources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip, Resources.Checkbox_ticked, @@ -280,7 +280,6 @@ failureMechanismContext.WrappedData.IsRelevant = false; failureMechanismContext.WrappedData.NotifyObservers(); }); - return changeRelevancyItem; } private static void ClearAllCalculationOutputInFailureMechanism(IFailureMechanism failureMechanism) Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs =================================================================== diff -u -rf7191448000db1a5f3698a1439b441da9afb72bc -r4435a35be229b12da5859395985ad38c9c5d4729 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision f7191448000db1a5f3698a1439b441da9afb72bc) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) @@ -394,7 +394,7 @@ } [Test] - public void CreateClearAllCalculationOutputInFailureMechanismItem_PerformClickOnCreatedItemAndCancelChangee_CalculationOutputNotCleared() + public void CreateClearAllCalculationOutputInFailureMechanismItem_PerformClickOnCreatedItemAndCancelChange_CalculationOutputNotCleared() { // Setup var mocks = new MockRepository(); @@ -519,7 +519,7 @@ } [Test] - public void CreatePerformAllCalculationsInGroupItem_IsEnabledFuncFalse_CreatesDecoratedAndEnabledItem() + public void CreatePerformAllCalculationsInGroupItem_IsEnabledFuncFalse_CreatesDecoratedAndDisabledItem() { // Setup var mocks = new MockRepository(); @@ -582,7 +582,7 @@ } [Test] - public void CreatePerformAllCalculationsInFailureMechanismItemItem_FailureMechanismItemWithCalculations_CreatesDecoratedAndEnabledItem() + public void CreatePerformAllCalculationsInFailureMechanismItem_FailureMechanismItemWithCalculations_CreatesDecoratedAndEnabledItem() { // Setup var mocks = new MockRepository(); @@ -608,7 +608,7 @@ } [Test] - public void CreatePerformAllCalculationsInFailureMechanismItemItem_FailureMechanismItemWithoutCalculations_CreatesDecoratedAndDisabledItem() + public void CreatePerformAllCalculationsInFailureMechanismItem_FailureMechanismItemWithoutCalculations_CreatesDecoratedAndDisabledItem() { // Setup var mocks = new MockRepository(); @@ -630,7 +630,7 @@ } [Test] - public void CreatePerformAllCalculationsInFailureMechanismItemItem_PerformClickOnCreatedItem_PerformAllCalculationMethodPerformed() + public void CreatePerformAllCalculationsInFailureMechanismItem_PerformClickOnCreatedItem_PerformAllCalculationMethodPerformed() { // Setup var mocks = new MockRepository(); @@ -644,7 +644,7 @@ calculationMock }); var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSectionMock); - var toolStripItem = RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInFailureMechanismItem(failureMechanismContext, (fmContext) => counter++, context => true); + var toolStripItem = RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInFailureMechanismItem(failureMechanismContext, fmContext => counter++, context => true); // Call toolStripItem.PerformClick(); @@ -655,6 +655,29 @@ } [Test] + public void CreateChangeRelevancyOfFailureMechanismItem_Always_CreateDecoratedItem() + { + // Setup + var mocks = new MockRepository(); + var failureMechanismMock = mocks.StrictMock(); + var assessmentSectionMock = mocks.StrictMock(); + + mocks.ReplayAll(); + + var failureMechanismContext = new TestFailureMechanismContext(failureMechanismMock, assessmentSectionMock); + + // Call + var toolStripItem = RingtoetsContextMenuItemFactory.CreateChangeRelevancyOfFailureMechanismItem(failureMechanismContext, null); + + // Assert + Assert.AreEqual(RingtoetsFormsResources.FailureMechanismContextMenuStrip_Is_relevant, toolStripItem.Text); + Assert.AreEqual(RingtoetsFormsResources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip, toolStripItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.Checkbox_ticked, toolStripItem.Image); + Assert.IsTrue(toolStripItem.Enabled); + mocks.VerifyAll(); + } + + [Test] public void CreateChangeRelevancyOfFailureMechanismItem_PerformClickOnRelevanceItem_RelevanceFalseAndObserversNotified() { // Setup @@ -673,9 +696,6 @@ toolStripItem.PerformClick(); // Assert - Assert.AreEqual(RingtoetsFormsResources.FailureMechanismContextMenuStrip_Is_relevant, toolStripItem.Text); - Assert.AreEqual(RingtoetsFormsResources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip, toolStripItem.ToolTipText); - TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.Checkbox_ticked, toolStripItem.Image); Assert.AreEqual(1, counter); mocks.VerifyAll(); } @@ -909,7 +929,7 @@ } [Test] - public void CreatePerformAllCalculationsInFailureMechanismItem_IsEnabledFuncFalse_CreatesDecoratedAndEnabledItem() + public void CreatePerformAllCalculationsInFailureMechanismItem_IsEnabledFuncFalse_CreatesDecoratedAndDisabledItem() { // Setup var mocks = new MockRepository(); Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs =================================================================== diff -u -rd1c60b79a5add63479f44fdbdbbd16d3593949dd -r4435a35be229b12da5859395985ad38c9c5d4729 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision d1c60b79a5add63479f44fdbdbbd16d3593949dd) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) @@ -182,7 +182,7 @@ { if (output != null) { - calculation.Output = new GrassCoverErosionInwardsOutput(double.NaN, double.NaN, (RoundedDouble)output.Beta, double.NaN, double.NaN); + calculation.Output = new GrassCoverErosionInwardsOutput(double.NaN, double.NaN, (RoundedDouble) output.Beta, double.NaN, double.NaN); } else { @@ -245,22 +245,22 @@ private ContextMenuStrip FailureMechanismEnabledContextMenuStrip(GrassCoverErosionInwardsFailureMechanismContext grassCoverErosionInwardsFailureMechanismContext, object parentData, TreeViewControl treeViewControl) { var builder = new RingtoetsContextMenuBuilder(Gui.Get(grassCoverErosionInwardsFailureMechanismContext, treeViewControl)); - return builder - .AddOpenItem() - .AddSeparator() - .AddChangeRelevancyOfFailureMechanismItem(grassCoverErosionInwardsFailureMechanismContext, RemoveAllViewsForItem) - .AddSeparator() - .AddPerformAllCalculationsInFailureMechanismItem(grassCoverErosionInwardsFailureMechanismContext, CalculateAll, EnablePerformAllCalculationsInFailureMechanism) - .AddClearAllCalculationOutputInFailureMechanismItem(grassCoverErosionInwardsFailureMechanismContext.WrappedData) - .AddSeparator() - .AddImportItem() - .AddExportItem() - .AddSeparator() - .AddExpandAllItem() - .AddCollapseAllItem() - .AddSeparator() - .AddPropertiesItem() - .Build(); + + return builder.AddOpenItem() + .AddSeparator() + .AddChangeRelevancyOfFailureMechanismItem(grassCoverErosionInwardsFailureMechanismContext, RemoveAllViewsForItem) + .AddSeparator() + .AddPerformAllCalculationsInFailureMechanismItem(grassCoverErosionInwardsFailureMechanismContext, CalculateAll, EnablePerformAllCalculationsInFailureMechanism) + .AddClearAllCalculationOutputInFailureMechanismItem(grassCoverErosionInwardsFailureMechanismContext.WrappedData) + .AddSeparator() + .AddImportItem() + .AddExportItem() + .AddSeparator() + .AddExpandAllItem() + .AddCollapseAllItem() + .AddSeparator() + .AddPropertiesItem() + .Build(); } private static bool EnablePerformAllCalculationsInFailureMechanism(GrassCoverErosionInwardsFailureMechanismContext context) @@ -345,18 +345,18 @@ .AddSeparator(); } - builder.AddCreateCalculationGroupItem(group); - builder.AddCreateCalculationItem(nodeData, AddCalculation); - builder.AddSeparator(); - builder.AddPerformAllCalculationsInGroupItem(group, nodeData, CalculateAll, EnablePerformAllCalculationsInGroup); - builder.AddClearAllCalculationOutputInGroupItem(group); - builder.AddSeparator(); + builder.AddCreateCalculationGroupItem(group) + .AddCreateCalculationItem(nodeData, AddCalculation) + .AddSeparator() + .AddPerformAllCalculationsInGroupItem(group, nodeData, CalculateAll, EnablePerformAllCalculationsInGroup) + .AddClearAllCalculationOutputInGroupItem(group) + .AddSeparator(); if (isNestedGroup) { - builder.AddRenameItem(); - builder.AddDeleteItem(); - builder.AddSeparator(); + builder.AddRenameItem() + .AddDeleteItem() + .AddSeparator(); } return builder.AddImportItem() Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/GrassCoverErosionInwardsCalculationFactory.cs =================================================================== diff -u -r89cf0d104a6e12180d2fae471ae318cad256707a -r4435a35be229b12da5859395985ad38c9c5d4729 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/GrassCoverErosionInwardsCalculationFactory.cs (.../GrassCoverErosionInwardsCalculationFactory.cs) (revision 89cf0d104a6e12180d2fae471ae318cad256707a) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/GrassCoverErosionInwardsCalculationFactory.cs (.../GrassCoverErosionInwardsCalculationFactory.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) @@ -26,7 +26,7 @@ namespace Ringtoets.GrassCoverErosionInwards.Data.TestUtil { /// - /// Factory for creating s. + /// Factory for creating objects. /// public static class GrassCoverErosionInwardsCalculationFactory { Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -r062281754a35164e1095479c9f1ccb8ee821f939 -r4435a35be229b12da5859395985ad38c9c5d4729 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 062281754a35164e1095479c9f1ccb8ee821f939) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) @@ -506,20 +506,20 @@ private ContextMenuStrip StandAloneFailureMechanismEnabledContextMenuStrip(StandAloneFailureMechanismContext nodeData, object parentData, TreeViewControl treeViewControl) { var builder = new RingtoetsContextMenuBuilder(Gui.Get(nodeData, treeViewControl)); - return builder - .AddChangeRelevancyOfFailureMechanismItem(nodeData, RemoveAllViewsForItem) - .AddSeparator() - .AddPerformAllCalculationsInFailureMechanismItem(nodeData, null, context => true) - .AddClearAllCalculationOutputInFailureMechanismItem(nodeData.WrappedData) - .AddSeparator() - .AddImportItem() - .AddExportItem() - .AddSeparator() - .AddExpandAllItem() - .AddCollapseAllItem() - .AddSeparator() - .AddPropertiesItem() - .Build(); + + return builder.AddChangeRelevancyOfFailureMechanismItem(nodeData, RemoveAllViewsForItem) + .AddSeparator() + .AddPerformAllCalculationsInFailureMechanismItem(nodeData, null, context => true) + .AddClearAllCalculationOutputInFailureMechanismItem(nodeData.WrappedData) + .AddSeparator() + .AddImportItem() + .AddExportItem() + .AddSeparator() + .AddExpandAllItem() + .AddCollapseAllItem() + .AddSeparator() + .AddPropertiesItem() + .Build(); } private void RemoveAllViewsForItem(StandAloneFailureMechanismContext failureMechanismContext) Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -r64d5609bb2912cd52dc74deffdd189222e240599 -r4435a35be229b12da5859395985ad38c9c5d4729 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 64d5609bb2912cd52dc74deffdd189222e240599) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) @@ -319,23 +319,23 @@ var validateAllItem = CreateValidateAllItem(pipingFailureMechanismContext.WrappedData); var builder = new RingtoetsContextMenuBuilder(Gui.Get(pipingFailureMechanismContext, treeViewControl)); - return builder - .AddOpenItem() - .AddSeparator() - .AddChangeRelevancyOfFailureMechanismItem(pipingFailureMechanismContext, RemoveAllViewsForItem) - .AddSeparator() - .AddCustomItem(validateAllItem) - .AddPerformAllCalculationsInFailureMechanismItem(pipingFailureMechanismContext, CalculateAll, context => true) - .AddClearAllCalculationOutputInFailureMechanismItem(pipingFailureMechanismContext.WrappedData) - .AddSeparator() - .AddImportItem() - .AddExportItem() - .AddSeparator() - .AddExpandAllItem() - .AddCollapseAllItem() - .AddSeparator() - .AddPropertiesItem() - .Build(); + + return builder.AddOpenItem() + .AddSeparator() + .AddChangeRelevancyOfFailureMechanismItem(pipingFailureMechanismContext, RemoveAllViewsForItem) + .AddSeparator() + .AddCustomItem(validateAllItem) + .AddPerformAllCalculationsInFailureMechanismItem(pipingFailureMechanismContext, CalculateAll, context => true) + .AddClearAllCalculationOutputInFailureMechanismItem(pipingFailureMechanismContext.WrappedData) + .AddSeparator() + .AddImportItem() + .AddExportItem() + .AddSeparator() + .AddExpandAllItem() + .AddCollapseAllItem() + .AddSeparator() + .AddPropertiesItem() + .Build(); } private void RemoveAllViewsForItem(PipingFailureMechanismContext failureMechanismContext)