use of org.eclipse.xsd.XSDIdentityConstraintDefinition 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];
}
use of org.eclipse.xsd.XSDIdentityConstraintDefinition 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];
}
use of org.eclipse.xsd.XSDIdentityConstraintDefinition 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);
}
use of org.eclipse.xsd.XSDIdentityConstraintDefinition in project tmdm-studio-se by Talend.
the class TypesLabelProvider method getText.
@Override
public String getText(Object obj) {
if (obj instanceof XSDElementDeclaration) {
String name = ((XSDElementDeclaration) obj).getName();
if (((XSDElementDeclaration) obj).isAbstract()) {
name += Messages.TypesLabelProvider_0;
}
String tail = ((XSDElementDeclaration) obj).getTargetNamespace() == null ? "" : // $NON-NLS-1$//$NON-NLS-2$
" : " + ((XSDElementDeclaration) obj).getTargetNamespace();
return name + tail;
}
if (obj instanceof XSDParticle) {
XSDParticle xsdParticle = (XSDParticle) obj;
XSDParticleContent content = xsdParticle.getContent();
XSDTerm xsdTerm = xsdParticle.getTerm();
// $NON-NLS-1$
String name = "";
if (content instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) content;
// $NON-NLS-1$
name += (decl.getName() == null ? "" : decl.getName());
if (decl.getTypeDefinition() == null) {
// $NON-NLS-1$//$NON-NLS-2$
name += " [" + ((XSDElementDeclaration) xsdTerm).getName() + "]";
}
} else if (content instanceof XSDModelGroup) {
// System.out.println("SHOULD NOT HAPPEN????");
if (xsdParticle.getContainer() instanceof XSDComplexTypeDefinition) {
String ctdName = ((XSDComplexTypeDefinition) xsdParticle.getContainer()).getName();
// $NON-NLS-1$
name = (ctdName != null ? ctdName : "");
}
/*
* int type = ((XSDModelGroup)xsdTerm).getCompositor().getValue(); switch (type) { case
* XSDCompositor.ALL: name= ""; break; case XSDCompositor.CHOICE: name= ""; break; case
* XSDCompositor.SEQUENCE: name= ""; break; }
*/
} else {
// $NON-NLS-1$
name = "[Any]";
}
if (!((xsdParticle.getMinOccurs() == 1) && (xsdParticle.getMaxOccurs() == 1))) {
// $NON-NLS-1$
name += " [";
name += xsdParticle.getMinOccurs();
// $NON-NLS-1$
name += "...";
// $NON-NLS-1$//$NON-NLS-2$
name += (xsdParticle.getMaxOccurs() == -1) ? "many" : "" + xsdParticle.getMaxOccurs();
// $NON-NLS-1$
name += "]";
}
return name;
}
if (obj instanceof XSDSimpleTypeDefinition) {
return getSimpleTypeDefinition((XSDSimpleTypeDefinition) obj);
}
if (obj instanceof XSDComplexTypeDefinition) {
return getComplexTypeDefinition((XSDComplexTypeDefinition) obj);
}
if (obj instanceof XSDModelGroup) {
// return the name of the complex type definition
XSDParticle particle = (XSDParticle) (((XSDModelGroup) obj).getContainer());
XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) particle.getContainer();
String name = complexTypeDefinition.getName();
if (name == null) {
// $NON-NLS-1$
name = "";
}
// return the occurrence
if (!((particle.getMinOccurs() == 1) && (particle.getMaxOccurs() == 1))) {
// $NON-NLS-1$
name += " [";
name += particle.getMinOccurs();
// $NON-NLS-1$
name += "...";
// $NON-NLS-1$//$NON-NLS-2$
name += (particle.getMaxOccurs() == -1) ? "many" : "" + particle.getMaxOccurs();
// $NON-NLS-1$
name += "]";
}
XSDTypeDefinition extendType = complexTypeDefinition.getBaseTypeDefinition();
// $NON-NLS-1$
String extendTypeName = "";
if (extendType != null && extendType != complexTypeDefinition && !"anyType".equals(extendType.getName())) {
// $NON-NLS-1$
// $NON-NLS-1$
extendTypeName = ":" + extendType.getName();
}
return name + extendTypeName;
}
if (obj instanceof XSDFacet) {
// $NON-NLS-1$
return ((XSDFacet) obj).getFacetName() + ": " + ((XSDFacet) obj).getLexicalValue();
}
if (obj instanceof XSDIdentityConstraintDefinition) {
return ((XSDIdentityConstraintDefinition) obj).getName();
}
if (obj instanceof XSDXPathDefinition) {
XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
return xpath.getValue();
}
if (obj instanceof XSDAttributeGroupDefinition) {
XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) obj;
// $NON-NLS-1$
String name = (attributeGroupDefinition.getName() == null ? "" : attributeGroupDefinition.getName());
if (attributeGroupDefinition.getContents().size() == 0) {
// $NON-NLS-1$//$NON-NLS-2$
name += " [" + attributeGroupDefinition.getResolvedAttributeGroupDefinition().getName() + "]";
}
return name;
}
if (obj instanceof XSDAttributeUse) {
XSDAttributeUse attributeUse = (XSDAttributeUse) obj;
String name = attributeUse.getAttributeDeclaration().getName();
if (name == null) {
// $NON-NLS-1$//$NON-NLS-2$
name = " [" + attributeUse.getAttributeDeclaration().getResolvedAttributeDeclaration().getName() + "]";
}
return name;
}
if (obj instanceof XSDAnnotation) {
// $NON-NLS-1$
return "Annotations";
}
if (obj instanceof Element) {
try {
Element e = (Element) obj;
if (e.getLocalName().equals("documentation")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_1 + e.getChildNodes().item(0).getNodeValue();
} 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 Util.iso2lang.get(source.substring(8).toLowerCase()) + Messages.TypesLabelProvider_2 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_ForeignKey")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_3 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_ForeignKey_NotSep")) {
// $NON-NLS-1$
Boolean v = Boolean.valueOf(e.getChildNodes().item(0).getNodeValue());
return Messages.SimpleXpathInputDialog_sepFkTabPanel + Messages.TypesLabelProvider_4 + v;
} else if (source.equals("X_ForeignKeyInfo")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_5 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_ForeignKey_Filter")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_6 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_SourceSystem")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_7 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_TargetSystem")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_8 + e.getChildNodes().item(0).getNodeValue();
} else if (source.startsWith("X_Description_")) {
// $NON-NLS-1$
return Util.iso2lang.get(source.substring(14).toLowerCase()) + Messages.TypesLabelProvider_9 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_Write")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_10 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_Deny_Create")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_11 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_Deny_LogicalDelete")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_12 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_Deny_PhysicalDelete")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_13 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_Hide")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_14 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_AutoExpand")) {
// $NON-NLS-1$
return Messages.TypesLabelProvider_15 + e.getChildNodes().item(0).getNodeValue();
} else if (source.equals("X_Retrieve_FKinfos")) {
// $NON-NLS-1$
return Messages.bind(Messages.XSDTreeLabelProvider_23, e.getChildNodes().item(0).getNodeValue());
} else if (source.equals("X_FKIntegrity")) {
// $NON-NLS-1$
return Messages.bind(Messages.XSDTreeLabelProvider_24, e.getChildNodes().item(0).getNodeValue());
} else if (source.equals("X_FKIntegrity_Override")) {
// $NON-NLS-1$
return Messages.bind(Messages.XSDTreeLabelProvider_25, e.getChildNodes().item(0).getNodeValue());
} else if (source.equals("X_Workflow")) {
// $NON-NLS-1$
return Messages.bind(Messages.XSDTreeLabelProvider_16, e.getChildNodes().item(0).getNodeValue());
}
if (source.equals("X_ForeignKey_Filter")) {
// $NON-NLS-1$
String nodeValue = e.getChildNodes().item(0).getNodeValue();
if (nodeValue.startsWith("$CFFP:")) {
// $NON-NLS-1$
nodeValue = StringEscapeUtils.unescapeXml(nodeValue).substring(6);
}
return Messages.bind(Messages.XSDTreeLabelProvider_26, nodeValue);
} else {
// $NON-NLS-1$
return source + ": " + Util.nodeToString((Element) obj);
}
} else {
return Util.nodeToString((Element) obj);
}
} else {
return Util.nodeToString((Element) obj);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
if (obj == null) {
// $NON-NLS-1$
return "NULL";
}
// $NON-NLS-1$//$NON-NLS-2$
return "?? " + obj.getClass().getName() + " : " + obj.toString();
}
use of org.eclipse.xsd.XSDIdentityConstraintDefinition in project tmdm-studio-se by Talend.
the class Util method retrieveXSDComponentPath.
public static List<String> retrieveXSDComponentPath(Object component, XSDSchema schema, List<String> buffer) {
String name = null;
if (component instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) component;
name = decl.getName();
// $NON-NLS-1$//$NON-NLS-2$
buffer.add("//xsd:element[@name='" + name + "']");
if (decl.getContainer() instanceof XSDSchemaImpl) {
return buffer;
} else {
return retrieveXSDComponentPath(decl.getContainer(), schema, buffer);
}
} else if (component instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) component;
XSDTerm term = particle.getTerm();
if (term instanceof XSDElementDeclaration && !(((XSDElementDeclaration) term).getContainer() instanceof XSDParticle)) {
String prefix = null;
String ns = ((XSDElementDeclaration) term).getTargetNamespace();
Iterator<Map.Entry<String, String>> iter = schema.getQNamePrefixToNamespaceMap().entrySet().iterator();
while (iter.hasNext() && ns != null) {
Map.Entry<String, String> entry = iter.next();
if (entry.getValue().equals(ns)) {
prefix = entry.getKey();
}
}
name = ((XSDElementDeclaration) term).getName();
buffer.add(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"//xsd:element[@name='" + name + "' or @ref='" + (prefix != null ? (prefix + ":" + name) : name) + "']");
return retrieveXSDComponentPath(particle.getContainer(), schema, buffer);
} else {
retrieveXSDComponentPath(particle.getContainer(), schema, buffer);
}
} else if (component instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition type = (XSDComplexTypeDefinition) component;
name = type.getName();
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
buffer.add("//xsd:complexType" + (name != null ? "[@name='" + name + "']" : ""));
if (type.getContainer() instanceof XSDSchemaImpl) {
return buffer;
}
return retrieveXSDComponentPath(type.getContainer(), schema, buffer);
} else if (component instanceof XSDSimpleTypeDefinition) {
// TreePath tPath=((TreeSelection)selection).getPaths()[0];
// Object elem = tPath.getSegment(0);
// return retrieveXSDComponentPath(elem, schema, buffer, selection);
String typeName = ((XSDSimpleTypeDefinition) component).getName();
// $NON-NLS-1$//$NON-NLS-2$
buffer.add("//xsd:simpleType[@name='" + typeName + "']");
return buffer;
} else if (component instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) component;
String literal = group.getCompositor().getLiteral();
// $NON-NLS-1$
buffer.add("//xsd:" + literal);
return retrieveXSDComponentPath(group.getContainer(), schema, buffer);
} else if (component instanceof XSDIdentityConstraintDefinition) {
XSDIdentityConstraintDefinition identify = (XSDIdentityConstraintDefinition) component;
XSDConcreteComponent c = identify.getContainer();
// $NON-NLS-1$//$NON-NLS-2$
buffer.add("//xsd:unique[@name='" + identify.getName() + "']");
return retrieveXSDComponentPath(c, schema, buffer);
} else if (component instanceof XSDXPathDefinition) {
XSDXPathDefinition path = (XSDXPathDefinition) component;
// $NON-NLS-1$//$NON-NLS-2$
buffer.add("//xsd:field[@xpath='" + path.getValue() + "']");
return retrieveXSDComponentPath(path.getContainer(), schema, buffer);
} else if (component instanceof XSDAnnotation) {
XSDAnnotation annon = (XSDAnnotation) component;
// $NON-NLS-1$
buffer.add("//xsd:annotation");
return retrieveXSDComponentPath(annon.getContainer(), schema, buffer);
} else {
return buffer;
}
return buffer;
}
Aggregations