Search in sources :

Example 26 with XSDAttributeGroupDefinition

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

the class XSDAttributeGroupDefinitionAdapter method getActions.

public String[] getActions(Object object) {
    List list = new ArrayList();
    list.add(AddXSDAttributeDeclarationAction.ID);
    list.add(AddXSDAnyAttributeAction.ID);
    list.add(BaseSelectionAction.SEPARATOR_ID);
    list.add(DeleteAction.ID);
    list.add(BaseSelectionAction.SEPARATOR_ID);
    Object schema = getEditorSchema();
    XSDAttributeGroupDefinition attributeGroupDefinition = getXSDAttributeGroupDefinition();
    if (attributeGroupDefinition.getSchema() == schema) {
        XSDConcreteComponent container = attributeGroupDefinition.getContainer();
        if (container == schema || container instanceof XSDRedefine) {
            list.add(SetInputToGraphView.ID);
        }
    } else {
        list.add(OpenInNewEditor.ID);
    }
    list.add(BaseSelectionAction.SEPARATOR_ID);
    list.add(ShowPropertiesViewAction.ID);
    return (String[]) list.toArray(new String[0]);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 27 with XSDAttributeGroupDefinition

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

the class XSDAttributeGroupDefinitionAdapter method getText.

public String getText() {
    XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition) target;
    String result = xsdAttributeGroupDefinition.isAttributeGroupDefinitionReference() ? xsdAttributeGroupDefinition.getQName() : xsdAttributeGroupDefinition.getName();
    return result == null ? Messages._UI_LABEL_ABSENT : result;
}
Also used : XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 28 with XSDAttributeGroupDefinition

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

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

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

Aggregations

XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)42 Iterator (java.util.Iterator)20 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)17 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)16 ArrayList (java.util.ArrayList)15 List (java.util.List)15 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)15 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)15 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)13 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)13 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)13 XSDSchema (org.eclipse.xsd.XSDSchema)12 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)11 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)11 XSDParticle (org.eclipse.xsd.XSDParticle)11 EList (org.eclipse.emf.common.util.EList)10 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)9 Element (org.w3c.dom.Element)9 XSDWildcard (org.eclipse.xsd.XSDWildcard)8 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)7