Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -rd510069b9f0375adf108e8c9ffdb7668e7bb11f4 -r1eed3e3f652618c52a462edc502cfd4250772314
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision d510069b9f0375adf108e8c9ffdb7668e7bb11f4)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314)
@@ -55,6 +55,7 @@
using Ringtoets.HeightStructures.Forms.PresentationObjects;
using Ringtoets.HydraRing.Data;
using Ringtoets.HydraRing.IO;
+using Ringtoets.Integration.Data;
using Ringtoets.Integration.Data.StandAlone;
using Ringtoets.Integration.Data.StandAlone.SectionResults;
using Ringtoets.Integration.Forms;
@@ -74,6 +75,7 @@
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
using UtilsResources = Core.Common.Utils.Properties.Resources;
using BaseResources = Core.Common.Base.Properties.Resources;
+using GuiResources = Core.Common.Gui.Properties.Resources;
namespace Ringtoets.Integration.Plugin
{
@@ -222,6 +224,50 @@
}
}
+ public IAssessmentSection GetAssessmentSectionFromFile()
+ {
+ if (Gui == null)
+ {
+ return null;
+ }
+
+ IAssessmentSection assessmentSection = null;
+ try
+ {
+ var assessmentSectionHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow);
+ var path = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory();
+ assessmentSection = assessmentSectionHandler.CreateAssessmentSectionFromFile(path);
+ }
+ catch (CriticalFileValidationException exception)
+ {
+ MessageBox.Show(exception.Message, BaseResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ log.Warn(exception.Message, exception.InnerException);
+ }
+ catch (CriticalFileReadException exception)
+ {
+ log.Error(exception.Message, exception.InnerException);
+ }
+
+ return assessmentSection;
+ }
+
+ public void SetAssessmentSectionToProject(RingtoetsProject ringtoetsProject, AssessmentSection assessmentSection)
+ {
+ if (assessmentSection == null)
+ {
+ return;
+ }
+ assessmentSection.Name = GetUniqueForAssessmentSectionName(ringtoetsProject.Items, assessmentSection.Name);
+ ringtoetsProject.Items.Add(assessmentSection);
+ ringtoetsProject.NotifyObservers();
+
+ if (Gui != null && (Gui.Selection == null || Gui.Selection.Equals(assessmentSection)))
+ {
+ Gui.Selection = assessmentSection;
+ Gui.DocumentViewController.OpenViewForData(Gui.Selection);
+ }
+ }
+
///
/// Returns all instances provided for data of .
///
@@ -322,31 +368,10 @@
public override IEnumerable GetDataItemInfos()
{
- if (Gui == null)
- {
- return Enumerable.Empty();
- }
+ IAssessmentSection assessmentSection = GetAssessmentSectionFromFile();
- IAssessmentSection assessmentSection = null;
- try
- {
- var assessmentSectionHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow);
- var path = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory();
- assessmentSection = assessmentSectionHandler.CreateAssessmentSectionFromFile(path);
- }
- catch (CriticalFileValidationException exception)
- {
- MessageBox.Show(exception.Message, BaseResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
- log.Warn(exception.Message, exception.InnerException);
- }
- catch (CriticalFileReadException exception)
- {
- log.Error(exception.Message, exception.InnerException);
- }
-
if (assessmentSection == null)
{
- return Enumerable.Empty();
}
return new DataItemInfo[]
@@ -358,8 +383,8 @@
Image = RingtoetsFormsResources.AssessmentSectionFolderIcon,
CreateData = owner =>
{
- var project = (Project) owner;
- assessmentSection.Name = GetUniqueForAssessmentSectionName(project, assessmentSection.Name);
+ var project = (RingtoetsProject) owner;
+ assessmentSection.Name = GetUniqueForAssessmentSectionName(project.Items, assessmentSection.Name);
return assessmentSection;
}
}
@@ -373,6 +398,15 @@
/// Sequence of child data.
public override IEnumerable