Search in sources :

Example 1 with XSDAttributeGroupContent

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

the class XSDVisitorForFields method visitComplexTypeDefinition.

public void visitComplexTypeDefinition(XSDComplexTypeDefinition type) {
    if (type.getAttributeContents() != null) {
        for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); ) {
            XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
            if (attrGroupContent instanceof XSDAttributeUse) {
                XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
                visitAttributeDeclaration(attrUse.getContent());
            // if (attrUse.getAttributeDeclaration() != attrUse.getContent())
            // {
            // visitAttributeDeclaration(attrUse.getContent());
            // }
            // else
            // {
            // thingsWeNeedToListenTo.add(attrUse.getAttributeDeclaration());
            // concreteComponentList.add(attrUse.getAttributeDeclaration());
            // }
            } else if (attrGroupContent instanceof XSDAttributeGroupDefinition) {
                XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) attrGroupContent;
                thingsWeNeedToListenTo.add(attrGroup);
                if (attrGroup.isAttributeGroupDefinitionReference()) {
                    attrGroup = attrGroup.getResolvedAttributeGroupDefinition();
                    visitAttributeGroupDefinition(attrGroup);
                }
            }
        }
    }
    if (type.getAttributeWildcard() != null) {
        thingsWeNeedToListenTo.add(type.getAttributeWildcard());
        concreteComponentList.add(type.getAttributeWildcard());
    }
    super.visitComplexTypeDefinition(type);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) Iterator(java.util.Iterator) XSDAttributeGroupContent(org.eclipse.xsd.XSDAttributeGroupContent) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 2 with XSDAttributeGroupContent

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

the class XSDVisitor method visitComplexTypeDefinition.

public void visitComplexTypeDefinition(XSDComplexTypeDefinition type) {
    XSDComplexTypeContent complexContent = type.getContent();
    if (complexContent != null) {
        if (complexContent instanceof XSDSimpleTypeDefinition) {
            visitSimpleTypeDefinition((XSDSimpleTypeDefinition) complexContent);
        } else if (complexContent instanceof XSDParticle) {
            visitParticle((XSDParticle) complexContent);
        }
    }
    if (type.getAttributeContents() != null) {
        for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); ) {
            XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
            if (attrGroupContent instanceof XSDAttributeUse) {
                XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
                visitAttributeDeclaration(attrUse.getContent());
            } else if (attrGroupContent instanceof XSDAttributeGroupDefinition) {
                visitAttributeGroupDefinition((XSDAttributeGroupDefinition) attrGroupContent);
            }
        }
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Iterator(java.util.Iterator) XSDParticle(org.eclipse.xsd.XSDParticle) XSDAttributeGroupContent(org.eclipse.xsd.XSDAttributeGroupContent) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 3 with XSDAttributeGroupContent

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

the class AttributeGroupDefinitionEditPart method getModelChildren.

protected List getModelChildren() {
    List list = new ArrayList();
    XSDAttributeGroupDefinitionAdapter adapter = (XSDAttributeGroupDefinitionAdapter) getModel();
    XSDAttributeGroupDefinition attributeGroupDefinition = adapter.getXSDAttributeGroupDefinition();
    Iterator i = attributeGroupDefinition.getResolvedAttributeGroupDefinition().getContents().iterator();
    while (i.hasNext()) {
        XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) i.next();
        if (attrGroupContent instanceof XSDAttributeGroupDefinition) {
            list.add(XSDAdapterFactory.getInstance().adapt(attrGroupContent));
        } else if (attrGroupContent instanceof XSDAttributeUse) {
            list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) XSDAdapterFactory.getInstance().adapt(((XSDAttributeUse) attrGroupContent).getAttributeDeclaration())));
        } else {
            list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) getModel()));
        }
    }
    if (list.isEmpty()) {
        list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) getModel()));
    }
    return list;
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) ArrayList(java.util.ArrayList) XSDAttributeGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter) Iterator(java.util.Iterator) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) ArrayList(java.util.ArrayList) List(java.util.List) TargetConnectionSpaceFiller(org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller) XSDAttributeGroupContent(org.eclipse.xsd.XSDAttributeGroupContent) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 4 with XSDAttributeGroupContent

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

the class XSDComplexTypeDefinitionAdapter method getAttributeGroupContent.

public List getAttributeGroupContent() {
    EList attrContent = getXSDComplexTypeDefinition().getAttributeContents();
    List attrUses = new ArrayList();
    List list = new ArrayList();
    for (Iterator it = attrContent.iterator(); it.hasNext(); ) {
        XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) it.next();
        if (attrGroupContent instanceof XSDAttributeGroupDefinition) {
            XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) attrGroupContent;
            list.add(XSDAdapterFactory.getInstance().adapt(attributeGroupDefinition));
            getAttributeUses(attributeGroupDefinition, attrUses);
        } else {
            attrUses.add(attrGroupContent);
            list.add(new TargetConnectionSpaceFiller(this));
        }
    }
    return list;
}
Also used : EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) TargetConnectionSpaceFiller(org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller) XSDAttributeGroupContent(org.eclipse.xsd.XSDAttributeGroupContent) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 5 with XSDAttributeGroupContent

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

the class MoveXSDAttributeAction method moveUnderXSDComplexTypeDefinition.

protected void moveUnderXSDComplexTypeDefinition(XSDComplexTypeDefinition complexType) {
    int originalIndex = 0;
    for (Iterator iterator = complexType.getAttributeContents().iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupContent attributeGroupContent = (XSDAttributeGroupContent) iterator.next();
        if (attributeGroupContent instanceof XSDAttributeUse) {
            XSDAttributeDeclaration attribute = ((XSDAttributeUse) attributeGroupContent).getContent();
            if (attribute == selected) {
                complexType.getAttributeContents().remove(attribute.getContainer());
                break;
            }
        }
        originalIndex++;
    }
    int index = 0;
    boolean addedBack = false;
    List attributeGroupContents = complexType.getAttributeContents();
    for (Iterator iterator = attributeGroupContents.iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupContent attributeGroupContent = (XSDAttributeGroupContent) iterator.next();
        if (attributeGroupContent instanceof XSDAttributeUse) {
            XSDAttributeDeclaration attribute = ((XSDAttributeUse) attributeGroupContent).getContent();
            if (insertType == INSERT_AFTER) {
                if (attribute == previousRefComponent) {
                    complexType.getAttributeContents().add(index + 1, selected.getContainer());
                    addedBack = true;
                    break;
                }
            } else if (insertType == INSERT_BEFORE) {
                if (attribute == nextRefComponent) {
                    complexType.getAttributeContents().add(index, selected.getContainer());
                    addedBack = true;
                    break;
                }
            }
        }
        index++;
    }
    if (attributeGroupContents.size() == 0) {
        complexType.getAttributeContents().add(selected.getContainer());
        addedBack = true;
    }
    if (!addedBack) {
        complexType.getAttributeContents().add(originalIndex, selected.getContainer());
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) Iterator(java.util.Iterator) List(java.util.List) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDAttributeGroupContent(org.eclipse.xsd.XSDAttributeGroupContent)

Aggregations

Iterator (java.util.Iterator)6 XSDAttributeGroupContent (org.eclipse.xsd.XSDAttributeGroupContent)6 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)5 List (java.util.List)4 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)4 ArrayList (java.util.ArrayList)2 TargetConnectionSpaceFiller (org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller)2 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)2 EList (org.eclipse.emf.common.util.EList)1 XSDAttributeGroupDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1 XSDParticle (org.eclipse.xsd.XSDParticle)1 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)1