Search in sources :

Example 51 with XSDSimpleTypeDefinition

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

the class TypesHelper method getUserSimpleTypes.

public java.util.List getUserSimpleTypes() {
    Vector items = new Vector();
    if (xsdSchema != null) {
        updateExternalImportGlobals();
        Iterator i = xsdSchema.getTypeDefinitions().iterator();
        while (i.hasNext()) {
            XSDTypeDefinition typeDefinition = (XSDTypeDefinition) i.next();
            if (typeDefinition instanceof XSDSimpleTypeDefinition) {
                items.add(typeDefinition);
            // items.add(typeDefinition.getQName(xsdSchema));
            }
        }
    // We need to add the anyType
    // items.add(getPrefix(xsdSchema.getSchemaForSchemaNamespace(), true) + "anyType");
    // items = addExternalImportedUserSimpleTypes(items);
    // items = (Vector) sortList(items);
    }
    return items;
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Iterator(java.util.Iterator) Vector(java.util.Vector) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 52 with XSDSimpleTypeDefinition

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

the class XSDSimpleTypeDefinitionAdapter method getChildren.

public ITreeElement[] getChildren() {
    List adapterList = new ArrayList();
    XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) target;
    List list = xsdSimpleTypeDefinition.getEnumerationFacets();
    populateAdapterList(list, adapterList);
    return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement)

Example 53 with XSDSimpleTypeDefinition

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

the class XSDSimpleTypeDefinitionAdapter method isAnonymous.

public boolean isAnonymous() {
    XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) target;
    EObject eContainer = xsdSimpleTypeDefinition.eContainer();
    return !(eContainer instanceof XSDSchema || eContainer instanceof XSDRedefine);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) EObject(org.eclipse.emf.ecore.EObject) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 54 with XSDSimpleTypeDefinition

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

the class OpenOnSelectionHelper method openOnSelection.

