Search in sources :

Example 6 with FieldConfigTransformation

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

the class FieldConfigTransformationTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigTransformation field = new FieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    field.attributeSelection("field");
// Does nothing
}
Also used : FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 7 with FieldConfigTransformation

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

the class FieldConfigTransformationTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#internal_setEnabled(boolean)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#isEnabled()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#createUI()}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigTransformation field = new FieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    // Text field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigTransformation field2 = new FieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    // Text field will not have been created
    expectedValue = true;
    field2.internal_setEnabled(expectedValue);
    assertFalse(field2.isEnabled());
    // Create text field
    field2.createUI();
    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 : FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 8 with FieldConfigTransformation

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

the class FieldConfigTransformationTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#revertToDefaultValue()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#setDefaultValue(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#getStringValue()}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigTransformation field = new FieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    String expectedDefaultValue = "default value";
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    assertNull(field.getStringValue());
    field.createUI();
    field.revertToDefaultValue();
    assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) == 0);
}
Also used : FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 9 with FieldConfigTransformation

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

the class FieldConfigTransformationTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigTransformation field = new FieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.undoAction(null);
    field.redoAction(null);
    String expectedTestValue = "test value";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedTestValue);
    assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
    String expectedUndoTestValue = "undo value";
    String expectedRedoTestValue = "redo value";
    UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
    field.undoAction(undoEvent);
    assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
    field.redoAction(undoEvent);
    assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
    // Increase code coverage status
    undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, Integer.valueOf(0), Double.valueOf(10.0));
    field.undoAction(undoEvent);
    field.redoAction(undoEvent);
}
Also used : FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigTransformation (com.sldeditor.ui.detail.config.transform.FieldConfigTransformation)9 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)8 Test (org.junit.Test)8 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 XMLFieldConfigBoolean (com.sldeditor.common.xml.ui.XMLFieldConfigBoolean)1 XMLFieldConfigColour (com.sldeditor.common.xml.ui.XMLFieldConfigColour)1 XMLFieldConfigColourMap (com.sldeditor.common.xml.ui.XMLFieldConfigColourMap)1 XMLFieldConfigDSProperties (com.sldeditor.common.xml.ui.XMLFieldConfigDSProperties)1 XMLFieldConfigDouble (com.sldeditor.common.xml.ui.XMLFieldConfigDouble)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigFeatureTypeConstraint (com.sldeditor.common.xml.ui.XMLFieldConfigFeatureTypeConstraint)1 XMLFieldConfigFont (com.sldeditor.common.xml.ui.XMLFieldConfigFont)1 XMLFieldConfigFontPreview (com.sldeditor.common.xml.ui.XMLFieldConfigFontPreview)1 XMLFieldConfigGeometry (com.sldeditor.common.xml.ui.XMLFieldConfigGeometry)1 XMLFieldConfigGeometryField (com.sldeditor.common.xml.ui.XMLFieldConfigGeometryField)1 XMLFieldConfigInlineFeature (com.sldeditor.common.xml.ui.XMLFieldConfigInlineFeature)1 XMLFieldConfigInteger (com.sldeditor.common.xml.ui.XMLFieldConfigInteger)1