Search in sources :

Example 46 with XSDTypeDefinition

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

the class UpdateComplexTypeDerivationBy method execute.

public void execute() {
    super.execute();
    try {
        beginRecording(complexType.getElement());
        XSDTypeDefinition originalBaseType = complexType.getBaseType();
        if (derivation.equals(XSDConstants.EXTENSION_ELEMENT_TAG)) {
            complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
        } else if (derivation.equals(XSDConstants.RESTRICTION_ELEMENT_TAG)) {
            complexType.setDerivationMethod(XSDDerivationMethod.RESTRICTION_LITERAL);
        }
        complexType.setBaseTypeDefinition(originalBaseType);
    } finally {
        endRecording();
    }
}
Also used : XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 47 with XSDTypeDefinition

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

the class UpdateTypeReferenceAndManageDirectivesCommand method execute.

public void execute() {
    try {
        beginRecording(concreteComponent.getElement());
        XSDComponent td = computeComponent();
        if (td != null && td instanceof XSDTypeDefinition) {
            UpdateTypeReferenceCommand command = new UpdateTypeReferenceCommand(concreteComponent, (XSDTypeDefinition) td);
            command.execute();
            XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
        }
    } catch (Exception e) {
    } finally {
        endRecording();
    }
}
Also used : XSDComponent(org.eclipse.xsd.XSDComponent) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 48 with XSDTypeDefinition

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

the class AddXSDEnumerationFacetAction method calculateEnabled.

protected boolean calculateEnabled() {
    boolean parentResult = super.calculateEnabled();
    boolean endResult = true;
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDComplexTypeDefinitionAdapter) {
        XSDComplexTypeDefinition definition = ((XSDComplexTypeDefinitionAdapter) selection).getXSDComplexTypeDefinition();
        XSDTypeDefinition baseType = definition.getBaseType();
        if (baseType instanceof XSDSimpleTypeDefinition)
            endResult = false;
    }
    endResult = endResult & parentResult;
    return endResult;
}
Also used : XSDComplexTypeDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 49 with XSDTypeDefinition

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

the class SetBaseTypeAndManagerDirectivesCommand method execute.

public void execute() {
    try {
        beginRecording(concreteComponent.getElement());
        XSDComponent td = computeComponent();
        if (td != null && td instanceof XSDTypeDefinition) {
            SetBaseTypeCommand command = new SetBaseTypeCommand(concreteComponent, (XSDTypeDefinition) td);
            command.execute();
            XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
        }
    } catch (Exception e) {
    } finally {
        endRecording();
    }
}
Also used : XSDComponent(org.eclipse.xsd.XSDComponent) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 50 with XSDTypeDefinition

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

the class XSDImpl method findTypesDerivedFrom.

/**
 * Adapted from public static List findTypesDerivedFrom(XSDSchema schema,
 * String namespace, String localName) in class XSDSchemaQueryTools found in
 * org.eclipse.xsd plugin.
 *
 * Find typeDefinitions that derive from a given type.
 *
 * @param type
 *          the type derived from
 * @return List of any XSDTypeDefinitions found
 */
public static List findTypesDerivedFrom(XSDTypeDefinition type) {
    ArrayList typesDerivedFrom = new ArrayList();
    if (type != null) {
        XSDSchema schema = type.getSchema();
        String localName = type.getName();
        if ((null != schema) && (null != localName)) {
            String namespace = schema.getTargetNamespace();
            // A handy convenience method quickly gets all
            // typeDefinitions within our schema; note that
            // whether or not this returns types in included,
            // imported, or redefined schemas is subject to change
            List typedefs = schema.getTypeDefinitions();
            for (Iterator iter = typedefs.iterator(); iter.hasNext(); ) {
                XSDTypeDefinition typedef = (XSDTypeDefinition) iter.next();
                if (typedef instanceof XSDComplexTypeDefinition) {
                    // of them match the requested one
                    if (isTypeDerivedFrom(typedef, namespace, localName)) {
                        // We found it, return the original one and continue
                        typesDerivedFrom.add(typedef);
                        continue;
                    }
                }
            }
        }
    }
    return typesDerivedFrom;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSchema(org.eclipse.xsd.XSDSchema) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)119 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)66 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)57 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)46 ArrayList (java.util.ArrayList)39 XSDParticle (org.eclipse.xsd.XSDParticle)36 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)32 Iterator (java.util.Iterator)26 XSDSchema (org.eclipse.xsd.XSDSchema)26 List (java.util.List)22 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)17 EList (org.eclipse.emf.common.util.EList)16 TreeObject (com.amalto.workbench.models.TreeObject)14 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)14 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)13 XSDTerm (org.eclipse.xsd.XSDTerm)13 XSDFactory (org.eclipse.xsd.XSDFactory)12 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)11 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)10 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)10