Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingData.cs
===================================================================
diff -u -r308703c02f5602704483e204ad9a475d90eece69 -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingData.cs (.../PipingData.cs) (revision 308703c02f5602704483e204ad9a475d90eece69)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingData.cs (.../PipingData.cs) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -167,6 +167,11 @@
public RingtoetsPipingSurfaceLine SurfaceLine { get; set; }
///
+ /// Gets or sets the soil profile.
+ ///
+ public PipingSoilProfile SoilProfile { get; set; }
+
+ ///
/// Gets or sets , which contains the results of a Piping calculation.
///
public PipingOutput Output { get; set; }
Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationInputs.cs
===================================================================
diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationInputs.cs (.../PipingCalculationInputs.cs) (revision 300a33d9acf653458b834b296becbf9ae552de8e)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationInputs.cs (.../PipingCalculationInputs.cs) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -19,6 +19,7 @@
public PipingCalculationInputs()
{
AvailablePipingSurfaceLines = Enumerable.Empty();
+ AvailablePipingSoilProfiles = Enumerable.Empty();
}
///
@@ -28,10 +29,16 @@
///
/// Gets or sets the available piping surface lines in order for the user to select
- /// one to set .
+ /// one to set .
///
public IEnumerable AvailablePipingSurfaceLines { get; set; }
+ ///
+ /// Gets or sets the available piping soil profiles in order for the user to select
+ /// one to set .
+ ///
+ public IEnumerable AvailablePipingSoilProfiles { get; set; }
+
#region IObservable
public void Attach(IObserver observer)
Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -rb02b755bf5d7a52b44deb11bdb9b1e70789306a0 -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b02b755bf5d7a52b44deb11bdb9b1e70789306a0)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -468,6 +468,24 @@
}
///
+ /// Looks up a localized string similar to Het ondergrondprofiel dat voor de piping berekening gebruikt wordt..
+ ///
+ public static string PipingDataSoilProfileDescription {
+ get {
+ return ResourceManager.GetString("PipingDataSoilProfileDescription", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Ondergrondprofiel.
+ ///
+ public static string PipingDataSoilProfileDisplayName {
+ get {
+ return ResourceManager.GetString("PipingDataSoilProfileDisplayName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to De dwarsdoorsnede die voor de piping berekening gebruikt wordt..
///
public static string PipingDataSurfaceLineDescription {
Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx
===================================================================
diff -u -rb02b755bf5d7a52b44deb11bdb9b1e70789306a0 -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision b02b755bf5d7a52b44deb11bdb9b1e70789306a0)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -412,4 +412,10 @@
Topniveaus
+
+ Het ondergrondprofiel dat voor de piping berekening gebruikt wordt.
+
+
+ Ondergrondprofiel
+
\ No newline at end of file
Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationInputsProperties.cs
===================================================================
diff -u -r308703c02f5602704483e204ad9a475d90eece69 -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationInputsProperties.cs (.../PipingCalculationInputsProperties.cs) (revision 308703c02f5602704483e204ad9a475d90eece69)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationInputsProperties.cs (.../PipingCalculationInputsProperties.cs) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -385,12 +385,37 @@
}
}
+ [Editor(typeof(PipingCalculationInputsSoilProfileSelectionEditor), typeof(UITypeEditor))]
+ [ResourcesCategory(typeof(Resources), "Categories_General")]
+ [ResourcesDisplayName(typeof(Resources), "PipingDataSoilProfileDisplayName")]
+ [ResourcesDescription(typeof(Resources), "PipingDataSoilProfileDescription")]
+ public PipingSoilProfile SoilProfile
+ {
+ get
+ {
+ return data.PipingData.SoilProfile;
+ }
+ set
+ {
+ data.PipingData.SoilProfile = value;
+ data.PipingData.NotifyObservers();
+ }
+ }
+
///
/// Gets the available surface lines on .
///
public IEnumerable GetAvailableSurfaceLines()
{
return data.AvailablePipingSurfaceLines;
}
+
+ ///
+ /// Gets the available soil profiles on .
+ ///
+ public IEnumerable GetAvailableSoilProfiles()
+ {
+ return data.AvailablePipingSoilProfiles;
+ }
}
}
\ No newline at end of file
Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj
===================================================================
diff -u -r617e40b29b2e1f5b5d2ad5abaeb4c6ad8ccffee4 -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 617e40b29b2e1f5b5d2ad5abaeb4c6ad8ccffee4)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -77,6 +77,7 @@
+
Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingCalculationInputsSoilProfileSelectionEditor.cs
===================================================================
diff -u
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingCalculationInputsSoilProfileSelectionEditor.cs (revision 0)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Forms/UITypeEditors/PipingCalculationInputsSoilProfileSelectionEditor.cs (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -0,0 +1,64 @@
+using System;
+using System.ComponentModel;
+using System.Drawing.Design;
+using System.Windows.Forms;
+using System.Windows.Forms.Design;
+using DelftTools.Utils.PropertyBag.Dynamic;
+using DelftTools.Utils.Reflection;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Forms.PropertyClasses;
+
+namespace Ringtoets.Piping.Forms.UITypeEditors
+{
+ public class PipingCalculationInputsSoilProfileSelectionEditor : UITypeEditor
+ {
+ private IWindowsFormsEditorService editorService;
+
+ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
+ {
+ return UITypeEditorEditStyle.DropDown;
+ }
+
+ public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
+ {
+ if (provider != null)
+ {
+ editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
+ }
+
+ if (editorService != null)
+ {
+ // Create editor:
+ var listBox = CreateSoilProfileSelectionControl(context);
+
+ // Open editor for user to select an item:
+ editorService.DropDownControl(listBox);
+
+ // Return user selected object, or original value if user did not select anything:
+ return listBox.SelectedItem ?? value;
+ }
+ return base.EditValue(context, provider, value);
+ }
+
+ private ListBox CreateSoilProfileSelectionControl(ITypeDescriptorContext context)
+ {
+ var listBox = new ListBox
+ {
+ SelectionMode = SelectionMode.One,
+ DisplayMember = TypeUtils.GetMemberName(sl => sl.Name)
+ };
+ listBox.SelectedValueChanged += (sender, eventArgs) => editorService.CloseDropDown();
+
+ var properties = (PipingCalculationInputsProperties)((DynamicPropertyBag)context.Instance).WrappedObject;
+ foreach (var soilProfile in properties.GetAvailableSoilProfiles())
+ {
+ int index = listBox.Items.Add(soilProfile);
+ if (ReferenceEquals(properties.SoilProfile, soilProfile))
+ {
+ listBox.SelectedIndex = index;
+ }
+ }
+ return listBox;
+ }
+ }
+}
\ No newline at end of file
Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs
===================================================================
diff -u -rb02b755bf5d7a52b44deb11bdb9b1e70789306a0 -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision b02b755bf5d7a52b44deb11bdb9b1e70789306a0)
+++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using System.Drawing;
-
+using System.Linq;
using DelftTools.Shell.Core;
using log4net;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.IO;
+using Ringtoets.Piping.IO.Exceptions;
using WtiFormsResources = Ringtoets.Piping.Forms.Properties.Resources;
using ApplicationResources = Ringtoets.Piping.Plugin.Properties.Resources;
@@ -130,9 +131,10 @@
{
return soilProfileReader.Read();
}
- catch
+ catch (PipingSoilProfileReadException e)
{
- return null;
+ log.Error(e.Message);
+ return Enumerable.Empty();
}
}
}
Index: src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfileImporterTest.cs
===================================================================
diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfileImporterTest.cs (.../PipingSoilProfileImporterTest.cs) (revision 300a33d9acf653458b834b296becbf9ae552de8e)
+++ src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfileImporterTest.cs (.../PipingSoilProfileImporterTest.cs) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
-
+using System.IO;
using DelftTools.Shell.Core;
-
+using DelftTools.TestUtils;
using NUnit.Framework;
using Rhino.Mocks;
@@ -18,6 +18,8 @@
[TestFixture]
public class PipingSoilProfilesImporterTest
{
+ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Plugins.Wti.WtiIOPath, "PipingSoilProfilesReader");
+
[Test]
public void DefaultConstructor_ExpectedValues()
{
@@ -44,7 +46,7 @@
}
[Test]
- public void CanImportOn_TargetIsCollectionOfPipingSurfaceLines_ReturnTrue()
+ public void CanImportOn_TargetIsCollectionOfPipingSoilProfile_ReturnTrue()
{
// Setup
var mocks = new MockRepository();
@@ -80,10 +82,10 @@
}
[Test]
- public void ImportItem_ImportingToValidTargetWithValidFile_ImportSurfaceLinesToCollection()
+ public void ImportItem_ImportingToValidTargetWithValidFile_ImportSoilProfilesToCollection()
{
// Setup
- const string validFilePath = "";
+ string validFilePath = Path.Combine(testDataPath, "complete.soil");
var piping = new PipingFailureMechanism();
var importer = new PipingSoilProfilesImporter();
@@ -99,5 +101,26 @@
// Assert
Assert.AreSame(importTarget, importedItem);
}
+
+ [Test]
+ public void ImportItem_ImportingToInvalidTargetWithValidFile_ImportSoilProfilesToCollection()
+ {
+ // Setup
+ string validFilePath = Path.Combine(testDataPath, "empty.soil");
+ var piping = new PipingFailureMechanism();
+
+ var importer = new PipingSoilProfilesImporter();
+
+ var importTarget = piping.SoilProfiles;
+
+ // Precondition
+ Assert.IsTrue(importer.CanImportOn(importTarget));
+
+ // Call
+ var importedItem = importer.ImportItem(validFilePath, importTarget);
+
+ // Assert
+ Assert.AreSame(importTarget, importedItem);
+ }
}
}
\ No newline at end of file
Index: src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/WtiGuiPluginTest.cs
===================================================================
diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -rac57fa1a2d441543bb026e785f1483586079cc7d
--- src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/WtiGuiPluginTest.cs (.../WtiGuiPluginTest.cs) (revision 300a33d9acf653458b834b296becbf9ae552de8e)
+++ src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/WtiGuiPluginTest.cs (.../WtiGuiPluginTest.cs) (revision ac57fa1a2d441543bb026e785f1483586079cc7d)
@@ -63,7 +63,7 @@
PropertyInfo[] propertyInfos = guiPlugin.GetPropertyInfos().ToArray();
// assert
- Assert.AreEqual(4, propertyInfos.Length);
+ Assert.AreEqual(5, propertyInfos.Length);
var wtiProjectProperties = propertyInfos.Single(pi => pi.ObjectType == typeof(WtiProject));
Assert.AreEqual(typeof(WtiProjectProperties), wtiProjectProperties.PropertyType);
@@ -88,6 +88,12 @@
Assert.IsNull(pipingSurfaceLineProperties.AdditionalDataCheck);
Assert.IsNull(pipingSurfaceLineProperties.GetObjectPropertiesData);
Assert.IsNull(pipingSurfaceLineProperties.AfterCreate);
+
+ var pipingSoilProfileProperties = propertyInfos.Single(pi => pi.ObjectType == typeof(PipingSoilProfile));
+ Assert.AreEqual(typeof(PipingSoilProfileProperties), pipingSoilProfileProperties.PropertyType);
+ Assert.IsNull(pipingSoilProfileProperties.AdditionalDataCheck);
+ Assert.IsNull(pipingSoilProfileProperties.GetObjectPropertiesData);
+ Assert.IsNull(pipingSoilProfileProperties.AfterCreate);
}
}
@@ -106,11 +112,12 @@
ITreeNodePresenter[] nodePresenters = guiPlugin.GetProjectTreeViewNodePresenters().ToArray();
// assert
- Assert.AreEqual(7, nodePresenters.Length);
+ Assert.AreEqual(8, nodePresenters.Length);
Assert.IsTrue(nodePresenters.Any(np => np is WtiProjectNodePresenter));
Assert.IsTrue(nodePresenters.Any(np => np is PipingSurfaceLineCollectionNodePresenter));
Assert.IsTrue(nodePresenters.Any(np => np is PipingSurfaceLineNodePresenter));
Assert.IsTrue(nodePresenters.Any(np => np is PipingSoilProfileCollectionNodePresenter));
+ Assert.IsTrue(nodePresenters.Any(np => np is PipingSoilProfileNodePresenter));
Assert.IsTrue(nodePresenters.Any(np => np is PipingCalculationInputsNodePresenter));
Assert.IsTrue(nodePresenters.Any(np => np is PipingFailureMechanismNodePresenter));
Assert.IsTrue(nodePresenters.Any(np => np is PipingOutputNodePresenter));