use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.
the class FieldConfigEnumTest method testCreateCopy.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
*/
@Test
public void testCreateCopy() {
boolean valueOnly = true;
class TestFieldConfigEnum extends FieldConfigEnum {
public TestFieldConfigEnum(FieldConfigCommonData commonData) {
super(commonData);
}
public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
return createCopy(fieldConfigBase);
}
}
TestFieldConfigEnum field = new TestFieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
FieldConfigEnum copy = (FieldConfigEnum) field.callCreateCopy(null);
assertNull(copy);
copy = (FieldConfigEnum) field.callCreateCopy(field);
assertEquals(field.getFieldId(), copy.getFieldId());
assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
assertEquals(field.isValueOnly(), copy.isValueOnly());
}
use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.
the class FieldConfigEnumTest method testGetFieldEnableState.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getFieldEnableState()}.
*/
@Test
public void testGetFieldEnableState() {
UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
SymbolTypeConfig s1 = new SymbolTypeConfig(Integer.class);
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);
boolean valueOnly = true;
FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.addConfig(configList);
// Now create the ui
field.createUI();
field.populateField("key3");
Map<FieldIdEnum, Boolean> actualMap = field.getFieldEnableState();
assertEquals(actualMap.get(FieldIdEnum.ANCHOR_POINT_H), Boolean.TRUE);
assertEquals(actualMap.get(FieldIdEnum.ANCHOR_POINT_V), Boolean.FALSE);
UndoManager.getInstance().setPopulationCheck(null);
}
use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testComboBox.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.common.xml.ui.FieldIdEnum)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.ui.detail.config.FieldId)}.
*/
@Test
public void testComboBox() {
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);
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
configList.add(s1);
FieldConfigEnum enumField = new FieldConfigEnum(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
enumField.addConfig(configList);
enumField.createUI();
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
fieldConfigManager.add(fieldId, enumField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
String expectedValue = "key2";
obj.populateComboBoxField(fieldId, expectedValue);
assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertNull(obj.getComboBox(wrongFieldEnum));
// Try with null - should revert to default value (first enum item)
obj.populateComboBoxField(fieldId, null);
expectedValue = "key1";
assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.
the class BasePanel method handleFieldState.
/**
* Handle field state for a specific combo box field.
*
* @param fieldId the field id
*/
protected void handleFieldState(FieldIdEnum fieldId) {
FieldConfigBase fieldConfig = fieldConfigManager.get(fieldId);
if (fieldConfig != null) {
if (fieldConfig instanceof FieldConfigEnum) {
FieldConfigEnum fieldEnum = (FieldConfigEnum) fieldConfig;
Map<FieldIdEnum, Boolean> stateMap = fieldEnum.getFieldEnableState();
if (stateMap != null) {
for (FieldIdEnum fieldKey : stateMap.keySet()) {
enableField(fieldKey, stateMap.get(fieldKey));
}
}
}
} else {
ConsoleManager.getInstance().error(this, String.format("handleFieldState - %s : %s", Localisation.getString(StandardPanel.class, "StandardPanel.unknownField"), fieldId));
}
}
use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.
the class BasePanel method handleFieldState.
/**
* Handle field state for all combo box fields.
*/
protected void handleFieldState() {
List<FieldConfigBase> fieldList = fieldConfigManager.getFields(FieldConfigEnum.class);
for (FieldConfigBase field : fieldList) {
FieldConfigEnum fieldEnum = (FieldConfigEnum) field;
Map<FieldIdEnum, Boolean> stateMap = fieldEnum.getFieldEnableState();
if (stateMap != null) {
for (FieldIdEnum fieldKey : stateMap.keySet()) {
enableField(fieldKey, stateMap.get(fieldKey));
}
}
}
}
Aggregations