Search in sources :

Example 6 with ITreeElement

use of org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement in project webtools.sourceediting by eclipse.

the class XSDAttributeGroupDefinitionAdapter method getChildren.

public ITreeElement[] getChildren() {
    XSDAttributeGroupDefinition xsdAttributeGroup = (XSDAttributeGroupDefinition) target;
    List list = new ArrayList();
    Iterator iterator = xsdAttributeGroup.getContents().iterator();
    while (iterator.hasNext()) {
        Object o = iterator.next();
        if (o instanceof XSDAttributeUse) {
            list.add(((XSDAttributeUse) o).getAttributeDeclaration());
        } else {
            list.add(o);
        }
    }
    XSDWildcard wildcard = xsdAttributeGroup.getAttributeWildcardContent();
    if (wildcard != null) {
        list.add(wildcard);
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 7 with ITreeElement

use of org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement in project webtools.sourceediting by eclipse.

the class XSDElementDeclarationAdapter method getChildren.

public ITreeElement[] getChildren() {
    XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) target;
    List list = new ArrayList();
    XSDTypeDefinition type = null;
    if (xsdElementDeclaration.isElementDeclarationReference()) {
        type = xsdElementDeclaration.getResolvedElementDeclaration().getTypeDefinition();
    } else {
        type = xsdElementDeclaration.getAnonymousTypeDefinition();
        if (type == null) {
            type = xsdElementDeclaration.getTypeDefinition();
        }
    }
    if (type instanceof XSDComplexTypeDefinition && type.getTargetNamespace() != null && !type.getTargetNamespace().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) {
        XSDComplexTypeDefinition ctType = (XSDComplexTypeDefinition) type;
        if (ctType != null) {
            if (xsdElementDeclaration.isGlobal())
                list.add(ctType);
        }
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 8 with ITreeElement

use of org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement 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 9 with ITreeElement

use of org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement in project webtools.sourceediting by eclipse.

the class XSDModelGroupAdapter method getChildren.

public ITreeElement[] getChildren() {
    XSDModelGroup xsdModelGroup = getXSDModelGroup();
    List list = new ArrayList();
    for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) {
        Object object = i.next();
        XSDParticleContent particle = ((XSDParticle) object).getContent();
        if (particle instanceof XSDElementDeclaration) {
            list.add(particle);
        } else if (particle instanceof XSDWildcard) {
            list.add(particle);
        } else if (particle instanceof XSDModelGroup) {
            list.add(particle);
        } else if (particle instanceof XSDModelGroupDefinition) {
            // list.add(((XSDModelGroupDefinition)particle).getResolvedModelGroupDefinition());
            list.add(particle);
        }
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 10 with ITreeElement

use of org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement in project webtools.sourceediting by eclipse.

the class XSDSchemaAdapter method getChildren.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getChildren()
   */
public ITreeElement[] getChildren() {
    XSDSchema xsdSchema = (XSDSchema) getTarget();
    children = new ArrayList();
    // already created
    if (fDirectivesCategory != null) {
        List directivesList = getDirectives(xsdSchema);
        List elementsList = getGlobalElements(xsdSchema);
        List attributesList = getAttributeList(xsdSchema);
        List groups = getGroups(xsdSchema);
        List types = getComplexTypes(xsdSchema);
        types.addAll(getSimpleTypes(xsdSchema));
        fDirectivesCategory.setChildren(directivesList);
        fDirectivesCategory.setAllChildren(directivesList);
        fElementsCategory.setChildren(elementsList);
        fElementsCategory.setAllChildren(getGlobalElements(xsdSchema, true));
        fAttributesCategory.setChildren(attributesList);
        fAttributesCategory.setAllChildren(getAttributeList(xsdSchema, true));
        fTypesCategory.setChildren(types);
        fTypesCategory.setAllChildren(getTypes(xsdSchema, true));
        fGroupsCategory.setChildren(groups);
        fGroupsCategory.setAllChildren(getGroups(xsdSchema, true));
    } else {
        createCategoryAdapters(xsdSchema);
    }
    children.add(fDirectivesCategory);
    children.add(fElementsCategory);
    children.add(fAttributesCategory);
    children.add(fTypesCategory);
    children.add(fGroupsCategory);
    return (ITreeElement[]) children.toArray(new ITreeElement[0]);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDSchema(org.eclipse.xsd.XSDSchema)

Aggregations

ITreeElement (org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement)11 ArrayList (java.util.ArrayList)9 List (java.util.List)9 Iterator (java.util.Iterator)3 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)3 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)3 XSDWildcard (org.eclipse.xsd.XSDWildcard)3 LineBorder (org.eclipse.draw2d.LineBorder)2 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)2 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)2 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)2 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)2 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)2 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)2 XSDParticle (org.eclipse.xsd.XSDParticle)2 XSDParticleContent (org.eclipse.xsd.XSDParticleContent)2 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)2 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)2 EList (org.eclipse.emf.common.util.EList)1 IStructureFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure)1