use of org.talend.commons.ui.swt.advanced.dataeditor.button.ImportPushButtonForExtendedTable in project tdi-studio-se by Talend.
the class HL7MetadataEmfToolbarEditor method createImportPushButton.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createPastButton()
*/
@Override
public ImportPushButton createImportPushButton() {
return new ImportPushButtonForExtendedTable(toolbar, extendedTableViewer) {
@Override
protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, File file) {
return new MetadataEmfImportXmlCommand(extendedTableModel, file);
}
@Override
public boolean getEnabledState() {
// 13749
return super.getEnabledState() && !isRepository;
}
@Override
protected void beforeCommandExecution() {
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
super.beforeCommandExecution();
} else {
MessageDialog.openError(HL7MetadataEmfToolbarEditor.this.getParentComposite().getShell(), "Can't import xml file", "Need to init a schema by choosing a file at first");
}
}
protected void afterCommandExecution(Command executedCommand) {
MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
String key = ((IModel) selectedObj).getDisplayName();
for (MetadataColumn col : tableEditorModel.getMetadataColumnList()) {
linker.getManager().updateRelationMapping(key, col, true);
}
}
linker.getMainui().redrawLinkers();
linker.getBackgroundRefresher().refreshBackground();
}
};
}
Aggregations