public boolean openOnSelection() {
    List selectedNodes = null;
    ISelection selection = textEditor.getSelectionProvider().getSelection();
    if (selection instanceof IStructuredSelection) {
        selectedNodes = ((IStructuredSelection) selection).toList();
    }
    if (selectedNodes != null && !selectedNodes.isEmpty()) {
        for (Iterator i = selectedNodes.iterator(); i.hasNext(); ) {
            Object obj = i.next();
            if (xsdSchema != null) {
                XSDConcreteComponent xsdComp = xsdSchema.getCorrespondingComponent((Node) obj);
                XSDConcreteComponent objectToReveal = null;
                if (xsdComp instanceof XSDElementDeclaration) {
                    XSDElementDeclaration elementDecl = (XSDElementDeclaration) xsdComp;
                    if (elementDecl.isElementDeclarationReference()) {
                        objectToReveal = elementDecl.getResolvedElementDeclaration();
                    } else {
                        XSDConcreteComponent typeDef = null;
                        if (elementDecl.getAnonymousTypeDefinition() == null) {
                            typeDef = elementDecl.getTypeDefinition();
                        }
                        XSDConcreteComponent subGroupAffiliation = elementDecl.getSubstitutionGroupAffiliation();
                        if (typeDef != null && subGroupAffiliation != null) {
                            // then jump to that, otherwise just go to the typeDef.
                            if (obj instanceof Attr && ((Attr) obj).getLocalName().equals(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE)) {
                                objectToReveal = subGroupAffiliation;
                            } else {
                                // if we fail, set the substitution group as the object to reveal as a backup plan.
                                if (revealObject(typeDef)) {
                                    return true;
                                } else {
                                    objectToReveal = subGroupAffiliation;
                                }
                            }
                        } else {
                            // one or more of these is null.  If the typeDef is non-null, use it.  Otherwise
                            // try and use the substitution group
                            objectToReveal = typeDef != null ? typeDef : subGroupAffiliation;
                        }
                    }
                } else if (xsdComp instanceof XSDModelGroupDefinition) {
                    XSDModelGroupDefinition elementDecl = (XSDModelGroupDefinition) xsdComp;
                    if (elementDecl.isModelGroupDefinitionReference()) {
                        objectToReveal = elementDecl.getResolvedModelGroupDefinition();
                    }
                } else if (xsdComp instanceof XSDAttributeDeclaration) {
                    XSDAttributeDeclaration attrDecl = (XSDAttributeDeclaration) xsdComp;
                    if (attrDecl.isAttributeDeclarationReference()) {
                        objectToReveal = attrDecl.getResolvedAttributeDeclaration();
                    } else if (attrDecl.getAnonymousTypeDefinition() == null) {
                        objectToReveal = attrDecl.getTypeDefinition();
                    }
                } else if (xsdComp instanceof XSDAttributeGroupDefinition) {
                    XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) xsdComp;
                    if (attrGroupDef.isAttributeGroupDefinitionReference()) {
                        objectToReveal = attrGroupDef.getResolvedAttributeGroupDefinition();
                    }
                } else if (xsdComp instanceof XSDIdentityConstraintDefinition) {
                    XSDIdentityConstraintDefinition idConstraintDef = (XSDIdentityConstraintDefinition) xsdComp;
                    if (idConstraintDef.getReferencedKey() != null) {
                        objectToReveal = idConstraintDef.getReferencedKey();
                    }
                } else if (xsdComp instanceof XSDSimpleTypeDefinition) {
                    XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) xsdComp;
                    objectToReveal = typeDef.getItemTypeDefinition();
                    if (objectToReveal == null) {
                        // if itemType attribute is not set, then check for memberType
                        List memberTypes = typeDef.getMemberTypeDefinitions();
                        if (memberTypes != null && memberTypes.size() > 0) {
                            objectToReveal = (XSDConcreteComponent) memberTypes.get(0);
                        }
                    }
                } else if (xsdComp instanceof XSDTypeDefinition) {
                    XSDTypeDefinition typeDef = (XSDTypeDefinition) xsdComp;
                    objectToReveal = typeDef.getBaseType();
                } else if (xsdComp instanceof XSDSchemaDirective) {
                    XSDSchemaDirective directive = (XSDSchemaDirective) xsdComp;
                    // String schemaLocation = URIHelper.removePlatformResourceProtocol(directive.getResolvedSchema().getSchemaLocation());
                    // openXSDEditor(schemaLocation);
                    // return false;
                    objectToReveal = directive.getResolvedSchema();
                }
                // now reveal the object if this isn't null
                if (objectToReveal != null) {
                    return revealObject(objectToReveal);
                }
            }
        }
    }
    return false;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Attr(org.w3c.dom.Attr) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) List(java.util.List) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 55 with XSDSimpleTypeDefinition

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

the class XSDBaseAdapter method getGlobalXSDContainer.

protected IADTObject getGlobalXSDContainer(XSDConcreteComponent component) {
    XSDConcreteComponent c = component.getContainer();
    // We want the top most structural component
    while (c != null && !(c.getContainer() instanceof XSDSchema) && !(c instanceof XSDComplexTypeDefinition) && !(c instanceof XSDSimpleTypeDefinition) && !(c instanceof XSDModelGroupDefinition) && !(c instanceof XSDAttributeGroupDefinition)) {
        c = c.getContainer();
    }
    Adapter adapter = XSDAdapterFactory.getInstance().adapt(c);
    if (adapter instanceof IADTObject)
        return (IADTObject) adapter;
    return null;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Adapter(org.eclipse.emf.common.notify.Adapter) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSchema(org.eclipse.xsd.XSDSchema) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Aggregations

XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)106 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)53 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)47 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)46 XSDParticle (org.eclipse.xsd.XSDParticle)34 ArrayList (java.util.ArrayList)33 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)26 Iterator (java.util.Iterator)24 List (java.util.List)18 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)18 XSDSchema (org.eclipse.xsd.XSDSchema)17 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)16 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)15 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)15 XSDFactory (org.eclipse.xsd.XSDFactory)15 EList (org.eclipse.emf.common.util.EList)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)12 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)12 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)11