use of com.amalto.workbench.dialogs.AnnotationOrderedListsDialog in project tmdm-studio-se by Talend.
the class XSDAnnotationLookupFieldsAction method doAction.
public IStatus doAction() {
try {
IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
XSDComponent xSDCom = null;
if (selection.getFirstElement() instanceof Element) {
TreePath tPath = ((TreeSelection) selection).getPaths()[0];
for (int i = 0; i < tPath.getSegmentCount(); i++) {
if (tPath.getSegment(i) instanceof XSDAnnotation)
xSDCom = (XSDAnnotation) (tPath.getSegment(i));
}
} else
xSDCom = (XSDComponent) selection.getFirstElement();
XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
struc.setXSDSchema(schema);
// (XSDComponent) selection.getFirstElement());
if (struc.getAnnotation() == null) {
throw new RuntimeException(Messages.bind(Messages.XSDAnnotationLookupFieldsAction_ExceptionInfo, xSDCom.getClass().getName()));
}
dlg = new AnnotationOrderedListsDialog(new ArrayList(struc.getLookupFields().values()), new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
dlg.close();
}
}, page.getSite().getShell(), Messages.XSDAnnotationLookupFieldsAction_SetLookupFields, Messages.XSDAnnotationLookupFieldsAction_LookupFields, page, AnnotationOrderedListsDialog.AnnotationLookupField_ActionType, null);
dlg.setBlockOnOpen(true);
int ret = dlg.open();
if (ret == Window.CANCEL) {
return Status.CANCEL_STATUS;
}
struc.setAccessRole(dlg.getXPaths(), false, (IStructuredContentProvider) page.getTreeViewer().getContentProvider(), // $NON-NLS-1$
"X_Lookup_Field");
if (struc.hasChanged()) {
page.refresh();
page.getTreeViewer().expandToLevel(xSDCom, 2);
page.markDirty();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDAnnotationLookupFieldsAction_ErrorMsg, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
use of com.amalto.workbench.dialogs.AnnotationOrderedListsDialog in project tmdm-studio-se by Talend.
the class XSDSetAnnotationPrimaryKeyInfoAction method doAction.
public IStatus doAction() {
try {
IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
XSDComponent xSDCom = null;
if (selection.getFirstElement() instanceof Element) {
TreePath tPath = ((TreeSelection) selection).getPaths()[0];
for (int i = 0; i < tPath.getSegmentCount(); i++) {
if (tPath.getSegment(i) instanceof XSDAnnotation)
xSDCom = (XSDAnnotation) (tPath.getSegment(i));
}
} else
xSDCom = (XSDComponent) selection.getFirstElement();
XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
struc.setXSDSchema(schema);
if (struc.getAnnotation() == null) {
throw new RuntimeException(Messages.bind(Messages.XSDSetAnnotationXX_ExceptionInfo1, xSDCom.getClass().getName()));
}
dlg = new AnnotationOrderedListsDialog(new ArrayList(struc.getPrimaryKeyInfos().values()), new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
dlg.close();
}
}, // $NON-NLS-1$
page.getSite().getShell(), // $NON-NLS-1$
Messages.XSDSetAnnotationXX_DialogTitle, // $NON-NLS-1$
"xPaths", // $NON-NLS-1$
page, AnnotationOrderedListsDialog.AnnotationPrimaKeyInfo_ActionType, null);
dlg.setBlockOnOpen(true);
int ret = dlg.open();
if (ret == Window.CANCEL) {
return Status.CANCEL_STATUS;
}
struc.setAccessRole(dlg.getXPaths(), false, (IStructuredContentProvider) page.getTreeViewer().getContentProvider(), // $NON-NLS-1$
"X_PrimaryKeyInfo");
if (struc.hasChanged()) {
page.refresh();
page.getTreeViewer().expandToLevel(xSDCom, 2);
page.markDirty();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDSetAnnotationXX_Msg, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
use of com.amalto.workbench.dialogs.AnnotationOrderedListsDialog in project tmdm-studio-se by Talend.
the class XSDSetAnnotationTargetSystemsAction method doAction.
public IStatus doAction() {
try {
IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
XSDComponent xSDCom = null;
if (selection.getFirstElement() instanceof Element) {
TreePath tPath = ((TreeSelection) selection).getPaths()[0];
for (int i = 0; i < tPath.getSegmentCount(); i++) {
if (tPath.getSegment(i) instanceof XSDAnnotation)
xSDCom = (XSDAnnotation) (tPath.getSegment(i));
}
} else
xSDCom = (XSDComponent) selection.getFirstElement();
XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
// XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement());
if (struc.getAnnotation() == null) {
throw new RuntimeException(Messages.bind(Messages.XSDSetAnnotationTargetSystemsAction_ExceptionInfo, xSDCom.getClass().getName()));
}
dlg = new AnnotationOrderedListsDialog(new ArrayList(struc.getTargetSystems().values()), new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
dlg.close();
}
}, page.getSite().getShell(), Messages.XSDSetAnnotationTargetSystemsAction_DialogTitle, Messages.XSDSetAnnotationTargetSystemsAction_DialogTip, page, AnnotationOrderedListsDialog.AnnotationTargetSystems_ActionType, dataModelName);
dlg.setBlockOnOpen(true);
int ret = dlg.open();
if (ret == Window.CANCEL) {
return Status.CANCEL_STATUS;
}
struc.setTargetSystems(dlg.getXPaths());
if (struc.hasChanged()) {
page.refresh();
page.getTreeViewer().expandToLevel(xSDCom, 2);
page.markDirty();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDSetAnnotationTargetSystemsAction_ErrorMsg, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
Aggregations