use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.
the class VOGeoServerLabelling method includeValue.
/**
* Find out whether to include value based on the value of another field.
*
* @param field the field
* @return true, if successful
*/
private boolean includeValue(FieldIdEnum field) {
DefaultOverride override = overrideMap.get(field);
if (override != null) {
String value = null;
FieldConfigBase fieldConfig = fieldConfigManager.get(override.getField());
if (fieldConfig instanceof FieldConfigBoolean) {
value = String.valueOf(fieldConfigVisitor.getBoolean(override.getField()));
} else if (fieldConfig instanceof FieldConfigInteger) {
value = String.valueOf(fieldConfigVisitor.getInteger(override.getField()));
} else if (fieldConfig instanceof FieldConfigDouble) {
value = String.valueOf(fieldConfigVisitor.getDouble(override.getField()));
} else if (fieldConfig instanceof FieldConfigEnum) {
value = String.valueOf(fieldConfigVisitor.getComboBox(override.getField()));
} else {
ConsoleManager.getInstance().error(this, "Unsupported field type : " + field + " " + fieldConfig.getClass().getName());
}
if (value != null) {
for (String legalValue : override.getLegalValues()) {
if (value.compareToIgnoreCase(legalValue) == 0) {
return true;
}
}
}
}
return false;
}
use of com.sldeditor.ui.detail.config.FieldConfigEnum in project sldeditor by robward-scisys.
the class VOGeoServerFTSComposite method populate.
/*
* (non-Javadoc)
*
* @see
* com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#populate(org.geotools.styling.
* FeatureTypeStyle)
*/
@Override
public void populate(FeatureTypeStyle featureTypeStyle) {
Map<String, String> options = featureTypeStyle.getOptions();
String compositeString = options.get(FeatureTypeStyle.COMPOSITE);
String name = null;
double opacity = DEFAULT_COMPOSITE_OPACITY;
if (compositeString != null) {
String[] components = compositeString.split(",");
FieldConfigEnum optionData = (FieldConfigEnum) fieldConfigVisitor.getFieldConfig(FieldIdEnum.VO_FTS_COMPOSITE_OPTION);
if (optionData.isValidOption(components[0])) {
name = components[0];
}
if (components.length == 2) {
try {
opacity = Double.valueOf(components[1]);
} catch (Exception e) {
// Do nothing and revert to default
}
}
}
fieldConfigVisitor.populateComboBoxField(FieldIdEnum.VO_FTS_COMPOSITE_OPTION, name);
fieldConfigVisitor.populateDoubleField(FieldIdEnum.VO_FTS_COMPOSITE_OPACITY, opacity);
GroupConfigInterface groupPanel = getGroup(GroupIdEnum.VO_FTS_COMPOSITE);
groupPanel.enable(compositeString != null);
}
use of com.sldeditor.ui.detail.config.FieldConfigEnum 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.FieldConfigEnum in project sldeditor by robward-scisys.
the class FieldConfigEnumTest method testSetVisible.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setVisible(boolean)}.
*/
@Test
public void testSetVisible() {
boolean valueOnly = true;
FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
boolean expectedValue = true;
field.setVisible(expectedValue);
field.createUI();
field.setVisible(expectedValue);
expectedValue = false;
field.setVisible(expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigEnum 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