Search in sources :

Example 11 with FieldConfigEnum

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

the class FieldConfigEnumTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#revertToDefaultValue()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#addConfig(java.util.List)}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setDefaultValue(java.lang.String)}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.revertToDefaultValue();
    assertEquals(0, field.getIntValue());
    SymbolTypeConfig s1 = new SymbolTypeConfig(null);
    s1.addOption("key1", "Value 1");
    s1.addOption("key2", "Value 2");
    s1.addOption("key3", "Value 3");
    s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
    s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    SymbolTypeConfig s2 = new SymbolTypeConfig(null);
    s2.addOption("key4", "Value 4");
    s2.addOption("key5", "Value 5");
    s2.addOption("key6", "Value 6");
    s2.addField(FieldIdEnum.ANGLE, true);
    s2.addField(FieldIdEnum.DESCRIPTION, false);
    configList.add(s2);
    field.addConfig(configList);
    field.createUI();
    String expectedDefaultValue = "key6";
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) == 0);
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) ArrayList(java.util.ArrayList) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) Test(org.junit.Test)

Example 12 with FieldConfigEnum

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

the class FieldConfigEnumTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    SymbolTypeConfig s1 = new SymbolTypeConfig(null);
    s1.addOption("key1", "Value 1");
    s1.addOption("key2", "Value 2");
    s1.addOption("key3", "Value 3");
    s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
    s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    SymbolTypeConfig s2 = new SymbolTypeConfig(null);
    s2.addOption("key4", "Value 4");
    s2.addOption("key5", "Value 5");
    s2.addOption("key6", "Value 6");
    s2.addField(FieldIdEnum.ANGLE, true);
    s2.addField(FieldIdEnum.DESCRIPTION, false);
    configList.add(s2);
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.addConfig(null);
    assertNull(field.getStringValue());
    field.addConfig(configList);
    // Now create the ui
    field.createUI();
    String expectedValue1 = "key2";
    field.populateField(expectedValue1);
    String expectedValue2 = "key6";
    field.populateField(expectedValue2);
    UndoManager.getInstance().undo();
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    ValueComboBoxData actualValue = field.getEnumValue();
    assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
    UndoManager.getInstance().redo();
    actualValueString = field.getStringValue();
    assertTrue(expectedValue2.compareTo(actualValueString) == 0);
    actualValue = field.getEnumValue();
    assertTrue(expectedValue2.compareTo(actualValue.getKey()) == 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)));
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Example 13 with FieldConfigEnum

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

the class FieldConfigEnumTest method testAttributeSelection.

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

Example 14 with FieldConfigEnum

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

the class FieldConfigEnumTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#internal_setEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#isEnabled()}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.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();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigEnum field2 = new FieldConfigEnum(new FieldConfigCommonData(Integer.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 : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigEnum (com.sldeditor.ui.detail.config.FieldConfigEnum)14 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)9 Test (org.junit.Test)9 SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)6 ArrayList (java.util.ArrayList)6 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)4 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)1 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)1 Geometry (com.vividsolutions.jts.geom.Geometry)1