Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs =================================================================== diff -u -r9734e921a416c44f379d4d29d26909b56c75f880 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs (.../HeightStructuresFailureMechanism.cs) (revision 9734e921a416c44f379d4d29d26909b56c75f880) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs (.../HeightStructuresFailureMechanism.cs) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -46,6 +46,7 @@ sectionResults = new List(); CalculationsGroup = new CalculationGroup(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, false); GeneralInput = new GeneralHeightStructuresInput(); + HeightStructures = new ObservableList(); ForeshoreProfiles = new ObservableList(); } @@ -63,6 +64,11 @@ public GeneralHeightStructuresInput GeneralInput { get; private set; } /// + /// Gets the available height structure within the scope of the height structure failure mechanism + /// + public ObservableList HeightStructures { get; private set; } + + /// /// Gets the available foreshore profiles for this instance. /// public ObservableList ForeshoreProfiles { get; private set; } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructureContext.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructureContext.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructureContext.cs (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; + +namespace Ringtoets.HeightStructures.Forms.PresentationObjects +{ + /// + /// The presentation object for + /// + public class HeightStructureContext : ObservableWrappedObjectContextBase> + { + /// + /// + /// + /// + /// + /// + public HeightStructureContext(ObservableList heightStructures, IAssessmentSection assessmentSection) + : base(heightStructures) + { + if (assessmentSection == null) + { + throw new ArgumentNullException("assessmentSection"); + } + + AssessmentSection = assessmentSection; + } + + public IAssessmentSection AssessmentSection { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -181,6 +181,15 @@ } /// + /// Looks up a localized string similar to Kunstwerken. + /// + public static string HeightStructureCollection_DisplayName { + get { + return ResourceManager.GetString("HeightStructureCollection_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Het hoogte kunstwerk toetsspoor. /// public static string HeightStructuresContext_DataDescription_HeightStructuresFailureMechanism { Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -213,4 +213,7 @@ De waarde voor de faalkans moet ingevuld zijn. + + Kunstwerken + \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -41,6 +41,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r9734e921a416c44f379d4d29d26909b56c75f880 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 9734e921a416c44f379d4d29d26909b56c75f880) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -21,6 +21,7 @@ using System.Collections; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Linq; using System.Windows.Forms; @@ -59,6 +60,20 @@ yield return new PropertyInfo(); } + public override IEnumerable GetImportInfos() + { + yield return new ImportInfo() + { + Name = HeightStructuresFormsResources.HeightStructureCollection_DisplayName, + Category = RingtoetsCommonFormsResources.Ringtoets_Category, + FileFilter = string.Format("{0} {1}", + HeightStructuresFormsResources.HeightStructureCollection_DisplayName, + RingtoetsCommonFormsResources.DataTypeDisplayName_csv_file_filter), + IsEnabled = context => context.AssessmentSection.ReferenceLine != null + //TODO: WTI-579 Hook this up with the importer + }; + } + public override IEnumerable GetViewInfos() { yield return new ViewInfo< @@ -121,6 +136,20 @@ .AddOpenItem() .Build() }; + + yield return new TreeNodeInfo + { + Text = heightStructureProfile => HeightStructuresFormsResources.HeightStructureCollection_DisplayName, + Image = heightStructureProfile => RingtoetsCommonFormsResources.GeneralFolderIcon, + ForeColor = ringtoetsPipingSurfaceLine => ringtoetsPipingSurfaceLine.WrappedData.Any() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText), + ChildNodeObjects = heightStructureProfile => heightStructureProfile.WrappedData.Cast().ToArray(), + ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) + .AddImportItem() + .AddSeparator() + .AddExpandAllItem() + .AddCollapseAllItem() + .Build() + }; } private void CalculateAll(HeightStructuresFailureMechanism failureMechanism, @@ -219,6 +248,7 @@ { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), + new HeightStructureContext(failureMechanism.HeightStructures, assessmentSection), new CommentContext(failureMechanism) }; } @@ -461,6 +491,5 @@ #endregion #endregion - } } \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs =================================================================== diff -u -r9734e921a416c44f379d4d29d26909b56c75f880 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs (.../HeightStructuresFailureMechanismTest.cs) (revision 9734e921a416c44f379d4d29d26909b56c75f880) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs (.../HeightStructuresFailureMechanismTest.cs) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -49,6 +49,7 @@ Assert.IsFalse(failureMechanism.CalculationsGroup.IsNameEditable); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanism.Calculations); + CollectionAssert.IsEmpty(failureMechanism.HeightStructures); CollectionAssert.IsEmpty(failureMechanism.CalculationsGroup.Children); CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles); } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructureProfileContextTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructureProfileContextTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructureProfileContextTest.cs (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -0,0 +1,70 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; + +namespace Ringtoets.HeightStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class HeightStructureProfileContextTest + { + [Test] + public void ParameteredConstructor_DefaultValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var heightStructureProfiles = new ObservableList(); + + // Call + var context = new HeightStructureContext(heightStructureProfiles, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>>(context); + Assert.AreSame(heightStructureProfiles, context.WrappedData); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + mocks.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Setup + var heightStructureProfiles = new ObservableList(); + + // Call + TestDelegate test = () => new HeightStructureContext(heightStructureProfiles, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r915001caffacbbee15c0e3bf449072245bc5f509 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 915001caffacbbee15c0e3bf449072245bc5f509) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -61,6 +61,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r9734e921a416c44f379d4d29d26909b56c75f880 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 9734e921a416c44f379d4d29d26909b56c75f880) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -117,7 +117,7 @@ Assert.AreEqual("Invoer", inputsFolder.Name); Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); - Assert.AreEqual(3, inputsFolder.Contents.Count); + Assert.AreEqual(4, inputsFolder.Contents.Count); var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputsFolder.Contents[0]; Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData); Assert.AreSame(assessmentSectionMock, failureMechanismSectionsContext.ParentAssessmentSection); @@ -126,7 +126,11 @@ Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); Assert.AreSame(assessmentSectionMock, profilesContext.ParentAssessmentSection); - var commentContext = (CommentContext) inputsFolder.Contents[2]; + var heightStructureContext = (HeightStructureContext) inputsFolder.Contents[2]; + Assert.AreSame(failureMechanism.HeightStructures, heightStructureContext.WrappedData); + Assert.AreSame(assessmentSectionMock, heightStructureContext.AssessmentSection); + + var commentContext = (CommentContext) inputsFolder.Contents[3]; Assert.AreSame(failureMechanism, commentContext.WrappedData); var calculationsFolder = (HeightStructuresCalculationGroupContext) children[1]; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r51d8e744ffb2168ca56ca4b6260ad9c2590c0170 -rcd4c32e6c897ceff2c5ae483e3bfb586ab9b6598 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 51d8e744ffb2168ca56ca4b6260ad9c2590c0170) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision cd4c32e6c897ceff2c5ae483e3bfb586ab9b6598) @@ -97,11 +97,12 @@ TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(7, treeNodeInfos.Length); + Assert.AreEqual(8, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresInputContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructureContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilityAssessmentOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyProbabilityAssessmentOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); @@ -134,5 +135,29 @@ } mocks.VerifyAll(); } + + [Test] + public void GetFileInfos_Always_ReturnsExpectedFileInfos() + { + // Setup + var mocks = new MockRepository(); + var guiStub = mocks.Stub(); + guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (var plugin = new HeightStructuresPlugin() + { + Gui = guiStub + }) + { + // Call + ImportInfo[] importInfos = plugin.GetImportInfos().ToArray(); + + // Assert + Assert.AreEqual(1, importInfos.Length); + Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(HeightStructureContext))); + } + mocks.VerifyAll(); + } } } \ No newline at end of file