Search in sources :

Example 11 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class XSDUtil method getValidElementPaths.

public static Set<String> getValidElementPaths(XSDElementDeclaration ed, IXPathSelectionFilter filter) {
    String curPrefix = ed.getName() + DIVIDE;
    XSDTypeDefinition type = ed.getType();
    Set<String> paths = new HashSet<String>();
    if (type instanceof XSDComplexTypeDefinition) {
        XSDParticle particle = type.getComplexType();
        iterateParticle(particle, filter, paths, curPrefix);
    }
    return paths;
}
Also used : XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) HashSet(java.util.HashSet)

Example 12 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class ConceptComposite method getSuperTypeName.

private String getSuperTypeName(XSDComplexTypeDefinition type) {
    XSDTypeDefinition baseType = type.getBaseTypeDefinition();
    if (baseType == null) {
        // $NON-NLS-1$
        return "";
    }
    String superTypeName = baseType.getName();
    if (superTypeName == null || "anyType".equalsIgnoreCase(superTypeName)) {
        // $NON-NLS-1$
        return "";
    }
    return superTypeName;
}
Also used : XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 13 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class Util method getAllObject.

public static Object[] getAllObject(Object elem, List<Object> objList, IStructuredContentProvider provider) {
    Object[] elems = provider.getElements(elem);
    for (Object obj : elems) {
        if (obj == null) {
            continue;
        }
        if (obj instanceof XSDModelGroup || obj instanceof XSDElementDeclaration || obj instanceof XSDParticle || obj instanceof XSDTypeDefinition) {
            if (!objList.contains(obj)) {
                objList.add(obj);
                getAllObject(obj, objList, provider);
            }
        }
    }
    return objList.toArray();
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XObject(com.sun.org.apache.xpath.internal.objects.XObject) TreeObject(com.amalto.workbench.models.TreeObject) EObject(org.eclipse.emf.ecore.EObject) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 14 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class Util method isUUID.

public static boolean isUUID(XSDElementDeclaration decl) {
    XSDTypeDefinition typeDefinition = decl.getTypeDefinition();
    if (null == typeDefinition) {
        return false;
    }
    String type = typeDefinition.getName();
    if (type == null) {
        type = typeDefinition.getBaseType().getName();
    }
    // set enum
    if (typeDefinition instanceof XSDSimpleTypeDefinition && Util.isCustomrType(decl.getSchema(), type)) {
        XSDSimpleTypeDefinition typedef = (XSDSimpleTypeDefinition) typeDefinition;
        if (typedef.getBaseTypeDefinition() != null && typedef.getEnumerationFacets().size() > 0) {
            // $NON-NLS-1$
            type = "enum";
        }
    }
    if ("UUID".equals(type) || "AUTO_INCREMENT".equals(type)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        return true;
    }
    return false;
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 15 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class XSDDeleteTypeDefinition method doAction.

@Override
public IStatus doAction() {
    IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
    ArrayList<Object> objList = new ArrayList<Object>();
    Util.getAllObject(page.getSite(), objList, (IStructuredContentProvider) page.getSchemaContentProvider());
    Util.getAllObject(page.getSite(), objList, (IStructuredContentProvider) page.getTypeContentProvider());
    XSDTypeDefinition usingElement = findUsingElement(selection, objList);
    if (usingElement != null) {
        String message = getInfoDialogMessage(usingElement);
        MessageDialog.openInformation(page.getSite().getShell(), Messages.XSDDeleteTypeDefinition_ConfirmDel, message);
        return Status.CANCEL_STATUS;
    }
    // edit by ymli; fix the bug:0012228. Made the multiple types can be deleted.
    for (Iterator<XSDTypeDefinition> iter = selection.iterator(); iter.hasNext(); ) {
        XSDTypeDefinition type = iter.next();
        if (type instanceof XSDSimpleTypeDefinition) {
            XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) type;
            if (xsdSimpType != null) {
                simpleType = xsdSimpType;
            }
            schema.getContents().remove(simpleType);
        } else {
            XSDComplexTypeDefinition complxType = (XSDComplexTypeDefinition) type;
            if (xsdCmpexType != null) {
                complxType = xsdCmpexType;
            }
            schema.getContents().remove(complxType);
        }
    }
    xsdSimpType = null;
    xsdCmpexType = null;
    page.refresh();
    page.markDirty();
    return Status.OK_STATUS;
}
Also used : XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) 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