Search in sources :

Example 71 with XSDParticle

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

the class TreeExpandHelper method getName.

private String getName(Object objA) {
    if (objA instanceof XSDElementDeclaration) {
        XSDElementDeclaration decl = (XSDElementDeclaration) objA;
        return decl.getName();
    }
    if (objA instanceof XSDModelGroup) {
        XSDModelGroup goup = (XSDModelGroup) objA;
        XSDParticle particle = (XSDParticle) goup.getContainer();
        XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) particle.getContainer();
        String name = complexTypeDefinition.getName();
        return name;
    }
    if (objA instanceof XSDModelGroupDefinition) {
        XSDModelGroupDefinition goupDef = (XSDModelGroupDefinition) objA;
        return goupDef.getName();
    }
    if (objA instanceof XSDParticle) {
        XSDParticle particle = (XSDParticle) objA;
        if (particle.getTerm() instanceof XSDElementDeclaration) {
            XSDElementDeclaration decl = (XSDElementDeclaration) particle.getTerm();
            return decl.getName();
        }
    }
    if (objA instanceof XSDAnnotation) {
        return null;
    }
    if (objA instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition constraint = (XSDIdentityConstraintDefinition) objA;
        return constraint.getName();
    }
    if (objA instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition simpleDefine = (XSDSimpleTypeDefinition) objA;
        return simpleDefine.getName();
    }
    if (objA instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition complexDefine = (XSDComplexTypeDefinition) objA;
        return complexDefine.getName();
    }
    return null;
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 72 with XSDParticle

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

the class XPathTreeContentProvider method getChildren.

@Override
public Object[] getChildren(Object parent) {
    if (parent instanceof XSDSchema) {
        EList xsdElementDeclarations = xsdSchema.getElementDeclarations();
        return filterOutDuplicatedElems(xsdElementDeclarations);
    }
    if (parent instanceof XSDAttributeGroupDefinition) {
        XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) parent;
        if (// a ref
        attributeGroupDefinition.getContents().size() == 0)
            attributeGroupDefinition = attributeGroupDefinition.getResolvedAttributeGroupDefinition();
        return attributeGroupDefinition.getContents().toArray(new Object[attributeGroupDefinition.getContents().size()]);
    }
    if (parent instanceof XSDParticle) {
        // a particle inside a choice or sequence or whatever
        XSDParticle xsdParticle = (XSDParticle) parent;
        return getXSDParticleChildren(xsdParticle);
    }
    if (parent instanceof XSDModelGroup) {
        XSDModelGroup modelGroup = ((XSDModelGroup) parent);
        EList list = modelGroup.getContents();
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition std = (XSDSimpleTypeDefinition) parent;
        if (std.getVariety().equals(XSDVariety.ATOMIC_LITERAL)) {
            ArrayList list = new ArrayList();
            // add Base Type if not a pre-defined type
            if (!std.getSchema().getSchemaForSchema().getTypeDefinitions().contains(std))
                list.add(std.getBaseTypeDefinition());
            list.addAll(std.getFacetContents());
            return list.toArray(new Object[list.size()]);
        }
        if (std.getVariety().equals(XSDVariety.LIST_LITERAL)) {
            // FIXME: How do we indicate it is a LIST?
            return new XSDSimpleTypeDefinition[] { std.getBaseTypeDefinition() };
        }
        if (std.getVariety().equals(XSDVariety.UNION_LITERAL))
            return std.getMemberTypeDefinitions().toArray(new XSDSimpleTypeDefinition[std.getMemberTypeDefinitions().size()]);
    // return new Object[]{std.getBaseTypeDefinition()};
    }
    if (parent instanceof XSDElementDeclaration) {
        // abstract elements do not have children
        if (((XSDElementDeclaration) parent).isAbstract())
            return new Object[0];
        ArrayList<Object> list = new ArrayList<Object>();
        // handle extensions and restrictions directly
        XSDTypeDefinition typeDefinition = ((XSDElementDeclaration) parent).getTypeDefinition();
        if (typeDefinition instanceof XSDComplexTypeDefinition) {
            list.addAll(getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) typeDefinition));
        } else {
            list.add(((XSDElementDeclaration) parent).getTypeDefinition());
        }
        // }
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDIdentityConstraintDefinition) {
        ArrayList list = new ArrayList();
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof Element) {
        // appinfos
        return new Object[0];
    }
    return new Object[0];
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) EList(org.eclipse.emf.common.util.EList) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 73 with XSDParticle

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

