Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPolygonDataProperties.cs =================================================================== diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -rc8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04 --- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPolygonDataProperties.cs (.../MapPolygonDataProperties.cs) (revision ac96d7c315129af851634ed5a4a6800b59ede718) +++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPolygonDataProperties.cs (.../MapPolygonDataProperties.cs) (revision c8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04) @@ -44,7 +44,8 @@ } } - [PropertyOrder(5)] + [PropertyOrder(8)] + [DynamicVisible] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_Color_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.MapPolygonData_FillColor_Description))] @@ -63,7 +64,8 @@ } } - [PropertyOrder(6)] + [PropertyOrder(9)] + [DynamicReadOnly] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_StrokeColor_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.MapPolygonData_StrokeColor_Description))] @@ -82,7 +84,8 @@ } } - [PropertyOrder(7)] + [PropertyOrder(10)] + [DynamicReadOnly] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_StrokeThickness_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.MapPolygonData_StrokeThickness_Description))] @@ -98,5 +101,26 @@ data.NotifyObservers(); } } + + public override bool DynamicVisibleValidationMethod(string propertyName) + { + if (propertyName == nameof(FillColor)) + { + return data.MapTheme == null; + } + + return base.DynamicVisibleValidationMethod(propertyName); + } + + public override bool DynamicReadonlyValidator(string propertyName) + { + if (propertyName == nameof(StrokeColor) + || propertyName == nameof(StrokeThickness)) + { + return data.MapTheme != null; + } + + return base.DynamicReadonlyValidator(propertyName); + } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs =================================================================== diff -u -r9e62d5abb9940400c2ce525fe16ed0a4bfa44629 -rc8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04 --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs (.../MapLineDataPropertiesTest.cs) (revision 9e62d5abb9940400c2ce525fe16ed0a4bfa44629) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs (.../MapLineDataPropertiesTest.cs) (revision c8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04) @@ -58,6 +58,11 @@ Assert.IsInstanceOf>(properties); Assert.IsNull(properties.Data); Assert.AreEqual("Lijnen", properties.Type); + + TestHelper.AssertTypeConverter( + nameof(MapLineDataProperties.Color)); + TestHelper.AssertTypeConverter( + nameof(MapLineDataProperties.DashStyle)); } [Test] @@ -81,7 +86,6 @@ const string styleCategory = "Stijl"; PropertyDescriptor colorProperty = dynamicProperties[colorPropertyIndex]; - Assert.IsInstanceOf(colorProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty, styleCategory, "Kleur", @@ -133,7 +137,6 @@ true); PropertyDescriptor styleProperty = dynamicProperties[styleWithMapThemePropertyIndex]; - Assert.IsInstanceOf(styleProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(styleProperty, styleCategory, "Lijnstijl", @@ -336,7 +339,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void DynamicVisibleValidationMethod_MapDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) + public void DynamicVisibleValidationMethod_MapLineDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) { // Setup var mapLineData = new MapLineData("Test") Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs =================================================================== diff -u -r9e62d5abb9940400c2ce525fe16ed0a4bfa44629 -rc8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04 --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision 9e62d5abb9940400c2ce525fe16ed0a4bfa44629) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision c8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04) @@ -62,10 +62,17 @@ Assert.IsInstanceOf>(properties); Assert.IsNull(properties.Data); Assert.AreEqual("Punten", properties.Type); + + TestHelper.AssertTypeConverter( + nameof(MapPointDataProperties.Color)); + TestHelper.AssertTypeConverter( + nameof(MapPointDataProperties.StrokeColor)); + TestHelper.AssertTypeConverter( + nameof(MapPointDataProperties.Symbol)); } [Test] - public void Constructor_Always_PropertiesHaveExpectedAttributesValues() + public void Constructor_MapPointDataWithoutMapTheme_PropertiesHaveExpectedAttributesValues() { // Setup var mapPointData = new MapPointData("Test") @@ -89,14 +96,12 @@ const string styleCategory = "Stijl"; PropertyDescriptor colorProperty = dynamicProperties[colorPropertyIndex]; - Assert.IsInstanceOf(colorProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty, styleCategory, "Kleur", "De kleur van de symbolen waarmee deze kaartlaag wordt weergegeven."); PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorPropertyIndex]; - Assert.IsInstanceOf(strokeColorProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, styleCategory, "Lijnkleur", @@ -115,15 +120,14 @@ "De grootte van de symbolen waarmee deze kaartlaag wordt weergegeven."); PropertyDescriptor symbolProperty = dynamicProperties[symbolPropertyIndex]; - Assert.IsInstanceOf(symbolProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(symbolProperty, styleCategory, "Symbool", "Het symbool waarmee deze kaartlaag wordt weergegeven."); } [Test] - public void Constructor_MapLineDataWithMapTheme_PropertiesHaveExpectedAttributesValues() + public void Constructor_MapPointDataWithMapTheme_PropertiesHaveExpectedAttributesValues() { // Setup var mapPointData = new MapPointData("Test") @@ -151,7 +155,6 @@ const string styleCategory = "Stijl"; PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorWithMapThemePropertyIndex]; - Assert.IsInstanceOf(strokeColorProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, styleCategory, "Lijnkleur", @@ -275,15 +278,15 @@ feature.MetaData["key"] = "value"; } - var mapData = new MapLineData("Test") + var mapData = new MapPointData("Test") { Features = new[] { feature } }; - var properties = new MapLineDataProperties + var properties = new MapPointDataProperties { Data = mapData }; @@ -302,7 +305,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void DynamicReadOnlyValidator_MapLineDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) + public void DynamicReadOnlyValidator_MapPointDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) { // Setup var mapData = new MapPointData("Test") @@ -374,19 +377,19 @@ public void DynamicVisibleValidationMethod_ShowLabels_ReturnsExpectedValuesForRelevantProperties(bool showLabels) { // Setup - var mapLineData = new MapLineData("Test") + var mapPointData = new MapPointData("Test") { ShowLabels = showLabels }; - var properties = new MapLineDataProperties + var properties = new MapPointDataProperties { - Data = mapLineData + Data = mapPointData }; // Call bool isSelectedMetaDataAttributeVisible = properties.DynamicVisibleValidationMethod( - nameof(MapLineDataProperties.SelectedMetaDataAttribute)); + nameof(MapPointDataProperties.SelectedMetaDataAttribute)); // Assert Assert.AreEqual(showLabels, isSelectedMetaDataAttributeVisible); @@ -395,7 +398,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void DynamicVisibleValidationMethod_MapDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) + public void DynamicVisibleValidationMethod_MapPointDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) { // Setup var mapPointData = new MapPointData("Test") Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPolygonDataPropertiesTest.cs =================================================================== diff -u -rd1b19bb139550ae19f474c28f94ff3329cae0236 -rc8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04 --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPolygonDataPropertiesTest.cs (.../MapPolygonDataPropertiesTest.cs) (revision d1b19bb139550ae19f474c28f94ff3329cae0236) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPolygonDataPropertiesTest.cs (.../MapPolygonDataPropertiesTest.cs) (revision c8e0c3cf1d78b5e7b79945ca64e4fe7c1ad92a04) @@ -29,6 +29,8 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; +using Core.Components.Gis.TestUtil; +using Core.Components.Gis.Theme; using Core.Plugins.Map.PropertyClasses; using NUnit.Framework; using Rhino.Mocks; @@ -42,6 +44,9 @@ private const int strokeColorPropertyIndex = 7; private const int strokeThicknessPropertyIndex = 8; + private const int strokeColorWithMapThemePropertyIndex = 8; + private const int strokeThicknessWithMapThemePropertyIndex = 9; + [Test] public void Constructor_ExpectedValues() { @@ -52,10 +57,16 @@ Assert.IsInstanceOf>(properties); Assert.IsNull(properties.Data); Assert.AreEqual("Polygonen", properties.Type); + + TestHelper.AssertTypeConverter( + nameof(MapPolygonDataProperties.FillColor)); + + TestHelper.AssertTypeConverter( + nameof(MapPolygonDataProperties.StrokeColor)); } [Test] - public void Constructor_Always_PropertiesHaveExpectedAttributesValues() + public void Constructor_MapPolygonDataWithoutMapTheme_PropertiesHaveExpectedAttributesValues() { // Setup var mapPolygonData = new MapPolygonData("Test") @@ -79,15 +90,13 @@ const string styleCategory = "Stijl"; PropertyDescriptor colorProperty = dynamicProperties[fillColorPropertyIndex]; - Assert.IsInstanceOf(colorProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(colorProperty, styleCategory, "Kleur", "De kleur van de vlakken waarmee deze kaartlaag wordt weergegeven."); - PropertyDescriptor widthProperty = dynamicProperties[strokeColorPropertyIndex]; - Assert.IsInstanceOf(colorProperty.Converter); - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(widthProperty, + PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, styleCategory, "Lijnkleur", "De kleur van de lijn van de vlakken waarmee deze kaartlaag wordt weergegeven."); @@ -100,6 +109,49 @@ } [Test] + public void Constructor_MapPolygonDataWithMapTheme_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mapPolygonData = new MapPolygonData("Test") + { + Features = new[] + { + new MapFeature(Enumerable.Empty()) + }, + ShowLabels = true, + MapTheme = new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + }; + + // Call + var properties = new MapPolygonDataProperties + { + Data = mapPolygonData + }; + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(10, dynamicProperties.Count); + const string styleCategory = "Stijl"; + + PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorWithMapThemePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, + styleCategory, + "Lijnkleur", + "De kleur van de lijn van de vlakken waarmee deze kaartlaag wordt weergegeven.", + true); + + PropertyDescriptor styleProperty = dynamicProperties[strokeThicknessWithMapThemePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(styleProperty, + styleCategory, + "Lijndikte", + "De dikte van de lijn van de vlakken waarmee deze kaartlaag wordt weergegeven.", + true); + } + + [Test] public void Data_SetNewMapPolygonDataInstance_ReturnCorrectPropertyValues() { // Setup @@ -167,5 +219,191 @@ Assert.AreEqual(newStrokeThickness, mapPolygonData.Style.StrokeThickness); mocks.VerifyAll(); } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicReadOnlyValidator_MapHasMetaData_ReturnsExpectedValuesForRelevantProperties(bool hasMetaData) + { + // Setup + var feature = new MapFeature(Enumerable.Empty()); + if (hasMetaData) + { + feature.MetaData["key"] = "value"; + } + + var mapData = new MapPolygonData("Test") + { + Features = new[] + { + feature + } + }; + + var properties = new MapPolygonDataProperties + { + Data = mapData + }; + + // Call + bool isShowLabelReadOnly = properties.DynamicReadonlyValidator( + nameof(properties.ShowLabels)); + bool isSelectedMetaDataReadOnly = properties.DynamicReadonlyValidator( + nameof(properties.SelectedMetaDataAttribute)); + + // Assert + Assert.AreNotEqual(hasMetaData, isShowLabelReadOnly); + Assert.AreNotEqual(hasMetaData, isSelectedMetaDataReadOnly); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicReadOnlyValidator_MapPolygonDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) + { + // Setup + var mapData = new MapPolygonData("Test") + { + MapTheme = hasMapTheme + ? new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + : null + }; + + var properties = new MapPolygonDataProperties + { + Data = mapData + }; + + // Call + bool isStrokeColorReadOnly = properties.DynamicReadonlyValidator( + nameof(MapPolygonDataProperties.StrokeColor)); + bool isStrokeThicknessReadOnly = properties.DynamicReadonlyValidator( + nameof(MapPolygonDataProperties.StrokeThickness)); + + // Assert + Assert.AreEqual(hasMapTheme, isStrokeColorReadOnly); + Assert.AreEqual(hasMapTheme, isStrokeThicknessReadOnly); + } + + [Test] + public void DynamicReadOnlyValidator_AnyOtherProperty_ReturnsFalse() + { + // Setup + var feature = new MapFeature(Enumerable.Empty()); + feature.MetaData["Key"] = "value"; + + var mapPolygonData = new MapPolygonData("Test") + { + Features = new[] + { + feature + }, + MapTheme = new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + }; + + var properties = new MapPolygonDataProperties + { + Data = mapPolygonData + }; + + // Call + bool isOtherPropertyReadOnly = properties.DynamicReadonlyValidator(string.Empty); + + // Assert + Assert.IsFalse(isOtherPropertyReadOnly); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_ShowLabels_ReturnsExpectedValuesForRelevantProperties(bool showLabels) + { + // Setup + var mapPolygonData = new MapPolygonData("Test") + { + ShowLabels = showLabels + }; + + var properties = new MapPolygonDataProperties + { + Data = mapPolygonData + }; + + // Call + bool isSelectedMetaDataAttributeVisible = properties.DynamicVisibleValidationMethod( + nameof(MapPolygonDataProperties.SelectedMetaDataAttribute)); + + // Assert + Assert.AreEqual(showLabels, isSelectedMetaDataAttributeVisible); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_MapPolygonDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) + { + // Setup + var mapPolygonData = new MapPolygonData("Test") + { + MapTheme = hasMapTheme + ? new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + : null + }; + + var properties = new MapPolygonDataProperties + { + Data = mapPolygonData + }; + + // Call + bool isFillColorVisible = properties.DynamicVisibleValidationMethod( + nameof(MapPolygonDataProperties.FillColor)); + bool isMapThemeAttributeNameVisible = properties.DynamicVisibleValidationMethod( + nameof(MapPolygonDataProperties.MapThemeAttributeName)); + bool isCategoriesVisible = properties.DynamicVisibleValidationMethod( + nameof(MapPolygonDataProperties.Categories)); + + // Assert + Assert.AreNotEqual(hasMapTheme, isFillColorVisible); + Assert.AreEqual(hasMapTheme, isMapThemeAttributeNameVisible); + Assert.AreEqual(hasMapTheme, isCategoriesVisible); + } + + [Test] + public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsTrue() + { + var mapPolygonData = new MapPolygonData("Test") + { + Features = new[] + { + new MapFeature(Enumerable.Empty()) + }, + ShowLabels = true, + MapTheme = new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + }; + + var properties = new MapPolygonDataProperties + { + Data = mapPolygonData + }; + + // Call + bool isOtherPropertyVisible = properties.DynamicVisibleValidationMethod(string.Empty); + + // Assert + Assert.IsFalse(isOtherPropertyVisible); + } } } \ No newline at end of file