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;
}
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);
}
}
}
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;
}
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();
}
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);
}
}
}
}
Aggregations