use of com.sldeditor.ui.detail.config.FieldConfigMapUnits in project sldeditor by robward-scisys.
the class InstantiateFields method addFieldMapUnits.
/**
* Adds the field map units.
*
* @param fieldData the field data
* @return the field config base
*/
private FieldConfigBase addFieldMapUnits(FieldData fieldData) {
FieldConfigMapUnits valueConfig = new FieldConfigMapUnits(fieldData.getCommonData());
String defaultValueObj = ConfigDefaultFactory.getString(fieldData.getDefaultValue());
if (defaultValueObj != null) {
valueConfig.setDefaultValue(defaultValueObj);
defaultFieldMap.put(fieldData.getId(), defaultValueObj);
}
return valueConfig;
}
use of com.sldeditor.ui.detail.config.FieldConfigMapUnits 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.FieldConfigMapUnits 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<>();
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, true);
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