use of com.sldeditor.ui.detail.config.FieldConfigGeometry 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;
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false), "button text");
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
field.populateField((String) null);
field.populateExpression((String) null);
String wktPoint = "POINT( 48.44 -123.37)";
field.populateField(wktPoint);
String actualValue = field.getStringValue();
assertTrue(wktPoint.compareTo(actualValue) == 0);
String wktPolygon = "POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))";
field.populateField(wktPolygon);
actualValue = field.getStringValue();
assertTrue(wktPolygon.compareTo(actualValue) == 0);
String wktLine = "LINESTRING(0 2, 2 0, 8 6)";
field.populateExpression(wktLine);
actualValue = field.getStringValue();
assertTrue(wktLine.compareTo(actualValue) == 0);
UndoManager.getInstance().undo();
actualValue = field.getStringValue();
assertTrue(wktPolygon.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(wktLine.compareTo(actualValue) == 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.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
boolean valueOnly = true;
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
field.attributeSelection(null);
// Does nothing
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#internal_setEnabled(boolean)}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#isEnabled()}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
// Text field will not have been created
boolean expectedValue = true;
field.internal_setEnabled(expectedValue);
assertFalse(field.isEnabled());
// Create text field
field.createUI();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertEquals(expectedValue, field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigGeometry field2 = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
// Text field will not have been created
expectedValue = true;
field2.internal_setEnabled(expectedValue);
assertFalse(field2.isEnabled());
// Create text field
field2.createUI();
assertEquals(expectedValue, field2.isEnabled());
expectedValue = false;
field2.internal_setEnabled(expectedValue);
// Actual value is coming from the attribute panel, not the text field
assertEquals(!expectedValue, field2.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigGeometry in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testAddButtonPressedListener.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#addButtonPressedListener(com.sldeditor.ui.detail.config.FieldConfigStringButtonInterface)}.
*/
@Test
public void testAddButtonPressedListener() {
boolean valueOnly = true;
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly), "button text");
field.addButtonPressedListener(null);
}
Aggregations