Search in sources :

Example 61 with XSDParticle

use of org.eclipse.xsd.XSDParticle 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 62 with XSDParticle

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

the class XSDVisitor method visitModelGroup.

public void visitModelGroup(XSDModelGroup modelGroup) {
    if (modelGroup.getContents() != null) {
        for (Iterator iterator = modelGroup.getContents().iterator(); iterator.hasNext(); ) {
            XSDParticle particle = (XSDParticle) iterator.next();
            visitParticle(particle);
        }
    }
}
Also used : Iterator(java.util.Iterator) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 63 with XSDParticle

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

the class XSDWildcardAdapter method getText.

public String getText() {
    XSDWildcard xsdWildcard = (XSDWildcard) target;
    StringBuffer result = new StringBuffer();
    Element element = xsdWildcard.getElement();
    if (element != null) {
        result.append(element.getNodeName());
        boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
        boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
        if (hasMinOccurs || hasMaxOccurs) {
            // $NON-NLS-1$
            result.append(" [");
            if (hasMinOccurs) {
                int min = ((XSDParticle) xsdWildcard.getContainer()).getMinOccurs();
                if (min == XSDParticle.UNBOUNDED) {
                    // $NON-NLS-1$
                    result.append("*");
                } else {
                    result.append(String.valueOf(min));
                }
            } else // print default
            {
                int min = ((XSDParticle) xsdWildcard.getContainer()).getMinOccurs();
                result.append(String.valueOf(min));
            }
            if (hasMaxOccurs) {
                int max = ((XSDParticle) xsdWildcard.getContainer()).getMaxOccurs();
                // $NON-NLS-1$
                result.append("..");
                if (max == XSDParticle.UNBOUNDED) {
                    // $NON-NLS-1$
                    result.append("*");
                } else {
                    result.append(String.valueOf(max));
                }
            } else // print default
            {
                // $NON-NLS-1$
                result.append("..");
                int max = ((XSDParticle) xsdWildcard.getContainer()).getMaxOccurs();
                result.append(String.valueOf(max));
            }
            // $NON-NLS-1$
            result.append("]");
        }
    }
    return result.toString();
}
Also used : IGraphElement(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement) Element(org.w3c.dom.Element) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 64 with XSDParticle

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

the class ModelGroupEditPart method getModelChildren.

protected List getModelChildren() {
    // XSDModelGroupAdapter modelGroupAdapter = (XSDModelGroupAdapter)getModel();
    // ArrayList ch = new ArrayList();
    // ITreeElement [] tree = modelGroupAdapter.getChildren();
    // int length = tree.length;
    // for (int i = 0; i < length; i++)
    // {
    // ch.add(tree[i]);
    // }
    List list = new ArrayList();
    XSDModelGroup xsdModelGroup = getXSDModelGroup();
    for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) {
        XSDParticle next = (XSDParticle) i.next();
        if (next.getContent() instanceof XSDElementDeclaration) {
            XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) next.getContent();
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(elementDeclaration);
            list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) adapter));
        }
        if (next.getContent() instanceof XSDModelGroupDefinition) {
            XSDModelGroupDefinition def = (XSDModelGroupDefinition) next.getContent();
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(def);
            list.add(adapter);
        } else if (next.getTerm() instanceof XSDModelGroup) {
            XSDModelGroup modelGroup = (XSDModelGroup) next.getTerm();
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(modelGroup);
            list.add(adapter);
        } else if (next.getTerm() instanceof XSDWildcard) {
            XSDWildcard wildCard = (XSDWildcard) next.getTerm();
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(wildCard);
            list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) adapter));
        }
    }
    if (list.size() == 0)
        list.add(new TargetConnectionSpaceFiller(null));
    return list;
// return ch;
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) List(java.util.List) Adapter(org.eclipse.emf.common.notify.Adapter) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) XSDModelGroupAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupAdapter) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) TargetConnectionSpaceFiller(org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 65 with XSDParticle

use of org.eclipse.xsd.XSDParticle in project tmdm-studio-se by Talend.

the class ComplexTypeConfigComposite method initUIContentsInGroup.

private void initUIContentsInGroup() {
    XSDParticle groupParticle = (XSDParticle) complexType.getContent();
    XSDModelGroup group = (XSDModelGroup) groupParticle.getContent();
    radGroupAll.setSelection(XSDCompositor.ALL_LITERAL.equals(group.getCompositor()));
    radGroupSequence.setSelection(XSDCompositor.SEQUENCE_LITERAL.equals(group.getCompositor()));
    radGroupChoice.setSelection(XSDCompositor.CHOICE_LITERAL.equals(group.getCompositor()));
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDParticle(org.eclipse.xsd.XSDParticle)

Aggregations

XSDParticle (org.eclipse.xsd.XSDParticle)146 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)103 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)93 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)75 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)36 ArrayList (java.util.ArrayList)34 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)34 XSDTerm (org.eclipse.xsd.XSDTerm)31 XSDFactory (org.eclipse.xsd.XSDFactory)27 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)24 XSDSchema (org.eclipse.xsd.XSDSchema)24 Test (org.junit.Test)23 Iterator (java.util.Iterator)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)21 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)19 EList (org.eclipse.emf.common.util.EList)17 XSDParticleContent (org.eclipse.xsd.XSDParticleContent)17 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 Element (org.w3c.dom.Element)16 List (java.util.List)15