use of com.amalto.workbench.dialogs.NewConceptOrElementDialog in project tmdm-studio-se by Talend.
the class XSDNewConceptAction method doAction.
@Override
public IStatus doAction() {
try {
List<String> customTypes = new ArrayList<String>();
for (Iterator<XSDTypeDefinition> iter = schema.getTypeDefinitions().iterator(); iter.hasNext(); ) {
XSDTypeDefinition type = iter.next();
if (type instanceof XSDSimpleTypeDefinition) {
customTypes.add(// $NON-NLS-1$ //$NON-NLS-2$
type.getName() + (type.getTargetNamespace() != null ? " : " + type.getTargetNamespace() : ""));
}
}
List<String> builtInTypes = new ArrayList<String>();
for (Iterator<XSDTypeDefinition> iter = schema.getSchemaForSchema().getTypeDefinitions().iterator(); iter.hasNext(); ) {
XSDTypeDefinition type = iter.next();
if (type instanceof XSDSimpleTypeDefinition) {
builtInTypes.add(type.getName());
}
}
NewConceptOrElementDialog id = new NewConceptOrElementDialog(this, page.getSite().getShell(), schema, Messages.XSDNewConceptAction_NewEntity, customTypes, builtInTypes);
id.setBlockOnOpen(true);
id.open();
if (id.getReturnCode() == Window.CANCEL) {
return Status.CANCEL_STATUS;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDNewConceptAction_ErrorMsg, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
use of com.amalto.workbench.dialogs.NewConceptOrElementDialog in project tmdm-studio-se by Talend.
the class XSDNewConceptAction method widgetSelected.
/**
* author: fliu .this fun is to support button click event invoked from the new expansion of Concept creation dialog
*/
public void widgetSelected(SelectionEvent e) {
// $NON-NLS-1$
NewConceptOrElementDialog dlg = (NewConceptOrElementDialog) ((Widget) e.getSource()).getData("dialog");
if (dlg.getReturnCode() == Window.OK) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
decl = factory.createXSDElementDeclaration();
decl.setName(dlg.getTypeName());
// $NON-NLS-1$
decl.setTypeDefinition(schema.resolveSimpleTypeDefinition(schema.getSchemaForSchemaNamespace(), "string"));
XSDIdentityConstraintDefinition uniqueKey = factory.createXSDIdentityConstraintDefinition();
uniqueKey.setIdentityConstraintCategory(XSDIdentityConstraintCategory.UNIQUE_LITERAL);
uniqueKey.setName(dlg.getTypeName());
XSDXPathDefinition selector = factory.createXSDXPathDefinition();
selector.setVariety(XSDXPathVariety.SELECTOR_LITERAL);
// $NON-NLS-1$
selector.setValue(".");
uniqueKey.setSelector(selector);
XSDXPathDefinition field = factory.createXSDXPathDefinition();
field.setVariety(XSDXPathVariety.FIELD_LITERAL);
// $NON-NLS-1$
field.setValue(".");
uniqueKey.getFields().add(field);
decl.getIdentityConstraintDefinitions().add(uniqueKey);
schema.getContents().add(decl);
// schema.getElementDeclarations().add(decl);
decl.updateElement();
// page.markDirty();
getOperationHistory();
UndoAction changeAction = null;
if (dlg.isComplexType()) {
changeAction = new XSDChangeToComplexTypeAction(page, decl, dlg.getComplexType(), dlg.isChoice(), dlg.isAll(), dlg.isAbstract(), dlg.getSuperTypeName());
} else {
changeAction = new XSDChangeToSimpleTypeAction(page, decl, dlg.getElementType(), dlg.isBuildIn());
}
dlg.close();
changeAction.setOmitTrack(true);
IStatus status = changeAction.execute();
if (status == Status.CANCEL_STATUS) {
schema.getContents().remove(decl);
}
page.refresh();
}
}
use of com.amalto.workbench.dialogs.NewConceptOrElementDialog in project tmdm-studio-se by Talend.
the class XSDNewElementAction method doAction.
@Override
public IStatus doAction() {
try {
List<String> customTypes = new ArrayList<String>();
for (Iterator<XSDTypeDefinition> iter = schema.getTypeDefinitions().iterator(); iter.hasNext(); ) {
XSDTypeDefinition type = iter.next();
if (type instanceof XSDSimpleTypeDefinition) {
customTypes.add(// $NON-NLS-1$ //$NON-NLS-2$
type.getName() + (type.getTargetNamespace() != null ? " : " + type.getTargetNamespace() : ""));
}
}
List<String> builtInTypes = new ArrayList<String>();
for (Iterator<XSDTypeDefinition> iter = schema.getSchemaForSchema().getTypeDefinitions().iterator(); iter.hasNext(); ) {
XSDTypeDefinition type = iter.next();
if (type instanceof XSDSimpleTypeDefinition) {
builtInTypes.add(type.getName());
}
}
NewConceptOrElementDialog id = new NewConceptOrElementDialog(this, page.getSite().getShell(), schema, Messages.XSDNewElementAction_Text, customTypes, builtInTypes);
id.setBlockOnOpen(true);
id.open();
if (id.getReturnCode() == Window.CANCEL) {
return Status.CANCEL_STATUS;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDNewElementAction_ErrorMsg, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
use of com.amalto.workbench.dialogs.NewConceptOrElementDialog in project tmdm-studio-se by Talend.
the class XSDNewElementAction method widgetSelected.
/**
* author: fliu this fun is to support button click event invoked from the new expansion of Element creation dialog
*/
public void widgetSelected(SelectionEvent e) {
// $NON-NLS-1$
NewConceptOrElementDialog dlg = (NewConceptOrElementDialog) ((Widget) e.getSource()).getData("dialog");
if (dlg.getReturnCode() == Window.OK) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
XSDElementDeclaration decl = factory.createXSDElementDeclaration();
decl.setName(dlg.getTypeName());
// $NON-NLS-1$
decl.setTypeDefinition(schema.resolveSimpleTypeDefinition(schema.getSchemaForSchemaNamespace(), "string"));
schema.getContents().add(decl);
// schema.getElementDeclarations().add(decl);
decl.updateElement();
// page.markDirty();
UndoAction changeAction = null;
if (dlg.isComplexType()) {
changeAction = new XSDChangeToComplexTypeAction(page, decl, dlg.getComplexType(), dlg.isChoice(), dlg.isAll(), dlg.isAbstract(), dlg.getSuperTypeName());
} else {
changeAction = new XSDChangeToSimpleTypeAction(page, decl, dlg.getElementType(), dlg.isBuildIn());
}
dlg.close();
changeAction.setOmitTrack(true);
IStatus status = changeAction.execute();
if (status == Status.CANCEL_STATUS) {
schema.getContents().remove(decl);
}
page.refresh();
}
}
Aggregations