use of com.sldeditor.ui.detail.config.FieldConfigBoolean in project sldeditor by robward-scisys.
the class FieldConfigBooleanTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigBoolean field = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.populateField(Boolean.TRUE);
field.populateField(Boolean.FALSE);
assertFalse(field.getBooleanValue());
UndoManager.getInstance().undo();
assertTrue(field.getBooleanValue());
UndoManager.getInstance().redo();
assertFalse(field.getBooleanValue());
field.setTestValue(null, true);
assertTrue(field.getBooleanValue());
assertTrue(field.getStringValue().toLowerCase().compareTo("true") == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
use of com.sldeditor.ui.detail.config.FieldConfigBoolean in project sldeditor by robward-scisys.
the class FieldConfigBooleanTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#generateExpression()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
FieldConfigBoolean field = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
field.setTestValue(null, true);
field.populateField((Boolean) null);
field.populateField(Boolean.TRUE);
field.populateExpression(null);
field.createUI();
field.createUI();
field.populateField(Boolean.TRUE);
assertTrue(field.getBooleanValue());
field.populateExpression(Boolean.FALSE);
assertFalse(field.getBooleanValue());
field.setTestValue(null, true);
assertTrue(field.getBooleanValue());
assertTrue(field.getStringValue().toLowerCase().compareTo("true") == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigBoolean in project sldeditor by robward-scisys.
the class FieldConfigPopulationTest method testBoolean.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.ui.detail.config.FieldId, java.lang.Boolean)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateBooleanField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.Boolean)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getBoolean(com.sldeditor.common.xml.ui.FieldIdEnum)}.
*/
@Test
public void testBoolean() {
FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
FieldConfigBoolean booleanField = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
booleanField.createUI();
fieldConfigManager.add(fieldId, booleanField);
FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
Boolean expectedValue = Boolean.TRUE;
obj.populateBooleanField(fieldId, expectedValue);
assertEquals(expectedValue.booleanValue(), obj.getBoolean(fieldId));
// This shouldn't work as it does not know about the field
FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
assertFalse(obj.getBoolean(wrongFieldEnum));
// Try with null - should revert to default value (false)
obj.populateBooleanField(fieldId, null);
assertFalse(obj.getBoolean(fieldId));
}
use of com.sldeditor.ui.detail.config.FieldConfigBoolean 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.FieldConfigBoolean in project sldeditor by robward-scisys.
the class FilterManager method convertParameters.
/**
* Convert function parameters to ui components.
*
* @param panelId the panel id
* @param functionName the function name
* @return the list of ui components to display
*/
@Override
public List<GroupConfigInterface> convertParameters(Class<?> panelId, FunctionName functionName) {
List<GroupConfigInterface> groupConfigList = new ArrayList<GroupConfigInterface>();
if (functionName != null) {
GroupConfig groupConfig = new GroupConfig();
StringBuilder funcPrototypeStringBuilder = new StringBuilder();
funcPrototypeStringBuilder.append(functionName.getName());
funcPrototypeStringBuilder.append("(");
int argCount = functionName.getArgumentCount();
if (functionName.getArgumentCount() < 0) {
argCount *= -1;
}
for (int index = 0; index < argCount; index++) {
int argIndex = index;
if (argIndex >= functionName.getArguments().size()) {
argIndex = functionName.getArguments().size() - 1;
}
String label = functionName.getArgumentNames().get(argIndex);
Parameter<?> parameterType = functionName.getArguments().get(argIndex);
boolean valueOnly = false;
FieldIdEnum id = FieldIdEnum.UNKNOWN;
if (index > 0) {
funcPrototypeStringBuilder.append(", ");
}
Class<?> type = parameterType.getType();
funcPrototypeStringBuilder.append(type.getSimpleName());
FieldConfigBase fieldConfig = null;
FieldConfigCommonData commonData = new FieldConfigCommonData(panelId, id, label, valueOnly);
if (type == java.lang.Number.class) {
fieldConfig = new FieldConfigDouble(commonData);
} else if (type == Double.class) {
fieldConfig = new FieldConfigDouble(commonData);
} else if (type == Float.class) {
fieldConfig = new FieldConfigDouble(commonData);
} else if (type == Integer.class) {
fieldConfig = new FieldConfigInteger(commonData);
} else if (type == Long.class) {
fieldConfig = new FieldConfigInteger(commonData);
} else if (type == String.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Object.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Boolean.class) {
fieldConfig = new FieldConfigBoolean(commonData);
} else if (type == Geometry.class) {
fieldConfig = new FieldConfigGeometry(commonData, null);
} else if (type == org.opengis.geometry.Geometry.class) {
fieldConfig = new FieldConfigGeometry(commonData, null);
} else if (type == LineString.class) {
fieldConfig = new FieldConfigGeometry(commonData, null);
} else if (type == Date.class) {
fieldConfig = new FieldConfigDate(commonData);
} else if (type == Class.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Classifier.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Unit.class) {
fieldConfig = new FieldConfigMapUnits(commonData);
} else if (type == Comparable.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Color.class) {
fieldConfig = new FieldConfigColour(commonData);
} else {
ConsoleManager.getInstance().error(this, Localisation.getField(ExpressionPanelv2.class, "FilterManager.error1") + type.getName());
}
groupConfig.addField(fieldConfig);
}
funcPrototypeStringBuilder.append(")");
groupConfig.setLabel(funcPrototypeStringBuilder.toString());
groupConfigList.add(groupConfig);
}
return groupConfigList;
}
Aggregations