use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class FieldConfigEnum method getFieldEnableState.
/**
* Gets the field enable state.
*
* @return the field enable state
*/
public Map<FieldIdEnum, Boolean> getFieldEnableState() {
ValueComboBoxData value = getEnumValue();
if (value == null) {
return null;
}
Class<?> panelId = value.getPanelId();
return fieldMap.get(panelId);
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class WindBarbDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
ValueComboBoxData windSpeedUnits = fieldConfigVisitor.getComboBox(FieldIdEnum.WINDBARB_WINDSPEED_UNITS);
Expression windSpeedExpression = fieldConfigVisitor.getExpression(FieldIdEnum.WINDBARB_WINDSPEED);
boolean inNorthernHemisphere = fieldConfigVisitor.getBoolean(FieldIdEnum.WINDBARB_NORTHERN_HEMISPHERE);
Object windSpeed = null;
if (windSpeedExpression == null) {
windSpeed = Integer.valueOf(0);
} else if (windSpeedExpression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl literalExpression = (LiteralExpressionImpl) windSpeedExpression;
windSpeed = literalExpression.getValue();
} else if (windSpeedExpression instanceof ConstantExpression) {
ConstantExpression constantExpression = (ConstantExpression) windSpeedExpression;
windSpeed = constantExpression.getValue();
} else if (windSpeedExpression instanceof AttributeExpressionImpl) {
AttributeExpressionImpl attributeExpression = (AttributeExpressionImpl) windSpeedExpression;
windSpeed = String.format("<ogc:PropertyName>%s</ogc:PropertyName>", attributeExpression.getPropertyName());
;
} else {
ConsoleManager.getInstance().error(this, Localisation.getField(WindBarbDetails.class, "WindBarb.windspeedError1") + windSpeedExpression.getClass().getName());
}
String url = String.format("windbarbs://default(%s)[%s]", windSpeed, windSpeedUnits.getKey());
if (!inNorthernHemisphere) {
url = url + HEMISPHERE_S;
}
windBarbsExpression = getFilterFactory().literal(url);
if (parentObj != null) {
parentObj.windBarbValueUpdated();
}
}
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class VOGeoServerLabellingUnderline method internal_updateSymbolEnumField.
/**
* Internal_update symbol enum field.
*
* @param options the options
* @param field the field
* @param key the key
*/
private void internal_updateSymbolEnumField(Map<String, String> options, FieldIdEnum field, String key) {
ValueComboBoxData value = fieldConfigVisitor.getComboBox(field);
Object object = getDefaultFieldValue(field);
String defaultValue = null;
if (object instanceof TextSymbolizer.PolygonAlignOptions) {
TextSymbolizer.PolygonAlignOptions option = (PolygonAlignOptions) object;
defaultValue = option.toString();
} else {
defaultValue = (String) object;
}
if (defaultValue == null) {
ConsoleManager.getInstance().error(this, "Failed to find default for field : " + field);
} else if (value.getKey().compareToIgnoreCase(defaultValue) != 0) {
options.put(key, value.getKey());
}
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class VOGeoServerRandomFill method internal_updateSymbolEnumField.
/**
* Internal_update symbol enum field.
*
* @param options the options
* @param field the field
* @param key the key
*/
private void internal_updateSymbolEnumField(Map<String, String> options, FieldIdEnum field, String key) {
ValueComboBoxData value = fieldConfigVisitor.getComboBox(field);
Object object = getDefaultFieldValue(field);
String defaultValue = null;
if (object instanceof TextSymbolizer.PolygonAlignOptions) {
TextSymbolizer.PolygonAlignOptions option = (PolygonAlignOptions) object;
defaultValue = option.toString();
} else {
defaultValue = (String) object;
}
if (defaultValue == null) {
ConsoleManager.getInstance().error(this, "Failed to find default for field : " + field);
} else if (value.getKey().compareToIgnoreCase(defaultValue) != 0) {
options.put(key, value.getKey());
}
}
use of com.sldeditor.ui.widgets.ValueComboBoxData 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