Search in sources :

Example 1 with ParametersModel

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

the class ParseMenuXML method parsePage.

/**
 * Parse: <br>
 * <ul>
 *    <li>&lt;fragment&gt; referencing a one of the below elements<br>
 *    <li>&lt;peripheralPage&gt;<br>
 *    <li>&lt;list&gt;<br>
 * </ul>
 * @param element    Element to parse
 *
 * @throws Exception
 */
private void parsePage(Element element) throws Exception {
    String name = element.getAttribute("name");
    if (name.equalsIgnoreCase("_instance")) {
        name = fProvider.getName();
    }
    // System.err.println("parsePage(<" + element.getTagName() + " name="+ name + ">)");
    String tooltip = getToolTip(element);
    String tagName = element.getTagName();
    if (tagName == "fragment") {
        /*
          * Parse fragment as if it was a continuation of the parent elements
          * This handles fragments that just include a href include a <peripheralPage>
          */
        for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
            if (node.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            parsePage((Element) node);
        }
    } else if (tagName == "peripheralPage") {
        fRootModel = new ParametersModel(null, name, tooltip);
        parseSectionsOrOtherContents(fRootModel, element);
    } else if (tagName == "list") {
        fRootModel = new ListModel(null, name);
        parseSectionsOrOtherContents(fRootModel, element);
    } else {
        throw new Exception("Expected <peripheralPage> or <list>");
    }
}
Also used : ParametersModel(net.sourceforge.usbdm.deviceEditor.model.ParametersModel) Node(org.w3c.dom.Node) UsbdmException(net.sourceforge.usbdm.jni.UsbdmException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with ParametersModel

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

the class ParseMenuXML method parseChildModel.

/**
 * Parse element containing: <ul>
 *   <li> &lt;fragment&gt; referencing only elements below
 *   <li> &lt;intOption&gt;
 *   <li> &lt;bitmaskOption&gt;
 *   <li> &lt;floatOption&gt;
 *   <li> &lt;binaryOption&gt;
 *   <li> &lt;irqOption&gt;
 *   <li> &lt;choiceOption&gt;
 *   <li> &lt;stringOption&gt;
 *   <li> &lt;numericListOption&gt;
 *   <li> &lt;pinListOption&gt;
 *   <li> &lt;aliasOption&gt;
 *   <li> &lt;constant&gt;
 *   <li> &lt;section&gt;
 *   <li> &lt;signals&gt;
 *   <li> Control items...
 *</ul>
 *
 * Elements found are added as children of the parentModel
 *
 * @param  parentModel  Model to attach children to
 * @param  menuElement  Menu element to parse
 *
 * @throws Exception
 */
void parseChildModel(BaseModel parentModel, Element element) throws Exception {
    String tagName = element.getTagName();
    String name = element.getAttribute("name");
    String toolTip = getToolTip(element);
    // System.err.println("parseChildModel(): " + tagName + ", " + element.getAttribute("name"));
    if (tagName == "fragment") {
        parseChildModels(parentModel, element);
    } else if (tagName == "category") {
        BaseModel model = new CategoryModel(parentModel, name, toolTip);
        parseChildModels(model, element);
    } else if (tagName == "indexedCategory") {
        parseIndexedCategoryOption(parentModel, element);
    } else if (tagName == "intOption") {
        parseLongOption(parentModel, element);
    } else if (tagName == "bitmaskOption") {
        parseBitmaskOption(parentModel, element);
    } else if (tagName == "floatOption") {
        parseDoubleOption(parentModel, element);
    } else if (tagName == "binaryOption") {
        parseBinaryOption(parentModel, element);
    } else if (tagName == "irqOption") {
        parseIrqOption(parentModel, element);
    } else if (tagName == "choiceOption") {
        parseChoiceOption(parentModel, element);
    } else if (tagName == "stringOption") {
        parseStringOption(parentModel, element);
    } else if (tagName == "numericListOption") {
        parseNumericListOption(parentModel, element);
    } else if (tagName == "pinListOption") {
        parsePinListOption(parentModel, element);
    } else if (tagName == "aliasOption") {
        parseAliasOption(parentModel, element);
    } else if (tagName == "constant") {
        parseConstant(parentModel, element);
    } else if (tagName == "section") {
        BaseModel model = new ParametersModel(parentModel, name, toolTip);
        parseChildModels(model, element);
    } else if (tagName == "list") {
        BaseModel model = new ListModel(parentModel, name);
        parseSectionsOrOther(model, element);
    } else if (tagName == "signals") {
        parseSignalsOption(parentModel, element);
    } else {
        parseControlItem(element);
    }
}
Also used : BaseModel(net.sourceforge.usbdm.deviceEditor.model.BaseModel) ParametersModel(net.sourceforge.usbdm.deviceEditor.model.ParametersModel) CategoryModel(net.sourceforge.usbdm.deviceEditor.model.CategoryModel) IndexedCategoryModel(net.sourceforge.usbdm.deviceEditor.model.IndexedCategoryModel)

Aggregations

ParametersModel (net.sourceforge.usbdm.deviceEditor.model.ParametersModel)2 FileNotFoundException (java.io.FileNotFoundException)1 BaseModel (net.sourceforge.usbdm.deviceEditor.model.BaseModel)1 CategoryModel (net.sourceforge.usbdm.deviceEditor.model.CategoryModel)1 IndexedCategoryModel (net.sourceforge.usbdm.deviceEditor.model.IndexedCategoryModel)1 UsbdmException (net.sourceforge.usbdm.jni.UsbdmException)1 Node (org.w3c.dom.Node)1