Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapLineDataProperties.cs =================================================================== diff -u -r40867963010e95b9df5c0f4dfa169707e151b514 -r9e62d5abb9940400c2ce525fe16ed0a4bfa44629 --- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapLineDataProperties.cs (.../MapLineDataProperties.cs) (revision 40867963010e95b9df5c0f4dfa169707e151b514) +++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapLineDataProperties.cs (.../MapLineDataProperties.cs) (revision 9e62d5abb9940400c2ce525fe16ed0a4bfa44629) @@ -46,7 +46,7 @@ } } - [PropertyOrder(5)] + [PropertyOrder(8)] [DynamicVisible] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_Color_DisplayName))] @@ -66,7 +66,7 @@ } } - [PropertyOrder(6)] + [PropertyOrder(9)] [DynamicReadOnly] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapData_StrokeThickness_DisplayName))] @@ -84,7 +84,7 @@ } } - [PropertyOrder(7)] + [PropertyOrder(10)] [DynamicReadOnly] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapLineData_DashStyle_DisplayName))] Index: Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPointDataProperties.cs =================================================================== diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -r9e62d5abb9940400c2ce525fe16ed0a4bfa44629 --- Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPointDataProperties.cs (.../MapPointDataProperties.cs) (revision ac96d7c315129af851634ed5a4a6800b59ede718) +++ Core/Plugins/src/Core.Plugins.Map/PropertyClasses/MapPointDataProperties.cs (.../MapPointDataProperties.cs) (revision 9e62d5abb9940400c2ce525fe16ed0a4bfa44629) @@ -46,7 +46,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.MapPointData_Color_Description))] @@ -65,7 +66,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.MapPointData_StrokeColor_Description))] @@ -84,7 +86,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.MapPointData_StrokeThickness_Description))] @@ -101,7 +104,8 @@ } } - [PropertyOrder(8)] + [PropertyOrder(11)] + [DynamicReadOnly] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapPointData_Size_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.MapPointData_Size_Description))] @@ -118,7 +122,8 @@ } } - [PropertyOrder(9)] + [PropertyOrder(12)] + [DynamicReadOnly] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Styling))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.MapPointData_Symbol_Displayname))] [ResourcesDescription(typeof(Resources), nameof(Resources.MapPointData_Symbol_Description))] @@ -135,5 +140,28 @@ data.NotifyObservers(); } } + + public override bool DynamicVisibleValidationMethod(string propertyName) + { + if (propertyName == nameof(Color)) + { + return data.MapTheme == null; + } + + return base.DynamicVisibleValidationMethod(propertyName); + } + + public override bool DynamicReadonlyValidator(string propertyName) + { + if (propertyName == nameof(StrokeColor) + || propertyName == nameof(StrokeThickness) + || propertyName == nameof(Size) + || propertyName == nameof(Symbol)) + { + 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 -r40867963010e95b9df5c0f4dfa169707e151b514 -r9e62d5abb9940400c2ce525fe16ed0a4bfa44629 --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs (.../MapLineDataPropertiesTest.cs) (revision 40867963010e95b9df5c0f4dfa169707e151b514) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapLineDataPropertiesTest.cs (.../MapLineDataPropertiesTest.cs) (revision 9e62d5abb9940400c2ce525fe16ed0a4bfa44629) @@ -45,7 +45,7 @@ private const int widthPropertyIndex = 7; private const int stylePropertyIndex = 8; - private const int widthWithMapThemePropertyIndex = 7; + private const int widthWithMapThemePropertyIndex = 8; private const int styleWithMapThemePropertyIndex = 9; [Test] @@ -66,10 +66,6 @@ // Setup var mapLineData = new MapLineData("Test") { - Features = new[] - { - new MapFeature(Enumerable.Empty()) - }, ShowLabels = true }; @@ -111,10 +107,6 @@ // Setup var mapLineData = new MapLineData("Test") { - Features = new[] - { - new MapFeature(Enumerable.Empty()) - }, ShowLabels = true, MapTheme = new MapTheme("Attribute", new[] { @@ -379,7 +371,7 @@ [Test] public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsTrue() { - var mapPointData = new MapLineData("Test") + var mapLineData = new MapLineData("Test") { Features = new[] { @@ -394,7 +386,7 @@ var properties = new MapLineDataProperties { - Data = mapPointData + Data = mapLineData }; // Call Index: Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs =================================================================== diff -u -rd1b19bb139550ae19f474c28f94ff3329cae0236 -r9e62d5abb9940400c2ce525fe16ed0a4bfa44629 --- Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision d1b19bb139550ae19f474c28f94ff3329cae0236) +++ Core/Plugins/test/Core.Plugins.Map.Test/PropertyClasses/MapPointDataPropertiesTest.cs (.../MapPointDataPropertiesTest.cs) (revision 9e62d5abb9940400c2ce525fe16ed0a4bfa44629) @@ -30,6 +30,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; @@ -45,6 +47,11 @@ private const int sizePropertyIndex = 9; private const int symbolPropertyIndex = 10; + private const int strokeColorWithMapThemePropertyIndex = 8; + private const int strokeThicknessWithMapThemePropertyIndex = 9; + private const int sizeWithMapThemePropertyIndex = 10; + private const int symbolWithMapThemePropertyIndex = 11; + [Test] public void Constructor_ExpectedValues() { @@ -89,7 +96,7 @@ "De kleur van de symbolen waarmee deze kaartlaag wordt weergegeven."); PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorPropertyIndex]; - Assert.IsInstanceOf(colorProperty.Converter); + Assert.IsInstanceOf(strokeColorProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, styleCategory, "Lijnkleur", @@ -116,6 +123,65 @@ } [Test] + public void Constructor_MapLineDataWithMapTheme_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mapPointData = new MapPointData("Test") + { + Features = new[] + { + new MapFeature(Enumerable.Empty()) + }, + ShowLabels = true, + MapTheme = new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + }; + + // Call + var properties = new MapPointDataProperties + { + Data = mapPointData + }; + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(12, dynamicProperties.Count); + const string styleCategory = "Stijl"; + + PropertyDescriptor strokeColorProperty = dynamicProperties[strokeColorWithMapThemePropertyIndex]; + Assert.IsInstanceOf(strokeColorProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeColorProperty, + styleCategory, + "Lijnkleur", + "De kleur van de lijn van de symbolen waarmee deze kaartlaag wordt weergegeven.", + true); + + PropertyDescriptor strokeThicknessProperty = dynamicProperties[strokeThicknessWithMapThemePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(strokeThicknessProperty, + styleCategory, + "Lijndikte", + "De dikte van de lijn van de symbolen waarmee deze kaartlaag wordt weergegeven.", + true); + + PropertyDescriptor sizeProperty = dynamicProperties[sizeWithMapThemePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sizeProperty, + styleCategory, + "Grootte", + "De grootte van de symbolen waarmee deze kaartlaag wordt weergegeven.", + true); + + PropertyDescriptor symbolProperty = dynamicProperties[symbolWithMapThemePropertyIndex]; + Assert.IsInstanceOf(symbolProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(symbolProperty, + styleCategory, + "Symbool", + "Het symbool waarmee deze kaartlaag wordt weergegeven.", + true); + } + + [Test] public void Data_SetNewMapPointDataInstance_ReturnCorrectPropertyValues() { // Setup @@ -196,5 +262,197 @@ Assert.AreEqual(newStrokeThickness, mapPointData.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 MapLineData("Test") + { + Features = new[] + { + feature + } + }; + + var properties = new MapLineDataProperties + { + 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_MapLineDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) + { + // Setup + var mapData = new MapPointData("Test") + { + MapTheme = hasMapTheme + ? new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + : null + }; + + var properties = new MapPointDataProperties + { + Data = mapData + }; + + // Call + bool isWidthReadOnly = properties.DynamicReadonlyValidator( + nameof(MapPointDataProperties.Size)); + bool isStrokeColorReadOnly = properties.DynamicReadonlyValidator( + nameof(MapPointDataProperties.StrokeColor)); + bool isStrokeThicknessReadOnly = properties.DynamicReadonlyValidator( + nameof(MapPointDataProperties.StrokeThickness)); + bool isDashStyleReadOnly = properties.DynamicReadonlyValidator( + nameof(MapPointDataProperties.Symbol)); + + // Assert + Assert.AreEqual(hasMapTheme, isWidthReadOnly); + Assert.AreEqual(hasMapTheme, isStrokeColorReadOnly); + Assert.AreEqual(hasMapTheme, isStrokeThicknessReadOnly); + Assert.AreEqual(hasMapTheme, isDashStyleReadOnly); + } + + [Test] + public void DynamicReadOnlyValidator_AnyOtherProperty_ReturnsFalse() + { + // Setup + var feature = new MapFeature(Enumerable.Empty()); + feature.MetaData["Key"] = "value"; + + var mapPointData = new MapPointData("Test") + { + Features = new[] + { + feature + }, + MapTheme = new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + }; + + var properties = new MapPointDataProperties + { + Data = mapPointData + }; + + // 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 mapLineData = new MapLineData("Test") + { + ShowLabels = showLabels + }; + + var properties = new MapLineDataProperties + { + Data = mapLineData + }; + + // Call + bool isSelectedMetaDataAttributeVisible = properties.DynamicVisibleValidationMethod( + nameof(MapLineDataProperties.SelectedMetaDataAttribute)); + + // Assert + Assert.AreEqual(showLabels, isSelectedMetaDataAttributeVisible); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_MapDataWithMapTheme_ReturnsExpectedValuesForRelevantProperties(bool hasMapTheme) + { + // Setup + var mapPointData = new MapPointData("Test") + { + MapTheme = hasMapTheme + ? new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + : null + }; + + var properties = new MapPointDataProperties + { + Data = mapPointData + }; + + // Call + bool isMapThemeAttributeNameVisible = properties.DynamicVisibleValidationMethod( + nameof(MapPointDataProperties.MapThemeAttributeName)); + bool isMapThemeCategoriesVisible = properties.DynamicVisibleValidationMethod( + nameof(MapPointDataProperties.Categories)); + bool isLineColorStyleVisible = properties.DynamicVisibleValidationMethod( + nameof(MapPointDataProperties.Color)); + + // Assert + Assert.AreEqual(hasMapTheme, isMapThemeAttributeNameVisible); + Assert.AreEqual(hasMapTheme, isMapThemeCategoriesVisible); + Assert.AreNotEqual(hasMapTheme, isLineColorStyleVisible); + } + + [Test] + public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsTrue() + { + var mapPointData = new MapPointData("Test") + { + Features = new[] + { + new MapFeature(Enumerable.Empty()) + }, + ShowLabels = true, + MapTheme = new MapTheme("Attribute", new[] + { + CategoryThemeTestFactory.CreateCategoryTheme() + }) + }; + + var properties = new MapPointDataProperties + { + Data = mapPointData + }; + + // Call + bool isOtherPropertyVisible = properties.DynamicVisibleValidationMethod(string.Empty); + + // Assert + Assert.IsFalse(isOtherPropertyVisible); + } } } \ No newline at end of file