Search in sources :

Example 91 with XSDSimpleTypeDefinition

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

the class AddXSDElementCommand method createXSDElementDeclarationForModelGroupDefinitions.

protected XSDParticle createXSDElementDeclarationForModelGroupDefinitions() {
    // $NON-NLS-1$
    XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
    XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
    ArrayList usedAttributeNames = new ArrayList();
    usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes(xsdModelGroupDefinition));
    element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
    usedAttributeNames));
    element.setTypeDefinition(type);
    XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
    particle.setContent(element);
    addedXSDConcreteComponent = element;
    return particle;
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 92 with XSDSimpleTypeDefinition

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

the class AddXSDElementCommand method createGlobalXSDElementDeclaration.

protected XSDElementDeclaration createGlobalXSDElementDeclaration() {
    ensureSchemaElement(xsdSchema);
    // $NON-NLS-1$
    XSDSimpleTypeDefinition type = xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string");
    XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
    XSDElementDeclaration element = factory.createXSDElementDeclaration();
    element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
    xsdSchema.getElementDeclarations()));
    element.setTypeDefinition(type);
    return element;
}
Also used : XSDFactory(org.eclipse.xsd.XSDFactory) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration)

Example 93 with XSDSimpleTypeDefinition

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

the class AddXSDRedefinedSimpleTypeAction method buildComponentsList.

protected void buildComponentsList(XSDRedefine xsdRedefine, Set redefinedComponentsNames, IComponentList componentList) {
    List typeDefinitions = xsdRedefine.getIncorporatedSchema().getTypeDefinitions();
    Iterator iterator = typeDefinitions.iterator();
    while (iterator.hasNext()) {
        XSDTypeDefinition typeDefinition = (XSDTypeDefinition) iterator.next();
        String typeDefinitionName = typeDefinition.getName();
        if (typeDefinition instanceof XSDSimpleTypeDefinition && !redefinedComponentsNames.contains(typeDefinitionName)) {
            componentList.add(typeDefinition);
        }
    }
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Iterator(java.util.Iterator) List(java.util.List) IComponentList(org.eclipse.wst.common.ui.internal.search.dialogs.IComponentList) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 94 with XSDSimpleTypeDefinition

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

the class EnumerationsSection method refresh.

/*
   * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
   */
public void refresh() {
    if (isReadOnly) {
        composite.setEnabled(false);
    } else {
        composite.setEnabled(true);
    }
    XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input;
    Iterator validFacets = st.getValidFacets().iterator();
    boolean isApplicable = false;
    while (validFacets.hasNext()) {
        String aValidFacet = (String) validFacets.next();
        if (aValidFacet.equals(XSDConstants.ENUMERATION_ELEMENT_TAG)) {
            isApplicable = true;
        }
    }
    if (isApplicable) {
        addButton.setEnabled(true);
        addManyButton.setEnabled(true);
    } else {
        addButton.setEnabled(false);
        addManyButton.setEnabled(false);
    }
    enumerationsTable.setInput(input);
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Iterator(java.util.Iterator)

Example 95 with XSDSimpleTypeDefinition

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

the class AddXSDSimpleTypeDefinitionCommand method execute.

public void execute() {
    if (parent instanceof XSDSchema) {
        ensureSchemaElement((XSDSchema) parent);
    }
    try {
        beginRecording(parent.getElement());
        XSDSimpleTypeDefinition typeDef = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
        // $NON-NLS-1$
        typeDef.setBaseTypeDefinition(parent.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
        if (parent instanceof XSDSchema) {
            // $NON-NLS-1$
            typeDef.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewSimpleType" : nameToAdd, ((XSDSchema) parent).getTypeDefinitions()));
            createdSimpleType = typeDef;
            try {
                XSDSchema xsdSchema = (XSDSchema) parent;
                // $NON-NLS-1$
                Text textNode = xsdSchema.getDocument().createTextNode("\n");
                xsdSchema.getElement().appendChild(textNode);
                xsdSchema.getContents().add(typeDef);
            } catch (Exception e) {
            }
        } else if (parent instanceof XSDElementDeclaration) {
            ((XSDElementDeclaration) parent).setAnonymousTypeDefinition(typeDef);
        } else if (parent instanceof XSDAttributeDeclaration) {
            ((XSDAttributeDeclaration) parent).setAnonymousTypeDefinition(typeDef);
        }
        formatChild(createdSimpleType.getElement());
        addedXSDConcreteComponent = createdSimpleType;
    } finally {
        endRecording();
    }
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Text(org.w3c.dom.Text) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDSchema(org.eclipse.xsd.XSDSchema)

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