use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class ReadMapUnits method read.
/**
* Read configuration file and store the configuration in the object.
*
* @param panelId the panel id
* @param resourceString the resource string
* @param fieldConfigMapUnits the field config map units
* @return true, if successful
*/
public boolean read(Class<?> panelId, String resourceString, FieldConfigMapUnits fieldConfigMapUnits) {
MapUnits mapUnits = (MapUnits) ParseXML.parseUIFile(resourceString, SCHEMA_RESOURCE, MapUnits.class);
if (mapUnits == null) {
return false;
}
Class<?> localisationClass = ReadPanelConfig.class;
if (mapUnits.getLocalisation() != null) {
try {
localisationClass = Class.forName(mapUnits.getLocalisation());
} catch (ClassNotFoundException e) {
ConsoleManager.getInstance().exception(ReadMapUnits.class, e);
}
}
XMLFieldConfigData xmlFieldConfig = mapUnits.getFieldConfigEnum();
if (xmlFieldConfig instanceof XMLFieldConfigEnum) {
String defaultValue = xmlFieldConfig.getDefault();
XMLFieldConfigEnumValueList valueList = ((XMLFieldConfigEnum) xmlFieldConfig).getValueList();
List<SymbolTypeConfig> configList = readValueListConfig(localisationClass, panelId, valueList);
fieldConfigMapUnits.addConfig(configList);
String defaultValueObj = ConfigDefaultFactory.getString(defaultValue);
if (defaultValueObj != null) {
fieldConfigMapUnits.setDefaultValue(defaultValueObj);
}
}
return true;
}
use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class ReadMapUnits 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());
}
}
return config;
}
use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class ReadPanelConfig 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 BaseValue method createEnum.
/**
* Creates the enum.
*
* @param commonData the common data
* @return the field config base
*/
protected FieldConfigBase createEnum(FieldConfigCommonData commonData) {
FieldConfigEnum fieldConfigEnum = new FieldConfigEnum(commonData);
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
SymbolTypeConfig symbolTypeConfig = new SymbolTypeConfig(null);
populateSymbolType(symbolTypeConfig);
configList.add(symbolTypeConfig);
fieldConfigEnum.addConfig(configList);
return fieldConfigEnum;
}
use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class FieldConfigEnumTest method testGenerateExpression.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#generateExpression()}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateField(java.lang.String)}. Test
* method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getEnumValue()}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getStringValue()}.
*/
@Test
public void testGenerateExpression() {
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.undoAction(null);
field.redoAction(null);
field.addConfig(null);
assertNull(field.getStringValue());
field.addConfig(configList);
// Try without creating the ui
field.populateExpression(null);
field.populateField((String) null);
field.setTestValue(null, (String) null);
// Now create the ui
field.createUI();
field.createUI();
String expectedValue1 = "key2";
field.populateField(expectedValue1);
String actualValueString = field.getStringValue();
assertTrue(expectedValue1.compareTo(actualValueString) == 0);
ValueComboBoxData actualValue = field.getEnumValue();
assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
// Try valid/invalid option values
assertTrue(field.isValidOption("key1"));
assertTrue(field.isValidOption("key4"));
assertFalse(field.isValidOption("key24"));
assertFalse(field.isValidOption(null));
}
Aggregations