use of org.eclipse.xsd.XSDComponent in project tmdm-studio-se by Talend.
the class XSDEditFacetAction method doAction.
@Override
public IStatus doAction() {
try {
IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
XSDComponent xSDCom = null;
if (selection.getFirstElement() instanceof XSDSimpleTypeDefinition) {
std = (XSDSimpleTypeDefinition) selection.getFirstElement();
} else {
TreePath tPath = ((TreeSelection) selection).getPaths()[0];
for (int i = 0; i < tPath.getSegmentCount(); i++) {
if (tPath.getSegment(i) instanceof XSDSimpleTypeDefinition) {
std = (XSDSimpleTypeDefinition) (tPath.getSegment(i));
}
}
}
/**
* totalDigits, fractionDigits, maxInclusive, maxExclusive, minInclusive, minExclusive
*/
if (facetName.equals("pattern")) {
// $NON-NLS-1$
editPattern();
} else if (facetName.equals("enumeration")) {
// $NON-NLS-1$
editEnumeration();
} else if (facetName.equals("length")) {
// $NON-NLS-1$
editLength();
} else if (facetName.equals("minLength")) {
// $NON-NLS-1$
editMinLength();
} else if (facetName.equals("maxLength")) {
// $NON-NLS-1$
editMaxLength();
} else if (facetName.equals("totalDigits")) {
// $NON-NLS-1$
editTotalDigits();
} else if (facetName.equals("fractionDigits")) {
// $NON-NLS-1$
editFractionDigits();
} else if (facetName.equals("maxInclusive")) {
// $NON-NLS-1$
editMaxInclusive();
} else if (facetName.equals("maxExclusive")) {
// $NON-NLS-1$
editMaxExclusive();
} else if (facetName.equals("minInclusive")) {
// $NON-NLS-1$
editMinInclusive();
} else if (facetName.equals("minExclusive")) {
// $NON-NLS-1$
editMinExclusive();
} else if (facetName.equals("whiteSpace")) {
// $NON-NLS-1$
editWhiteSpace();
} else {
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditFacetAction_ErrorMsg1, facetName));
return Status.CANCEL_STATUS;
}
std.updateElement();
page.getTreeViewer().refresh(true);
page.markDirty();
page.refresh();
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditFacetAction_ErrorMsg2, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
Aggregations