Index: Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs
===================================================================
diff -u -rb9851915fb250e14a7608ae243fe94b6ab8d8abf -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision b9851915fb250e14a7608ae243fe94b6ab8d8abf)
+++ Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -23,6 +23,7 @@
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
+using Core.Common.Base.IO;
using Core.Common.Base.Service;
using Core.Common.Gui.Forms;
using Core.Common.Gui.Forms.ProgressDialog;
@@ -122,21 +123,49 @@
private void ImportItemsUsingDialog(ImportInfo importInfo, object target)
{
+ FileDialogResult filePathSelection = GetFilePath(importInfo.FileFilter);
+
+ if (filePathSelection.FileSelected && importInfo.VerifyUpdates(target))
+ {
+ RunImportActivity(importInfo.CreateFileImporter(target, filePathSelection.FileName), importInfo.Name);
+ }
+ }
+
+ private void RunImportActivity(IFileImporter importer, string importName)
+ {
+ log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data);
+
+ var activity = new FileImportActivity(importer, importName);
+ ActivityProgressDialogRunner.Run(dialogParent, activity);
+ }
+
+ private static FileDialogResult GetFilePath(string fileFilter)
+ {
using (var dialog = new OpenFileDialog
{
- Multiselect = true,
- Filter = importInfo.FileFilter,
+ Multiselect = false,
+ Filter = fileFilter,
Title = Resources.OpenFileDialog_Title
})
{
- if (dialog.ShowDialog(dialogParent) == DialogResult.OK)
- {
- log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data);
+ DialogResult result = dialog.ShowDialog();
+ bool fileSelected = result.Equals(DialogResult.OK);
- FileImportActivity[] importActivitiesToRun = dialog.FileNames.Select(f => new FileImportActivity(importInfo.CreateFileImporter(target, f), importInfo.Name)).ToArray();
- ActivityProgressDialogRunner.Run(dialogParent, importActivitiesToRun);
- }
+ return new FileDialogResult(fileSelected, dialog.FileName);
}
}
+
+ private class FileDialogResult
+ {
+ public FileDialogResult(bool fileSelected, string fileName)
+ {
+ FileSelected = fileSelected;
+ FileName = fileName;
+ }
+
+ public string FileName { get; }
+
+ public bool FileSelected { get; }
+ }
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (revision 45440093089496f59ed420e772136756c229e30b)
@@ -0,0 +1,157 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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 System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base.IO;
+using Core.Common.Base.Service;
+using Core.Common.Gui.Forms;
+using Core.Common.Gui.Forms.ProgressDialog;
+using Core.Common.Gui.Plugin;
+using Core.Common.Gui.Properties;
+using Core.Common.Utils.Reflection;
+using log4net;
+
+namespace Core.Common.Gui.Commands
+{
+ ///
+ /// Class responsible for handling import workflow with user interaction.
+ ///
+ public class GuiUpdateHandler : IUpdateCommandHandler
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(GuiImportHandler));
+
+ private readonly IWin32Window dialogParent;
+ private readonly IEnumerable updateInfos;
+ private readonly DialogBasedInquiryHelper inquiryHelper;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The parent window to show dialogs on top.
+ /// An enumeration of .
+ public GuiUpdateHandler(IWin32Window dialogParent, IEnumerable updateInfos)
+ {
+ if (dialogParent == null)
+ {
+ throw new ArgumentNullException(nameof(dialogParent));
+ }
+ if (updateInfos == null)
+ {
+ throw new ArgumentNullException(nameof(updateInfos));
+ }
+ this.dialogParent = dialogParent;
+ this.updateInfos = updateInfos;
+ inquiryHelper = new DialogBasedInquiryHelper(dialogParent);
+ }
+
+ public bool CanUpdateOn(object target)
+ {
+ return GetSupportedUpdateInfos(target).Any();
+ }
+
+ public void UpdateOn(object target)
+ {
+ UpdateInfo updateInfo = GetSupportedUpdaterUsingDialog(target);
+ if (updateInfo != null)
+ {
+ UpdateItemsUsingDialog(updateInfo, target);
+ }
+ }
+
+ private IEnumerable GetSupportedUpdateInfos(object target)
+ {
+ if (target == null)
+ {
+ return Enumerable.Empty();
+ }
+
+ var targetType = target.GetType();
+
+ return updateInfos.Where(info => (info.DataType == targetType || targetType.Implements(info.DataType)) && info.IsEnabled(target));
+ }
+
+ private UpdateInfo GetSupportedUpdaterUsingDialog(object target)
+ {
+ UpdateInfo[] supportedUpdateInfo = GetSupportedUpdateInfos(target).ToArray();
+ if (supportedUpdateInfo.Length == 0)
+ {
+ MessageBox.Show(dialogParent,
+ Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_item,
+ Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_Error);
+ log.ErrorFormat(Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_item_0_,
+ target);
+ return null;
+ }
+
+ if (supportedUpdateInfo.Length == 1)
+ {
+ return supportedUpdateInfo[0];
+ }
+
+ using (var selectUpdaterDialog = new SelectItemDialog(dialogParent, Resources.GuiUpdateHandler_GetSupportedUpdaterUsingDialog_Select_updater))
+ {
+ foreach (UpdateInfo updateInfo in supportedUpdateInfo)
+ {
+ string category = string.IsNullOrEmpty(updateInfo.Category) ?
+ Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_Data_Update :
+ updateInfo.Category;
+ Image itemImage = updateInfo.Image ?? Resources.brick;
+
+ selectUpdaterDialog.AddItemType(updateInfo.Name, category, itemImage, null);
+ }
+
+ if (selectUpdaterDialog.ShowDialog() == DialogResult.OK)
+ {
+ return supportedUpdateInfo.First(i => i.Name == selectUpdaterDialog.SelectedItemTypeName);
+ }
+ }
+
+ return null;
+ }
+
+ private void UpdateItemsUsingDialog(UpdateInfo updateInfo, object target)
+ {
+ string filePath = updateInfo.CurrentPath(target);
+ if (!File.Exists(filePath))
+ {
+ FileResult fileDialogResult = inquiryHelper.GetSourceFileLocation(updateInfo.FileFilter);
+ filePath = fileDialogResult.FilePath;
+ }
+ if (filePath != null && updateInfo.VerifyUpdates(target))
+ {
+ RunUpdateActivity(updateInfo.CreateFileImporter(target, filePath), updateInfo.Name);
+ }
+ }
+
+ private void RunUpdateActivity(IFileImporter importer, string importName)
+ {
+ log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data);
+
+ var activity = new FileImportActivity(importer, importName);
+ ActivityProgressDialogRunner.Run(dialogParent, activity);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Commands/IUpdateCommandHandler.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/Commands/IUpdateCommandHandler.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/Commands/IUpdateCommandHandler.cs (revision 45440093089496f59ed420e772136756c229e30b)
@@ -0,0 +1,49 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.
+
+namespace Core.Common.Gui.Commands
+{
+ ///
+ /// Interface declaring commands/methods related to importing data.
+ ///
+ public interface IUpdateCommandHandler
+ {
+ ///
+ /// Indicates if there are updaters for the given target object.
+ ///
+ /// The target object to check updater availability for.
+ /// true if there are updaters available, false otherwise.
+ bool CanUpdateOn(object target);
+
+ ///
+ /// Perform the update workflow by the following steps:
+ ///
+ /// If multiple updaters are available for the target object, ask the user
+ /// which updater to use;
+ /// Check whether the path to the already imported file exists;
+ /// If not, ask the user which file to use to update from;
+ /// Import from the user specified file and update the target object.
+ ///
+ ///
+ /// The data object to update.
+ void UpdateOn(object target);
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs
===================================================================
diff -u -r0d3788fdf7aa5b050974f69bcea4f8e71a096d58 -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision 0d3788fdf7aa5b050974f69bcea4f8e71a096d58)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -42,32 +42,34 @@
/// Creates a new instance of .
///
/// The from which to obtain
- /// information to render and bind actions to the items of the . If null,
- /// this builder will not render items which require this type of information.
+ /// information to render and bind actions to the items of the . If null,
+ /// this builder will not render items which require this type of information.
/// The from which to obtain
- /// information to render and bind actions to the items of the . If null,
- /// this builder will not render items which require this type of information.
+ /// information to render and bind actions to the items of the . If null,
+ /// this builder will not render items which require this type of information.
/// The from which to obtain
- /// information to render and bind actions to the items of the . If null,
- /// this builder will not render items which require this type of information.
+ /// information to render and bind actions to the items of the . If null,
+ /// this builder will not render items which require this type of information.
+ ///
/// The from which to obtain information to render
- /// and bind actions to the items of the . If null, this builder will not
- /// render items which require this type of information.
+ /// and bind actions to the items of the . If null, this builder will not
+ /// render items which require this type of information.
/// The data object for which to create a .
/// The to use while executing the actions.
/// Thrown when any input argument is null.
public ContextMenuBuilder(IApplicationFeatureCommands featureCommandHandler,
IImportCommandHandler importCommandHandler,
IExportCommandHandler exportCommandHandler,
- IViewCommands viewCommands,
- object dataValue,
+ IUpdateCommandHandler updateCommandHandler,
+ IViewCommands viewCommands, object dataValue,
TreeViewControl treeViewControl)
{
try
{
guiItemsFactory = new GuiContextMenuItemFactory(featureCommandHandler,
importCommandHandler,
exportCommandHandler,
+ updateCommandHandler,
viewCommands,
dataValue);
@@ -128,6 +130,12 @@
return this;
}
+ public IContextMenuBuilder AddUpdateItem()
+ {
+ AddItem(guiItemsFactory.CreateUpdateItem());
+ return this;
+ }
+
public IContextMenuBuilder AddCustomImportItem(string text, string toolTip, Image image)
{
AddItem(guiItemsFactory.CreateCustomImportItem(text, toolTip, image));
Index: Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs
===================================================================
diff -u -r589249bddd12bd66da39205d408ff6e907220116 -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision 589249bddd12bd66da39205d408ff6e907220116)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -35,6 +35,7 @@
private readonly IApplicationFeatureCommands applicationFeatureCommandHandler;
private readonly IImportCommandHandler importCommandHandler;
private readonly IExportCommandHandler exportCommandHandler;
+ private readonly IUpdateCommandHandler updateCommandHandler;
private readonly IViewCommands viewCommands;
private readonly object dataObject;
@@ -54,6 +55,7 @@
public GuiContextMenuItemFactory(IApplicationFeatureCommands applicationFeatureCommandHandler,
IImportCommandHandler importCommandHandler,
IExportCommandHandler exportCommandHandler,
+ IUpdateCommandHandler updateCommandHandler,
IViewCommands viewCommandsHandler,
object dataObject)
{
@@ -72,6 +74,11 @@
throw new ArgumentNullException(nameof(exportCommandHandler),
Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_export_handler);
}
+ if (updateCommandHandler == null)
+ {
+ throw new ArgumentNullException(nameof(updateCommandHandler),
+ Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_update_handler);
+ }
if (viewCommandsHandler == null)
{
throw new ArgumentNullException(nameof(viewCommandsHandler),
@@ -85,6 +92,7 @@
this.applicationFeatureCommandHandler = applicationFeatureCommandHandler;
this.importCommandHandler = importCommandHandler;
this.exportCommandHandler = exportCommandHandler;
+ this.updateCommandHandler = updateCommandHandler;
viewCommands = viewCommandsHandler;
this.dataObject = dataObject;
}
@@ -138,6 +146,25 @@
}
///
+ /// Creates a which is bound to the action of updating
+ /// the data of the given .
+ ///
+ /// The created .
+ public ToolStripItem CreateUpdateItem()
+ {
+ bool canImport = updateCommandHandler.CanUpdateOn(dataObject);
+ var newItem = new ToolStripMenuItem(Resources.Update)
+ {
+ ToolTipText = Resources.Update_ToolTip,
+ Image = Resources.RefreshIcon,
+ Enabled = canImport
+ };
+ newItem.Click += (s, e) => updateCommandHandler.UpdateOn(dataObject);
+
+ return newItem;
+ }
+
+ ///
/// Creates a which is bound to the action of importing
/// to the data of the given .
///
Index: Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs
===================================================================
diff -u -r0d3788fdf7aa5b050974f69bcea4f8e71a096d58 -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs (.../IContextMenuBuilder.cs) (revision 0d3788fdf7aa5b050974f69bcea4f8e71a096d58)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs (.../IContextMenuBuilder.cs) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -79,6 +79,12 @@
IContextMenuBuilder AddImportItem();
///
+ /// Adds an item to the , which updates the data of the .
+ ///
+ /// The itself.
+ IContextMenuBuilder AddUpdateItem();
+
+ ///
/// Adds an item to the , which imports to the data of the .
///
/// The text of the import item.
Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -r0ce9c8ee8f2918efdef2f85992c00c7da3f5b5eb -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 0ce9c8ee8f2918efdef2f85992c00c7da3f5b5eb)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -107,10 +107,12 @@
+
+
@@ -120,6 +122,9 @@
+
+
+
@@ -135,11 +140,13 @@
+
+
@@ -362,6 +369,7 @@
+
Index: Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs (revision 45440093089496f59ed420e772136756c229e30b)
@@ -0,0 +1,91 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.Windows.Forms;
+using Core.Common.Gui.Properties;
+using CoreCommonBaseResources = Core.Common.Base.Properties.Resources;
+
+namespace Core.Common.Gui
+{
+ ///
+ /// Class which inquires the user for application inputs based on dialogs.
+ ///
+ public class DialogBasedInquiryHelper : IInquiryHelper
+ {
+ private readonly IWin32Window dialogParent;
+
+ public DialogBasedInquiryHelper(IWin32Window dialogParent)
+ {
+ this.dialogParent = dialogParent;
+ }
+
+ public FileResult GetSourceFileLocation()
+ {
+ return GetSourceFileLocation(new ExpectedFile());
+ }
+
+ public FileResult GetSourceFileLocation(ExpectedFile filter)
+ {
+ string filePath = null;
+ using (OpenFileDialog dialog = new OpenFileDialog
+ {
+ Multiselect = false,
+ Title = Resources.OpenFileDialog_Title,
+ Filter = filter.Filter
+ })
+ {
+ DialogResult result = dialog.ShowDialog();
+ if (result == DialogResult.OK)
+ {
+ filePath = dialog.FileName;
+ }
+ }
+ return new FileResult(filePath);
+ }
+
+ public FileResult GetTargetFileLocation()
+ {
+ string filePath = null;
+ using (SaveFileDialog dialog = new SaveFileDialog
+ {
+ Title = Resources.SaveFileDialog_Title
+ })
+ {
+ DialogResult result = dialog.ShowDialog();
+ if (result == DialogResult.OK)
+ {
+ filePath = dialog.FileName;
+ }
+ }
+ return new FileResult(filePath);
+ }
+
+ public bool InquireContinuation(string query)
+ {
+ DialogResult dialog = MessageBox.Show(
+ dialogParent,
+ query,
+ CoreCommonBaseResources.Confirm,
+ MessageBoxButtons.OKCancel);
+ return dialog == DialogResult.OK;
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/ExpectedFile.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/ExpectedFile.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/ExpectedFile.cs (revision 45440093089496f59ed420e772136756c229e30b)
@@ -0,0 +1,76 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.
+
+namespace Core.Common.Gui
+{
+ ///
+ /// Class which produces a file filter based on the expected extension. If no specific
+ /// extension is expected, then a filter for all file types will be produced.
+ ///
+ public class ExpectedFile {
+
+ private readonly string extension = "*";
+ private readonly string description = "Alle bestanden";
+
+ ///
+ /// Creates a new instance of which filters
+ /// for all files.
+ ///
+ public ExpectedFile()
+ {
+ }
+
+ ///
+ /// Creates a new instance of which filters files based on
+ /// a specified file extension.
+ ///
+ /// The extension of the files to filter on.
+ public ExpectedFile(string typeExtension)
+ {
+ extension = typeExtension;
+ description = $"{typeExtension.ToUpperInvariant()}-bestanden";
+ }
+
+ ///
+ /// Creates a new instance of which filters files based on
+ /// a specified file extension.
+ ///
+ /// The extension of the files to filter on.
+ /// The description of files which have
+ /// as their extension.
+ public ExpectedFile(string typeExtension, string typeDescription)
+ {
+ description = typeDescription;
+ extension = typeExtension;
+ }
+
+ ///
+ /// Gets a filter string for the .
+ ///
+ public string Filter
+ {
+ get
+ {
+ return $"{description} (*.{extension})|*.{extension}";
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/FileResult.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/FileResult.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/FileResult.cs (revision 45440093089496f59ed420e772136756c229e30b)
@@ -0,0 +1,55 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.
+
+namespace Core.Common.Gui
+{
+ ///
+ /// The result of a file inquiry operation.
+ ///
+ public class FileResult
+ {
+ ///
+ /// Creates a new .
+ ///
+ /// The path to a file.
+ public FileResult(string filePath)
+ {
+ FilePath = filePath;
+ }
+
+ ///
+ /// Gets the path to the file.
+ ///
+ public string FilePath { get; }
+
+ ///
+ /// Returns true if the contains a
+ /// , false othwerise.
+ ///
+ public bool HasFilePath
+ {
+ get
+ {
+ return FilePath != null;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Forms/SelectItemDialog.cs
===================================================================
diff -u -r49c5da81f49a23dd6e66526d264a08bf510e6963 -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/Forms/SelectItemDialog.cs (.../SelectItemDialog.cs) (revision 49c5da81f49a23dd6e66526d264a08bf510e6963)
+++ Core/Common/src/Core.Common.Gui/Forms/SelectItemDialog.cs (.../SelectItemDialog.cs) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -63,7 +63,7 @@
{
get
{
- return SelectedItem != null ? SelectedItem.Tag : null;
+ return SelectedItem?.Tag;
}
}
@@ -74,7 +74,7 @@
{
get
{
- return SelectedItem != null ? SelectedItem.Name : null;
+ return SelectedItem?.Name;
}
}
Index: Core/Common/src/Core.Common.Gui/GuiCore.cs
===================================================================
diff -u -rb2b9fdf365e70928a05c57966eeed30d9050e528 -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision b2b9fdf365e70928a05c57966eeed30d9050e528)
+++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -120,6 +120,7 @@
storageCommandHandler = new StorageCommandHandler(projectStore, projectFactory, this, MainWindow);
importCommandHandler = new GuiImportHandler(MainWindow, Plugins.SelectMany(p => p.GetImportInfos()));
exportCommandHandler = new GuiExportHandler(MainWindow, Plugins.SelectMany(p => p.GetExportInfos()));
+ updateCommandHandler = new GuiUpdateHandler(MainWindow, Plugins.SelectMany(p => p.GetUpdateInfos()));
WindowsApplication.EnableVisualStyles();
ViewPropertyEditor.ViewCommands = ViewCommands;
@@ -203,7 +204,8 @@
return new ContextMenuBuilder(applicationFeatureCommands,
importCommandHandler,
- exportCommandHandler,
+ exportCommandHandler,
+ updateCommandHandler,
ViewCommands,
value,
treeViewControl);
@@ -691,6 +693,7 @@
private readonly ViewCommandHandler viewCommandHandler;
private readonly GuiImportHandler importCommandHandler;
private readonly GuiExportHandler exportCommandHandler;
+ private readonly GuiUpdateHandler updateCommandHandler;
private readonly IStorageCommands storageCommandHandler;
public IApplicationFeatureCommands ApplicationCommands
Index: Core/Common/src/Core.Common.Gui/IInquiryHelper.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (revision 45440093089496f59ed420e772136756c229e30b)
@@ -0,0 +1,60 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.
+
+namespace Core.Common.Gui
+{
+ ///
+ /// Specifies the interface for classes that can be used to inquire information from
+ /// the user.
+ ///
+ public interface IInquiryHelper
+ {
+ ///
+ /// Returns a containing a path to an existing file
+ /// if the user did not cancel the inquiry.
+ ///
+ /// A new .
+ FileResult GetSourceFileLocation();
+
+ ///
+ /// Returns a containing a path to an existing file
+ /// if the user did not cancel the inquiry.
+ ///
+ /// A filter to which the path in the returned
+ /// complies.
+ /// A new .
+ FileResult GetSourceFileLocation(ExpectedFile filter);
+
+ ///
+ /// Returns a containing a path to a (non-existing) file
+ /// if the user did not cancel the inquiry.
+ ///
+ /// A containing a path to a (non-existing) file.
+ FileResult GetTargetFileLocation();
+
+ ///
+ /// Gets the confirmation of a user.
+ ///
+ /// The query to which the user needs to answer.
+ /// true if the user confirmed, false otherwise.
+ bool InquireContinuation(string query);
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Plugin/ImportInfo.cs
===================================================================
diff -u -r587f6330c5876eb326e8bea5e82a3650866cc475 -r45440093089496f59ed420e772136756c229e30b
--- Core/Common/src/Core.Common.Gui/Plugin/ImportInfo.cs (.../ImportInfo.cs) (revision 587f6330c5876eb326e8bea5e82a3650866cc475)
+++ Core/Common/src/Core.Common.Gui/Plugin/ImportInfo.cs (.../ImportInfo.cs) (revision 45440093089496f59ed420e772136756c229e30b)
@@ -45,6 +45,8 @@
///
public Func