Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -rd0c45d1cb039e274f638638d5b3d6631c88c2228 -r3340c93e5fd1ccd9b38c1c88cecbf06f0e3e02d6
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 3340c93e5fd1ccd9b38c1c88cecbf06f0e3e02d6)
@@ -119,6 +119,7 @@
+
Form
Index: Core/Common/src/Core.Common.Gui/ExportImportCommandHandler.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/ExportImportCommandHandler.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/ExportImportCommandHandler.cs (revision 3340c93e5fd1ccd9b38c1c88cecbf06f0e3e02d6)
@@ -0,0 +1,84 @@
+using System;
+using System.Linq;
+
+using Core.Common.Base.IO;
+using Core.Common.Gui.Properties;
+
+using log4net;
+
+namespace Core.Common.Gui
+{
+ ///
+ /// Class responsible for exporting and importing of data.
+ ///
+ public class ExportImportCommandHandler : IExportImportCommandHandler
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(ExportImportCommandHandler));
+
+ private readonly IGui gui;
+ private readonly GuiImportHandler importHandler;
+ private readonly GuiExportHandler exportHandler;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The GUI.
+ public ExportImportCommandHandler(IGui gui)
+ {
+ this.gui = gui;
+ importHandler = CreateGuiImportHandler(this.gui);
+ exportHandler = CreateGuiExportHandler(this.gui);
+ }
+
+ public bool CanImportOn(object obj)
+ {
+ return gui.ApplicationCore.GetSupportedFileImporters(obj).Any();
+ }
+
+ public void ImportOn(object target, IFileImporter importer = null)
+ {
+ try
+ {
+ if (importer == null)
+ {
+ importHandler.ImportDataTo(target);
+ }
+ else
+ {
+ importHandler.ImportUsingImporter(importer, target);
+ }
+ }
+ catch (Exception)
+ {
+ log.ErrorFormat(Resources.GuiCommandHandler_ImportOn_Unable_to_import_on_0_, target);
+ }
+ }
+
+ public bool CanExportFrom(object obj)
+ {
+ return gui.ApplicationCore.GetSupportedFileExporters(obj).Any();
+ }
+
+ public void ExportFrom(object data, IFileExporter exporter = null)
+ {
+ if (exporter == null)
+ {
+ exportHandler.ExportFrom(data);
+ }
+ else
+ {
+ exportHandler.GetExporterDialog(exporter, data);
+ }
+ }
+
+ private static GuiImportHandler CreateGuiImportHandler(IGui gui)
+ {
+ return new GuiImportHandler(gui);
+ }
+
+ private static GuiExportHandler CreateGuiExportHandler(IGui gui)
+ {
+ return new GuiExportHandler(gui.MainWindow, o => gui.ApplicationCore.GetSupportedFileExporters(o), o => gui.DocumentViewsResolver.CreateViewForData(o));
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs
===================================================================
diff -u -rd0c45d1cb039e274f638638d5b3d6631c88c2228 -r3340c93e5fd1ccd9b38c1c88cecbf06f0e3e02d6
--- Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
+++ Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision 3340c93e5fd1ccd9b38c1c88cecbf06f0e3e02d6)
@@ -23,16 +23,14 @@
{
private static readonly ILog Log = LogManager.GetLogger(typeof(GuiCommandHandler));
- private readonly GuiImportHandler guiImportHandler;
- private readonly GuiExportHandler guiExportHandler;
private readonly IGui gui;
+ private readonly ExportImportCommandHandler exportImportCommandHandler;
public GuiCommandHandler(IGui gui)
{
this.gui = gui;
- guiImportHandler = CreateGuiImportHandler();
- guiExportHandler = CreateGuiExportHandler();
+ exportImportCommandHandler = new ExportImportCommandHandler(gui);
}
public object GetDataOfActiveView()
@@ -167,57 +165,26 @@
public bool CanImportOn(object obj)
{
- return gui.ApplicationCore.GetSupportedFileImporters(obj).Any();
+ return exportImportCommandHandler.CanImportOn(obj);
}
public void ImportOn(object target, IFileImporter importer = null)
{
- try
- {
- if (importer == null)
- {
- guiImportHandler.ImportDataTo(target);
- }
- else
- {
- guiImportHandler.ImportUsingImporter(importer, target);
- }
- }
- catch (Exception)
- {
- Log.ErrorFormat(Resources.GuiCommandHandler_ImportOn_Unable_to_import_on_0_, target);
- }
+ exportImportCommandHandler.ImportOn(target, importer);
}
public bool CanExportFrom(object obj)
{
- return gui.ApplicationCore.GetSupportedFileExporters(obj).Any();
+ return exportImportCommandHandler.CanExportFrom(obj);
}
public void ExportFrom(object data, IFileExporter exporter = null)
{
- if (exporter == null)
- {
- guiExportHandler.ExportFrom(data);
- }
- else
- {
- guiExportHandler.GetExporterDialog(exporter, data);
- }
+ exportImportCommandHandler.ExportFrom(data, exporter);
}
#endregion
- private GuiImportHandler CreateGuiImportHandler()
- {
- return new GuiImportHandler(gui);
- }
-
- private GuiExportHandler CreateGuiExportHandler()
- {
- return new GuiExportHandler(gui.MainWindow, o => gui.ApplicationCore.GetSupportedFileExporters(o), o => gui.DocumentViewsResolver.CreateViewForData(o));
- }
-
private void AddProjectToMruList()
{
var mruList = (StringCollection) Settings.Default["mruList"];
Index: Core/Common/src/Core.Common.Gui/IExportImportCommandHandler.cs
===================================================================
diff -u -rd0c45d1cb039e274f638638d5b3d6631c88c2228 -r3340c93e5fd1ccd9b38c1c88cecbf06f0e3e02d6
--- Core/Common/src/Core.Common.Gui/IExportImportCommandHandler.cs (.../IExportImportCommandHandler.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
+++ Core/Common/src/Core.Common.Gui/IExportImportCommandHandler.cs (.../IExportImportCommandHandler.cs) (revision 3340c93e5fd1ccd9b38c1c88cecbf06f0e3e02d6)
@@ -2,6 +2,9 @@
namespace Core.Common.Gui
{
+ ///
+ /// Interface declaring commands/methods related to importing and exporting data.
+ ///
public interface IExportImportCommandHandler
{
///