use of org.eclipse.xsd.XSDModelGroup in project tmdm-studio-se by Talend.
the class DOMViewDialog method collectKeyWords.
private void collectKeyWords(XSDElementDeclaration elementDeclaration, Set<String> keys) {
String elementName = elementDeclaration.getName();
keys.add(elementName);
XSDTypeDefinition typeDefinition = elementDeclaration.getType();
if (typeDefinition instanceof XSDComplexTypeDefinition) {
XSDParticle particle = (XSDParticle) ((XSDComplexTypeDefinition) typeDefinition).getContent();
XSDTerm term = particle.getTerm();
if (term instanceof XSDModelGroup) {
EList<XSDParticle> particles = ((XSDModelGroup) term).getContents();
for (XSDParticle p : particles) {
XSDTerm childTerm = p.getTerm();
if (childTerm instanceof XSDElementDeclaration) {
collectKeyWords((XSDElementDeclaration) childTerm, keys);
}
}
}
}
}
use of org.eclipse.xsd.XSDModelGroup in project tmdm-studio-se by Talend.
the class ComplexTypeWrapper method changeGroupType.
public boolean changeGroupType() {
XSDParticle groupParticle = (XSDParticle) curXSDComplexType.getContent();
XSDModelGroup group = (XSDModelGroup) groupParticle.getContent();
if (group.getCompositor().equals(newGroupType))
return false;
group.setCompositor(newGroupType);
group.updateElement();
return true;
}
use of org.eclipse.xsd.XSDModelGroup in project tmdm-studio-se by Talend.
the class Util method getTopElement.
public static String getTopElement(XSDElementDeclaration parent, XSDElementDeclaration son) {
XSDTypeDefinition type = parent.getTypeDefinition();
if (!(type instanceof XSDComplexTypeDefinition)) {
return null;
}
List<XSDComplexTypeDefinition> hierarchyComplexTypes = getAllSuperComplexTypes((XSDComplexTypeDefinition) type);
for (XSDComplexTypeDefinition complexType : hierarchyComplexTypes) {
if (complexType.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) complexType.getContent();
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) particle.getTerm();
EList<XSDParticle> elist = group.getContents();
for (XSDParticle pt : elist) {
if (pt.getContent() instanceof XSDElementDeclaration) {
XSDElementDeclaration ele = (XSDElementDeclaration) pt.getContent();
if (ele == son) {
return ele.getName();
/*
* ArrayList<String> complexTypes = new ArrayList<String>(); XSDElementDeclaration spec
* = findOutSpecialSonElement( (XSDElementDeclaration) pt.getContent(), son,
* complexTypes); if (spec != null) return spec.getName();
*/
// if (ele.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
//
// return ele.getName() + "/"//$NON-NLS-1$
// + getTopElement(ele, son, (XSDComplexTypeDefinition) ele.getTypeDefinition());
//
//
// }
}
}
}
}
}
}
// $NON-NLS-1$
return "";
}
use of org.eclipse.xsd.XSDModelGroup in project tmdm-studio-se by Talend.
the class Util method getParent.
public static Object getParent(Object son) {
if (!((son instanceof XSDElementDeclaration) || (son instanceof XSDParticle))) {
return null;
}
XSDElementDeclaration elem = null;
if (son instanceof XSDParticle) {
elem = (XSDElementDeclaration) ((XSDParticle) son).getContent();
} else if (son instanceof XSDElementDeclaration) {
elem = (XSDElementDeclaration) son;
}
if (elem == null || elem.getSchema() == null) {
return null;
}
EList<XSDSchemaContent> parentList = elem.getSchema().getContents();
for (XSDSchemaContent top : parentList) {
if (!(top instanceof XSDElementDeclaration) && !(top instanceof XSDComplexTypeDefinition)) {
continue;
}
if (top instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) top;
if (decl == son) {
return decl;
}
if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition type = (XSDComplexTypeDefinition) decl.getTypeDefinition();
if (type.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) type.getContent();
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) particle.getTerm();
EList<XSDParticle> elist = group.getContents();
for (XSDParticle pt : elist) {
if (pt.getContent() instanceof XSDElementDeclaration) {
if (((XSDElementDeclaration) pt.getContent()) == elem) {
return decl;
}
}
Set<XSDConcreteComponent> complexTypes = new HashSet<XSDConcreteComponent>();
XSDElementDeclaration spec = findOutSpecialSonElement((XSDElementDeclaration) pt.getContent(), elem, complexTypes);
if (spec != null) {
return spec;
}
}
}
}
}
} else {
XSDComplexTypeDefinition type = (XSDComplexTypeDefinition) top;
if (type.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) type.getContent();
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) particle.getTerm();
EList<XSDParticle> elist = group.getContents();
for (XSDParticle pt : elist) {
if (pt.getContent() instanceof XSDElementDeclaration) {
if (((XSDElementDeclaration) pt.getContent()) == elem) {
return top;
}
}
if (pt.getContent() instanceof XSDElementDeclaration) {
Set<XSDConcreteComponent> complexTypes = new HashSet<XSDConcreteComponent>();
XSDElementDeclaration spec = findOutSpecialSonElement((XSDElementDeclaration) pt.getContent(), elem, complexTypes);
if (spec != null) {
return spec;
}
}
}
}
}
}
}
return null;
}
use of org.eclipse.xsd.XSDModelGroup in project tmdm-studio-se by Talend.
the class XSDAnnotationsStructure method inputChanged.
protected void inputChanged(Object component) {
if (component instanceof XSDAnnotation) {
annotation = (XSDAnnotation) component;
if (annotation.getContainer() instanceof XSDElementDeclaration) {
declaration = (XSDElementDeclaration) annotation.getContainer();
} else if (annotation.getContainer() instanceof XSDComplexTypeDefinition) {
complexTypeDef = (XSDComplexTypeDefinition) annotation.getContainer();
}
}
if (component instanceof XSDElementDeclaration) {
declaration = (XSDElementDeclaration) component;
if (declaration.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = declaration.getAnnotation();
}
}
if (component instanceof XSDComplexTypeDefinition) {
complexTypeDef = (XSDComplexTypeDefinition) component;
componet = complexTypeDef;
if (complexTypeDef.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = complexTypeDef.getAnnotation();
}
}
if (component instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) component;
if (group.getContainer().getContainer() instanceof XSDComplexTypeDefinition) {
complexTypeDef = (XSDComplexTypeDefinition) group.getContainer().getContainer();
if (complexTypeDef.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = complexTypeDef.getAnnotation();
}
}
}
if (component instanceof XSDParticle) {
XSDTerm term = ((XSDParticle) component).getTerm();
if (term instanceof XSDElementDeclaration) {
declaration = (XSDElementDeclaration) term;
if (declaration.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = declaration.getAnnotation();
}
}
}
}
Aggregations