Search in sources :

Example 11 with SymbolTypeConfig

use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig 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 SymbolTypeConfig

use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig 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)

Aggregations

SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)12 ArrayList (java.util.ArrayList)8 FieldConfigEnum (com.sldeditor.ui.detail.config.FieldConfigEnum)6 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)5 Test (org.junit.Test)5 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 XMLFieldConfigEnumValue (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue)2 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)2 XMLFieldConfigEnumValueField (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueField)2 XMLFieldConfigEnumValueItem (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueItem)2 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 MapUnits (com.sldeditor.common.xml.ui.MapUnits)1 XMLFieldConfigData (com.sldeditor.common.xml.ui.XMLFieldConfigData)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 XMLFieldConfigEnumValueGroup (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueGroup)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)1