use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.
the class XSDUtil method getValidElementPaths.
public static Set<String> getValidElementPaths(XSDElementDeclaration ed, IXPathSelectionFilter filter) {
String curPrefix = ed.getName() + DIVIDE;
XSDTypeDefinition type = ed.getType();
Set<String> paths = new HashSet<String>();
if (type instanceof XSDComplexTypeDefinition) {
XSDParticle particle = type.getComplexType();
iterateParticle(particle, filter, paths, curPrefix);
}
return paths;
}
use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.
the class ConceptComposite method getSuperTypeName.
private String getSuperTypeName(XSDComplexTypeDefinition type) {
XSDTypeDefinition baseType = type.getBaseTypeDefinition();
if (baseType == null) {
// $NON-NLS-1$
return "";
}
String superTypeName = baseType.getName();
if (superTypeName == null || "anyType".equalsIgnoreCase(superTypeName)) {
// $NON-NLS-1$
return "";
}
return superTypeName;
}
use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.
the class Util method getAllObject.
public static Object[] getAllObject(Object elem, List<Object> objList, IStructuredContentProvider provider) {
Object[] elems = provider.getElements(elem);
for (Object obj : elems) {
if (obj == null) {
continue;
}
if (obj instanceof XSDModelGroup || obj instanceof XSDElementDeclaration || obj instanceof XSDParticle || obj instanceof XSDTypeDefinition) {
if (!objList.contains(obj)) {
objList.add(obj);
getAllObject(obj, objList, provider);
}
}
}
return objList.toArray();
}
use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.
the class Util method isUUID.
public static boolean isUUID(XSDElementDeclaration decl) {
XSDTypeDefinition typeDefinition = decl.getTypeDefinition();
if (null == typeDefinition) {
return false;
}
String type = typeDefinition.getName();
if (type == null) {
type = typeDefinition.getBaseType().getName();
}
// set enum
if (typeDefinition instanceof XSDSimpleTypeDefinition && Util.isCustomrType(decl.getSchema(), type)) {
XSDSimpleTypeDefinition typedef = (XSDSimpleTypeDefinition) typeDefinition;
if (typedef.getBaseTypeDefinition() != null && typedef.getEnumerationFacets().size() > 0) {
// $NON-NLS-1$
type = "enum";
}
}
if ("UUID".equals(type) || "AUTO_INCREMENT".equals(type)) {
// $NON-NLS-1$ //$NON-NLS-2$
return true;
}
return false;
}
use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.
the class XSDDeleteTypeDefinition method doAction.
@Override
public IStatus doAction() {
IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
ArrayList<Object> objList = new ArrayList<Object>();
Util.getAllObject(page.getSite(), objList, (IStructuredContentProvider) page.getSchemaContentProvider());
Util.getAllObject(page.getSite(), objList, (IStructuredContentProvider) page.getTypeContentProvider());
XSDTypeDefinition usingElement = findUsingElement(selection, objList);
if (usingElement != null) {
String message = getInfoDialogMessage(usingElement);
MessageDialog.openInformation(page.getSite().getShell(), Messages.XSDDeleteTypeDefinition_ConfirmDel, message);
return Status.CANCEL_STATUS;
}
// edit by ymli; fix the bug:0012228. Made the multiple types can be deleted.
for (Iterator<XSDTypeDefinition> iter = selection.iterator(); iter.hasNext(); ) {
XSDTypeDefinition type = iter.next();
if (type instanceof XSDSimpleTypeDefinition) {
XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) type;
if (xsdSimpType != null) {
simpleType = xsdSimpType;
}
schema.getContents().remove(simpleType);
} else {
XSDComplexTypeDefinition complxType = (XSDComplexTypeDefinition) type;
if (xsdCmpexType != null) {
complxType = xsdCmpexType;
}
schema.getContents().remove(complxType);
}
}
xsdSimpType = null;
xsdCmpexType = null;
page.refresh();
page.markDirty();
return Status.OK_STATUS;
}
Aggregations