use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig 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.symboltype.SymbolTypeConfig 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.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class ReadMapUnits method readValueListConfig.
/**
* Read value list configuration.
*
* @param localisationClass the localisation class
* @param panelId the panel id
* @param valueList the xml value obj
* @return the list
*/
private List<SymbolTypeConfig> readValueListConfig(Class<?> localisationClass, Class<?> panelId, XMLFieldConfigEnumValueList valueList) {
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
for (XMLFieldConfigEnumValue valueObj : valueList.getValue()) {
SymbolTypeConfig config = parseSymbolTypeConfig(localisationClass, panelId, valueObj);
configList.add(config);
}
return configList;
}
use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class ReadPanelConfig method parseSymbolTypeConfig.
/**
* Parses the symbol type configuration.
*
* @param localisationClass the localisation class
* @param panelId the panel id
* @param valueObj the value obj
* @return the symbol type config
*/
public static SymbolTypeConfig parseSymbolTypeConfig(Class<?> localisationClass, Class<?> panelId, XMLFieldConfigEnumValue valueObj) {
SymbolTypeConfig config = new SymbolTypeConfig(panelId);
String groupName = valueObj.getGroupName();
boolean isSeparateGroup = valueObj.getSeparateGroup();
if (groupName != null) {
config.setGroupName(groupName);
}
config.setSeparateGroup(isSeparateGroup);
for (XMLFieldConfigEnumValueItem itemObj : valueObj.getItem()) {
config.addOption(itemObj.getId(), getLocalisedText(localisationClass, itemObj.getLabel()));
}
FieldList fieldList = valueObj.getFieldList();
if (fieldList != null) {
for (XMLFieldConfigEnumValueField field : fieldList.getField()) {
config.addField(field.getId(), field.getEnabled());
}
for (XMLFieldConfigEnumValueGroup group : fieldList.getGroup()) {
config.addGroup(group.getId(), group.getEnabled());
}
}
return config;
}
use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class FieldConfigEnum method addConfig.
/**
* Adds the config.
*
* @param configList the config list
*/
public void addConfig(List<SymbolTypeConfig> configList) {
if (configList != null) {
for (SymbolTypeConfig config : configList) {
if (config != null) {
fieldMap.putAll(config.getFieldMap());
Map<String, String> optionMap = config.getOptionMap();
for (String key : optionMap.keySet()) {
addValue(key, optionMap.get(key));
}
}
}
}
}
Aggregations