Search in sources :

Example 1 with ImportPushButtonForExtendedTable

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();
        }
    };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ImportPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.ImportPushButtonForExtendedTable) IModel(org.talend.designer.hl7.model.IModel) MetadataEmfExportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand) MetadataEmfPasteCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand) ExtendedTableResetDBTypesCommand(org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand) Command(org.eclipse.gef.commands.Command) MetadataEmfTableEditor(org.talend.core.ui.metadata.editor.MetadataEmfTableEditor) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) File(java.io.File) MetadataEmfImportXmlCommand(org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand)

Aggregations

File (java.io.File)1 Command (org.eclipse.gef.commands.Command)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ImportPushButtonForExtendedTable (org.talend.commons.ui.swt.advanced.dataeditor.button.ImportPushButtonForExtendedTable)1 ExtendedTableModel (org.talend.commons.ui.swt.extended.table.ExtendedTableModel)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 MetadataEmfTableEditor (org.talend.core.ui.metadata.editor.MetadataEmfTableEditor)1 ExtendedTableResetDBTypesCommand (org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand)1 MetadataEmfExportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand)1 MetadataEmfImportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand)1 MetadataEmfPasteCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand)1 IModel (org.talend.designer.hl7.model.IModel)1 HL7MultiSchemaUI (org.talend.designer.hl7.ui.HL7MultiSchemaUI)1