Index: Core/Common/src/Core.Common.Base/Plugin/ApplicationCore.cs
===================================================================
diff -u -r3e0ac8e7988d37424638e2b768e15a783897e126 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/src/Core.Common.Base/Plugin/ApplicationCore.cs (.../ApplicationCore.cs) (revision 3e0ac8e7988d37424638e2b768e15a783897e126)
+++ Core/Common/src/Core.Common.Base/Plugin/ApplicationCore.cs (.../ApplicationCore.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -64,17 +64,6 @@
///
/// The owner to get the enumeration of supported for.
/// The enumeration of supported .
- public IEnumerable GetSupportedDataItemInfos(object owner)
- {
- if (owner == null)
- {
- return Enumerable.Empty();
- }
-
- return plugins.SelectMany(p => p.GetDataItemInfos())
- .Where(dataItemInfo => dataItemInfo.AdditionalOwnerCheck == null || dataItemInfo.AdditionalOwnerCheck(owner));
- }
-
public virtual void Dispose()
{
foreach (var plugin in plugins.ToArray())
Index: Core/Common/src/Core.Common.Base/Plugin/ApplicationPlugin.cs
===================================================================
diff -u -r5b9a225deb21ddb302ddfd070154f61cd2d1b091 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/src/Core.Common.Base/Plugin/ApplicationPlugin.cs (.../ApplicationPlugin.cs) (revision 5b9a225deb21ddb302ddfd070154f61cd2d1b091)
+++ Core/Common/src/Core.Common.Base/Plugin/ApplicationPlugin.cs (.../ApplicationPlugin.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -19,23 +19,10 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System.Collections.Generic;
-using Core.Common.Base.IO;
-
namespace Core.Common.Base.Plugin
{
///
/// Class that provides application plugin objects (data items).
///
- public abstract class ApplicationPlugin
- {
- ///
- /// This method returns an enumeration of .
- ///
- /// The enumeration of provided by the .
- public virtual IEnumerable GetDataItemInfos()
- {
- yield break;
- }
- }
+ public abstract class ApplicationPlugin {}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Commands/ProjectCommandHandler.cs
===================================================================
diff -u -ref1c61d94f2aec3b4ff32fcf03253d7ad386c8e5 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/src/Core.Common.Gui/Commands/ProjectCommandHandler.cs (.../ProjectCommandHandler.cs) (revision ef1c61d94f2aec3b4ff32fcf03253d7ad386c8e5)
+++ Core/Common/src/Core.Common.Gui/Commands/ProjectCommandHandler.cs (.../ProjectCommandHandler.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -22,13 +22,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
-
using Core.Common.Base.Data;
using Core.Common.Base.Plugin;
using Core.Common.Gui.Forms;
using Core.Common.Gui.Properties;
using Core.Common.Gui.Selection;
-
using log4net;
namespace Core.Common.Gui.Commands
@@ -42,25 +40,25 @@
private readonly IProjectOwner projectOwner;
private readonly IWin32Window dialogOwner;
- private readonly ApplicationCore applicationCore;
private readonly IApplicationSelection applicationSelection;
private readonly IDocumentViewController documentViewController;
+ private readonly IEnumerable dataItemInfos;
///
/// Initializes a new instance of the class.
///
/// Class owning the application's instance.
/// The window on which dialogs should be shown on top.
- /// The application-plugins host.
+ /// An enumeration of .
/// The application selection mechanism.
/// The controller for Document Views.
public ProjectCommandHandler(IProjectOwner projectOwner, IWin32Window dialogParent,
- ApplicationCore applicationCore, IApplicationSelection applicationSelection,
- IDocumentViewController documentViewController)
+ IEnumerable dataItemInfos, IApplicationSelection applicationSelection,
+ IDocumentViewController documentViewController)
{
this.projectOwner = projectOwner;
dialogOwner = dialogParent;
- this.applicationCore = applicationCore;
+ this.dataItemInfos = dataItemInfos;
this.applicationSelection = applicationSelection;
this.documentViewController = documentViewController;
}
@@ -72,7 +70,7 @@
log.Error(Resources.ProjectCommandHandler_AddNewItem_There_needs_to_be_a_project_to_add_an_item);
}
- using (var selectDataDialog = CreateSelectionDialogWithItems(applicationCore.GetSupportedDataItemInfos(parent).ToArray()))
+ using (var selectDataDialog = CreateSelectionDialogWithItems(GetSupportedDataItemInfos(parent).ToArray()))
{
if (selectDataDialog.ShowDialog() == DialogResult.OK)
{
@@ -94,11 +92,11 @@
projectOwner.Project.NotifyObservers();
}
- private SelectItemDialog CreateSelectionDialogWithItems(IEnumerable dataItemInfos)
+ private SelectItemDialog CreateSelectionDialogWithItems(IEnumerable supportedDataItemInfos)
{
var selectDataDialog = new SelectItemDialog(dialogOwner);
- foreach (var dataItemInfo in dataItemInfos)
+ foreach (var dataItemInfo in supportedDataItemInfos)
{
selectDataDialog.AddItemType(dataItemInfo.Name, dataItemInfo.Category, dataItemInfo.Image, dataItemInfo);
}
@@ -115,5 +113,21 @@
return dataItemInfo.CreateData != null ? dataItemInfo.CreateData(parent) : null;
}
+
+ ///
+ /// This method returns an enumeration of that are supported for .
+ ///
+ /// The owner to get the enumeration of supported for.
+ /// The enumeration of supported .
+ private IEnumerable GetSupportedDataItemInfos(object parent)
+ {
+ if (parent == null)
+ {
+ return Enumerable.Empty();
+ }
+
+ return dataItemInfos
+ .Where(dataItemInfo => dataItemInfo.AdditionalOwnerCheck == null || dataItemInfo.AdditionalOwnerCheck(parent));
+ }
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/GuiCore.cs
===================================================================
diff -u -r5b9a225deb21ddb302ddfd070154f61cd2d1b091 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 5b9a225deb21ddb302ddfd070154f61cd2d1b091)
+++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -125,7 +125,7 @@
exportImportCommandHandler = new ExportImportCommandHandler(MainWindow,
Plugins.SelectMany(p => p.GetFileImporters()),
Plugins.SelectMany(p => p.GetFileExporters()));
- projectCommandHandler = new ProjectCommandHandler(this, MainWindow, ApplicationCore, this, this);
+ projectCommandHandler = new ProjectCommandHandler(this, MainWindow, Plugins.SelectMany(p => p.GetDataItemInfos()), this, this);
WindowsApplication.EnableVisualStyles();
ViewPropertyEditor.ViewCommands = ViewCommands;
Index: Core/Common/src/Core.Common.Gui/Plugin/GuiPlugin.cs
===================================================================
diff -u -r5b9a225deb21ddb302ddfd070154f61cd2d1b091 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/src/Core.Common.Gui/Plugin/GuiPlugin.cs (.../GuiPlugin.cs) (revision 5b9a225deb21ddb302ddfd070154f61cd2d1b091)
+++ Core/Common/src/Core.Common.Gui/Plugin/GuiPlugin.cs (.../GuiPlugin.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.IO;
+using Core.Common.Base.Plugin;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.Forms;
@@ -78,6 +79,15 @@
}
///
+ /// This method returns an enumeration of .
+ ///
+ /// The enumeration of provided by the .
+ public virtual IEnumerable GetDataItemInfos()
+ {
+ yield break;
+ }
+
+ ///
/// Returns all instances provided for data of this plugin.
///
public virtual IEnumerable GetPropertyInfos()
Index: Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj
===================================================================
diff -u -r95072939afd1772892c79416dc2e9f747a8fe000 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 95072939afd1772892c79416dc2e9f747a8fe000)
+++ Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -97,7 +97,6 @@
-
Index: Core/Common/test/Core.Common.Base.Test/Plugin/ApplicationCoreTest.cs
===================================================================
diff -u -r5b9a225deb21ddb302ddfd070154f61cd2d1b091 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/test/Core.Common.Base.Test/Plugin/ApplicationCoreTest.cs (.../ApplicationCoreTest.cs) (revision 5b9a225deb21ddb302ddfd070154f61cd2d1b091)
+++ Core/Common/test/Core.Common.Base.Test/Plugin/ApplicationCoreTest.cs (.../ApplicationCoreTest.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -20,13 +20,8 @@
// All rights reserved.
using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using Core.Common.Base.IO;
using Core.Common.Base.Plugin;
using NUnit.Framework;
-using Rhino.Mocks;
namespace Core.Common.Base.Test.Plugin
{
@@ -42,125 +37,5 @@
// Assert
Assert.IsInstanceOf(applicationCore);
}
-
- [Test]
- public void GetSupportedDataItemInfos_SimpleApplicationPluginWithDataItemInfosAdded_ShouldOnlyProvideSupportedDataItemInfos()
- {
- // Setup
- var mocks = new MockRepository();
- var supportedDataItemInfo = new DataItemInfo
- {
- AdditionalOwnerCheck = o => true
- };
- var unsupportedDataItemInfo = new DataItemInfo
- {
- AdditionalOwnerCheck = o => false // AdditionalOwnerCheck false
- };
-
- mocks.ReplayAll();
-
- var applicationCore = new ApplicationCore();
- var applicationPlugin = new SimpleApplicationPlugin
- {
- DataItemInfos = new[]
- {
- supportedDataItemInfo,
- unsupportedDataItemInfo,
- }
- };
-
- applicationCore.AddPlugin(applicationPlugin);
-
- // Call
- var supportedDataItemInfos = applicationCore.GetSupportedDataItemInfos(new object()).ToArray();
-
- // Assert
- Assert.AreEqual(1, supportedDataItemInfos.Length);
- Assert.AreSame(supportedDataItemInfo, supportedDataItemInfos[0]);
- }
-
- [Test]
- public void GetSupportedDataItemInfos_SimpleApplicationPluginWithDataItemInfosAdded_ShouldProvideNoDataItemInfosWhenTargetEqualsNull()
- {
- // Setup
- var dataItemInfo = new DataItemInfo
- {
- AdditionalOwnerCheck = o => true
- };
-
- var applicationCore = new ApplicationCore();
- var applicationPlugin = new SimpleApplicationPlugin
- {
- DataItemInfos = new[]
- {
- dataItemInfo
- }
- };
-
- applicationCore.AddPlugin(applicationPlugin);
-
- // Call / Assert
- CollectionAssert.IsEmpty(applicationCore.GetSupportedDataItemInfos(null));
- }
-
- private class SimpleApplicationPlugin : ApplicationPlugin
- {
- public IEnumerable FileExporters { private get; set; }
-
- public IEnumerable DataItemInfos { private get; set; }
-
- public override IEnumerable GetDataItemInfos()
- {
- return DataItemInfos;
- }
- }
-
- private class SimpleFileImporter : FileImporterBase
- {
- public override string Name
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public override string Category
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public override Bitmap Image
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public override string FileFilter
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public override ProgressChangedDelegate ProgressChanged { protected get; set; }
-
- public override bool Import(object targetItem, string filePath)
- {
- throw new NotImplementedException();
- }
- }
-
- private class A {}
-
- private class B : A {}
-
- private class C : B {}
}
}
\ No newline at end of file
Fisheye: Tag 7709ae832723e3dd8499b674a7c78c75bae8e5d7 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Base.Test/Plugin/ApplicationPluginTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/test/Core.Common.Gui.Test/Commands/ProjectCommandHandlerTest.cs
===================================================================
diff -u -r151bab16a7ebc1bffc0621ab56c6dc219db1e90f -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/test/Core.Common.Gui.Test/Commands/ProjectCommandHandlerTest.cs (.../ProjectCommandHandlerTest.cs) (revision 151bab16a7ebc1bffc0621ab56c6dc219db1e90f)
+++ Core/Common/test/Core.Common.Gui.Test/Commands/ProjectCommandHandlerTest.cs (.../ProjectCommandHandlerTest.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -20,15 +20,11 @@
// All rights reserved.
using System.Windows.Forms;
-
using Core.Common.Base;
using Core.Common.Base.Data;
-using Core.Common.Base.Plugin;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Selection;
-
using NUnit.Framework;
-
using Rhino.Mocks;
namespace Core.Common.Gui.Test.Commands
@@ -42,13 +38,11 @@
// Setup
var project = new Project();
var childData = new object();
-
var mocks = new MockRepository();
var projectOwner = mocks.Stub();
projectOwner.Project = project;
var dialogParent = mocks.Stub();
- var applicationCore = mocks.Stub();
var applicationSelection = mocks.Stub();
var documentViewController = mocks.Stub();
@@ -57,9 +51,8 @@
mocks.ReplayAll();
project.Attach(observer);
+ var commandHandler = new ProjectCommandHandler(projectOwner, dialogParent, null, applicationSelection, documentViewController);
- var commandHandler = new ProjectCommandHandler(projectOwner, dialogParent, applicationCore, applicationSelection, documentViewController);
-
// Call
commandHandler.AddItemToProject(childData);
Index: Core/Common/test/Core.Common.Gui.Test/Plugin/GuiPluginTest.cs
===================================================================
diff -u -r5b9a225deb21ddb302ddfd070154f61cd2d1b091 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Core/Common/test/Core.Common.Gui.Test/Plugin/GuiPluginTest.cs (.../GuiPluginTest.cs) (revision 5b9a225deb21ddb302ddfd070154f61cd2d1b091)
+++ Core/Common/test/Core.Common.Gui.Test/Plugin/GuiPluginTest.cs (.../GuiPluginTest.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System.Linq;
using Core.Common.Gui.Plugin;
using NUnit.Framework;
using Rhino.Mocks;
@@ -236,6 +237,19 @@
}
[Test]
+ public void GetDataItemInfos_ReturnEmptyEnumerable()
+ {
+ // Setup
+ var guiPlugin = new SimpleGuiPlugin();
+
+ // Call
+ var dataItemInfos = guiPlugin.GetDataItemInfos().ToArray();
+
+ // Assert
+ CollectionAssert.IsEmpty(dataItemInfos);
+ }
+
+ [Test]
public void Dispose_SetGuiToNull()
{
// Setup
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsApplicationPlugin.cs
===================================================================
diff -u -raf42240385db3d3f04bca830513c7464e6f74668 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsApplicationPlugin.cs (.../RingtoetsApplicationPlugin.cs) (revision af42240385db3d3f04bca830513c7464e6f74668)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsApplicationPlugin.cs (.../RingtoetsApplicationPlugin.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -19,13 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System.Collections.Generic;
-using System.Linq;
-using Core.Common.Base.Data;
using Core.Common.Base.Plugin;
-using Ringtoets.Common.Data.AssessmentSection;
-using Ringtoets.Common.Forms.Helpers;
-using Ringtoets.Integration.Data;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
using RingtoetsFormsResources = Ringtoets.Integration.Forms.Properties.Resources;
@@ -34,28 +28,5 @@
///
/// The application plugin for Ringtoets.
///
- public class RingtoetsApplicationPlugin : ApplicationPlugin
- {
- public override IEnumerable GetDataItemInfos()
- {
- yield return new DataItemInfo
- {
- Name = RingtoetsFormsResources.AssessmentSection_DisplayName,
- Category = RingtoetsCommonFormsResources.Ringtoets_Category,
- Image = RingtoetsFormsResources.AssessmentSectionFolderIcon,
- CreateData = owner =>
- {
- var project = (Project) owner;
- var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
- assessmentSection.Name = GetUniqueForAssessmentSectionName(project, assessmentSection.Name);
- return assessmentSection;
- }
- };
- }
-
- private static string GetUniqueForAssessmentSectionName(Project project, string baseName)
- {
- return NamingHelper.GetUniqueName(project.Items.OfType(), baseName, a => a.Name);
- }
- }
+ public class RingtoetsApplicationPlugin : ApplicationPlugin {}
}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -raf42240385db3d3f04bca830513c7464e6f74668 -r7709ae832723e3dd8499b674a7c78c75bae8e5d7
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision af42240385db3d3f04bca830513c7464e6f74668)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 7709ae832723e3dd8499b674a7c78c75bae8e5d7)
@@ -27,6 +27,7 @@
using System.Windows.Forms;
using Core.Common.Base.Data;
using Core.Common.Base.IO;
+using Core.Common.Base.Plugin;
using Core.Common.Controls.TreeView;
using Core.Common.Controls.Views;
using Core.Common.Gui;
@@ -42,6 +43,7 @@
using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Probability;
+using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.PropertyClasses;
using Ringtoets.Common.Forms.TreeNodeInfos;
@@ -53,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.PresentationObjects;
@@ -316,6 +319,23 @@
yield return new FailureMechanismSectionsImporter();
}
+ public override IEnumerable GetDataItemInfos()
+ {
+ yield return new DataItemInfo
+ {
+ Name = RingtoetsFormsResources.AssessmentSection_DisplayName,
+ Category = RingtoetsCommonFormsResources.Ringtoets_Category,
+ Image = RingtoetsFormsResources.AssessmentSectionFolderIcon,
+ CreateData = owner =>
+ {
+ var project = (Project)owner;
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ assessmentSection.Name = GetUniqueForAssessmentSectionName(project, assessmentSection.Name);
+ return assessmentSection;
+ }
+ };
+ }
+
///
/// Gets the child data instances that have definitions of some parent data object.
///
@@ -645,6 +665,11 @@
#region AssessmentSection
+ private static string GetUniqueForAssessmentSectionName(Project project, string baseName)
+ {
+ return NamingHelper.GetUniqueName(project.Items.OfType(), baseName, a => a.Name);
+ }
+
private object[] AssessmentSectionChildNodeObjects(IAssessmentSection nodeData)
{
var childNodes = new List