Index: Core/Gui/src/Core.Gui/GuiCore.cs =================================================================== diff -u -r76fb7e42934ada3ec6ec79f986ff5fe3e026433b -rfa4af6aff7cfd67238db0daaef5560aa86ac9e3e --- Core/Gui/src/Core.Gui/GuiCore.cs (.../GuiCore.cs) (revision 76fb7e42934ada3ec6ec79f986ff5fe3e026433b) +++ Core/Gui/src/Core.Gui/GuiCore.cs (.../GuiCore.cs) (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -27,7 +27,6 @@ using System.Globalization; using System.Linq; using System.Reflection; -using System.Web.UI.WebControls; using System.Windows; using Core.Common.Base; using Core.Common.Base.Data; @@ -44,6 +43,7 @@ using Core.Gui.Forms.ViewHost; using Core.Gui.Helpers; using Core.Gui.Plugin; +using Core.Gui.Plugin.Map; using Core.Gui.Properties; using Core.Gui.Settings; using log4net; @@ -485,7 +485,8 @@ DocumentViewController = new DocumentViewController(ViewHost, Plugins.SelectMany(p => p.GetViewInfos()), mainWindow); - PropertyResolver = new PropertyResolver(Plugins.SelectMany(p => p.GetPropertyInfos())); + PropertyResolver = new PropertyResolver(Plugins.SelectMany(p => p.GetPropertyInfos()) + .Concat(MapPropertyInfoFactory.Create())); applicationFeatureCommands = new ApplicationFeatureCommandHandler(PropertyResolver, mainWindow); mainWindow.InitializeToolWindows(); Index: Core/Gui/src/Core.Gui/Plugin/Map/MapPropertyInfoFactory.cs =================================================================== diff -u --- Core/Gui/src/Core.Gui/Plugin/Map/MapPropertyInfoFactory.cs (revision 0) +++ Core/Gui/src/Core.Gui/Plugin/Map/MapPropertyInfoFactory.cs (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Collections.Generic; +using Core.Components.Gis.Data; +using Core.Gui.Forms.Map; +using Core.Gui.Helpers; +using Core.Gui.PresentationObjects.Map; +using Core.Gui.PropertyClasses.Map; + +namespace Core.Gui.Plugin.Map +{ + /// + /// Factory for creating objects for . + /// + public static class MapPropertyInfoFactory + { + /// + /// Creates the objects. + /// + /// The creates objects. + public static IEnumerable Create() + { + yield return new PropertyInfo + { + CreateInstance = context => new MapDataCollectionProperties( + (MapDataCollection) context.WrappedData) + }; + yield return new PropertyInfo + { + CreateInstance = context => new MapPointDataProperties( + (MapPointData) context.WrappedData, + MapDataContextHelper.GetParentsFromContext(context)) + }; + yield return new PropertyInfo + { + CreateInstance = context => new MapLineDataProperties( + (MapLineData) context.WrappedData, + MapDataContextHelper.GetParentsFromContext(context)) + }; + yield return new PropertyInfo + { + CreateInstance = context => new MapPolygonDataProperties( + (MapPolygonData) context.WrappedData, + MapDataContextHelper.GetParentsFromContext(context)) + }; + } + + } +} \ No newline at end of file Index: Core/Gui/test/Core.Gui.Test/Plugin/Map/MapDataCollectionContextPropertyInfoTest.cs =================================================================== diff -u --- Core/Gui/test/Core.Gui.Test/Plugin/Map/MapDataCollectionContextPropertyInfoTest.cs (revision 0) +++ Core/Gui/test/Core.Gui.Test/Plugin/Map/MapDataCollectionContextPropertyInfoTest.cs (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Components.Gis.Data; +using Core.Gui.Plugin; +using Core.Gui.Plugin.Map; +using Core.Gui.PresentationObjects.Map; +using Core.Gui.PropertyBag; +using Core.Gui.PropertyClasses.Map; +using NUnit.Framework; + +namespace Core.Gui.Test.Plugin.Map +{ + [TestFixture] + public class FailureMechanismSectionsPropertyInfoTest + { + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + info = MapPropertyInfoFactory.Create().Single(pi => pi.PropertyObjectType == typeof(MapDataCollectionProperties)); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(MapDataCollectionContext), info.DataType); + Assert.AreEqual(typeof(MapDataCollectionProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithValidArguments_NewPropertiesWithMapDataCollectionAsData() + { + // Setup + var mapDataCollection = new MapDataCollection("Test"); + var context = new MapDataCollectionContext(mapDataCollection, null); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(mapDataCollection, objectProperties.Data); + } + } +} \ No newline at end of file Index: Core/Gui/test/Core.Gui.Test/Plugin/Map/MapLineDataContextPropertyInfoTest.cs =================================================================== diff -u --- Core/Gui/test/Core.Gui.Test/Plugin/Map/MapLineDataContextPropertyInfoTest.cs (revision 0) +++ Core/Gui/test/Core.Gui.Test/Plugin/Map/MapLineDataContextPropertyInfoTest.cs (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Components.Gis.Data; +using Core.Gui.Plugin; +using Core.Gui.Plugin.Map; +using Core.Gui.PresentationObjects.Map; +using Core.Gui.PropertyBag; +using Core.Gui.PropertyClasses.Map; +using NUnit.Framework; + +namespace Core.Gui.Test.Plugin.Map +{ + [TestFixture] + public class MapLineDataContextPropertyInfoTest + { + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + info = MapPropertyInfoFactory.Create().Single(pi => pi.PropertyObjectType == typeof(MapLineDataProperties)); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(MapLineDataContext), info.DataType); + Assert.AreEqual(typeof(MapLineDataProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithValidArguments_NewPropertiesWithMapLineDataAsData() + { + // Setup + var mapData = new MapLineData("Test"); + var context = new MapLineDataContext(mapData, new MapDataCollectionContext(new MapDataCollection("test"), null)); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(mapData, objectProperties.Data); + } + } +} \ No newline at end of file Index: Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPointDataContextPropertyInfoTest.cs =================================================================== diff -u --- Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPointDataContextPropertyInfoTest.cs (revision 0) +++ Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPointDataContextPropertyInfoTest.cs (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Components.Gis.Data; +using Core.Gui.Plugin; +using Core.Gui.Plugin.Map; +using Core.Gui.PresentationObjects.Map; +using Core.Gui.PropertyBag; +using Core.Gui.PropertyClasses.Map; +using NUnit.Framework; + +namespace Core.Gui.Test.Plugin.Map +{ + [TestFixture] + public class MapPointDataContextPropertyInfoTest + { + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + info = MapPropertyInfoFactory.Create().Single(pi => pi.PropertyObjectType == typeof(MapPointDataProperties)); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(MapPointDataContext), info.DataType); + Assert.AreEqual(typeof(MapPointDataProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithValidArguments_NewPropertiesWithMapPointDataAsData() + { + // Setup + var mapData = new MapPointData("Test"); + var context = new MapPointDataContext(mapData, new MapDataCollectionContext(new MapDataCollection("test"), null)); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(mapData, objectProperties.Data); + } + } +} \ No newline at end of file Index: Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPolygonDataContextPropertyInfoTest.cs =================================================================== diff -u --- Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPolygonDataContextPropertyInfoTest.cs (revision 0) +++ Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPolygonDataContextPropertyInfoTest.cs (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Components.Gis.Data; +using Core.Gui.Plugin; +using Core.Gui.Plugin.Map; +using Core.Gui.PresentationObjects.Map; +using Core.Gui.PropertyBag; +using Core.Gui.PropertyClasses.Map; +using NUnit.Framework; + +namespace Core.Gui.Test.Plugin.Map +{ + [TestFixture] + public class MapPolygonDataContextPropertyInfoTest + { + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + info = MapPropertyInfoFactory.Create().Single(pi => pi.PropertyObjectType == typeof(MapPolygonDataProperties)); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(MapPolygonDataContext), info.DataType); + Assert.AreEqual(typeof(MapPolygonDataProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithValidArguments_NewPropertiesWithMapPolygonDataAsData() + { + // Setup + var mapData = new MapPolygonData("Test"); + var context = new MapPolygonDataContext(mapData, new MapDataCollectionContext(new MapDataCollection("test"), null)); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(mapData, objectProperties.Data); + } + } +} \ No newline at end of file Index: Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPropertyInfoFactoryTest.cs =================================================================== diff -u --- Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPropertyInfoFactoryTest.cs (revision 0) +++ Core/Gui/test/Core.Gui.Test/Plugin/Map/MapPropertyInfoFactoryTest.cs (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -0,0 +1,65 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Gui.Plugin; +using Core.Gui.Plugin.Map; +using Core.Gui.PresentationObjects.Map; +using Core.Gui.PropertyClasses.Map; +using Core.Gui.TestUtil; +using NUnit.Framework; + +namespace Core.Gui.Test.Plugin.Map +{ + [TestFixture] + public class MapPropertyInfoFactoryTest + { + [Test] + public void Create_Always_ReturnsPropertyInfos() + { + // Call + PropertyInfo[] propertyInfos = MapPropertyInfoFactory.Create().ToArray(); + + // Assert + Assert.AreEqual(4, propertyInfos.Length); + + PluginTestHelper.AssertPropertyInfoDefined( + propertyInfos, + typeof(MapDataCollectionContext), + typeof(MapDataCollectionProperties)); + + PluginTestHelper.AssertPropertyInfoDefined( + propertyInfos, + typeof(MapPointDataContext), + typeof(MapPointDataProperties)); + + PluginTestHelper.AssertPropertyInfoDefined( + propertyInfos, + typeof(MapLineDataContext), + typeof(MapLineDataProperties)); + + PluginTestHelper.AssertPropertyInfoDefined( + propertyInfos, + typeof(MapPolygonDataContext), + typeof(MapPolygonDataProperties)); + } + } +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.Map/MapPlugin.cs =================================================================== diff -u -rf0f17d026a0647b413041c182da7dc2f1d001c18 -rfa4af6aff7cfd67238db0daaef5560aa86ac9e3e --- Core/Plugins/src/Core.Plugins.Map/MapPlugin.cs (.../MapPlugin.cs) (revision f0f17d026a0647b413041c182da7dc2f1d001c18) +++ Core/Plugins/src/Core.Plugins.Map/MapPlugin.cs (.../MapPlugin.cs) (revision fa4af6aff7cfd67238db0daaef5560aa86ac9e3e) @@ -56,28 +56,8 @@ Gui.ViewHost.ActiveDocumentViewChanged += OnActiveDocumentViewChanged; activated = true; - } + } - public override IEnumerable GetPropertyInfos() - { - yield return new PropertyInfo - { - CreateInstance = context => new MapDataCollectionProperties((MapDataCollection) context.WrappedData) - }; - yield return new PropertyInfo - { - CreateInstance = context => new MapPointDataProperties((MapPointData) context.WrappedData, MapDataContextHelper.GetParentsFromContext(context)) - }; - yield return new PropertyInfo - { - CreateInstance = context => new MapLineDataProperties((MapLineData) context.WrappedData, MapDataContextHelper.GetParentsFromContext(context)) - }; - yield return new PropertyInfo - { - CreateInstance = context => new MapPolygonDataProperties((MapPolygonData) context.WrappedData, MapDataContextHelper.GetParentsFromContext(context)) - }; - } - public override IEnumerable GetImportInfos() { yield return new ImportInfo Fisheye: Tag fa4af6aff7cfd67238db0daaef5560aa86ac9e3e refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.Map.Test/PropertyInfos/MapDataCollectionContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fa4af6aff7cfd67238db0daaef5560aa86ac9e3e refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.Map.Test/PropertyInfos/MapLineDataContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fa4af6aff7cfd67238db0daaef5560aa86ac9e3e refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.Map.Test/PropertyInfos/MapPointDataContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fa4af6aff7cfd67238db0daaef5560aa86ac9e3e refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.Map.Test/PropertyInfos/MapPolygonDataContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff?