Search in sources :

Example 1 with XSDNotationDeclaration

use of org.eclipse.xsd.XSDNotationDeclaration in project webtools.sourceediting by eclipse.

the class XSDCommonUIUtils method getInputXSDAnnotation.

public static XSDAnnotation getInputXSDAnnotation(XSDConcreteComponent input, boolean createIfNotExist) {
    XSDAnnotation xsdAnnotation = null;
    XSDFactory factory = XSDFactory.eINSTANCE;
    if (input instanceof XSDAttributeDeclaration) {
        XSDAttributeDeclaration xsdComp = (XSDAttributeDeclaration) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDAttributeGroupDefinition) {
        XSDAttributeGroupDefinition xsdComp = (XSDAttributeGroupDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDElementDeclaration) {
        XSDElementDeclaration xsdComp = (XSDElementDeclaration) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDNotationDeclaration) {
        XSDNotationDeclaration xsdComp = (XSDNotationDeclaration) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDXPathDefinition) {
        XSDXPathDefinition xsdComp = (XSDXPathDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDModelGroup) {
        XSDModelGroup xsdComp = (XSDModelGroup) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDModelGroupDefinition) {
        XSDModelGroupDefinition xsdComp = (XSDModelGroupDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition xsdComp = (XSDIdentityConstraintDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDWildcard) {
        XSDWildcard xsdComp = (XSDWildcard) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDSchema) {
        XSDSchema xsdComp = (XSDSchema) input;
        List list = xsdComp.getAnnotations();
        if (list.size() > 0) {
            xsdAnnotation = (XSDAnnotation) list.get(0);
        } else {
            if (createIfNotExist && xsdAnnotation == null) {
                xsdAnnotation = factory.createXSDAnnotation();
                if (xsdComp.getContents() != null) {
                    xsdComp.getContents().add(0, xsdAnnotation);
                }
            }
        }
        return xsdAnnotation;
    } else if (input instanceof XSDFacet) {
        XSDFacet xsdComp = (XSDFacet) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDTypeDefinition) {
        XSDTypeDefinition xsdComp = (XSDTypeDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDInclude) {
        XSDInclude xsdComp = (XSDInclude) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDImport) {
        XSDImport xsdComp = (XSDImport) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDRedefine) {
        XSDRedefine xsdComp = (XSDRedefine) input;
        List contents = xsdComp.getContents();
        for (int i = 0; i < contents.size(); i++) {
            Object content = contents.get(i);
            if (content instanceof XSDAnnotation) {
                xsdAnnotation = (XSDAnnotation) content;
                break;
            }
        }
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            contents.add(0, xsdAnnotation);
        }
        return xsdAnnotation;
    } else if (input instanceof XSDAnnotation) {
        xsdAnnotation = (XSDAnnotation) input;
    }
    if (createIfNotExist) {
        formatAnnotation(xsdAnnotation);
    }
    return xsdAnnotation;
}
Also used : XSDFactory(org.eclipse.xsd.XSDFactory) XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDFacet(org.eclipse.xsd.XSDFacet) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) EObject(org.eclipse.emf.ecore.EObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDImport(org.eclipse.xsd.XSDImport) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDSchema(org.eclipse.xsd.XSDSchema) XSDInclude(org.eclipse.xsd.XSDInclude)

Example 2 with XSDNotationDeclaration

use of org.eclipse.xsd.XSDNotationDeclaration in project webtools.sourceediting by eclipse.

the class XSDVisitor method visitSchema.

public void visitSchema(XSDSchema schema) {
    this.schema = schema;
    for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
        XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
        visitAttributeDeclaration(attr);
    }
    for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
        visitTypeDefinition(type);
    }
    for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
        XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
        visitElementDeclaration(element);
    }
    for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
        XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
        visitIdentityConstraintDefinition(identityConstraint);
    }
    for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
        visitModelGroupDefinition(modelGroup);
    }
    for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
        visitAttributeGroupDefinition(attributeGroup);
    }
    for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
        XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
        visitNotationDeclaration(element);
    }
}
Also used : XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 3 with XSDNotationDeclaration

use of org.eclipse.xsd.XSDNotationDeclaration in project webtools.sourceediting by eclipse.

the class XSDVisitor method visitSchema.

public void visitSchema(XSDSchema schema) {
    this.schema = schema;
    for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
        XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
        visitAttributeDeclaration(attr);
    }
    for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
        visitTypeDefinition(type);
    }
    for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
        XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
        visitElementDeclaration(element);
    }
    for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
        XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
        visitIdentityConstraintDefinition(identityConstraint);
    }
    for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
        visitModelGroupDefinition(modelGroup);
    }
    for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
        visitAttributeGroupDefinition(attributeGroup);
    }
    for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
        XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
        visitNotationDeclaration(element);
    }
}
Also used : XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 4 with XSDNotationDeclaration

use of org.eclipse.xsd.XSDNotationDeclaration in project webtools.sourceediting by eclipse.

the class XSDVisitor method visitSchema.

public void visitSchema(XSDSchema schema) {
    this.schema = schema;
    for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
        XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
        visitAttributeDeclaration(attr);
    }
    for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
        visitTypeDefinition(type);
    }
    for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
        XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
        visitElementDeclaration(element);
    }
    for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
        XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
        visitIdentityConstraintDefinition(identityConstraint);
    }
    for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
        visitModelGroupDefinition(modelGroup);
    }
    for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
        visitAttributeGroupDefinition(attributeGroup);
    }
    for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
        XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
        visitNotationDeclaration(element);
    }
}
Also used : XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Aggregations

XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)4 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)4 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)4 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)4 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)4 XSDNotationDeclaration (org.eclipse.xsd.XSDNotationDeclaration)4 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)4 Iterator (java.util.Iterator)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 EObject (org.eclipse.emf.ecore.EObject)1 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)1 XSDFacet (org.eclipse.xsd.XSDFacet)1 XSDFactory (org.eclipse.xsd.XSDFactory)1 XSDImport (org.eclipse.xsd.XSDImport)1 XSDInclude (org.eclipse.xsd.XSDInclude)1 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)1 XSDRedefine (org.eclipse.xsd.XSDRedefine)1 XSDSchema (org.eclipse.xsd.XSDSchema)1