Search in sources :

Example 31 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.

the class GraphicPanelFieldManagerTest method testRemoveField.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#removeField(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testRemoveField() {
    Class<?> expectedPanelId = StrokeDetails.class;
    GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(expectedPanelId);
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr.removeField(null);
    // Does n't exists yet
    mgr.removeField(stringField);
    mgr.addField(stringField);
    FieldIdEnum actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
    assertEquals(stringField, mgr.getData(expectedPanelId, actualFieldId));
    mgr.removeField(stringField);
    actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
    assertEquals(FieldIdEnum.UNKNOWN, actualFieldId);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 32 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.

the class GraphicPanelFieldManagerTest method testAddMultiOptionGroup.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addMultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getMultiOptionGroup(java.lang.Class, com.sldeditor.common.xml.ui.GroupIdEnum)}.
 */
@Test
public void testAddMultiOptionGroup() {
    Class<?> expectedPanelId = StrokeDetails.class;
    GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(expectedPanelId);
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr.addField(stringField);
    MultiOptionGroup multiOption = new MultiOptionGroup();
    GroupIdEnum expectedGroupId = GroupIdEnum.FILLSYMBOL;
    multiOption.setId(expectedGroupId);
    mgr.addMultiOptionGroup(multiOption);
    MultiOptionGroup actualValue = mgr.getMultiOptionGroup(null, null);
    assertNull(actualValue);
    actualValue = mgr.getMultiOptionGroup(expectedPanelId, expectedGroupId);
    assertEquals(multiOption, actualValue);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) GroupIdEnum(com.sldeditor.common.xml.ui.GroupIdEnum) Test(org.junit.Test)

Example 33 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.

the class GraphicPanelFieldManagerTest method testAddGraphicPanelFieldManager.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#add(com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
 */
@Test
public void testAddGraphicPanelFieldManager() {
    // Set up manager 1
    Class<?> expectedPanelId = StrokeDetails.class;
    GraphicPanelFieldManager mgr1 = new GraphicPanelFieldManager(expectedPanelId);
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr1.addField(stringField);
    assertTrue(mgr1.getFields(FieldConfigBoolean.class).isEmpty());
    assertEquals(1, mgr1.getFields(FieldConfigString.class).size());
    // Set up manager 2
    Class<?> expectedPanelId2 = PointFillDetails.class;
    GraphicPanelFieldManager mgr2 = new GraphicPanelFieldManager(expectedPanelId2);
    FieldIdEnum expectedFieldId2 = FieldIdEnum.ANGLE;
    FieldConfigDouble doubleField = new FieldConfigDouble(new FieldConfigCommonData(Double.class, expectedFieldId2, "test label", false));
    mgr2.addField(doubleField);
    assertEquals(1, mgr2.getFields(FieldConfigDouble.class).size());
    // Add manager 2 to manager 1
    mgr1.add(mgr2);
    FieldIdEnum actualFieldId = mgr1.getFieldEnum(expectedPanelId, stringField);
    assertEquals(expectedFieldId, actualFieldId);
    actualFieldId = mgr1.getFieldEnum(expectedPanelId2, doubleField);
    assertEquals(expectedFieldId2, actualFieldId);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 34 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.

the class GraphicPanelFieldManagerTest method testGraphicPanelFieldManager.

/**
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#GraphicPanelFieldManager(java.lang.Class)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#get(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#get(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getFieldEnum(java.lang.Class, com.sldeditor.ui.detail.config.FieldConfigBase)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getComponentId()}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addField(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#add(com.sldeditor.ui.detail.config.FieldId, com.sldeditor.ui.detail.config.FieldConfigBase)}.
 * Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getData(java.lang.Class, com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testGraphicPanelFieldManager() {
    // Try with a null panel id
    GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(null);
    assertNull(mgr.get(FieldIdEnum.FILTER));
    Class<?> expectedPanelId = StrokeDetails.class;
    mgr = new GraphicPanelFieldManager(expectedPanelId);
    assertEquals(FieldIdEnum.UNKNOWN, mgr.getFieldEnum(PointFillDetails.class, null));
    assertEquals(expectedPanelId, mgr.getComponentId());
    // Now try with a field
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
    mgr.addField(null);
    mgr.addField(stringField);
    FieldIdEnum actualFieldId = mgr.getFieldEnum(expectedPanelId, stringField);
    assertEquals(expectedFieldId, actualFieldId);
    assertNull(mgr.getData(null, null));
    assertNull(mgr.getData(expectedPanelId, null));
    assertEquals(stringField, mgr.getData(expectedPanelId, actualFieldId));
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 35 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.

the class LineSymbolizerDetailsTest method testLineSymbolizerDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#LineSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testLineSymbolizerDetails() {
    LineSymbolizerDetails panel = new LineSymbolizerDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);
    LineSymbolizer symbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) LineSymbolizerDetails(com.sldeditor.ui.detail.LineSymbolizerDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Aggregations

FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)37 Test (org.junit.Test)32 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)21 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)20 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)13 NamedLayer (org.geotools.styling.NamedLayer)12 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)11 Style (org.geotools.styling.Style)11 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)10 Rule (org.geotools.styling.Rule)10 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)8 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)5 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)3 Geometry (com.vividsolutions.jts.geom.Geometry)3 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)2 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)2 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)2