Search in sources :

Example 1 with FieldConfigInteger

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

the class FieldConfigIntegerTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    int expectedValue1 = 134;
    field.createUI();
    field.populateField(expectedValue1);
    assertEquals(expectedValue1, field.getIntValue());
    int expectedValue2 = 9876;
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
    assertEquals(expectedValue2, field.getIntValue());
    UndoManager.getInstance().undo();
    assertEquals(expectedValue1, field.getIntValue());
    UndoManager.getInstance().redo();
    assertEquals(expectedValue2, field.getIntValue());
    // 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 : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 2 with FieldConfigInteger

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

the class FieldConfigIntegerTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.attributeSelection(null);
    field.createUI();
    assertTrue(field.isEnabled());
    field.attributeSelection("test");
    assertFalse(field.isEnabled());
    field.attributeSelection(null);
    assertTrue(field.isEnabled());
}
Also used : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 3 with FieldConfigInteger

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

the class FieldConfigIntegerTest method testSetVisible.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigInteger field = new FieldConfigInteger(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 : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 4 with FieldConfigInteger

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

the class FieldConfigIntegerTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#revertToDefaultValue()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigInteger#setDefaultValue(int)}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.revertToDefaultValue();
    assertEquals(0, field.getIntValue());
    field.createUI();
    Integer expectedDefaultValue = 42;
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    assertEquals(expectedDefaultValue.intValue(), field.getIntValue());
    assertTrue(String.valueOf(expectedDefaultValue).compareTo(field.getStringValue()) == 0);
}
Also used : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 5 with FieldConfigInteger

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

the class FieldConfigIntegerTest method testSetConfig.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#testSetConfig(double, double, double)}.
 */
@Test
public void testSetConfig() {
    boolean valueOnly = true;
    FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.createUI();
    int minValue = 10;
    int maxValue = 20;
    int stepSize = 1;
    field.setConfig(minValue, maxValue, stepSize);
    // Should be set to the minimum value
    int expectedValue1 = 1;
    field.populateField(expectedValue1);
    assertEquals(minValue, field.getIntValue());
    // Should be set to the maximum value
    int expectedValue2 = 41;
    field.populateField(expectedValue2);
    assertEquals(maxValue, field.getIntValue());
}
Also used : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)16 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)14 Test (org.junit.Test)11 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)4 Geometry (com.vividsolutions.jts.geom.Geometry)4 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)3 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)3 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)2 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)2 BoxLayout (javax.swing.BoxLayout)2 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)2 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)2 Expression (org.opengis.filter.expression.Expression)2 ColourRamp (com.sldeditor.colourramp.ColourRamp)1 ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)1 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 XMLTwoColourRamp (com.sldeditor.common.xml.ui.XMLTwoColourRamp)1 Disjoint (com.sldeditor.filter.v2.function.geometry.Disjoint)1 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)1