Example usage for org.jdom2 Element getAttributes

List of usage examples for org.jdom2 Element getAttributes

Introduction

In this page you can find the example usage for org.jdom2 Element getAttributes.

Prototype

public List<Attribute> getAttributes() 

Source Link

Document

This returns the complete set of attributes for this element, as a List of Attribute objects in no particular order, or an empty list if there are none.

Usage

From source file:org.openflexo.foundation.viewpoint.rm.ViewPointResourceImpl.java

License:Open Source License

private static void convertNames16ToNames17(Document document) {

    // Convert common properties
    addProperty("userID", "FLX", document, null);

    // Edition Patterns
    // Edition patterns name
    convertOldNameToNewNames("EditionPattern", "FlexoConcept", document);
    // Parent pattern role is no more an attribute but an element
    IteratorIterable<? extends Content> fcElementsIterator = document
            .getDescendants(new ElementFilter("FlexoConcept"));
    List<Element> fcElements = IteratorUtils.toList(fcElementsIterator);

    for (Element fc : fcElements) {
        if (fc.getAttribute("parentEditionPattern") != null) {
            Element parentEp = new Element("ParentFlexoConcept");
            Attribute parentIdRef = new Attribute("idref",
                    getFlexoConceptID(document, fc.getAttributeValue("parentEditionPattern")));
            parentEp.getAttributes().add(parentIdRef);
            fc.removeAttribute("parentEditionPattern");
            fc.addContent(parentEp);/*from   w  w w .  jav a  2 s .  c  o m*/
        }
    }

    // Pattern Roles
    // Pattern roles properties
    changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document,
            "ContainedEditionPatternInstancePatternRole");
    changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document,
            "AddressedSelectEditionPatternInstance");
    changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document,
            "SelectEditionPatternInstance");
    changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document,
            "EditionPatternInstanceParameter");
    changePropertyName("paletteElementID", "paletteElementId", document, "FMLDiagramPaletteElementBinding");
    changePropertyName("editionPattern", "flexoConcept", document, "PaletteElement");
    removeProperties("patternRole", document);
    removeProperty("className", document, "DrawingGraphicalRepresentation");
    removeProperty("className", document, "ShapeGraphicalRepresentation");
    removeProperty("className", document, "ConnectorGraphicalRepresentation");
    // Pattern roles name
    convertOldNameToNewNames("ContainedEditionPatternInstancePatternRole", "FlexoConceptInstanceRole",
            document);
    convertOldNameToNewNames("EditionPatternInstancePatternRole", "FlexoConceptInstanceRole", document);
    convertOldNameToNewNames("ContainedShapePatternRole", "ShapeRole", document);
    convertOldNameToNewNames("ShapePatternRole", "ShapeRole", document);
    convertOldNameToNewNames("ContextShapePatternRole", "ShapeRole", document);
    convertOldNameToNewNames("ParentShapePatternRole", "ParentShapeRole", document);
    convertOldNameToNewNames("ContainedEMFObjectIndividualPatternRole", "EMFObjectIndividualRole", document);
    convertOldNameToNewNames("EMFObjectIndividualPatternRole", "EMFObjectIndividualRole", document);
    convertOldNameToNewNames("ContainedConnectorPatternRole", "ConnectorRole", document);
    convertOldNameToNewNames("ConnectorPatternRole", "ConnectorRole", document);
    convertOldNameToNewNames("ContainedOWLIndividualPatternRole", "OWLIndividualRole", document);
    convertOldNameToNewNames("OWLIndividualPatternRole", "OWLIndividualRole", document);
    convertOldNameToNewNames("ContainedObjectPropertyStatementPatternRole", "ObjectPropertyStatementRole",
            document);
    convertOldNameToNewNames("ObjectPropertyStatementPatternRole", "ObjectPropertyStatementRole", document);
    convertOldNameToNewNames("ContainedDataPropertyStatementPatternRole", "DataPropertyStatementRole",
            document);
    convertOldNameToNewNames("DataPropertyStatementPatternRole", "DataPropertyStatementRole", document);
    convertOldNameToNewNames("ContainedExcelCellPatternRole", "ExcelCellRole", document);
    convertOldNameToNewNames("ExcelCellPatternRole", "ExcelCellRole", document);
    convertOldNameToNewNames("ContainedExcelSheetPatternRole", "ExcelSheetRole", document);
    convertOldNameToNewNames("ExcelSheetPatternRole", "ExcelSheetRole", document);
    convertOldNameToNewNames("ContainedExcelRowPatternRole", "ExcelRowRole", document);
    convertOldNameToNewNames("ExcelRowPatternRole", "ExcelRowRole", document);
    convertOldNameToNewNames("ContainedDiagramPatternRole", "DiagramRole", document);
    convertOldNameToNewNames("DiagramPatternRole", "DiagramRole", document);
    convertOldNameToNewNames("ContainedXMLIndividualPatternRole", "XMLIndividualRole", document);
    convertOldNameToNewNames("XMLIndividualPatternRole", "XMLIndividualRole", document);
    convertOldNameToNewNames("ContainedXSIndividualPatternRole", "XSIndividualRole", document);
    convertOldNameToNewNames("XSIndividualPatternRole", "XSIndividualRole", document);
    convertOldNameToNewNames("ContainedXSClassPatternRole", "XSClassRole", document);
    convertOldNameToNewNames("XSClassPatternRole", "XSClassRole", document);

    // Actions
    convertOldNameToNewNames("EditionPatternInstanceParameter", "FlexoConceptInstanceParameter", document);
    convertOldNameToNewNames("MatchEditionPatternInstance", "MatchFlexoConceptInstance", document);
    convertOldNameToNewNames("CreateEditionPatternInstanceParameter", "CreateFlexoConceptInstanceParameter",
            document);
    // Retrieve Fetch Actions
    IteratorIterable<? extends Content> fetchElementsIterator = document
            .getDescendants(new ElementFilter("FetchRequestIterationAction"));
    List<Element> fetchElements = IteratorUtils.toList(fetchElementsIterator);
    for (Element fetchElement : fetchElements) {
        for (Element child : fetchElement.getChildren()) {
            if (child.getName().equals("AddressedSelectEditionPatternInstance")) {
                child.setName("FetchRequest_SelectFlexoConceptInstance");
            }
            if (child.getName().equals("AddressedSelectEMFObjectIndividual")) {
                child.setName("FetchRequest_SelectEMFObjectIndividual");
            }
            if (child.getName().equals("AddressedSelectIndividual")) {
                child.setName("FetchRequest_SelectIndividual");
            }
            if (child.getName().equals("AddressedSelectExcelCell")) {
                child.setName("FetchRequest_SelectExcelCell");
            }
            if (child.getName().equals("AddressedSelectExcelRow")) {
                child.setName("FetchRequest_SelectExcelRow");
            }
            if (child.getName().equals("AddressedSelectExcelSheet")) {
                child.setName("FetchRequest_SelectExcelSheet");
            }
            if (child.getName().equals("AddressedSelectEditionPatternInstance")) {
                child.setName("FetchRequest_SelectFlexoConceptInstance");
            }
        }
    }
    // Built-in actions
    convertOldNameToNewNames("DeclarePatternRole", "DeclareFlexoRole", document);
    convertOldNameToNewNames("AddEditionPatternInstance", "AddFlexoConceptInstance", document);
    convertOldNameToNewNames("AddEditionPatternInstanceParameter", "AddFlexoConceptInstanceParameter",
            document);
    convertOldNameToNewNames("AddressedSelectEditionPatternInstance", "SelectFlexoConceptInstance", document);
    convertOldNameToNewNames("AddressedSelectFlexoConceptInstance", "SelectFlexoConceptInstance", document);
    convertOldNameToNewNames("SelectEditionPatternInstance", "SelectFlexoConceptInstance", document);

    // Model Slots
    for (Content content : document.getDescendants()) {
        if (content instanceof Element) {
            Element element = (Element) content;
            if ((element.getParentElement() != null)
                    && (element.getParentElement().getName().equals("DiagramSpecification")
                            || element.getParentElement().getName().equals("VirtualModel"))) {
                if (element.getName().equals("EMFModelSlot")) {
                    element.setName("ModelSlot_EMFModelSlot");
                } else if (element.getName().equals("XMLModelSlot")) {
                    element.setName("ModelSlot_XMLModelSlot");
                } else if (element.getName().equals("XSDModelSlot")) {
                    element.setName("ModelSlot_XSDModelSlot");
                } else if (element.getName().equals("BasicExcelModelSlot")) {
                    element.setName("ModelSlot_BasicExcelModelSlot");
                } else if (element.getName().equals("SemanticsExcelModelSlot")) {
                    element.setName("ModelSlot_SemanticsExcelModelSlot");
                } else if (element.getName().equals("BasicPowerpointModelSlot")) {
                    element.setName("ModelSlot_SemanticsPowerpointModelSlot");
                } else if (element.getName().equals("OWLModelSlot")) {
                    element.setName("ModelSlot_OWLModelSlot");
                } else if (element.getName().equals("VirtualModelModelSlot")) {
                    element.setName("ModelSlot_VirtualModelModelSlot");
                }
            } else {
                if (element.getName().equals("AddressedEMFModelSlot")) {
                    element.setName("EMFModelSlot");
                } else if (element.getName().equals("AddressedXMLModelSlot")) {
                    element.setName("XMLModelSlot");
                } else if (element.getName().equals("AddressedXSDModelSlot")) {
                    element.setName("XSDModelSlot");
                } else if (element.getName().equals("AddressedBasicExcelModelSlot")) {
                    element.setName("BasicExcelModelSlot");
                } else if (element.getName().equals("AddressedSemanticsExcelModelSlot")) {
                    element.setName("SemanticsExcelModelSlot");
                } else if (element.getName().equals("AddressedBasicPowerpointModelSlot")) {
                    element.setName("BasicPowerpointModelSlot");
                } else if (element.getName().equals("AddressedSemanticsPowerpointModelSlot")) {
                    element.setName("SemanticsPowerpointModelSlot");
                } else if (element.getName().equals("AddressedOWLModelSlot")) {
                    element.setName("OWLModelSlot");
                } else if (element.getName().equals("AddressedDiagramModelSlot")) {
                    element.setName("TypedDiagramModelSlot");
                } else if (element.getName().equals("AddressedVirtualModelModelSlot")) {
                    element.setName("VirtualModelModelSlot");
                }
            }
        }
    }

    // Palettes/ExampleDiagrams
    // Retrieve Connector GRs
    IteratorIterable<? extends Content> connectorGRElementsIterator = document
            .getDescendants(new ElementFilter("ConnectorGraphicalRepresentation"));
    List<Element> connectorGRElements = IteratorUtils.toList(connectorGRElementsIterator);
    for (Element connectorGRElement : connectorGRElements) {
        Element grSpec = null;
        if (connectorGRElement.getChild("RectPolylinConnector") != null) {
            grSpec = connectorGRElement.getChild("RectPolylinConnector");
        } else if (connectorGRElement.getChild("LineConnector") != null) {
            grSpec = connectorGRElement.getChild("LineConnector");
        } else if (connectorGRElement.getChild("CurvedPolylinConnector") != null) {
            grSpec = connectorGRElement.getChild("CurvedPolylinConnector");
        } else if (connectorGRElement.getChild("ArcConnector") != null) {
            grSpec = connectorGRElement.getChild("ArcConnector");
        }
        if (connectorGRElement.getAttribute("startSymbol") != null) {
            Attribute startSymbol = new Attribute("startSymbol",
                    connectorGRElement.getAttributeValue("startSymbol"));
            grSpec.getAttributes().add(startSymbol);
            connectorGRElement.removeAttribute("startSymbol");
        }
        if (connectorGRElement.getAttribute("endSymbol") != null) {
            Attribute endSymbol = new Attribute("endSymbol", connectorGRElement.getAttributeValue("endSymbol"));
            grSpec.getAttributes().add(endSymbol);
            connectorGRElement.removeAttribute("endSymbol");
        }
        if (connectorGRElement.getAttribute("middleSymbol") != null) {
            Attribute middleSymbol = new Attribute("middleSymbol",
                    connectorGRElement.getAttributeValue("middleSymbol"));
            grSpec.getAttributes().add(middleSymbol);
            connectorGRElement.removeAttribute("middleSymbol");
        }
        if (connectorGRElement.getAttribute("startSymbolSize") != null) {
            Attribute startSymbolSize = new Attribute("startSymbolSize",
                    connectorGRElement.getAttributeValue("startSymbolSize"));
            grSpec.getAttributes().add(startSymbolSize);
            connectorGRElement.removeAttribute("startSymbolSize");
        }
        if (connectorGRElement.getAttribute("endSymbolSize") != null) {
            Attribute endSymbolSize = new Attribute("endSymbolSize",
                    connectorGRElement.getAttributeValue("endSymbolSize"));
            grSpec.getAttributes().add(endSymbolSize);
            connectorGRElement.removeAttribute("endSymbolSize");
        }
        if (connectorGRElement.getAttribute("middleSymbolSize") != null) {
            Attribute middleSymbolSize = new Attribute("middleSymbolSize",
                    connectorGRElement.getAttributeValue("middleSymbolSize"));
            grSpec.getAttributes().add(middleSymbolSize);
            connectorGRElement.removeAttribute("middleSymbolSize");
        }
        if (connectorGRElement.getAttribute("relativeMiddleSymbolLocation") != null) {
            Attribute relativeMiddleSymbolLocation = new Attribute("relativeMiddleSymbolLocation",
                    connectorGRElement.getAttributeValue("relativeMiddleSymbolLocation"));
            grSpec.getAttributes().add(relativeMiddleSymbolLocation);
            connectorGRElement.removeAttribute("relativeMiddleSymbolLocation");
        }
    }

    convertOldNameToNewNames("Palette", "DiagramPalette", document);
    convertOldNameToNewNames("PaletteElement", "DiagramPaletteElement", document);
    convertOldNameToNewNames("Shema", "Diagram", document);
    convertOldNameToNewNames("ContainedShape", "Shape", document);
    convertOldNameToNewNames("ContainedConnector", "Connector", document);
    convertOldNameToNewNames("FromShape", "StartShape", document);
    convertOldNameToNewNames("ToShape", "EndShape", document);
    convertOldNameToNewNames("Border", "ShapeBorder", document);
    convertOldNameToNewNames("LineConnector", "LineConnectorSpecification", document);
    convertOldNameToNewNames("CurvedPolylinConnector", "CurvedPolylinConnectorSpecification", document);
    convertOldNameToNewNames("RectPolylinConnector", "RectPolylinConnectorSpecification", document);

    removeNamedElements(document, "PrimaryConceptOWLIndividualPatternRole");
    removeNamedElements(document, "StartShapeGraphicalRepresentation");
    removeNamedElements(document, "EndShapeGraphicalRepresentation");
    removeNamedElements(document, "ArtifactFromShapeGraphicalRepresentation");
    removeNamedElements(document, "ArtifactToShapeGraphicalRepresentation");
    removeNamedElements(document, "PrimaryRepresentationConnectorPatternRole");
    removeNamedElements(document, "PrimaryRepresentationShapePatternRole");
    removeNamedElements(document, "PrimaryConceptObjectPropertyStatementPatternRole");
    removeNamedElements(document, "ToShapePatternRole");
    removeNamedElements(document, "StartShapeGraphicalRepresentation");
    removeNamedElements(document, "EndShapeGraphicalRepresentation");

    // Change all "this"
    for (Content content : document.getDescendants()) {
        if (content instanceof Element) {
            Element element = (Element) content;
            for (Attribute attribute : element.getAttributes()) {
                if (attribute.getValue().startsWith("this")) {
                    if (element.getName().equals("ModelSlot_VirtualModelModelSlot")) {
                        attribute.setValue(attribute.getValue().replace("this", "virtualModelInstance"));
                    }
                    if (element.getName().equals("VirtualModelModelSlot")) {
                        attribute.setValue(attribute.getValue().replace("this", "virtualModelInstance"));
                    }
                    if (attribute.getName().equals("virtualModelInstance")) {
                        attribute.setValue(attribute.getValue().replace("this", "virtualModelInstance"));
                    } else {
                        attribute.setValue(attribute.getValue().replace("this", "flexoBehaviourInstance"));
                    }
                }
            }
        }
    }

}