the class XSDTreeContentProvider method getChildren.

public Object[] getChildren(Object parent) {
    if (parent instanceof XSDSchema) {
        EList xsdElementDeclarations = xsdSchema.getElementDeclarations();
        List<XSDElementDeclaration> list = new ArrayList<XSDElementDeclaration>();
        if (filter != null && !filter.isAll()) {
            for (XSDElementDeclaration el : (XSDElementDeclaration[]) xsdElementDeclarations.toArray(new XSDElementDeclaration[xsdElementDeclarations.size()])) {
                if (isInclude(el.getAnnotation())) {
                    list.add(el);
                }
            }
            return filterOutDuplicatedElems(list);
        }
        return filterOutDuplicatedElems(xsdElementDeclarations);
    }
    if (parent instanceof XSDAttributeGroupDefinition) {
        XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) parent;
        if (// a ref
        attributeGroupDefinition.getContents().size() == 0)
            attributeGroupDefinition = attributeGroupDefinition.getResolvedAttributeGroupDefinition();
        return attributeGroupDefinition.getContents().toArray(new Object[attributeGroupDefinition.getContents().size()]);
    }
    if (parent instanceof XSDParticle) {
        // a particle inside a choice or sequence or whatever
        XSDParticle xsdParticle = (XSDParticle) parent;
        return getXSDParticleChildren(xsdParticle);
    }
    if (parent instanceof XSDModelGroup) {
        XSDModelGroup modelGroup = ((XSDModelGroup) parent);
        EList list = modelGroup.getContents();
        List<XSDParticle> ls = new ArrayList<XSDParticle>();
        if (filter != null && !filter.isAll()) {
            for (XSDParticle el : (XSDParticle[]) list.toArray(new XSDParticle[list.size()])) {
                XSDTerm tm = el.getTerm();
                if (tm instanceof XSDElementDeclaration) {
                    XSDAnnotation annotation = ((XSDElementDeclaration) tm).getAnnotation();
                    if (isInclude(annotation)) {
                        ls.add(el);
                    }
                }
            }
            return ls.toArray(new XSDParticle[ls.size()]);
        }
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition std = (XSDSimpleTypeDefinition) parent;
        if (std.getVariety().equals(XSDVariety.ATOMIC_LITERAL)) {
            ArrayList list = new ArrayList();
            // add Base Type if not a pre-defined type
            if (std != null && std.getSchema() != null && std.getSchema().getSchemaForSchema() != null)
                if (!std.getSchema().getSchemaForSchema().getTypeDefinitions().contains(std))
                    list.add(std.getBaseTypeDefinition());
            list.addAll(std.getFacetContents());
            return list.toArray(new Object[list.size()]);
        }
        if (std.getVariety().equals(XSDVariety.LIST_LITERAL)) {
            // FIXME: How do we indicate it is a LIST?
            return new XSDSimpleTypeDefinition[] { std.getBaseTypeDefinition() };
        }
        if (std.getVariety().equals(XSDVariety.UNION_LITERAL))
            return std.getMemberTypeDefinitions().toArray(new XSDSimpleTypeDefinition[std.getMemberTypeDefinitions().size()]);
    // return new Object[]{std.getBaseTypeDefinition()};
    }
    if (parent instanceof XSDElementDeclaration) {
        // abstract elements do not have children
        if (((XSDElementDeclaration) parent).isAbstract())
            return new Object[0];
        ArrayList<Object> list = new ArrayList<Object>();
        // handle extensions and restrictions directly
        XSDTypeDefinition typeDefinition = ((XSDElementDeclaration) parent).getTypeDefinition();
        if (typeDefinition instanceof XSDComplexTypeDefinition) {
            list.addAll(Util.getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) typeDefinition));
        } else {
            list.add(((XSDElementDeclaration) parent).getTypeDefinition());
        }
        // the keys
        if (filter != null && !filter.isAll()) {
        } else {
            list.addAll(((XSDElementDeclaration) parent).getIdentityConstraintDefinitions());
        }
        // the annotations
        XSDAnnotation annotation = ((XSDElementDeclaration) parent).getAnnotation();
        if (filter != null && !filter.isAll()) {
        } else {
            if (annotation != null) {
                list.add(annotation);
            }
        }
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDIdentityConstraintDefinition) {
        ArrayList list = new ArrayList();
        if (filter != null && !filter.isAll()) {
        } else {
            list.add(((XSDIdentityConstraintDefinition) parent).getSelector());
            list.addAll(((XSDIdentityConstraintDefinition) parent).getFields());
        }
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDAnnotation) {
        ArrayList list = new ArrayList();
        if (filter != null && !filter.isAll()) {
        } else {
            XSDAnnotation annotation = (XSDAnnotation) parent;
            list.addAll(annotation.getUserInformation());
            list.addAll(annotation.getApplicationInformation());
        }
        return list.size() == 0 ? new Object[0] : list.toArray(new Object[list.size()]);
    }
    if (parent instanceof Element) {
        // appinfos
        return new Object[0];
    }
    return new Object[0];
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) EList(org.eclipse.emf.common.util.EList) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 74 with XSDParticle

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

