Search in sources :

Example 46 with FieldConfigCommonData

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

the class FieldConfigColourTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigColour#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigColour#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    String colour1 = "#123456";
    field.populateExpression(colour1);
    String colour2 = "#AABBCC";
    field.populateExpression(colour2);
    UndoManager.getInstance().undo();
    String actualValue = field.getStringValue();
    assertTrue(colour1.compareTo(actualValue) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(colour2.compareTo(actualValue) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) Test(org.junit.Test)

Example 47 with FieldConfigCommonData

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

the class FieldConfigColourTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigColour#internal_setEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigColour#isEnabled()}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    // Text field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigColour field2 = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    // Text field will not have been created
    expectedValue = true;
    field2.internal_setEnabled(expectedValue);
    assertFalse(field2.isEnabled());
    // Create text field
    field2.createUI();
    assertEquals(expectedValue, field2.isEnabled());
    expectedValue = false;
    field2.internal_setEnabled(expectedValue);
    // Actual value is coming from the attribute panel, not the text field
    assertEquals(!expectedValue, field2.isEnabled());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) Test(org.junit.Test)

Example 48 with FieldConfigCommonData

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

the class FieldConfigDSPropertiesTest method testCreateCopy.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testCreateCopy() {
    boolean valueOnly = true;
    class TestFieldConfigDSProperties extends FieldConfigDSProperties {

        public TestFieldConfigDSProperties(FieldConfigCommonData commonData) {
            super(commonData);
        }

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigDSProperties field = new TestFieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    FieldConfigDSProperties copy = (FieldConfigDSProperties) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigDSProperties) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 49 with FieldConfigCommonData

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

the class FieldConfigDSPropertiesTest method testSetVisible.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    field.createUI();
    field.setVisible(expectedValue);
    expectedValue = false;
    field.setVisible(expectedValue);
}
Also used : FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 50 with FieldConfigCommonData

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

the class FieldConfigDSPropertiesTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    assertNull(field.getStringValue());
    // Now create the ui
    field.createUI();
    String expectedValue1 = "Date_2";
    field.populateField(expectedValue1);
    String expectedValue2 = "String_3";
    field.populateField(expectedValue2);
    UndoManager.getInstance().undo();
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    UndoManager.getInstance().redo();
    actualValueString = field.getStringValue();
    assertTrue(expectedValue2.compareTo(actualValueString) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
    DataSourceFactory.reset();
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigDSProperties(com.sldeditor.ui.detail.config.FieldConfigDSProperties) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)322 Test (org.junit.Test)316 Geometry (com.vividsolutions.jts.geom.Geometry)69 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)54 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)44 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)38 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)34 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)24 StyleBuilder (org.geotools.styling.StyleBuilder)24 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)22 UndoEvent (com.sldeditor.common.undo.UndoEvent)20 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)20 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)20 Expression (org.opengis.filter.expression.Expression)20 FieldConfigWindBarbs (com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs)18 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)17 FieldConfigTTF (com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF)17 FieldConfigFilename (com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename)16 FieldConfigArrow (com.sldeditor.ui.detail.vendor.geoserver.marker.arrow.FieldConfigArrow)16 FieldConfigWKT (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT)16