Search in sources :

Example 1 with GroupConfig

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);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) GroupIdEnum(com.sldeditor.common.xml.ui.GroupIdEnum) Test(org.junit.Test)

Example 2 with GroupConfig

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);
                }
            }
        }
    }
}
Also used : OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 3 with GroupConfig

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;
}
Also used : 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) PanelConfig(com.sldeditor.common.xml.ui.PanelConfig) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 4 with GroupConfig

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;
}
Also used : FieldConfigDate(com.sldeditor.ui.detail.config.FieldConfigDate) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) ArrayList(java.util.ArrayList) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) LineString(com.vividsolutions.jts.geom.LineString) Classifier(org.geotools.filter.function.Classifier) RangedClassifier(org.geotools.filter.function.RangedClassifier) FieldConfigMapUnits(com.sldeditor.ui.detail.config.FieldConfigMapUnits) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Point(com.vividsolutions.jts.geom.Point) Disjoint(com.sldeditor.filter.v2.function.geometry.Disjoint) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) Date(java.util.Date) FieldConfigDate(com.sldeditor.ui.detail.config.FieldConfigDate) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

Example 5 with GroupConfig

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;
}
Also used : XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) XMLFieldConfigVendorOption(com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLFieldConfigVendorOption(com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLFieldConfigData(com.sldeditor.common.xml.ui.XMLFieldConfigData) List(java.util.List) ArrayList(java.util.ArrayList) FieldList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList) XMLFieldConfigEnumValueList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

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