use of org.eclipse.xsd.XSDParticle in project tmdm-studio-se by Talend.
the class ComplexTypeInputDialogR method valid.
private boolean valid() {
elementName = elementNameText.getText().trim();
if (((elementName == null) || ("".equals(elementName)))) {
// $NON-NLS-1$
MessageDialog.openError(this.getShell(), Messages._Error, Messages._BusinessNameCannotEmpty);
setReturnCode(-1);
elementNameText.setFocus();
return false;
}
if (elementName.replaceAll("\\s", "").length() != elementName.length()) {
// $NON-NLS-1$//$NON-NLS-2$
MessageDialog.openError(this.getShell(), Messages._Error, Messages._BusinessNameCannotContainEmpty);
setReturnCode(-1);
elementNameText.setFocus();
return false;
}
if ("".equals(minOccursText.getText()) && "".equals(maxOccursText.getText())) {
// $NON-NLS-1$//$NON-NLS-2$
minOccurs = 1;
maxOccurs = 1;
return false;
}
try {
minOccurs = Integer.parseInt(minOccursText.getText());
} catch (Exception e1) {
MessageDialog.openError(this.getShell(), Messages._Error, Messages._MinNoLessThanZero);
setReturnCode(-1);
minOccursText.setFocus();
return false;
}
if (minOccurs < 0) {
MessageDialog.openError(this.getShell(), Messages._Error, Messages._MinNoLessThanZero);
setReturnCode(-1);
minOccursText.setFocus();
return false;
}
if ("".equals(maxOccursText.getText())) {
// $NON-NLS-1$
maxOccurs = -1;
} else {
try {
maxOccurs = Integer.parseInt(maxOccursText.getText());
} catch (Exception e2) {
MessageDialog.openError(this.getShell(), Messages._Error, Messages._MaxOccBeNum);
setReturnCode(-1);
maxOccursText.setFocus();
return false;
}
if ((maxOccurs < minOccurs) || (maxOccurs <= 0)) {
maxOccurs = -1;
}
}
// get position of the selected particle in the container
for (Iterator<XSDParticle> iter = group.getContents().iterator(); iter.hasNext(); ) {
XSDParticle p = iter.next();
if (p.getTerm() instanceof XSDElementDeclaration) {
XSDElementDeclaration thisDecl = (XSDElementDeclaration) p.getTerm();
if (thisDecl.getName().equals(elementName)) {
MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages._BusinessEle, elementName));
return false;
}
}
}
// for
String typeName = getTypeName();
if (!"".equals(typeName)) {
// $NON-NLS-1$
EList<XSDTypeDefinition> list = xsdSchema.getTypeDefinitions();
for (Iterator<XSDTypeDefinition> iter = list.iterator(); iter.hasNext(); ) {
XSDTypeDefinition td = iter.next();
if (td.getName().equals(typeName)) {
if (td instanceof XSDSimpleTypeDefinition) {
MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages._ThisType, typeName));
return false;
}
}
}
}
return true;
}
use of org.eclipse.xsd.XSDParticle 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.XSDParticle in project tmdm-studio-se by Talend.
the class XpathSelectDialog method getXpath.
private String getXpath(StructuredSelection sel) {
// $NON-NLS-1$
String path = "";
// $NON-NLS-1$
String totalXpath = "";
TreeItem item;
TreeItem[] items = domViewer.getTree().getSelection();
for (int i = 0; i < items.length; i++) {
item = items[i];
XSDConcreteComponent component = (XSDConcreteComponent) item.getData();
if (!(component instanceof XSDParticle) && !(component instanceof XSDElementDeclaration)) {
continue;
}
do {
component = (XSDConcreteComponent) item.getData();
if (component instanceof XSDParticle) {
if (((XSDParticle) component).getTerm() instanceof XSDElementDeclaration) {
// $NON-NLS-1$
path = "/" + ((XSDElementDeclaration) ((XSDParticle) component).getTerm()).getName() + path;
}
} else if (component instanceof XSDElementDeclaration) {
// $NON-NLS-1$//$NON-NLS-2$
path = (isAbsolutePath ? "/" : "") + ((XSDElementDeclaration) component).getName() + path;
}
item = item.getParentItem();
} while (item != null);
if (i == 0) {
totalXpath = path;
} else {
// $NON-NLS-1$
totalXpath += "&" + path;
}
// $NON-NLS-1$
path = "";
}
// for(i=0
if (context != null && conceptName != null) {
if (totalXpath.equals(conceptName)) {
// $NON-NLS-1$
totalXpath = totalXpath.replaceAll(conceptName, "/");
} else {
// $NON-NLS-1$//$NON-NLS-2$
totalXpath = totalXpath.replaceAll(conceptName + "/", "");
}
if (totalXpath.equals(context) || totalXpath.equals(context.replaceAll(conceptName + "/", ""))) {
// $NON-NLS-1$//$NON-NLS-2$
// $NON-NLS-1$
totalXpath = ".";
}
if (// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
totalXpath.indexOf('/') == -1 && !totalXpath.equals(".") && !"/".equals(totalXpath) && !"/".equals(context) && !context.equals(conceptName)) {
// $NON-NLS-1$
totalXpath = "../" + totalXpath;
}
}
return totalXpath;
}
use of org.eclipse.xsd.XSDParticle 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.XSDParticle in project tmdm-studio-se by Talend.
the class Util method getChildElements.
public static Map<String, XSDParticle> getChildElements(String parentxpath, XSDComplexTypeDefinition ctype, boolean onlyTopLevel, final Set<Object> visited) throws Exception {
if (visited == null || ctype == null) {
throw new IllegalArgumentException();
}
if (parentxpath == null) {
// $NON-NLS-1$
parentxpath = "";
}
Map<String, XSDParticle> childElements = new HashMap<String, XSDParticle>();
XSDTypeDefinition baseType = ctype.getBaseType();
if (!visited.contains(ctype)) {
visited.add(ctype);
if (baseType instanceof XSDComplexTypeDefinition && baseType != ctype) {
XSDComplexTypeDefinition cmpType = (XSDComplexTypeDefinition) baseType;
childElements.putAll(getChildElements(parentxpath, cmpType, onlyTopLevel, visited));
}
childElements.putAll(getComplexChilds(parentxpath, ctype, onlyTopLevel, visited));
}
return childElements;
}
Aggregations