Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r250f2f821d2540a5c562d5fa9ccaab669dacb24b -r8e74b5d6680386fce48486c8253b62331f7d7055 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 250f2f821d2540a5c562d5fa9ccaab669dacb24b) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 8e74b5d6680386fce48486c8253b62331f7d7055) @@ -25,6 +25,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Base.IO; using Core.Common.Controls.TreeView; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.ProgressDialog; @@ -43,6 +44,7 @@ using Ringtoets.Common.Forms.ImportInfos; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Common.Service; using Ringtoets.Common.Utils; using Ringtoets.HeightStructures.Data; @@ -89,16 +91,14 @@ { yield return new ImportInfo { - CreateFileImporter = (context, filePath) => new HeightStructuresImporter(context.WrappedData, - context.AssessmentSection.ReferenceLine, - new HeightStructureReplaceDataStrategy(context.FailureMechanism), - filePath), Name = RingtoetsCommonFormsResources.StructuresImporter_DisplayName, Category = RingtoetsCommonFormsResources.Ringtoets_Category, Image = RingtoetsCommonFormsResources.StructuresIcon, - FileFilterGenerator = new FileFilterGenerator(RingtoetsCommonIOResources.Shape_file_filter_Extension, - RingtoetsCommonIOResources.Shape_file_filter_Description), - IsEnabled = context => context.AssessmentSection.ReferenceLine != null + IsEnabled = IsHeightStructuresImporterEnabled, + FileFilterGenerator = HeightStructureFileFilter(), + CreateFileImporter = (context, filePath) => CreateHeightStructuresImporter(context, + filePath, + new ImportMessageProvider()) }; yield return RingtoetsImportInfoFactory.CreateCalculationConfigurationImportInfo( @@ -111,6 +111,22 @@ context.FailureMechanism)); } + public override IEnumerable GetUpdateInfos() + { + yield return new UpdateInfo + { + Name = RingtoetsCommonDataResources.StructureCollection_TypeDescriptor, + Category = RingtoetsCommonFormsResources.Ringtoets_Category, + Image = RingtoetsCommonFormsResources.StructuresIcon, + IsEnabled = IsHeightStructuresImporterEnabled, + FileFilterGenerator = HeightStructureFileFilter(), + CreateFileImporter = (context, filePath) => CreateHeightStructuresImporter(context, + filePath, + new UpdateMessageProvider()), + CurrentPath = context => context.WrappedData.SourcePath + }; + } + public override IEnumerable GetExportInfos() { yield return RingtoetsExportInfoFactory.CreateCalculationGroupConfigurationExportInfo( @@ -194,16 +210,7 @@ ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText), ChildNodeObjects = context => context.WrappedData.Cast().ToArray(), - ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl) - .AddImportItem() - .AddSeparator() - .AddDeleteChildrenItem() - .AddSeparator() - .AddCollapseAllItem() - .AddExpandAllItem() - .AddSeparator() - .AddPropertiesItem() - .Build() + ContextMenuStrip = HeightStructuresContextContextMenuStrip }; yield return new TreeNodeInfo @@ -359,6 +366,24 @@ #endregion + #region HeightStructuresContext TreeNodeInfo + + private ContextMenuStrip HeightStructuresContextContextMenuStrip(HeightStructuresContext nodeData, + object parentData, TreeViewControl treeViewControl) + { + return Gui.Get(nodeData, treeViewControl) + .AddImportItem() + .AddUpdateItem() + .AddSeparator() + .AddCollapseAllItem() + .AddExpandAllItem() + .AddSeparator() + .AddPropertiesItem() + .Build(); + } + + #endregion + #region HeightStructuresFailureMechanismContext TreeNodeInfo private static object[] FailureMechanismEnabledChildNodeObjects(HeightStructuresFailureMechanismContext context) @@ -736,5 +761,30 @@ #endregion #endregion + + #region Importers + + #region HeightStructuresImporter + + private static IFileImporter CreateHeightStructuresImporter(HeightStructuresContext context, string filePath, IImporterMessageProvider messageProvider) + { + return new HeightStructuresImporter(context.WrappedData, context.AssessmentSection.ReferenceLine, + filePath, messageProvider, new HeightStructureUpdateDataStrategy(context.FailureMechanism)); + } + + private static bool IsHeightStructuresImporterEnabled(HeightStructuresContext context) + { + return context.AssessmentSection.ReferenceLine != null; + } + + private static FileFilterGenerator HeightStructureFileFilter() + { + return new FileFilterGenerator(RingtoetsCommonIOResources.Shape_file_filter_Extension, + RingtoetsCommonIOResources.Shape_file_filter_Description); + } + + #endregion + + #endregion } } \ No newline at end of file