Search in sources :

Example 1 with TargetConnectionSpaceFiller

use of org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller 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 2 with TargetConnectionSpaceFiller

use of org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller 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 3 with TargetConnectionSpaceFiller

use of org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller 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 4 with TargetConnectionSpaceFiller

use of org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller in project webtools.sourceediting by eclipse.

the class ModelGroupDefinitionReferenceEditPart method getModelChildren.

protected List getModelChildren() {
    List list = new ArrayList();
    XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter) getModel();
    XSDModelGroupDefinition groupDef = ((XSDModelGroupDefinition) adapter.getTarget());
    XSDModelGroupDefinition resolvedGroupDef = groupDef.getResolvedModelGroupDefinition();
    XSDModelGroup xsdModelGroup = resolvedGroupDef.getModelGroup();
    ArrayList listOfVisibleGroupRefs = new ArrayList();
    for (EditPart ep = getParent(); ep != null; ) {
        Object object = ep.getModel();
        if (object instanceof XSDModelGroupDefinitionAdapter) {
            Object model = ((XSDModelGroupDefinitionAdapter) object).getTarget();
            if (model instanceof XSDModelGroupDefinition) {
                listOfVisibleGroupRefs.add(((XSDModelGroupDefinition) model).getResolvedModelGroupDefinition());
            }
        }
        ep = ep.getParent();
    }
    boolean isCyclic = (listOfVisibleGroupRefs.contains(resolvedGroupDef));
    if (xsdModelGroup != null && !isCyclic)
        list.add(XSDAdapterFactory.getInstance().adapt(xsdModelGroup));
    if (isCyclic)
        list.add(new TargetConnectionSpaceFiller(null));
    return list;
}
Also used : XSDModelGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) ArrayList(java.util.ArrayList) BaseEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) ArrayList(java.util.ArrayList) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) TargetConnectionSpaceFiller(org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller)

Aggregations

ArrayList (java.util.ArrayList)4 List (java.util.List)4 TargetConnectionSpaceFiller (org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller)4 Iterator (java.util.Iterator)3 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)2 XSDAttributeGroupContent (org.eclipse.xsd.XSDAttributeGroupContent)2 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)2 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)2 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)2 Adapter (org.eclipse.emf.common.notify.Adapter)1 EList (org.eclipse.emf.common.util.EList)1 EditPart (org.eclipse.gef.EditPart)1 XSDAttributeGroupDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter)1 XSDModelGroupAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupAdapter)1 XSDModelGroupDefinitionAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter)1 BaseEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart)1 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)1 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)1 XSDParticle (org.eclipse.xsd.XSDParticle)1 XSDWildcard (org.eclipse.xsd.XSDWildcard)1