Search in sources :

Example 26 with XSDModelGroupDefinition

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

the class XSDRedefineAdapter method notifyChanged.

public void notifyChanged(final Notification msg) {
    class CategoryNotification extends NotificationImpl {

        protected Object category;

        public CategoryNotification(Object category) {
            super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition());
            this.category = category;
        }

        public Object getNotifier() {
            return category;
        }

        public Object getFeature() {
            return msg.getFeature();
        }
    }
    if (children == null) {
        getChildren();
    }
    Object newValue = msg.getNewValue();
    Object oldValue = msg.getOldValue();
    if (XSDPackage.eINSTANCE.getXSDRedefine_Contents() == msg.getFeature()) {
        if ((newValue instanceof XSDAttributeGroupDefinition) || oldValue instanceof XSDAttributeGroupDefinition) {
            CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES);
            Assert.isTrue(adapter != null);
            List list = getCategoryChildren(CategoryAdapter.ATTRIBUTES);
            adapter.setChildren(list);
            adapter.setAllChildren(list);
            if (adapter.getModel() instanceof XSDSchemaAdapter) {
                XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
                schemaAdapter.notifyChanged(msg);
            }
            notifyListeners(new CategoryNotification(adapter), adapter.getText());
            return;
        } else if ((newValue instanceof XSDComplexTypeDefinition || newValue instanceof XSDSimpleTypeDefinition) || (oldValue instanceof XSDComplexTypeDefinition || oldValue instanceof XSDSimpleTypeDefinition)) {
            CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES);
            Assert.isTrue(adapter != null);
            List types = getCategoryChildren(CategoryAdapter.TYPES);
            adapter.setChildren(types);
            adapter.setAllChildren(types);
            if (adapter.getModel() instanceof XSDSchemaAdapter) {
                XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
                schemaAdapter.notifyChanged(msg);
            }
            notifyListeners(new CategoryNotification(adapter), adapter.getText());
            return;
        } else if (newValue instanceof XSDModelGroupDefinition || oldValue instanceof XSDModelGroupDefinition) {
            CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS);
            Assert.isTrue(adapter != null);
            List list = getCategoryChildren(CategoryAdapter.GROUPS);
            adapter.setChildren(list);
            adapter.setAllChildren(list);
            if (adapter.getModel() instanceof XSDSchemaAdapter) {
                XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
                schemaAdapter.notifyChanged(msg);
            }
            notifyListeners(new CategoryNotification(adapter), adapter.getText());
            return;
        } else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) {
            return;
        }
    }
    super.notifyChanged(msg);
}
Also used : NotificationImpl(org.eclipse.emf.common.notify.impl.NotificationImpl) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) ArrayList(java.util.ArrayList) List(java.util.List) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 27 with XSDModelGroupDefinition

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

the class XSDVisitor method visitParticleContent.

public void visitParticleContent(XSDParticleContent particleContent) {
    if (particleContent instanceof XSDModelGroupDefinition) {
        XSDModelGroupDefinition modelGroupDef = (XSDModelGroupDefinition) particleContent;
        if (particleStack.contains(modelGroupDef)) {
            return;
        }
        particleStack.push(modelGroupDef);
        visitModelGroupDefinition(modelGroupDef);
        particleStack.pop();
    } else if (particleContent instanceof XSDModelGroup) {
        visitModelGroup((XSDModelGroup) particleContent);
    } else if (particleContent instanceof XSDElementDeclaration) {
        visitElementDeclaration((XSDElementDeclaration) particleContent);
    } else if (particleContent instanceof XSDWildcard) {
        visitWildcard((XSDWildcard) particleContent);
    }
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 28 with XSDModelGroupDefinition

use of org.eclipse.xsd.XSDModelGroupDefinition 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 29 with XSDModelGroupDefinition

use of org.eclipse.xsd.XSDModelGroupDefinition 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 30 with XSDModelGroupDefinition

use of org.eclipse.xsd.XSDModelGroupDefinition 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)

Aggregations

XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)43 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)19 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)18 List (java.util.List)15 ArrayList (java.util.ArrayList)13 Iterator (java.util.Iterator)12 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)11 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)11 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)11 XSDParticle (org.eclipse.xsd.XSDParticle)10 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)10 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)9 XSDSchema (org.eclipse.xsd.XSDSchema)9 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)8 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)7 XSDRedefine (org.eclipse.xsd.XSDRedefine)6 XSDWildcard (org.eclipse.xsd.XSDWildcard)6 Adapter (org.eclipse.emf.common.notify.Adapter)5 EObject (org.eclipse.emf.ecore.EObject)4 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)4