Search in sources :

Example 1 with OutputTable

use of org.talend.designer.dbmap.model.table.OutputTable in project tdi-studio-se by Talend.

the class ExternalDataConverter method prepareOutputTables.

public ArrayList<OutputTable> prepareOutputTables(List<IOConnection> outputConnections, List<IMetadataTable> outputMetadataTables, ExternalDbMapData externalData) {
    Map<String, ExternalDbMapTable> nameToOutpuPersistentTable = new HashMap<String, ExternalDbMapTable>();
    if (externalData != null) {
        for (ExternalDbMapTable persistentTable : externalData.getOutputTables()) {
            nameToOutpuPersistentTable.put(persistentTable.getName(), persistentTable);
        }
    }
    Map<String, IOConnection> nameToOutputConn = new HashMap<String, IOConnection>();
    if (outputConnections != null) {
        for (IOConnection connection : outputConnections) {
            if (connection.getConnectionType().equals(EConnectionType.FLOW_MAIN) || connection.getConnectionType().equals(EConnectionType.FLOW_REF) || connection.getConnectionType().equals(EConnectionType.TABLE) || connection.getConnectionType().equals(EConnectionType.TABLE_REF)) {
                nameToOutputConn.put(connection.getUniqueName(), connection);
            }
        }
    }
    ArrayList<OutputTable> outputDataMapTables = new ArrayList<OutputTable>();
    for (IMetadataTable table : outputMetadataTables) {
        IOConnection connection = nameToOutputConn.get(table.getTableName());
        OutputTable outputTable = null;
        if (connection != null) {
            ExternalDbMapTable persistentTable = nameToOutpuPersistentTable.get(connection.getUniqueName());
            outputTable = new OutputTable(this.mapperManager, table.clone(), connection.getUniqueName(), connection.getName());
            outputTable.initFromExternalData(persistentTable);
        } else {
            ExternalDbMapTable persistentTable = nameToOutpuPersistentTable.get(table.getTableName());
            if (persistentTable != null) {
                outputTable = new OutputTable(this.mapperManager, table, persistentTable.getName(), persistentTable.getTableName());
                outputTable.initFromExternalData(persistentTable);
            } else {
                outputTable = new OutputTable(this.mapperManager, table, table.getTableName(), table.getLabel());
            }
        }
        if (outputTable != null) {
            outputDataMapTables.add(outputTable);
        }
    }
    return outputDataMapTables;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) HashMap(java.util.HashMap) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) ArrayList(java.util.ArrayList) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 2 with OutputTable

use of org.talend.designer.dbmap.model.table.OutputTable in project tdi-studio-se by Talend.

the class MapperMain method getMetadataListOut.

/**
     * DOC amaumont Comment method "getMetadataListOut".
     * 
     * @return
     */
public List<IMetadataTable> getMetadataListOut() {
    List<OutputTable> tables = mapperManager.getOutputTables();
    List<IMetadataTable> metadataTables = new ArrayList<IMetadataTable>(tables.size());
    for (OutputTable table : tables) {
        metadataTables.add(table.getMetadataTable());
    }
    return metadataTables;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 3 with OutputTable

use of org.talend.designer.dbmap.model.table.OutputTable in project tdi-studio-se by Talend.

the class DataMapTableView method addTablesListeners.

/**
     * DOC amaumont Comment method "addTableForColumnsListeners".
     */
private void addTablesListeners() {
    tableViewerCreatorForColumns.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        @Override
        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

        @Override
        public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
    tableViewerForEntries.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            int[] selectionIndices = tableViewerForEntries.getTable().getSelectionIndices();
            if (selectionIndices.length > 0) {
                selectThisDataMapTableView();
                onSelectedEntries(event.getSelection(), selectionIndices);
                // bug 18414
                MetadataTableEditorView metadataTableEditorView = null;
                if (getZone() == Zone.INPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getInputMetaEditorView();
                } else if (getZone() == Zone.OUTPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getOutputMetaEditorView();
                }
                if (metadataTableEditorView != null) {
                    metadataTableEditorView.getTableViewerCreator().refresh();
                }
            }
        }
    });
    tableForEntries.addListener(SWT.DragDetect, new Listener() {

        @Override
        public void handleEvent(Event event) {
            onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
        }
    });
    tableViewerCreatorForColumns.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (forceExecuteSelectionEvent) {
                forceExecuteSelectionEvent = false;
                onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
            }
        }
    });
    tableForEntries.addListener(SWT.KeyDown, new Listener() {

        @Override
        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForColumns, event);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<IColumnEntry>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<IColumnEntry> event) {
            TableViewerCreator tableViewerCreator = tableViewerCreatorForColumns;
            ITableEntry tableEntry = event.bean;
            parseExpressionIfNeeded(event, tableViewerCreator, tableEntry);
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    if (abstractDataMapTable instanceof OutputTable) {
        OutputTable outputTable = (OutputTable) abstractDataMapTable;
        outputTable.getWhereTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getWhereTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, extendedTableViewerForFilters);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, entendedTableViewerForOtherClauses);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
    }
}
Also used : SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) FocusListener(org.eclipse.swt.events.FocusListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) KeyListener(org.eclipse.swt.events.KeyListener) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 4 with OutputTable

