Search in sources :

Example 1 with IndexedCategoryModel

use of net.sourceforge.usbdm.deviceEditor.model.IndexedCategoryModel in project usbdm-eclipse-plugins by podonoghue.

the class ParseMenuXML method parseIndexedCategoryOption.

private void parseIndexedCategoryOption(BaseModel parent, Element element) throws Exception {
    IndexedCategoryModel model = (IndexedCategoryModel) parseCommonAttributes(parent, element, IndexedCategoryVariable.class);
    IndexedCategoryVariable variable = model.getVariable();
    variable.setValue(element.getAttribute("value"));
    int dimension = getIntAttribute(element, "dim");
    model.setDimension(dimension);
    parseChildModels(model, element);
    for (int index = 1; index < dimension; index++) {
        IndexedCategoryModel newModel = model.clone(parent, fProvider, index);
        if (newModel.getName() == model.getName()) {
            newModel.setName(model.getName() + "[" + index + "]");
        }
        IndexedCategoryVariable newVariable = newModel.getVariable();
        newVariable.setValue(newVariable.getValueAsString().replaceAll("\\.$", Integer.toString(index)));
    }
    variable.setValue(variable.getValueAsString().replaceAll("\\.$", Integer.toString(0)));
}
Also used : IndexedCategoryVariable(net.sourceforge.usbdm.deviceEditor.information.IndexedCategoryVariable) IndexedCategoryModel(net.sourceforge.usbdm.deviceEditor.model.IndexedCategoryModel)

Aggregations

IndexedCategoryVariable (net.sourceforge.usbdm.deviceEditor.information.IndexedCategoryVariable)1 IndexedCategoryModel (net.sourceforge.usbdm.deviceEditor.model.IndexedCategoryModel)1