the class XSDTreeLabelProvider method getImage.

@Override
public Image getImage(Object obj) {
    if (obj instanceof XSDElementDeclaration) {
        // top declaration
        XSDElementDeclaration decl = (XSDElementDeclaration) obj;
        // check if concept or "just" element
        boolean isConcept = false;
        EList l = decl.getIdentityConstraintDefinitions();
        for (Iterator iter = l.iterator(); iter.hasNext(); ) {
            XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
            if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
                isConcept = true;
                break;
            }
        }
        // display approprite image
        if (isConcept) {
            return ImageCache.getCreatedImage(EImage.CONCEPT.getPath());
        } else {
            return ImageCache.getCreatedImage(EImage.ELEMENT_ONLY.getPath());
        /*
                 * if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) return
                 * PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_FOLDER); else
                 * return ImageCache.getCreatedImage( "icons/elements_obj_+.gif");
                 */
        }
    }
    if (obj instanceof XSDParticle) {
        XSDParticle xsdParticle = (XSDParticle) obj;
        XSDTerm xsdTerm = xsdParticle.getTerm();
        if (xsdTerm instanceof XSDElementDeclaration) {
            // get Type of Parent Group
            List<Object> realKeyInfos = Util.getRealKeyInfos(entity, xsdParticle);
            if (realKeyInfos != null && realKeyInfos.size() > 0) {
                return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
            }
            if (XSDUtil.hasFKInfo((XSDElementDeclaration) xsdTerm)) {
                return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
            }
            XSDConcreteComponent xsdConcreteComponent = xsdParticle.getContainer();
            if (xsdConcreteComponent instanceof XSDModelGroup) {
                return ImageCache.getCreatedImage(EImage.SCHEMAELEMENT.getPath());
            }
        /*
                 * if(((XSDElementDeclaration) xsdTerm).getAnonymousTypeDefinition() instanceof
                 * XSDComplexTypeDefinition) return ImageCache.getCreatedImage( EImage.COMPLEXTYPE.getPath()); else
                 * return ImageCache.getCreatedImage( EImage.SIMPLETYPE.getPath());
                 */
        } else if (xsdTerm instanceof XSDModelGroup) {
            int type = ((XSDModelGroup) xsdTerm).getCompositor().getValue();
            switch(type) {
                case XSDCompositor.ALL:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
                case XSDCompositor.CHOICE:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
                case XSDCompositor.SEQUENCE:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
            }
        } else if (xsdTerm instanceof XSDWildcard) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/wildcard.gif");
        } else {
            log.info(Messages.bind(Messages.XSDTreeLabelProvider_27, xsdTerm.getClass().getName()));
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/error.gif");
        }
    }
    if (obj instanceof XSDSimpleTypeDefinition) {
        return ImageCache.getCreatedImage(EImage.SIMPLETYPE.getPath());
    }
    if (obj instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition) obj;
        XSDComplexTypeContent ctc = ctd.getContent();
        if (ctc instanceof XSDParticle) {
            if (((XSDParticle) ctc).getTerm() instanceof XSDModelGroup) {
                int type = ((XSDModelGroup) ((XSDParticle) ctc).getTerm()).getCompositor().getValue();
                switch(type) {
                    case XSDCompositor.ALL:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
                    case XSDCompositor.CHOICE:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
                    case XSDCompositor.SEQUENCE:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
                }
            }
        } else {
            // simple Type!!!
            log.info(Messages.bind(Messages.XSDTreeLabelProvider_28, ctc.getClass().getName()));
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/error.gif");
        }
    }
    if (obj instanceof XSDModelGroup) {
        int type = ((XSDModelGroup) obj).getCompositor().getValue();
        switch(type) {
            case XSDCompositor.ALL:
                return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
            case XSDCompositor.CHOICE:
                return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
            case XSDCompositor.SEQUENCE:
                return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
        }
    }
    if (obj instanceof XSDFacet) {
        return ImageCache.getCreatedImage(EImage.FACET.getPath());
    }
    if (obj instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition identity = (XSDIdentityConstraintDefinition) obj;
        if (identity.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
            return ImageCache.getCreatedImage(EImage.KEYS.getPath());
        }
        return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
    }
    if (obj instanceof XSDXPathDefinition) {
        XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
        if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL)) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/field.gif");
        }
        // $NON-NLS-1$
        return ImageCache.getCreatedImage("icons/selector.gif");
    }
    if (obj instanceof XSDAttributeGroupDefinition) {
        // $NON-NLS-1$
        return ImageCache.getCreatedImage("icons/attribute_group.gif");
    }
    if (obj instanceof XSDAttributeUse) {
        XSDAttributeUse att = (XSDAttributeUse) obj;
        if ("xmlns".equals(att.getAttributeDeclaration().getTargetNamespace())) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
        }
        if (att.getUse().equals(XSDAttributeUseCategory.REQUIRED_LITERAL)) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute_mandatory.gif");
        } else {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute.gif");
        }
    }
    if (obj instanceof XSDAttributeDeclaration) {
        XSDAttributeDeclaration attributeDec = (XSDAttributeDeclaration) obj;
        if (// $NON-NLS-1$
        "xmlns".equals(attributeDec.getTargetNamespace())) {
            return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
        } else {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute.gif");
        }
    }
    if (obj instanceof XSDAnnotation) {
        return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
    }
    if (obj instanceof Element) {
        try {
            Element e = (Element) obj;
            if (e.getLocalName().equals("documentation")) {
                // $NON-NLS-1$
                return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
            } else if (e.getLocalName().equals("appinfo")) {
                // $NON-NLS-1$
                // $NON-NLS-1$
                String source = e.getAttribute("source");
                if (source != null) {
                    if (source.startsWith("X_Label_")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.LABEL.getPath());
                    } else if (source.equals("X_ForeignKey")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
                    } else if (source.equals("X_Visible_Rule")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
                    } else if (source.equals("X_Default_Value_Rule")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
                    } else if (source.equals("X_ForeignKeyInfo")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_ForeignKeyInfoFormat")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    // fix bug 0013194 by rhou.
                    } else if (source.equals("X_FKIntegrity")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_FKIntegrity_Override")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_Retrieve_FKinfos")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_SourceSystem")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SOURCESYSTEM.getPath());
                    } else if (source.equals("X_TargetSystem")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.TARGETSYSTEM.getPath());
                    } else if (source.startsWith("X_Description_")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                    } else if (source.equals("X_Write")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_Create")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_LogicalDelete")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_PhysicalDelete")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Lookup_Field")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.BROWSE.getPath());
                    } else if (source.equals("X_Hide")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Schematron")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
                    } else if (source.equals("X_Workflow")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.WORKFLOW_PROCESS.getPath());
                    } else if (source.equals("X_AutoExpand")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.DEFAULT.getPath());
                    }
                    if (source.equals("X_ForeignKey_Filter")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.FILTER_PS.getPath());
                    } else if (source.startsWith("X_Display_Format_")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.THIN_MIN_VIEW.getPath());
                    } else {
                        return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                    }
                } else {
                    return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                }
            } else {
                return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    // $NON-NLS-1$
    return ImageCache.getCreatedImage("icons/small_warn.gif");
// return PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_ELEMENT);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) Element(org.w3c.dom.Element) XSDFacet(org.eclipse.xsd.XSDFacet) Iterator(java.util.Iterator) XSDTerm(org.eclipse.xsd.XSDTerm) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) EList(org.eclipse.emf.common.util.EList) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 75 with XSDParticle

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

the class TypesContentProvider method getComplexTypeDefinitionChildren.

private ArrayList<Object> getComplexTypeDefinitionChildren(XSDComplexTypeDefinition complexTypeDefinition) {
    // System.out.println("getComplexTypeDefinitionChildren "+complexTypeDefinition+": "+complexTypeDefinition.getContent());
    // System.out.println(
    // "getComplexTypeDefinitionChildren BASE TYPE "+
    // complexTypeDefinition.getBaseTypeDefinition().getName()+" : "+
    // complexTypeDefinition.getDerivationMethod().getName()
    // );
    XSDComplexTypeContent xsdComplexTypeContent = complexTypeDefinition.getContent();
    ArrayList<Object> list = new ArrayList<Object>();
    // Now determine whether ref. If ref look at the base Type definition
    if (xsdComplexTypeContent == null) {
        XSDTypeDefinition typeDefinition = complexTypeDefinition.getBaseTypeDefinition();
        // if a simple type return the simple type
        if (typeDefinition instanceof XSDSimpleTypeDefinition) {
            list.add(typeDefinition);
            return list;
        } else {
        }
        // it is a complex Type
        xsdComplexTypeContent = ((XSDComplexTypeDefinition) typeDefinition).getContent();
    }
    // check if we are extending a complex Definition
    if ("extension".equals(complexTypeDefinition.getDerivationMethod().getName())) {
        // $NON-NLS-1$
        if (complexTypeDefinition.getBaseTypeDefinition() instanceof XSDComplexTypeDefinition) {
            list.addAll(getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) complexTypeDefinition.getBaseTypeDefinition()));
        }
    }
    // Attributes
    if (complexTypeDefinition.getAttributeContents() != null)
        list.addAll(complexTypeDefinition.getAttributeContents());
    // Annotations
    if (complexTypeDefinition.getAnnotations() != null)
        list.addAll(complexTypeDefinition.getAnnotations());
    // simple type return the simple type
    if (xsdComplexTypeContent instanceof XSDSimpleTypeDefinition) {
        list.add(xsdComplexTypeContent);
        return list;
    }
    // xsd Particle: we have a model group
    if (xsdComplexTypeContent instanceof XSDParticle) {
        // System.out.println("Model Group?: "+((XSDParticle)xsdComplexTypeContent).getTerm());
        if (((XSDParticle) xsdComplexTypeContent).getTerm() instanceof XSDModelGroup) {
            // return the model group
            list.add(((XSDParticle) xsdComplexTypeContent).getTerm());
            return list;
        } else {
            // wild card or element declaration '?)
            list.add(((XSDParticle) xsdComplexTypeContent).getTerm());
            return list;
        }
    }
    // what else could it be ?
    list.add(xsdComplexTypeContent);
    return list;
}
Also used : XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDParticle (org.eclipse.xsd.XSDParticle)146 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)103 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)93 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)75 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)36 ArrayList (java.util.ArrayList)34 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)34 XSDTerm (org.eclipse.xsd.XSDTerm)31 XSDFactory (org.eclipse.xsd.XSDFactory)27 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)24 XSDSchema (org.eclipse.xsd.XSDSchema)24 Test (org.junit.Test)23 Iterator (java.util.Iterator)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)21 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)19 EList (org.eclipse.emf.common.util.EList)17 XSDParticleContent (org.eclipse.xsd.XSDParticleContent)17 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 Element (org.w3c.dom.Element)16 List (java.util.List)15