Search in sources :

Example 31 with XSDAttributeGroupDefinition

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

the class XSDComplexTypeDefinitionAdapter method getChildren.

public ITreeElement[] getChildren() {
    XSDComplexTypeDefinition xsdComplexTypeDefinition = getXSDComplexTypeDefinition();
    List list = new ArrayList();
    // Add attributes
    for (Iterator i = xsdComplexTypeDefinition.getAttributeContents().iterator(); i.hasNext(); ) {
        Object obj = i.next();
        if (obj instanceof XSDAttributeUse) {
            list.add(((XSDAttributeUse) obj).getAttributeDeclaration());
        } else if (obj instanceof XSDAttributeGroupDefinition) {
            getAttributeUses((XSDAttributeGroupDefinition) obj, list);
        }
    }
    // Add enumerations
    boolean canHaveEnumerations = xsdComplexTypeDefinition.getContentType() instanceof XSDSimpleTypeDefinition && XSDDerivationMethod.RESTRICTION_LITERAL.equals(xsdComplexTypeDefinition.getDerivationMethod());
    if (canHaveEnumerations) {
        Object contentType = getContentType();
        if (contentType != null) {
            for (Iterator iterator = ((XSDSimpleTypeDefinition) contentType).getEnumerationFacets().iterator(); iterator.hasNext(); ) {
                XSDEnumerationFacet enumerationFacet = (XSDEnumerationFacet) iterator.next();
                list.add(enumerationFacet);
            }
        }
    }
    XSDWildcard anyAttr = xsdComplexTypeDefinition.getAttributeWildcard();
    if (anyAttr != null)
        list.add(anyAttr);
    // get immediate XSD Model Group of this complex type
    if (xsdComplexTypeDefinition.getContent() != null) {
        XSDComplexTypeContent xsdComplexTypeContent = xsdComplexTypeDefinition.getContent();
        if (xsdComplexTypeContent instanceof XSDParticle) {
            XSDParticleContent particleContent = ((XSDParticle) xsdComplexTypeContent).getContent();
            if (particleContent instanceof XSDModelGroup) {
                list.add(particleContent);
            }
        }
    }
    // get inherited XSD Model Group of this complex type
    boolean showInheritedContent = XSDEditorPlugin.getPlugin().getShowInheritedContent();
    if (showInheritedContent) {
        XSDTypeDefinition typeDef = xsdComplexTypeDefinition.getBaseTypeDefinition();
        if (typeDef instanceof XSDComplexTypeDefinition) {
            XSDComplexTypeDefinition baseCT = (XSDComplexTypeDefinition) typeDef;
            if (baseCT.getTargetNamespace() != null && !baseCT.getTargetNamespace().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) {
                if (baseCT.getContent() != null) {
                    XSDComplexTypeContent xsdComplexTypeContent = baseCT.getContent();
                    if (xsdComplexTypeContent instanceof XSDParticle) {
                        XSDParticleContent particleContent = ((XSDParticle) xsdComplexTypeContent).getContent();
                        if (particleContent instanceof XSDModelGroup) {
                            list.add(particleContent);
                        }
                    }
                }
            }
        }
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDEnumerationFacet(org.eclipse.xsd.XSDEnumerationFacet) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 32 with XSDAttributeGroupDefinition

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

the class XSDSchemaAdapter method getAttributeGroupList.

public List getAttributeGroupList(XSDSchema xsdSchema, boolean showFromIncludes) {
    List attributeGroupList = new ArrayList();
    for (Iterator i = xsdSchema.getAttributeGroupDefinitions().iterator(); i.hasNext(); ) {
        XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) i.next();
        if (shouldShowComponent(attrGroup, xsdSchema, showFromIncludes)) {
            attributeGroupList.add(attrGroup);
        }
    }
    List adapterList = new ArrayList();
    populateAdapterList(attributeGroupList, adapterList);
    return adapterList;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 33 with XSDAttributeGroupDefinition

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

the class XSDVisitorForFields method visitAttributeGroupDefinition.

public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) {
    for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext(); ) {
        Object o = it.next();
        if (o instanceof XSDAttributeUse) {
            XSDAttributeUse attributeUse = (XSDAttributeUse) o;
            concreteComponentList.add(attributeUse.getAttributeDeclaration());
            thingsWeNeedToListenTo.add(attributeUse.getAttributeDeclaration());
        } else if (o instanceof XSDAttributeGroupDefinition) {
            XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) o;
            thingsWeNeedToListenTo.add(attrGroup);
            if (attrGroup.isAttributeGroupDefinitionReference()) {
                attrGroup = attrGroup.getResolvedAttributeGroupDefinition();
                visitAttributeGroupDefinition(attrGroup);
            }
        }
    }
    XSDWildcard anyAttribute = attributeGroup.getAttributeWildcardContent();
    if (anyAttribute != null) {
        concreteComponentList.add(anyAttribute);
        thingsWeNeedToListenTo.add(anyAttribute);
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) Iterator(java.util.Iterator) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 34 with XSDAttributeGroupDefinition

use of org.eclipse.xsd.XSDAttributeGroupDefinition 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 35 with XSDAttributeGroupDefinition

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

the class TypesHelper method getGlobalAttributeGroups.

public java.util.List getGlobalAttributeGroups() {
    Vector items = new Vector();
    if (xsdSchema != null) {
        updateExternalImportGlobals();
        if (xsdSchema.getAttributeGroupDefinitions() != null) {
            Iterator i = xsdSchema.getAttributeGroupDefinitions().iterator();
            while (i.hasNext()) {
                XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) i.next();
                String name = attributeGroupDefinition.getQName(xsdSchema);
                if (name != null) {
                    items.add(name);
                }
            }
        }
        // items = addExternalImportedAttributeGroups(items);
        items = (Vector) sortList(items);
    }
    return items;
}
Also used : Iterator(java.util.Iterator) Vector(java.util.Vector) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Aggregations

XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)42 Iterator (java.util.Iterator)20 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)17 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)16 ArrayList (java.util.ArrayList)15 List (java.util.List)15 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)15 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)15 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)13 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)13 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)13 XSDSchema (org.eclipse.xsd.XSDSchema)12 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)11 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)11 XSDParticle (org.eclipse.xsd.XSDParticle)11 EList (org.eclipse.emf.common.util.EList)10 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)9 Element (org.w3c.dom.Element)9 XSDWildcard (org.eclipse.xsd.XSDWildcard)8 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)7