use of org.talend.designer.dbmap.model.table.OutputTable in project tdi-studio-se by Talend.

the class OutputDataMapTableView method initTableFilters.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView#initTableConstraints()
     */
@Override
protected void initTableFilters(Composite parent) {
    /**
         * create whereFiltersTable
         */
    // createFiltersTable(parent);
    //$NON-NLS-1$
    filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalWhereClauses");
    extendedTableViewerForFilters = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getWhereTableFiltersEntriesModel(), parent) {

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
             * getTableConstraintSize()
             */
        @Override
        protected int getTableConstraintSize() {
            int retSize = 0;
            if (abstractDataMapTable instanceof OutputTable) {
                retSize = ((OutputTable) abstractDataMapTable).getWhereFilterEntries().size();
            }
            return retSize;
        }

        @Override
        protected void setTextCellEditor(TextCellEditor textEditor) {
            if (textEditor != null) {
                whereConstraintExpressionTextEditor = (Text) textEditor.getControl();
            }
        }
    };
    // correct partially layout problem with GTK when cell editor value is applied
    ((ExtendedTableViewerForFilters) extendedTableViewerForFilters).createFiltersTable();
    TableViewerCreator tableViewerCreatorForWhereClauses = extendedTableViewerForFilters.getTableViewerCreator();
    tableViewerCreatorForWhereClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
    List<FilterTableEntry> whereEntries = ((OutputTable) getDataMapTable()).getWhereFilterEntries();
    tableViewerCreatorForWhereClauses.init(whereEntries);
    /**
         * create otherFiltersTable
         */
    IComponent component = getMapperManager().getComponent().getComponent();
    if (component != null && "tELTOracleMap".equals(component.getName())) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses.oracle");
    } else {
        //$NON-NLS-1$
        filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses");
    }
    entendedTableViewerForOtherClauses = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getOtherTableFiltersEntriesModel(), parent) {

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
             * getTableConstraintSize()
             */
        @Override
        public int getTableConstraintSize() {
            int retSize = 0;
            if (abstractDataMapTable instanceof OutputTable) {
                retSize = ((OutputTable) abstractDataMapTable).getOtherFilterEntries().size();
            }
            return retSize;
        }

        @Override
        protected void setTextCellEditor(TextCellEditor textEditor) {
            if (textEditor != null) {
                otherConstraintExpressionTextEditor = (Text) textEditor.getControl();
            }
        }
    };
    ((ExtendedTableViewerForFilters) entendedTableViewerForOtherClauses).createFiltersTable();
    TableViewerCreator tableViewerCreatorForOtherClauses = entendedTableViewerForOtherClauses.getTableViewerCreator();
    tableViewerCreatorForOtherClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
    List<FilterTableEntry> otherEntries = ((OutputTable) getDataMapTable()).getOtherFilterEntries();
    tableViewerCreatorForOtherClauses.init(otherEntries);
    // updateGridDataHeightForTableConstraints(entendedTableViewerForOtherClauses.getTable());
    updateGridDataHeightForTableConstraints();
    if (WindowSystem.isGTK()) {
        tableViewerCreatorForWhereClauses.layout();
        entendedTableViewerForOtherClauses.getTableViewerCreator().layout();
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) IComponent(org.talend.core.model.components.IComponent) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) Text(org.eclipse.swt.widgets.Text) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 5 with OutputTable

use of org.talend.designer.dbmap.model.table.OutputTable in project tdi-studio-se by Talend.

the class MapperManager method removeSelectedOutputTable.

public void removeSelectedOutputTable() {
    OutputDataMapTableView currentSelectedDataMapTableView = uiManager.getCurrentSelectedOutputTableView();
    if (currentSelectedDataMapTableView != null) {
        OutputTable outputTable = (OutputTable) currentSelectedDataMapTableView.getDataMapTable();
        String tableTitle = ((AbstractDataMapTable) currentSelectedDataMapTableView.getDataMapTable()).getTitle();
        if (MessageDialog.openConfirm(currentSelectedDataMapTableView.getShell(), //$NON-NLS-1$
        Messages.getString("MapperManager.removeOutputTableTitle"), Messages.getString("MapperManager.removeOutputTableTitleMessage", new Object[] { tableTitle }))) {
            //$NON-NLS-1$
            IProcess process = mapperComponent.getProcess();
            uiManager.removeOutputTableView(currentSelectedDataMapTableView);
            uiManager.updateToolbarButtonsStates(Zone.OUTPUTS);
            process.removeUniqueConnectionName(outputTable.getUniqueName());
            uiManager.refreshSqlExpression();
        }
    }
}
Also used : AbstractDataMapTable(org.talend.designer.dbmap.model.table.AbstractDataMapTable) IProcess(org.talend.core.model.process.IProcess) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Aggregations

OutputTable (org.talend.designer.dbmap.model.table.OutputTable)18 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)9 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)8 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)7 InputTable (org.talend.designer.dbmap.model.table.InputTable)7 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)6 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Control (org.eclipse.swt.widgets.Control)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 IOConnection (org.talend.designer.dbmap.external.connection.IOConnection)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 ControlListener (org.eclipse.swt.events.ControlListener)2 Point (org.eclipse.swt.graphics.Point)2 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)2 IProcess (org.talend.core.model.process.IProcess)2 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)2