Search in sources :

Example 1 with XSDParticleImpl

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

the class Util method doChangeElementTypeToSequence.

private static IStatus doChangeElementTypeToSequence(XSDComplexTypeDefinition compx, int maxOccurs) {
    XSDParticleImpl partCnt = (XSDParticleImpl) compx.getContent();
    XSDModelGroupImpl mdlGrp = (XSDModelGroupImpl) partCnt.getTerm();
    if ((maxOccurs > 1 || maxOccurs == -1) && mdlGrp.getCompositor() != XSDCompositor.SEQUENCE_LITERAL) {
        // change the parent element to xsd:sequence
        if (!MessageDialog.openConfirm(null, Messages.Util_32, Messages.Util_33)) {
            return Status.CANCEL_STATUS;
        }
        mdlGrp.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
        compx.updateElement();
    }
    return Status.OK_STATUS;
}
Also used : XSDParticleImpl(org.eclipse.xsd.impl.XSDParticleImpl) XSDModelGroupImpl(org.eclipse.xsd.impl.XSDModelGroupImpl)

Example 2 with XSDParticleImpl

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

the class ConceptComposite method updateElementGroup.

private void updateElementGroup(XSDComplexTypeDefinition type) {
    if (type != null) {
        XSDParticleImpl partCnt = (XSDParticleImpl) type.getContent();
        if (partCnt != null) {
            XSDModelGroupImpl mdlGrp = (XSDModelGroupImpl) partCnt.getTerm();
            XSDCompositor typeComposite = mdlGrp.getCompositor();
            if (typeComposite.equals(XSDCompositor.SEQUENCE_LITERAL)) {
                setSequence();
            } else if (typeComposite.equals(XSDCompositor.ALL_LITERAL)) {
                setAll();
            } else if (typeComposite.equals(XSDCompositor.CHOICE_LITERAL)) {
                setChoice();
            }
            enableRadioButtons(false);
        }
    }
}
Also used : XSDParticleImpl(org.eclipse.xsd.impl.XSDParticleImpl) XSDCompositor(org.eclipse.xsd.XSDCompositor) XSDModelGroupImpl(org.eclipse.xsd.impl.XSDModelGroupImpl)

Example 3 with XSDParticleImpl

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

the class Util method getComplexChilds.

/**
 * use the map from path to XSDParticle,path is separated by '/' or '//'
 */
private static Map<String, XSDParticle> getComplexChilds(String parentxpath, XSDComplexTypeDefinition ctype, boolean onlyTopLevel, final Set<Object> visited) throws Exception {
    Map<String, XSDParticle> childDecls = new HashMap<String, XSDParticle>();
    if (ctype.getContent() instanceof XSDParticle) {
        XSDParticleImpl particle = (XSDParticleImpl) ctype.getContent();
        if (particle.getTerm() instanceof XSDModelGroup) {
            XSDModelGroup group = (XSDModelGroup) particle.getTerm();
            EList<XSDParticle> particles = group.getParticles();
            for (XSDParticle part : particles) {
                if (part.getTerm() instanceof XSDElementDeclaration) {
                    XSDElementDeclaration el = (XSDElementDeclaration) part.getTerm();
                    if (el.getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
                        // $NON-NLS-1$
                        String child = parentxpath.length() == 0 ? el.getName() : parentxpath + "/" + el.getName();
                        childDecls.put(child, part);
                    } else {
                        String complexTypeChildPath = parentxpath.length() == 0 ? "//" + el.getName() : // $NON-NLS-1$
                        parentxpath + "//" + // $NON-NLS-1$
                        el.getName();
                        childDecls.put(complexTypeChildPath, part);
                        if (!onlyTopLevel && el.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
                            // $NON-NLS-1$
                            String child = parentxpath.length() == 0 ? el.getName() : parentxpath + "/" + el.getName();
                            childDecls.putAll(getChildElements(child, (XSDComplexTypeDefinition) el.getTypeDefinition(), onlyTopLevel, visited));
                        }
                    }
                }
            }
        }
    }
    return childDecls;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDParticleImpl(org.eclipse.xsd.impl.XSDParticleImpl) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 4 with XSDParticleImpl

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

the class XSDAbstractNewXPathAction method updateElementForAddedfield.

protected void updateElementForAddedfield(XSDIdentityConstraintDefinition icd, String fieldName) {
    if (icd == null || fieldName == null)
        return;
    XSDElementDeclaration entity = (XSDElementDeclaration) icd.getContainer();
    XSDComplexTypeDefinition ctype = (XSDComplexTypeDefinition) entity.getTypeDefinition();
    if (ctype.getContent() instanceof XSDParticle) {
        XSDParticleImpl particle = (XSDParticleImpl) ctype.getContent();
        if (particle.getTerm() instanceof XSDModelGroup) {
            XSDModelGroup group = (XSDModelGroup) particle.getTerm();
            EList<XSDParticle> particles = group.getParticles();
            for (XSDParticle part : particles) {
                if (part.getTerm() instanceof XSDElementDeclaration) {
                    XSDElementDeclaration el = (XSDElementDeclaration) part.getTerm();
                    if (el.getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
                        if (fieldName.equals(el.getName())) {
                            part.setMinOccurs(1);
                            part.setMaxOccurs(1);
                            break;
                        }
                    }
                }
            }
        }
    }
    entity.updateElement();
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDParticleImpl(org.eclipse.xsd.impl.XSDParticleImpl) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 5 with XSDParticleImpl

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

the class ConceptComposite method updateComponents.

private void updateComponents() {
    String typeName = typeNameCombo.getText().trim();
    XSDComplexTypeDefinition type = getTypeByName(typeName);
    if (type != null) {
        setAbstract(type.isAbstract());
        XSDParticleImpl partCnt = (XSDParticleImpl) type.getContent();
        updateElementGroup(type);
        setSuperName(getSuperTypeName(type));
        btnAbstract.setEnabled(false);
    } else {
        // for anonymous type
        if (typeName.length() == 0) {
            enableRadioButtons(false);
            superTypeNameCombo.select(0);
            setAbstract(false);
            btnAbstract.setEnabled(false);
            superTypeNameCombo.setEnabled(false);
        } else {
            superTypeNameCombo.setEnabled(true);
            // new custom type
            String superTypeName = superTypeNameCombo.getText().trim();
            XSDComplexTypeDefinition superType = getTypeByName(superTypeName);
            if (superType != null) {
                updateElementGroup(superType);
                btnAbstract.setEnabled(true);
            } else if (superTypeName.length() == 0) {
                enableRadioButtons(true);
                btnAbstract.setEnabled(true);
            }
        }
    }
}
Also used : XSDParticleImpl(org.eclipse.xsd.impl.XSDParticleImpl) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition)

Aggregations

XSDParticleImpl (org.eclipse.xsd.impl.XSDParticleImpl)6 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)4 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)3 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)3 XSDParticle (org.eclipse.xsd.XSDParticle)3 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)2 XSDModelGroupImpl (org.eclipse.xsd.impl.XSDModelGroupImpl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 XSDCompositor (org.eclipse.xsd.XSDCompositor)1 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)1