Search in sources :

Example 6 with GroupConfig

use of com.sldeditor.ui.detail.config.base.GroupConfig in project sldeditor by robward-scisys.

the class ReadPanelConfig method parseMultiOptionGroup.

/**
 * Parses the multi option group.
 *
 * @param localisationClass the localisation class
 * @param panelId the panel id
 * @param xmlMultiGroupObj the xml multi group obj
 * @return the multi option group
 */
private MultiOptionGroup parseMultiOptionGroup(Class<?> localisationClass, Class<?> panelId, XMLMultiOptionGroup xmlMultiGroupObj) {
    MultiOptionGroup multiOptionGroupConfig = new MultiOptionGroup();
    multiOptionGroupConfig.setId(xmlMultiGroupObj.getId());
    multiOptionGroupConfig.setLabel(getLocalisedText(localisationClass, xmlMultiGroupObj.getLabel()));
    multiOptionGroupConfig.setShowLabel(xmlMultiGroupObj.getShowLabel());
    multiOptionGroupConfig.setOptional(xmlMultiGroupObj.getOption());
    List<XMLOptionGroup> optionGroupList = xmlMultiGroupObj.getOptionGroup();
    for (XMLOptionGroup xmlOptionGroup : optionGroupList) {
        OptionGroup optionGroup = new OptionGroup();
        optionGroup.setId(xmlOptionGroup.getId());
        optionGroup.setLabel(getLocalisedText(localisationClass, xmlOptionGroup.getLabel()));
        optionGroup.setShowLabel(xmlOptionGroup.getShowLabel());
        List<XMLGroupConfig> xmlGroupConfigList = xmlOptionGroup.getGroup();
        if (xmlGroupConfigList != null) {
            for (XMLGroupConfig xmlGroupConfig : xmlGroupConfigList) {
                GroupConfig groupConfig = parseGroup(localisationClass, panelId, xmlGroupConfig);
                optionGroup.addGroup(groupConfig);
            }
        }
        multiOptionGroupConfig.addGroup(optionGroup);
    }
    return multiOptionGroupConfig;
}
Also used : XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) XMLOptionGroup(com.sldeditor.common.xml.ui.XMLOptionGroup) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) XMLOptionGroup(com.sldeditor.common.xml.ui.XMLOptionGroup)

Example 7 with GroupConfig

use of com.sldeditor.ui.detail.config.base.GroupConfig in project sldeditor by robward-scisys.

the class BasePanel method populateOptionGroup.

/**
 * Populate option group.
 *
 * @param parent the parent
 * @param optionGroupConfig the option group config
 */
private void populateOptionGroup(UpdateSymbolInterface parent, GroupConfig optionGroupConfig) {
    List<FieldConfigBase> fieldList = optionGroupConfig.getFieldConfigList();
    fieldConfigManager.addGroup(optionGroupConfig);
    // Create field user interface
    for (FieldConfigBase field : fieldList) {
        addFieldConfig(field);
        fieldConfigManager.addField(field);
    }
    // Register for notifications when data has changed
    registerForSymbolUpdates(fieldList, parent);
    for (GroupConfigInterface subOptionGroupConfig : optionGroupConfig.getSubGroupList()) {
        if (subOptionGroupConfig instanceof GroupConfig) {
            populateOptionGroup(parent, (GroupConfig) subOptionGroupConfig);
        } else if (subOptionGroupConfig instanceof MultiOptionGroup) {
            MultiOptionGroup multiOption = (MultiOptionGroup) subOptionGroupConfig;
            fieldConfigManager.addMultiOptionGroup(multiOption);
            for (OptionGroup optionGroup : multiOption.getGroupList()) {
                for (GroupConfigInterface subMultiOptionGroupConfig : optionGroup.getGroupList()) {
                    if (subMultiOptionGroupConfig instanceof GroupConfig) {
                        populateOptionGroup(parent, (GroupConfig) subMultiOptionGroupConfig);
                    }
                }
            }
        }
    }
}
Also used : OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 8 with GroupConfig

use of com.sldeditor.ui.detail.config.base.GroupConfig in project sldeditor by robward-scisys.

the class FilterManagerTest method testConvertParameters.

/**
 * Test method for
 * {@link com.sldeditor.filter.v2.function.FilterManager#convertParameters(java.lang.Class, com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.capability.FunctionName)}.
 */
@Test
public void testConvertParameters() {
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
    List<FunctionName> functionNameList = functionFactory.getFunctionNames();
    // Try with empty parameters
    Class<?> panelId = null;
    List<GroupConfigInterface> list = FilterManager.getInstance().convertParameters(panelId, null);
    assertTrue(list.isEmpty());
    // Find a known function
    for (FunctionName functionName : functionNameList) {
        list = FilterManager.getInstance().convertParameters(panelId, functionName);
        System.out.println(functionName.getName());
        assertEquals(1, list.size());
        GroupConfig groupConfig = (GroupConfig) list.get(0);
        List<FieldConfigBase> fieldList = groupConfig.getFieldConfigList();
        assertEquals(functionName.getName(), fieldList.size(), Math.abs(functionName.getArgumentCount()));
        List<String> argList = new ArrayList<String>();
        for (int fieldIndex = 0; fieldIndex < fieldList.size(); fieldIndex++) {
            checkFieldType(fieldIndex, fieldList, functionName, argList);
        }
        StringBuilder sb = new StringBuilder();
        sb.append(functionName.getName());
        sb.append("(");
        for (int index = 0; index < argList.size(); index++) {
            if (index > 0) {
                sb.append(", ");
            }
            sb.append(argList.get(index));
        }
        sb.append(")");
        String prototype = groupConfig.getLabel();
        assertNotNull(functionName.getName(), prototype);
        assertNotNull(functionName.getName(), sb.toString());
        assertTrue(prototype.compareTo(sb.toString()) == 0);
    }
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ArrayList(java.util.ArrayList) LineString(com.vividsolutions.jts.geom.LineString) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FunctionName(org.opengis.filter.capability.FunctionName) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) Test(org.junit.Test)

Aggregations

GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)8 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)6 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)5 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)3 XMLGroupConfig (com.sldeditor.common.xml.ui.XMLGroupConfig)3 XMLMultiOptionGroup (com.sldeditor.common.xml.ui.XMLMultiOptionGroup)3 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)3 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)3 ArrayList (java.util.ArrayList)3 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 LineString (com.vividsolutions.jts.geom.LineString)2 Test (org.junit.Test)2 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)1 PanelConfig (com.sldeditor.common.xml.ui.PanelConfig)1 XMLFieldConfigData (com.sldeditor.common.xml.ui.XMLFieldConfigData)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 XMLFieldConfigVendorOption (com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption)1