Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj =================================================================== diff -u -rf67a4a5faeca53255e37c31e7eb849e5dd8d54f9 -r62866464bfe7d4dc1949370f577365d51c25bfa0 --- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision f67a4a5faeca53255e37c31e7eb849e5dd8d54f9) +++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -105,7 +105,6 @@ - Fisheye: Tag 62866464bfe7d4dc1949370f577365d51c25bfa0 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Base/Plugin/DataItemInfo.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Gui/Commands/ProjectCommandHandler.cs =================================================================== diff -u -r1e5d9b5cfc66cb8187d534d891afef1c9080378b -r62866464bfe7d4dc1949370f577365d51c25bfa0 --- Core/Common/src/Core.Common.Gui/Commands/ProjectCommandHandler.cs (.../ProjectCommandHandler.cs) (revision 1e5d9b5cfc66cb8187d534d891afef1c9080378b) +++ Core/Common/src/Core.Common.Gui/Commands/ProjectCommandHandler.cs (.../ProjectCommandHandler.cs) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -23,8 +23,7 @@ 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.Plugin; using Core.Common.Gui.Properties; using Core.Common.Gui.Selection; using log4net; @@ -61,7 +60,6 @@ this.dataItemInfos = dataItemInfos; this.applicationSelection = applicationSelection; this.viewController = viewController; - } public void AddNewItem(object parent) Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -r3fdd2bee85bdf8b556c52d6706ed887c2b70bed4 -r62866464bfe7d4dc1949370f577365d51c25bfa0 --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 3fdd2bee85bdf8b556c52d6706ed887c2b70bed4) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -151,6 +151,7 @@ + Index: Core/Common/src/Core.Common.Gui/Plugin/DataItemInfo.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Plugin/DataItemInfo.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Plugin/DataItemInfo.cs (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -0,0 +1,147 @@ +// 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.Drawing; + +namespace Core.Common.Gui.Plugin +{ + /// + /// Class that holds information for creating data objects. + /// + public class DataItemInfo + { + /// + /// Constructs a new . + /// + public DataItemInfo() + { + Name = ""; + Category = ""; + } + + /// + /// Gets or sets the of the data to create. + /// + public Type ValueType { get; set; } + + /// + /// Gets or sets the name of the data to create. + /// + public string Name { get; set; } + + /// + /// Gets or sets the category of the data to create. + /// + public string Category { get; set; } + + /// + /// Gets or sets the image of the data to create. + /// + public Image Image { get; set; } + + /// + /// Gets or sets a method for determining whether or not the data item information is relevant for the proposed owner. + /// + public Func AdditionalOwnerCheck { get; set; } + + /// + /// Gets or sets a function for creating the data. + /// The object parameter holds the proposed owner of the data to create. + /// + public Func CreateData { get; set; } + } + + /// + /// Class that holds information for creating data objects. + /// + /// The type of data to create. + public class DataItemInfo + { + /// + /// Constructs a new . + /// + public DataItemInfo() + { + Name = ""; + Category = ""; + } + + /// + /// Gets the of the data to create. + /// + public Type ValueType + { + get + { + return typeof(TValue); + } + } + + /// + /// Gets or sets the name of the data to create. + /// + public string Name { get; set; } + + /// + /// Gets or sets the category of the data to create. + /// + public string Category { get; set; } + + /// + /// Gets or sets the image of the data to create. + /// + public Image Image { get; set; } + + /// + /// Gets or sets a method for determining whether or not the data item information is relevant for the proposed owner. + /// + public Func AdditionalOwnerCheck { get; set; } + + /// + /// Gets or sets a function for creating the data. + /// The object parameter holds the proposed owner of the data to create. + /// + public Func CreateData { get; set; } + + /// + /// This operator converts a into a . + /// + /// The to convert. + /// The converted . + public static implicit operator DataItemInfo(DataItemInfo dataItemInfo) + { + return new DataItemInfo + { + ValueType = dataItemInfo.ValueType, + Name = dataItemInfo.Name, + Category = dataItemInfo.Category, + Image = dataItemInfo.Image, + AdditionalOwnerCheck = dataItemInfo.AdditionalOwnerCheck != null + ? owner => dataItemInfo.AdditionalOwnerCheck(owner) + : (Func) null, + CreateData = dataItemInfo.CreateData != null + ? owner => dataItemInfo.CreateData(owner) + : (Func) null + }; + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Plugin/PluginBase.cs =================================================================== diff -u -r6fefc4422dcc5076f0ff430f73d829a6670f0285 -r62866464bfe7d4dc1949370f577365d51c25bfa0 --- Core/Common/src/Core.Common.Gui/Plugin/PluginBase.cs (.../PluginBase.cs) (revision 6fefc4422dcc5076f0ff430f73d829a6670f0285) +++ Core/Common/src/Core.Common.Gui/Plugin/PluginBase.cs (.../PluginBase.cs) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -23,7 +23,6 @@ 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; Index: Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj =================================================================== diff -u -rf67a4a5faeca53255e37c31e7eb849e5dd8d54f9 -r62866464bfe7d4dc1949370f577365d51c25bfa0 --- Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision f67a4a5faeca53255e37c31e7eb849e5dd8d54f9) +++ Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -79,7 +79,6 @@ 3.5 - @@ -96,7 +95,6 @@ - @@ -112,10 +110,6 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base - - {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} - Core.Common.Utils - {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Fisheye: Tag 62866464bfe7d4dc1949370f577365d51c25bfa0 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Base.Test/Plugin/DataItemInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj =================================================================== diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -r62866464bfe7d4dc1949370f577365d51c25bfa0 --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -133,6 +133,7 @@ TestView.cs + Index: Core/Common/test/Core.Common.Gui.Test/Plugin/DataItemInfoTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Plugin/DataItemInfoTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Plugin/DataItemInfoTest.cs (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -0,0 +1,152 @@ +// 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.Drawing; +using Core.Common.Gui.Plugin; +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Plugin +{ + [TestFixture] + public class DataItemInfoTest + { + [Test] + public void DefaultConstructor_NonGeneric_ExpectedValues() + { + // Call + var dataItemInfo = new DataItemInfo(); + + // Assert + Assert.IsNull(dataItemInfo.ValueType); + Assert.AreEqual("", dataItemInfo.Name); + Assert.AreEqual("", dataItemInfo.Category); + Assert.IsNull(dataItemInfo.Image); + Assert.IsNull(dataItemInfo.AdditionalOwnerCheck); + Assert.IsNull(dataItemInfo.CreateData); + } + + [Test] + public void DefaultConstructor_Generic_ExpectedValues() + { + // Call + var dataItemInfo = new DataItemInfo(); + + // Assert + Assert.AreEqual(typeof(double), dataItemInfo.ValueType); + Assert.AreEqual("", dataItemInfo.Name); + Assert.AreEqual("", dataItemInfo.Category); + Assert.IsNull(dataItemInfo.Image); + Assert.IsNull(dataItemInfo.AdditionalOwnerCheck); + Assert.IsNull(dataItemInfo.CreateData); + } + + [Test] + public void GetSetAutomaticProperties_NonGeneric_ExpectedBehavior() + { + // Setup / Call + var dataItemInfo = new DataItemInfo + { + ValueType = typeof(double), + Name = "Some double", + Category = "Nice category", + Image = new Bitmap(16, 16), + AdditionalOwnerCheck = o => true, + CreateData = o => 1.2, + }; + + // Assert + Assert.AreEqual(typeof(double), dataItemInfo.ValueType); + Assert.AreEqual("Some double", dataItemInfo.Name); + Assert.AreEqual("Nice category", dataItemInfo.Category); + Assert.IsNotNull(dataItemInfo.Image); + Assert.IsTrue(dataItemInfo.AdditionalOwnerCheck(null)); + Assert.AreEqual(1.2, dataItemInfo.CreateData(null)); + } + + [Test] + public void GetSetAutomaticProperties_Generic_ExpectedBehavior() + { + // Setup / Call + var dataItemInfo = new DataItemInfo + { + Name = "Some integer", + Category = "Better category", + Image = new Bitmap(16, 16), + AdditionalOwnerCheck = o => false, + CreateData = o => -1, + }; + + // assert + Assert.AreEqual(typeof(int), dataItemInfo.ValueType); + Assert.AreEqual("Some integer", dataItemInfo.Name); + Assert.AreEqual("Better category", dataItemInfo.Category); + Assert.IsNotNull(dataItemInfo.Image); + Assert.IsFalse(dataItemInfo.AdditionalOwnerCheck(null)); + Assert.AreEqual(-1, dataItemInfo.CreateData(null)); + } + + [Test] + public void ImplicitConversion_FromGenericToNonGeneric_ShouldCopyValues() + { + // Setup + var info = new DataItemInfo + { + Name = "Some integer", + Category = "Better category", + Image = new Bitmap(16, 16), + AdditionalOwnerCheck = o => false, + CreateData = o => -1, + }; + + // Call + var nonGenericInfo = (DataItemInfo) info; + + // Assert + Assert.AreEqual(info.ValueType, nonGenericInfo.ValueType); + Assert.AreEqual(info.Name, nonGenericInfo.Name); + Assert.AreEqual(info.Category, nonGenericInfo.Category); + Assert.AreEqual(info.AdditionalOwnerCheck(1), nonGenericInfo.AdditionalOwnerCheck(1)); + Assert.AreEqual(info.CreateData(null), nonGenericInfo.CreateData(null)); + } + + [Test] + public void ImplicitConversion_FromGenericToNonGenericWithoutMethodsSet_MethodsShouldBeNull() + { + // Setup + var info = new DataItemInfo + { + Name = "Some integer", + Category = "Better category", + Image = new Bitmap(16, 16) + }; + + // Call + var nonGenericInfo = (DataItemInfo) info; + + // Assert + Assert.AreEqual(info.ValueType, nonGenericInfo.ValueType); + Assert.AreEqual(info.Name, nonGenericInfo.Name); + Assert.AreEqual(info.Category, nonGenericInfo.Category); + Assert.IsNull(nonGenericInfo.AdditionalOwnerCheck); + Assert.IsNull(nonGenericInfo.CreateData); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r1e5d9b5cfc66cb8187d534d891afef1c9080378b -r62866464bfe7d4dc1949370f577365d51c25bfa0 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 1e5d9b5cfc66cb8187d534d891afef1c9080378b) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) @@ -28,13 +28,11 @@ 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; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms; -using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.Forms.ProgressDialog; using Core.Common.Gui.Plugin; using Core.Common.IO.Exceptions;