From source file:org.openflexo.technologyadapter.owl.model.OWLOntology.java

License:Open Source License

private static String findOntologyURIWithRDFBaseMethod(File aFile) {
    Document document;//  w  w w. j  a  v  a  2  s .com
    try {
        logger.fine("Try to find URI for " + aFile);
        document = readXMLFile(aFile);
        Element root = getElement(document, "RDF");
        if (root != null) {
            Iterator it = root.getAttributes().iterator();
            while (it.hasNext()) {
                Attribute at = (Attribute) it.next();
                if (at.getName().equals("base")) {
                    logger.fine("Returned " + at.getValue());
                    return at.getValue();
                }
            }
        }
        root = getElement(document, "Ontology");
        if (root != null) {
            Iterator it = root.getAttributes().iterator();
            while (it.hasNext()) {
                Attribute at = (Attribute) it.next();
                if (at.getName().equals("base")) {
                    logger.fine("Returned " + at.getValue());
                    return at.getValue();
                }
            }
        }
    } catch (JDOMException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    logger.fine("Returned null");
    return null;
}

From source file:org.openflexo.technologyadapter.owl.model.OWLOntology.java

License:Open Source License

public static String findOntologyName(File aFile) {
    if (aFile == null || !aFile.exists() || aFile.length() == 0) {
        if (aFile != null && aFile.length() == 0) {
            aFile.delete();//  w ww  .  j  av  a2 s .c o m
        }
        return null;
    }

    Document document;
    try {
        logger.fine("Try to find name for " + aFile);
        document = readXMLFile(aFile);
        Element root = getElement(document, "RDF");
        if (root != null) {
            Element ontology = getElement(root, "Ontology");
            if (ontology != null) {
                Element title = getElement(root, "title");
                if (title != null) {
                    return title.getValue();
                }
                List<Attribute> l = ontology.getAttributes();
                for (int i = 0; i < l.size(); i++) {
                    Attribute a = l.get(i);
                    if (a.getName().equals("title")) {
                        return a.getValue();
                    }
                }
            }
        }
    } catch (JDOMException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return aFile.getName();
}

From source file:org.rascalmpl.library.lang.xml.DOM.java

License:Open Source License

private IConstructor convertElement(Element e, boolean trim) {
    IListWriter kids = vf.listWriter(Factory.Node);
    for (Object o : e.getAttributes()) {
        Attribute attr = (Attribute) o;
        IString key = vf.string(attr.getName());
        IString val = vf.string(attr.getValue());

        kids.insert(vf.constructor(Factory.Node_attribute, convertNamespace(attr.getNamespace()), key, val));
    }/* w w  w .  java  2 s.c  om*/

    int len = e.getContentSize();
    for (int i = 0; i < len; i++) {
        try {
            kids.append(convertContent(e.getContent(i), trim));
        } catch (Skip c) { // Ugh, terrible, but I'm in hurry
            continue;
        }
    }

    IString name = vf.string(e.getName());
    return vf.constructor(Factory.Node_element, convertNamespace(e.getNamespace()), name, kids.done());
}

From source file:org.universaal.tools.configurationEditor.editors.ConfigurationEditor.java

License:Apache License

private void createMainBar(String xml, ExpandBar mainBar) {

    Composite mainComp = new Composite(mainBar, SWT.NONE);
    GridLayout mainLayout = new GridLayout(2, false);
    mainComp.setLayout(mainLayout);/*from   w w w.  j  a v  a  2  s .c  o m*/

    try {

        this.doc = new SAXBuilder().build(new StringReader(xml));
        Element config = doc.getRootElement();

        Label l1;
        Text t1;

        ExpandItem itemMain = new ExpandItem(mainBar, SWT.NONE, 0);
        itemMain.setText("Configuration");
        itemMain.setControl(mainComp);

        List<Attribute> ats = config.getAttributes();

        for (Attribute at : ats) {

            l1 = new Label(mainComp, SWT.NONE);
            l1.setText(at.getName() + ":");

            t1 = new Text(mainComp, SWT.SINGLE | SWT.BORDER);
            t1.setEditable(true);
            t1.setText(at.getValue());

            // ------------- <Listener> --------------

            WidgetMapping.put(t1, at);
            t1.addModifyListener(widgetListener);

            // ------------- </Listener> --------------

            GridData gd = new GridData();
            gd.horizontalAlignment = GridData.FILL;
            gd.grabExcessHorizontalSpace = true;
            t1.setLayoutData(gd);

        }

        itemMain.setHeight(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
        itemMain.setExpanded(true);

        createCategoryList(config);

    } catch (JDOMException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.universaal.tools.configurationEditor.editors.ConfigurationEditor.java

License:Apache License

private void showCategory(Element el) {

    for (Control wi : selectedItemGroup.getChildren()) {
        wi.dispose();//from   w ww .j av a2  s. c o m
    }

    Label l1;
    Text t1;

    List<Attribute> cAts = el.getAttributes();

    for (Attribute at : cAts) {

        l1 = new Label(selectedItemGroup, SWT.NONE);
        l1.setText(at.getName() + ":");

        t1 = new Text(selectedItemGroup, SWT.SINGLE | SWT.BORDER);
        t1.setEditable(true);
        t1.setText(at.getValue());

        // ------------- <Listener> --------------

        WidgetMapping.put(t1, at);
        t1.addModifyListener(widgetListener);

        // ------------- </Listener> --------------

        GridData gd = new GridData();
        gd.horizontalAlignment = GridData.FILL;
        gd.grabExcessHorizontalSpace = true;
        t1.setLayoutData(gd);

    }

}

From source file:org.universaal.tools.configurationEditor.editors.ConfigurationEditor.java

License:Apache License

private void showSimpleConfigItem(Element el) {
    for (Control wi : selectedItemGroup.getChildren()) {
        wi.dispose();/*from www .  java  2  s  .co  m*/
    }

    List<Attribute> tiAtts = el.getAttributes();
    Label l1;
    Text t1;

    for (Attribute att : tiAtts) {
        l1 = new Label(selectedItemGroup, SWT.NONE);
        l1.setText(att.getName() + ":");

        t1 = new Text(selectedItemGroup, SWT.SINGLE | SWT.BORDER);
        t1.setEditable(true);
        t1.setText(att.getValue());

        // ------------- <Listener> --------------

        WidgetMapping.put(t1, att);
        t1.addModifyListener(widgetListener);

        // ------------- </Listener> --------------

        GridData gd = new GridData();
        gd.horizontalAlignment = GridData.FILL;
        gd.grabExcessHorizontalSpace = true;
        t1.setLayoutData(gd);
    }

    // TI's children
    List<Element> tiEls = el.getChildren();

    for (Element tiEl : tiEls) {

        if (tiEl.getName().equals("validators")) {
            //DO NOTHING!
        } else {

            l1 = new Label(selectedItemGroup, SWT.NONE);
            l1.setText(tiEl.getName() + ":");

            t1 = new Text(selectedItemGroup, SWT.SINGLE | SWT.BORDER);
            t1.setEditable(true);
            t1.setText(tiEl.getValue());

            // ------------- <Listener> --------------

            WidgetMapping.put(t1, tiEl);
            t1.addModifyListener(widgetListener);

            // ------------- </Listener> --------------

            GridData gd = new GridData();
            gd.horizontalAlignment = GridData.FILL;
            gd.grabExcessHorizontalSpace = true;
            t1.setLayoutData(gd);
        }
    }

}

From source file:org.universaal.tools.configurationEditor.editors.ConfigurationEditor.java

License:Apache License

private void showMapConfigItem(Element el) {
    for (Control wi : selectedItemGroup.getChildren()) {
        wi.dispose();/*from ww w .  j  a v a 2 s  . co m*/
    }

    List<Attribute> tiAtts = el.getAttributes();
    Label l1;
    Text t1;

    for (Attribute att : tiAtts) {
        l1 = new Label(selectedItemGroup, SWT.NONE);
        l1.setText(att.getName() + ":");

        t1 = new Text(selectedItemGroup, SWT.SINGLE | SWT.BORDER);
        t1.setEditable(true);
        t1.setText(att.getValue());

        // ------------- <Listener> --------------

        WidgetMapping.put(t1, att);
        t1.addModifyListener(widgetListener);

        // ------------- </Listener> --------------

        GridData gd = new GridData();
        gd.horizontalAlignment = GridData.FILL;
        gd.grabExcessHorizontalSpace = true;
        t1.setLayoutData(gd);
    }

    // TI's children
    List<Element> tiEls = el.getChildren();

    for (Element tiEl : tiEls) {

        // mapConfigItem
        if (tiEl.getName().equals("options")) {
            //            l1 = new Label(selectedItemGroup, SWT.NONE);
            //            l1.setText(tiEl.getName() + ":");

            //            Combo combo = new Combo(selectedItemGroup, SWT.NONE | SWT.READ_ONLY);

            List<Element> opt = tiEl.getChildren();
            for (Element e : opt) {
                l1 = new Label(selectedItemGroup, SWT.NONE);
                l1.setText(e.getName() + ":");
                t1 = new Text(selectedItemGroup, SWT.SINGLE | SWT.BORDER);
                t1.setEditable(true);
                t1.setText(e.getValue());

                // ------------- <Listener> --------------
                WidgetMapping.put(t1, e);
                t1.addModifyListener(widgetListener);
                // ------------- </Listener> --------------

                GridData gd = new GridData();
                gd.horizontalAlignment = GridData.FILL;
                gd.grabExcessHorizontalSpace = true;
                t1.setLayoutData(gd);
            }

            //            GridData gd = new GridData();
            //            gd.horizontalAlignment = GridData.FILL;
            //            gd.grabExcessHorizontalSpace = true;
            //            combo.setLayoutData(gd);

            // Validators
        } else if (tiEl.getName().equals("validators")) {
            //DO NOTHING!
        } else {

            l1 = new Label(selectedItemGroup, SWT.NONE);
            l1.setText(tiEl.getName() + ":");

            t1 = new Text(selectedItemGroup, SWT.SINGLE | SWT.BORDER);
            t1.setEditable(true);
            t1.setText(tiEl.getValue());

            // ------------- <Listener> --------------

            WidgetMapping.put(t1, tiEl);
            t1.addModifyListener(widgetListener);

            // ------------- </Listener> --------------

            GridData gd = new GridData();
            gd.horizontalAlignment = GridData.FILL;
            gd.grabExcessHorizontalSpace = true;
            t1.setLayoutData(gd);
        }
    }

}

From source file:org.yawlfoundation.yawl.elements.YNet.java

License:Open Source License

public void setIncomingData(YPersistenceManager pmgr, Element incomingData)
        throws YDataStateException, YPersistenceException {
    for (YParameter parameter : getInputParameters().values()) {
        Element actualParam = incomingData.getChild(parameter.getName());
        if (parameter.isMandatory() && actualParam == null) {
            throw new IllegalArgumentException("The input data for Net:" + getID()
                    + " is missing mandatory input data for a parameter (" + parameter.getName() + ").  "
                    + " Alternatively the data is there but the query in the super net produced data with"
                    + " the wrong name (Check your specification). "
                    + new XMLOutputter(Format.getPrettyFormat()).outputString(incomingData).trim());
        }/*w  ww .  j  a  va 2  s. c  o m*/

        // remove any attributes - not required and cause validation errors if left
        if ((actualParam != null) && !actualParam.getAttributes().isEmpty()) {
            JDOMUtil.stripAttributes(actualParam);
        }
    }

    // validate against schema
    getSpecification().getDataValidator().validate(getInputParameters().values(), incomingData, getID());

    for (Element element : incomingData.getChildren()) {
        if (getInputParameters().containsKey(element.getName())) {
            addData(pmgr, element.clone());
        } else {
            throw new IllegalArgumentException(
                    "Element " + element + " is not a valid input parameter of " + this);
        }
    }
}

From source file:org.yawlfoundation.yawl.engine.interfce.Marshaller.java

License:Open Source License

public static Hashtable<String, String> unmarshalWorkItemAttributes(Element item) {
    YAttributeMap result = new YAttributeMap();
    result.fromJDOM(item.getAttributes());
    return result;
}