Search in sources :

Example 21 with XSDAttributeDeclaration

use of org.eclipse.xsd.XSDAttributeDeclaration 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 22 with XSDAttributeDeclaration

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

the class XSDAttributeDragAndDropCommand method getElement.

/*
   * (non-Javadoc)
   * @see org.eclipse.wst.xsd.ui.internal.commands.BaseDragAndDropCommand#getElement()
   */
protected Element getElement() {
    XSDAttributeDeclarationAdapter adapter = (XSDAttributeDeclarationAdapter) itemToDrag.getModel();
    XSDAttributeDeclaration target = (XSDAttributeDeclaration) adapter.getTarget();
    XSDConcreteComponent parent = (XSDConcreteComponent) target.eContainer();
    return parent.getElement();
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDAttributeDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 23 with XSDAttributeDeclaration

use of org.eclipse.xsd.XSDAttributeDeclaration 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 24 with XSDAttributeDeclaration

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

the class XSDSchemaAdapter method getAttributeList.

public List getAttributeList(XSDSchema xsdSchema, boolean showFromIncludes) {
    List attributesList = new ArrayList();
    for (Iterator iter = xsdSchema.getAttributeDeclarations().iterator(); iter.hasNext(); ) {
        Object o = iter.next();
        if (o instanceof XSDAttributeDeclaration) {
            XSDAttributeDeclaration attr = (XSDAttributeDeclaration) o;
            if (attr != null) {
                if (attr.getTargetNamespace() != null) {
                    if (!(attr.getTargetNamespace().equals(XSDConstants.SCHEMA_INSTANCE_URI_2001))) {
                        if (shouldShowComponent(attr, xsdSchema, showFromIncludes)) {
                            attributesList.add(attr);
                        }
                    }
                } else {
                    if (shouldShowComponent(attr, xsdSchema, showFromIncludes)) {
                        attributesList.add(attr);
                    }
                }
            }
        }
    }
    attributesList.addAll(getAttributeGroupList(xsdSchema, showFromIncludes));
    List adapterList = new ArrayList();
    populateAdapterList(attributesList, adapterList);
    return adapterList;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 25 with XSDAttributeDeclaration

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

the class XSDAttributeReferenceEditManager method modifyComponentReference.

public void modifyComponentReference(Object referencingObject, ComponentSpecification referencedComponent) {
    XSDAttributeDeclaration concreteComponent = null;
    if (referencingObject instanceof Adapter) {
        Adapter adapter = (Adapter) referencingObject;
        if (adapter.getTarget() instanceof XSDAttributeDeclaration) {
            concreteComponent = (XSDAttributeDeclaration) adapter.getTarget();
        }
    } else if (referencingObject instanceof XSDConcreteComponent) {
        concreteComponent = (XSDAttributeDeclaration) referencingObject;
    }
    if (concreteComponent != null) {
        if (referencedComponent.isNew()) {
            XSDAttributeDeclaration attributeDec = null;
            if (referencedComponent.getMetaName() == IXSDSearchConstants.ATTRIBUTE_META_NAME) {
                AddXSDAttributeDeclarationCommand command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, concreteComponent.getSchema());
                command.setNameToAdd(referencedComponent.getName());
                command.execute();
                attributeDec = (XSDAttributeDeclaration) command.getAddedComponent();
            }
            if (attributeDec != null) {
                Command command = new UpdateAttributeReferenceCommand(Messages._UI_ACTION_UPDATE_ATTRIBUTE_REFERENCE, concreteComponent, attributeDec);
                command.execute();
            }
            XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
        } else {
            Command command = new UpdateAttributeReferenceAndManagerDirectivesCommand(concreteComponent, referencedComponent.getName(), referencedComponent.getQualifier(), referencedComponent.getFile());
            command.setLabel(Messages._UI_ACTION_UPDATE_ATTRIBUTE_REFERENCE);
            command.execute();
        }
    }
}
Also used : AddXSDAttributeDeclarationCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAttributeDeclarationCommand) UpdateAttributeReferenceCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceCommand) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) UpdateAttributeReferenceAndManagerDirectivesCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceAndManagerDirectivesCommand) UpdateAttributeReferenceCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceCommand) Command(org.eclipse.gef.commands.Command) AddXSDAttributeDeclarationCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAttributeDeclarationCommand) Adapter(org.eclipse.emf.common.notify.Adapter) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) UpdateAttributeReferenceAndManagerDirectivesCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeReferenceAndManagerDirectivesCommand)

Aggregations

XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)49 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)27 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)18 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)17 Iterator (java.util.Iterator)16 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)16 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)15 XSDSchema (org.eclipse.xsd.XSDSchema)15 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)14 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)13 List (java.util.List)10 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)10 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)9 ArrayList (java.util.ArrayList)8 Element (org.w3c.dom.Element)8 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)7 XSDParticle (org.eclipse.xsd.XSDParticle)7 XSDNamedComponent (org.eclipse.xsd.XSDNamedComponent)6 XSDWildcard (org.eclipse.xsd.XSDWildcard)6 EList (org.eclipse.emf.common.util.EList)5