use of com.amalto.workbench.utils.inputvalidator.EditXSDEleDecNameValidator in project tmdm-studio-se by Talend.
the class EntityWrapper method init.
private void init() {
if (sourceEntity != null) {
name = sourceEntity.getName();
for (XSDIdentityConstraintDefinition eachId : sourceEntity.getIdentityConstraintDefinitions()) {
keys.add(new KeyWrapper(eachId));
}
nameValidator = new EditXSDEleDecNameValidator(sourceEntity.getSchema());
}
}
use of com.amalto.workbench.utils.inputvalidator.EditXSDEleDecNameValidator in project tmdm-studio-se by Talend.
the class XSDEditElementAction method doAction.
@Override
public IStatus doAction() {
try {
ISelection selection = page.getTreeViewer().getSelection();
XSDElementDeclaration decl = (XSDElementDeclaration) ((IStructuredSelection) selection).getFirstElement();
ArrayList<Object> objList = new ArrayList<Object>();
IStructuredContentProvider provider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
String oldName = decl.getName();
InputDialog id = new InputDialog(page.getSite().getShell(), Messages.XSDEditElementAction_EditElement, Messages.XSDEditElementAction_EnterNameForElement, oldName, new EditXSDEleDecNameValidator(schema));
id.setBlockOnOpen(true);
int ret = id.open();
if (ret == Window.CANCEL) {
return Status.CANCEL_STATUS;
}
Object[] objs = Util.getAllObject(page.getSite(), objList, provider);
Object[] allForeignKeyRelatedInfos = Util.getAllForeignKeyRelatedInfos(page.getSite(), new ArrayList<Object>(), provider, new HashSet<Object>());
decl.setName(id.getValue());
decl.updateElement();
Util.updateReference(decl, objs, allForeignKeyRelatedInfos, oldName, id.getValue());
// change unique key with new name of concept
EList list = decl.getIdentityConstraintDefinitions();
XSDIdentityConstraintDefinition toUpdate = null;
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
if (icd.getName().equals(oldName)) {
toUpdate = icd;
break;
}
}
if (toUpdate != null) {
toUpdate.setName(id.getValue());
toUpdate.updateElement();
}
page.refresh();
page.markDirty();
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditElementAction_ErrorEditElement, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
Aggregations