Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -rad75a347a7586757599297f2b2e776100d827264 -r9214f74184b5923e0fb04b86d50c5bf8e5e57cdc --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision ad75a347a7586757599297f2b2e776100d827264) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 9214f74184b5923e0fb04b86d50c5bf8e5e57cdc) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections; using System.Collections.Generic; using System.Drawing; @@ -34,10 +33,12 @@ using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources; +using ClosingStructuresDataResources = Ringtoets.ClosingStructures.Data.Properties.Resources; namespace Ringtoets.ClosingStructures.Plugin { @@ -61,9 +62,6 @@ }; } - /// - /// Returns all instances provided for data of . - /// public override IEnumerable GetTreeNodeInfos() { yield return RingtoetsTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo( @@ -77,6 +75,11 @@ CalculationGroupContextContextMenuStrip, CalculationGroupContextOnNodeRemoved); + yield return RingtoetsTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo( + null, + null, + null); + yield return new TreeNodeInfo> { Text = context => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, @@ -101,6 +104,21 @@ }; } + public override IEnumerable GetImportInfos() + { + yield return new ImportInfo + { + CreateFileImporter = (context, filePath) => new ClosingStructuresImporter(context.WrappedData, + context.AssessmentSection.ReferenceLine, + filePath), + Name = RingtoetsCommonFormsResources.StructuresImporter_DisplayName, + Category = RingtoetsCommonFormsResources.Ringtoets_Category, + Image = RingtoetsCommonFormsResources.StructuresIcon, + FileFilter = RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter, + IsEnabled = context => context.AssessmentSection.ReferenceLine != null + }; + } + #region ViewInfo #region ClosingStructuresFailureMechanismResultView ViewInfo @@ -226,8 +244,32 @@ private static object[] CalculationGroupContextChildNodeObjects(ClosingStructuresCalculationGroupContext context) { - //Part of WTI-550 - return new object[0]; + var childNodeObjects = new List(); + + foreach (ICalculationBase calculationItem in context.WrappedData.Children) + { + var calculation = calculationItem as ClosingStructuresCalculation; + var group = calculationItem as CalculationGroup; + + if (calculation != null) + { + childNodeObjects.Add(new ClosingStructuresCalculationContext(calculation, + context.FailureMechanism, + context.AssessmentSection)); + } + else if (group != null) + { + childNodeObjects.Add(new ClosingStructuresCalculationGroupContext(group, + context.FailureMechanism, + context.AssessmentSection)); + } + else + { + childNodeObjects.Add(calculationItem); + } + } + + return childNodeObjects.ToArray(); } private ContextMenuStrip CalculationGroupContextContextMenuStrip(ClosingStructuresCalculationGroupContext context, object parentData, TreeViewControl treeViewControl) @@ -245,7 +287,7 @@ .AddSeparator() .AddRemoveAllChildrenItem(group, Gui.ViewCommands); } - + builder.AddSeparator() .AddValidateAllCalculationsInGroupItem(context, c => ValidateAll(), ValidateAllDataAvailableAndGetErrorMessage) .AddPerformAllCalculationsInGroupItem(group, context, CalculateAll, ValidateAllDataAvailableAndGetErrorMessage) @@ -276,14 +318,19 @@ CalculateAll(context.FailureMechanism, group.GetCalculations().OfType()); } - private void AddCalculation(ClosingStructuresCalculationGroupContext closingStructuresCalculationGroupContext) + private void AddCalculation(ClosingStructuresCalculationGroupContext context) { - + var calculation = new ClosingStructuresCalculation + { + Name = NamingHelper.GetUniqueName(context.WrappedData.Children, ClosingStructuresDataResources.ClosingStructuresCalculation_DefaultName, c => c.Name) + }; + context.WrappedData.Children.Add(calculation); + context.WrappedData.NotifyObservers(); } private static void CalculationGroupContextOnNodeRemoved(ClosingStructuresCalculationGroupContext context, object parentNodeData) { - var parentGroupContext = (ClosingStructuresCalculationGroupContext)parentNodeData; + var parentGroupContext = (ClosingStructuresCalculationGroupContext) parentNodeData; parentGroupContext.WrappedData.Children.Remove(context.WrappedData); parentGroupContext.NotifyObservers(); @@ -303,20 +350,5 @@ { //Add calculate logic, part of WTI-554 } - - public override IEnumerable GetImportInfos() - { - yield return new ImportInfo - { - CreateFileImporter = (context, filePath) => new ClosingStructuresImporter(context.WrappedData, - context.AssessmentSection.ReferenceLine, - filePath), - Name = RingtoetsCommonFormsResources.StructuresImporter_DisplayName, - Category = RingtoetsCommonFormsResources.Ringtoets_Category, - Image = RingtoetsCommonFormsResources.StructuresIcon, - FileFilter = RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter, - IsEnabled = context => context.AssessmentSection.ReferenceLine != null - }; - } } } \ No newline at end of file