Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -r2d0a1ea654af9fb4685e01c7d4883884c8a9249f -r50b203a8d5c805fc548fb6b92c70a847190da6a5
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 2d0a1ea654af9fb4685e01c7d4883884c8a9249f)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 50b203a8d5c805fc548fb6b92c70a847190da6a5)
@@ -48,7 +48,6 @@
using Ringtoets.Common.Forms.TreeNodeInfos;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Common.IO;
-using Ringtoets.Common.IO.Exceptions;
using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
using Ringtoets.HeightStructures.Data;
@@ -58,7 +57,6 @@
using Ringtoets.Integration.Data;
using Ringtoets.Integration.Data.StandAlone;
using Ringtoets.Integration.Data.StandAlone.SectionResults;
-using Ringtoets.Integration.Forms;
using Ringtoets.Integration.Forms.Commands;
using Ringtoets.Integration.Forms.PresentationObjects;
using Ringtoets.Integration.Forms.PropertyClasses;
@@ -202,7 +200,7 @@
#endregion
- private readonly string shapeFileDirectory = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory();
+ private AssessmentSectionFromFileCommandHandler assessmentSectionFromFileCommandHandler;
public override IRibbonCommandHandler RibbonCommandHandler
{
@@ -226,64 +224,13 @@
}
}
- ///
- /// Returns a new , based upon the in a dialog selected .
- ///
- /// The newly created .
- /// Thrown when is null.
- public IAssessmentSection GetAssessmentSectionFromFile()
+ public override void Activate()
{
- if (Gui == null)
- {
- throw new InvalidOperationException("Gui must be set.");
- }
-
- IAssessmentSection assessmentSection = null;
- try
- {
- var assessmentSectionHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow);
- assessmentSection = assessmentSectionHandler.CreateAssessmentSectionFromFile(shapeFileDirectory);
- }
- 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;
+ base.Activate();
+ assessmentSectionFromFileCommandHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow, Gui, Gui.DocumentViewController);
}
///
- /// Adds to and ensures a unique name.
- ///
- /// The to add the to.
- /// The to add.
- public void SetAssessmentSectionToProject(RingtoetsProject ringtoetsProject, AssessmentSection assessmentSection)
- {
- if (ringtoetsProject == null)
- {
- throw new ArgumentNullException("ringtoetsProject");
- }
- if (assessmentSection == null)
- {
- throw new ArgumentNullException("assessmentSection");
- }
-
- assessmentSection.Name = GetUniqueForAssessmentSectionName(ringtoetsProject.AssessmentSections, assessmentSection.Name);
- ringtoetsProject.AssessmentSections.Add(assessmentSection);
- ringtoetsProject.NotifyObservers();
-
- if (Gui != null)
- {
- Gui.DocumentViewController.OpenViewForData(assessmentSection);
- }
- }
-
- ///
/// Returns all instances provided for data of .
///
public override IEnumerable GetPropertyInfos()
@@ -526,7 +473,7 @@
RingtoetsCommonFormsResources.RingtoetsProject_DisplayName,
RingtoetsCommonFormsResources.RingtoetsProject_ToolTip,
GuiResources.PlusIcon,
- (s, e) => SetAssessmentSectionFromFileToProject(nodeData));
+ (s, e) => assessmentSectionFromFileCommandHandler.CreateAssessmentSectionFromFile());
return Gui.Get(nodeData, treeViewControl)
.AddCustomItem(addItem)
@@ -543,16 +490,6 @@
};
}
- private void SetAssessmentSectionFromFileToProject(RingtoetsProject ringtoetsProject)
- {
- var assessmentSection = GetAssessmentSectionFromFile();
- if (!(assessmentSection is AssessmentSection))
- {
- return;
- }
- SetAssessmentSectionToProject(ringtoetsProject, (AssessmentSection) assessmentSection);
- }
-
private static ViewInfo, IEnumerable, TView> CreateFailureMechanismResultViewInfo()
where TResult : FailureMechanismSectionResult
where TView : FailureMechanismResultView