Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -rcf60de33a75f1d729639a4ba7f30e3b319f9ed6d -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision cf60de33a75f1d729639a4ba7f30e3b319f9ed6d) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -563,14 +563,17 @@ .Build(); } - private StrictContextMenuItem CreateUpdateStructureItem(StructuresCalculation[] calculations) + private StrictContextMenuItem CreateUpdateStructureItem( + IEnumerable> calculations) { var contextMenuEnabled = true; string toolTipMessage = RingtoetsCommonFormsResources.StructuresPlugin_CreateUpdateStructureItem_Update_all_calculations_with_Structure_Tooltip; - IList> calculationsToUpdate = calculations - .Where(c => c.InputParameters.Structure != null && !c.InputParameters.IsStructureInputSynchronized) - .ToList(); + StructuresCalculation[] calculationsToUpdate = calculations + .Where(calc => calc.InputParameters.Structure != null + && !calc.InputParameters.IsStructureInputSynchronized) + .ToArray(); + if (!calculationsToUpdate.Any()) { contextMenuEnabled = false; Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r50270a48a7cdc395d4fc4b964a42730740fb15ee -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 50270a48a7cdc395d4fc4b964a42730740fb15ee) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -470,7 +470,7 @@ var failureMechanism = new TestClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - + var assessmentSection = mocks.Stub(); var nodeData = new ClosingStructuresCalculationGroupContext(group, @@ -1206,53 +1206,6 @@ } [Test] - public void GivenCalculationWithOutputAndInputInSync_WhenUpdateStructuresClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() - { - // Given - var assessmentSection = mocks.Stub(); - var structure = new TestClosingStructure(); - var calculation = new StructuresCalculation - { - InputParameters = - { - Structure = structure - }, - Output = new TestStructuresOutput() - }; - - var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.CalculationsGroup.Children.Add(calculation); - - var nodeData = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection); - - var inputObserver = mocks.StrictMock(); - calculation.InputParameters.Attach(inputObserver); - - var calculationObserver = mocks.StrictMock(); - calculation.Attach(calculationObserver); - - using (var treeViewControl = new TreeViewControl()) - { - var mainWindow = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(g => g.MainWindow).Return(mainWindow); - mocks.ReplayAll(); - - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) - { - // When - menu.Items[contextMenuUpdateStructureAllIndexRootGroup].PerformClick(); - - // Then - Assert.IsTrue(calculation.HasOutput); - Assert.IsTrue(calculation.InputParameters.IsStructureInputSynchronized); - - // Note: observer assertions are verified in the TearDown() - } - } - } - - [Test] public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateStructuresClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -557,8 +557,13 @@ bool isNestedGroup = parentData is GrassCoverErosionInwardsCalculationGroupContext; StrictContextMenuItem generateCalculationsItem = CreateGenerateCalculationsItem(context); - StrictContextMenuItem updateDikeProfileItem = CreateUpdateDikeProfileItem(context); + GrassCoverErosionInwardsCalculation[] calculations = context.WrappedData + .GetCalculations() + .OfType() + .ToArray(); + StrictContextMenuItem updateDikeProfileItem = CreateUpdateDikeProfileItem(calculations); + builder.AddImportItem() .AddExportItem() .AddSeparator(); @@ -609,15 +614,16 @@ .Build(); } - private StrictContextMenuItem CreateUpdateDikeProfileItem(GrassCoverErosionInwardsCalculationGroupContext nodeData) + private StrictContextMenuItem CreateUpdateDikeProfileItem(IEnumerable calculations) { var contextMenuEnabled = true; string toolTipMessage = Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_all_calculations_with_DikeProfile_Tooltip; - IList calculationsToUpdate = nodeData.WrappedData.GetCalculations() - .OfType() - .Where(c => c.InputParameters.DikeProfile != null && !c.InputParameters.IsDikeProfileInputSynchronized) - .ToList(); + GrassCoverErosionInwardsCalculation[] calculationsToUpdate = calculations + .Where(calc => calc.InputParameters.DikeProfile != null + && !calc.InputParameters.IsDikeProfileInputSynchronized) + .ToArray(); + if (!calculationsToUpdate.Any()) { contextMenuEnabled = false; Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r8dc7980c928c8e808007aa66dacaa01ee6fe47fb -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 8dc7980c928c8e808007aa66dacaa01ee6fe47fb) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -716,79 +716,6 @@ } [Test] - public void GivenCalculationWithOutputAndInputInSync_WhenUpdateDikeProfilesClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() - { - // Given - var calculation1InputObserver = mocks.StrictMock(); - var calculation2InputObserver = mocks.StrictMock(); - - var calculation1Observer = mocks.StrictMock(); - var calculation2Observer = mocks.StrictMock(); - - var dikeProfile = new TestDikeProfile(); - var calculation1 = new GrassCoverErosionInwardsCalculation - { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation1.Attach(calculation1Observer); - calculation1.InputParameters.Attach(calculation1InputObserver); - - var calculation2 = new GrassCoverErosionInwardsCalculation - { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation2.Attach(calculation2Observer); - calculation2.InputParameters.Attach(calculation2InputObserver); - - var childGroup = new CalculationGroup(); - childGroup.Children.Add(calculation1); - - var emptyChildGroup = new CalculationGroup(); - var group = new CalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); - - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSection); - - using (var treeViewControl = new TreeViewControl()) - { - var mainWindow = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(g => g.MainWindow).Return(mainWindow); - mocks.ReplayAll(); - - plugin.Gui = gui; - - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // When - menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); - - // Then - Assert.IsTrue(calculation1.HasOutput); - Assert.IsTrue(calculation1.InputParameters.IsDikeProfileInputSynchronized); - Assert.IsTrue(calculation2.HasOutput); - Assert.IsTrue(calculation2.InputParameters.IsDikeProfileInputSynchronized); - - // Note: observer assertions are verified in the TearDown() - } - } - } - - [Test] public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateDikeProfilesClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -rcf60de33a75f1d729639a4ba7f30e3b319f9ed6d -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision cf60de33a75f1d729639a4ba7f30e3b319f9ed6d) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -575,14 +575,17 @@ .Build(); } - private StrictContextMenuItem CreateUpdateStructureItem(StructuresCalculation[] calculations) + private StrictContextMenuItem CreateUpdateStructureItem( + IEnumerable> calculations) { var contextMenuEnabled = true; string toolTipMessage = RingtoetsCommonFormsResources.StructuresPlugin_CreateUpdateStructureItem_Update_all_calculations_with_Structure_Tooltip; - IList> calculationsToUpdate = calculations - .Where(c => c.InputParameters.Structure != null && !c.InputParameters.IsStructureInputSynchronized) - .ToList(); + StructuresCalculation[] calculationsToUpdate = calculations + .Where(calc => calc.InputParameters.Structure != null + && !calc.InputParameters.IsStructureInputSynchronized) + .ToArray(); + if (!calculationsToUpdate.Any()) { contextMenuEnabled = false; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r8dc7980c928c8e808007aa66dacaa01ee6fe47fb -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 8dc7980c928c8e808007aa66dacaa01ee6fe47fb) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -1367,53 +1367,6 @@ } [Test] - public void GivenCalculationWithOutputAndInputInSync_WhenUpdateStructuresClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() - { - // Given - var assessmentSection = mocks.Stub(); - var structure = new TestHeightStructure(); - var calculation = new StructuresCalculation - { - InputParameters = - { - Structure = structure - }, - Output = new TestStructuresOutput() - }; - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.CalculationsGroup.Children.Add(calculation); - - var nodeData = new HeightStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection); - - var inputObserver = mocks.StrictMock(); - calculation.InputParameters.Attach(inputObserver); - - var calculationObserver = mocks.StrictMock(); - calculation.Attach(calculationObserver); - - using (var treeViewControl = new TreeViewControl()) - { - var mainWindow = mocks.Stub(); - guiStub.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - guiStub.Stub(g => g.MainWindow).Return(mainWindow); - mocks.ReplayAll(); - - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) - { - // When - menu.Items[contextMenuUpdateStructureAllIndexRootGroup].PerformClick(); - - // Then - Assert.IsTrue(calculation.HasOutput); - Assert.IsTrue(calculation.InputParameters.IsStructureInputSynchronized); - - // Note: observer assertions are verified in the TearDown() - } - } - } - - [Test] public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateStructuresClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -28,7 +28,6 @@ using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; -using Core.Common.Gui.Forms; using Core.Common.Gui.Forms.ProgressDialog; using Core.Common.Gui.Plugin; using Core.Common.Utils; @@ -883,8 +882,12 @@ bool isNestedGroup = parentData is PipingCalculationGroupContext; StrictContextMenuItem generateCalculationsItem = CreateGeneratePipingCalculationsItem(nodeData); - StrictContextMenuItem updateEntryAndExitPointsItem = CreateUpdateEntryAndExitPointItem(nodeData); + PipingCalculationScenario[] calculations = nodeData.WrappedData.GetCalculations() + .OfType() + .ToArray(); + StrictContextMenuItem updateEntryAndExitPointsItem = CreateUpdateEntryAndExitPointItem(calculations); + if (!isNestedGroup) { builder.AddOpenItem() @@ -1006,15 +1009,16 @@ parentGroupContext.NotifyObservers(); } - private StrictContextMenuItem CreateUpdateEntryAndExitPointItem(PipingCalculationGroupContext nodeData) + private StrictContextMenuItem CreateUpdateEntryAndExitPointItem(IEnumerable calculations) { var contextMenuEnabled = true; string toolTipMessage = Resources.PipingPlugin_CreateUpdateEntryAndExitPointItem_Update_all_calculations_with_surface_line_ToolTip; - IList calculationsToUpdate = nodeData.WrappedData.GetCalculations() - .OfType() - .Where(c => c.InputParameters.SurfaceLine != null && !c.InputParameters.IsEntryAndExitPointInputSynchronized) - .ToList(); + PipingCalculationScenario[] calculationsToUpdate = calculations + .Where(calc => calc.InputParameters.SurfaceLine != null + && !calc.InputParameters.IsEntryAndExitPointInputSynchronized) + .ToArray(); + if (!calculationsToUpdate.Any()) { contextMenuEnabled = false; Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -rb9588439685292e10bcf3a4fcebfc187fd7bd03e -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision b9588439685292e10bcf3a4fcebfc187fd7bd03e) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -540,7 +540,7 @@ builder.AddUpdateForeshoreProfileOfCalculationsItem(calculations, inquiryHelper, SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput) - .AddCustomItem(CreateUpdateStructuresItem(calculations)) + .AddCustomItem(CreateUpdateStructureItem(calculations)) .AddSeparator() .AddValidateAllCalculationsInGroupItem( context, @@ -571,28 +571,29 @@ .Build(); } - private StrictContextMenuItem CreateUpdateStructuresItem(StructuresCalculation[] calculations) + private StrictContextMenuItem CreateUpdateStructureItem( + IEnumerable> calculations) { - var enabled = true; + var contextMenuEnabled = true; string toolTipMessage = RingtoetsCommonFormsResources.StructuresPlugin_CreateUpdateStructureItem_Update_all_calculations_with_Structure_Tooltip; - StructuresCalculation[] calculationsToBeUpdated = + StructuresCalculation[] calculationToUpdate = calculations.Where(calc => calc.InputParameters.Structure != null && !calc.InputParameters.IsStructureInputSynchronized) .ToArray(); - if (!calculationsToBeUpdated.Any()) + if (!calculationToUpdate.Any()) { - enabled = false; + contextMenuEnabled = false; toolTipMessage = RingtoetsCommonFormsResources.CreateUpdateContextMenuItem_No_calculations_to_update_ToolTip; } return new StrictContextMenuItem(RingtoetsCommonFormsResources.StructuresPlugin_CreateUpdateStructureItem_Update_all_Structures, toolTipMessage, RingtoetsCommonFormsResources.UpdateItemIcon, - (sender, args) => UpdateStructureDependentDataOfCalculation(calculationsToBeUpdated)) + (sender, args) => UpdateStructureDependentDataOfCalculation(calculationToUpdate)) { - Enabled = enabled + Enabled = contextMenuEnabled }; } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r7326c5c94201fa88fcfa4c73215f79088fcfee42 -re402805257d7185512020535bd0df9cd01a7734e --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 7326c5c94201fa88fcfa4c73215f79088fcfee42) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision e402805257d7185512020535bd0df9cd01a7734e) @@ -670,7 +670,7 @@ } [Test] - public void ContextMenuStrip_CalculationGroupWithoutCalculation_ContextMenuItemUpdateStructuresDisabledAndToolTipSet() + public void ContextMenuStrip_CalculationGroupWithoutCalculations_ContextMenuItemUpdateStructuresDisabledAndToolTipSet() { // Setup var group = new CalculationGroup(); @@ -701,7 +701,7 @@ } [Test] - public void ContextMenuStrip_CalculationGroupWithCalculationWithoutStructure_ContextMenuItemUpdateStructuresDisabledAndTooltipSet() + public void ContextMenuStrip_CalculationGroupWithCalculationsWithoutStructure_ContextMenuItemUpdateStructuresDisabledAndToolTipSet() { // Setup var calculation = new StructuresCalculation(); @@ -739,7 +739,7 @@ } [Test] - public void ContextMenuStrip_CalculationGroupWithCalculationWithInputInSynchAndStructure_ContextMenuItemUpdateStructuresDisabledAndToolTipSet() + public void ContextMenuStrip_CalculationGroupWithCalculationWithStructureAndInputInSync_ContextMenuItemUpdateStructuresDisabledAndToolTipSet() { // Setup var calculation = new TestStabilityPointStructuresCalculation(); @@ -777,7 +777,7 @@ } [Test] - public void ContextMenuStrip_CalculationGroupWithCalculationsWithInputOutOfSyncAndStructure_ContextMenuItemUpdateStructuresEnabledAndToolTipSet() + public void ContextMenuStrip_CalculationGroupWithCalculationWithStructureAndInputOutOfSync_ContextMenuItemUpdateStructuresEnabledAndToolTipSet() { // Setup var calculation = new TestStabilityPointStructuresCalculation(); @@ -815,7 +815,7 @@ } [Test] - public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateAllStructuresClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() + public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateStructuresClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given var assessmentSection = mocks.Stub();