use of com.sldeditor.ui.detail.config.base.GroupConfig in project sldeditor by robward-scisys.
the class GraphicPanelFieldManagerTest method testAddGroup.
/**
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#getGroup(java.lang.Class, com.sldeditor.common.xml.ui.GroupIdEnum)}.
* Test method for {@link com.sldeditor.ui.detail.GraphicPanelFieldManager#addGroup(com.sldeditor.ui.detail.config.base.GroupConfig)}.
*/
@Test
public void testAddGroup() {
Class<?> expectedPanelId = StrokeDetails.class;
GraphicPanelFieldManager mgr = new GraphicPanelFieldManager(expectedPanelId);
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(String.class, expectedFieldId, "test label", false), "button text");
mgr.addField(stringField);
GroupConfig multiOption = new GroupConfig();
GroupIdEnum expectedGroupId = GroupIdEnum.FILLSYMBOL;
multiOption.setId(expectedGroupId);
mgr.addGroup(multiOption);
GroupConfigInterface actualValue = mgr.getGroup(null, null);
assertNull(actualValue);
actualValue = mgr.getGroup(expectedPanelId, expectedGroupId);
assertEquals(multiOption, actualValue);
}
use of com.sldeditor.ui.detail.config.base.GroupConfig in project sldeditor by robward-scisys.
the class BasePanel method populateGroup.
/**
* Populate group.
*
* @param parent the parent
* @param parentBox the parent box
* @param groupConfig the group config
* @param parentField the parent field
*/
private void populateGroup(UpdateSymbolInterface parent, Box parentBox, GroupConfigInterface groupConfig, FieldConfigBase parentField) {
groupConfig.createTitle(parentBox, parent);
if (groupConfig instanceof GroupConfig) {
GroupConfig group = (GroupConfig) groupConfig;
List<FieldConfigBase> fieldList = group.getFieldConfigList();
fieldConfigManager.addGroup(group);
// Register for notifications when data has changed
registerForSymbolUpdates(fieldList, parent);
// Create field user interface
for (FieldConfigBase field : fieldList) {
field.setParent(parentField);
addField(parentBox, parentField, field);
}
for (GroupConfigInterface subGroup : group.getSubGroupList()) {
populateGroup(parent, parentBox, subGroup, parentField);
}
} else if (groupConfig instanceof MultiOptionGroup) {
MultiOptionGroup multiOption = (MultiOptionGroup) groupConfig;
fieldConfigManager.addMultiOptionGroup(multiOption);
multiOption.createUI(fieldConfigManager, parentBox, parent, parent.getClass());
for (OptionGroup optionGroup : multiOption.getGroupList()) {
for (GroupConfigInterface optionGroupConfig : optionGroup.getGroupList()) {
if (optionGroupConfig instanceof GroupConfig) {
populateOptionGroup(parent, (GroupConfig) optionGroupConfig);
}
}
}
}
}
use of com.sldeditor.ui.detail.config.base.GroupConfig in project sldeditor by robward-scisys.
the class ReadPanelConfig method read.
/**
* Read configuration file and store the configuration in the object.
*
* @param panelId the panel id
* @param resourceString the resource string
* @return true, if successful
*/
public boolean read(Class<?> panelId, String resourceString) {
groupList = new ArrayList<GroupConfigInterface>();
PanelConfig panelConfig = (PanelConfig) ParseXML.parseUIFile(resourceString, SCHEMA_RESOURCE, PanelConfig.class);
if (panelConfig == null) {
return false;
}
Class<?> localisationClass = ReadPanelConfig.class;
if (panelConfig.getLocalisation() != null) {
try {
localisationClass = Class.forName(panelConfig.getLocalisation());
} catch (ClassNotFoundException e) {
ConsoleManager.getInstance().exception(ReadPanelConfig.class, e);
}
}
panelTitle = getLocalisedText(localisationClass, panelConfig.getPanelTitle());
vendorOptionVersion = getVendorOptionVersion(panelConfig);
for (Object groupObj : panelConfig.getGroupOrMultiOptionGroup()) {
if (groupObj instanceof XMLGroupConfig) {
GroupConfig groupConfig = parseGroup(localisationClass, panelId, (XMLGroupConfig) groupObj);
groupList.add(groupConfig);
} else if (groupObj instanceof XMLMultiOptionGroup) {
MultiOptionGroup groupConfig = parseMultiOptionGroup(localisationClass, panelId, (XMLMultiOptionGroup) groupObj);
groupList.add(groupConfig);
}
}
return true;
}
use of com.sldeditor.ui.detail.config.base.GroupConfig 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.base.GroupConfig in project sldeditor by robward-scisys.
the class ReadPanelConfig method parseGroup.
/**
* Parses the group if fields.
*
* @param localisationClass the localisation class
* @param panelId the panel id
* @param xmlGroupObj the xml group object
* @return the group config
*/
private GroupConfig parseGroup(Class<?> localisationClass, Class<?> panelId, XMLGroupConfig xmlGroupObj) {
GroupConfig groupConfig = new GroupConfig();
groupConfig.setId(xmlGroupObj.getId());
groupConfig.setLabel(groupTitle(getLocalisedText(localisationClass, xmlGroupObj.getLabel())));
groupConfig.setShowLabel(xmlGroupObj.getShowLabel());
groupConfig.setOptional(xmlGroupObj.getOption());
for (Object obj : xmlGroupObj.getFieldList()) {
if (obj instanceof XMLFieldConfigData) {
addField(localisationClass, panelId, groupConfig, (XMLFieldConfigData) obj);
} else if (obj instanceof XMLGroupConfig) {
GroupConfig subGroup = parseGroup(localisationClass, panelId, (XMLGroupConfig) obj);
groupConfig.addGroup(subGroup);
} else if (obj instanceof XMLMultiOptionGroup) {
MultiOptionGroup subGroup = parseMultiOptionGroup(localisationClass, panelId, (XMLMultiOptionGroup) obj);
groupConfig.addGroup(subGroup);
} else if (obj instanceof XMLFieldConfigVendorOption) {
XMLFieldConfigVendorOption vendorOption = (XMLFieldConfigVendorOption) obj;
FieldIdEnum id = vendorOption.getId();
String label = null;
boolean valueOnly = true;
FieldConfigCommonData commonData = new FieldConfigCommonData(panelId, id, label, valueOnly);
List<VendorOptionInterface> veList = null;
veList = vendorOptionFactory.getVendorOptionList(vendorOption.getClazz());
if ((veList == null) || veList.isEmpty()) {
ConsoleManager.getInstance().error(this, Localisation.getField(FieldConfigBase.class, "FieldConfigVendorOption.missingVendorOptionClass") + vendorOption.getClazz());
}
FieldConfigVendorOption placeHolder = new FieldConfigVendorOption(commonData, veList);
groupConfig.addField(placeHolder);
}
}
return groupConfig;
}
Aggregations