Search in sources :

Example 1 with AbstractInOutTable

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

the class ProblemsAnalyser method checkProblems.

public List<Problem> checkProblems(ExternalDbMapData externalData) {
    problems.clear();
    if (externalData != null) {
        List<IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getIncomingConnections());
        List<IConnection> outgoingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getOutgoingConnections());
        ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
        MapperMain mapperMain = mapperManager.getComponent().getMapperMain();
        List<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
        ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
        List<IOConnection> outputsIOConnections = mapperMain.createIOConnections(outgoingConnections);
        ArrayList<OutputTable> outputTables = converter.prepareOutputTables(outputsIOConnections, this.mapperManager.getComponent().getMetadataList(), externalData);
        List<? super AbstractInOutTable> tablesWriteMode = new ArrayList<AbstractInOutTable>();
        tablesWriteMode.addAll(inputTables);
        tablesWriteMode.addAll(outputTables);
        List<? extends AbstractInOutTable> tablesReadMode = (List<? extends AbstractInOutTable>) tablesWriteMode;
        ProblemsManager problemsManager = new ProblemsManager(mapperManager);
        ArrayList<Problem> problemsLocal = new ArrayList<Problem>();
        for (AbstractInOutTable table : tablesReadMode) {
            List<IColumnEntry> columnEntries = table.getColumnEntries();
            problemsManager.checkProblemsForAllEntries(columnEntries);
            for (IColumnEntry entry : columnEntries) {
                List<Problem> problemsOfEntry = entry.getProblems();
                if (problemsOfEntry != null) {
                    problemsLocal.addAll(problemsOfEntry);
                }
            }
        }
        problems.addAll(problemsLocal);
    }
    return getProblems();
}
Also used : ExternalDataConverter(org.talend.designer.dbmap.external.converter.ExternalDataConverter) ArrayList(java.util.ArrayList) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IConnection(org.talend.core.model.process.IConnection) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) ArrayList(java.util.ArrayList) List(java.util.List) Problem(org.talend.core.model.process.Problem) MapperMain(org.talend.designer.dbmap.MapperMain) ProblemsManager(org.talend.designer.dbmap.managers.ProblemsManager)

Example 2 with AbstractInOutTable

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

the class DataMapTableView method createTableForColumns.

/**
     * DOC amaumont Comment method "createTableForColumns".
     * 
     * @param parent
     */
private void createTableForColumns(Composite parent) {
    this.extendedTableViewerForColumns = new AbstractExtendedTableViewer<IColumnEntry>(abstractDataMapTable.getTableColumnsEntriesModel(), parent) {

        @Override
        protected void createColumns(TableViewerCreator<IColumnEntry> tableViewerCreator, Table table) {
            initColumnsOfTableColumns(tableViewerCreator);
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer#initTableListeners()
             */
        @Override
        protected void initTableListeners() {
            super.initTableListeners();
            getTableViewerCreator().addCellValueModifiedListener(new ITableCellValueModifiedListener() {

                @Override
                public void cellValueModified(TableCellValueModifiedEvent e) {
                    // System.out.println();
                    // System.out.println(getTable().hashCode());
                    // System.out.println(e.tableItem.getParent().hashCode());
                    // if (e.tableItem.getParent().isFocusControl()) {
                    // only if table of item is actually the focus control
                    getTableViewerCreator().getSelectionHelper().deselectAll();
                    getTable().forceFocus();
                // }
                }
            });
        }

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
             * (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
             */
        @Override
        protected void setTableViewerCreatorOptions(final TableViewerCreator<IColumnEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setColumnsResizableByDefault(true);
            newTableViewerCreator.setBorderVisible(false);
            newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
            newTableViewerCreator.setKeyboardManagementForCellEdition(false);
            // tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable() instanceof
            // AbstractInOutTable);
            newTableViewerCreator.setFirstColumnMasked(true);
            if (getDataMapTable() instanceof AbstractInOutTable) {
                if (imageKey == null) {
                    imageKey = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.KEY_ICON);
                }
                if (imageEmpty == null) {
                    imageEmpty = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.EMPTY);
                }
            }
            newTableViewerCreator.setLabelProvider(new DefaultTableLabelProvider(newTableViewerCreator) {

                @Override
                public Color getBackground(Object element, int columnIndex) {
                    Color backgroundCellColor = getBackgroundCellColor(newTableViewerCreator, element, columnIndex);
                    if (backgroundCellColor != null) {
                        return backgroundCellColor;
                    }
                    return super.getBackground(element, columnIndex);
                }

                @Override
                public Color getForeground(Object element, int columnIndex) {
                    Color foregroundCellColor = getForegroundCellColor(newTableViewerCreator, element, columnIndex);
                    if (foregroundCellColor != null) {
                        return foregroundCellColor;
                    }
                    return getForegroundCellColor(newTableViewerCreator, element, columnIndex);
                }

                @Override
                public Image getColumnImage(Object element, int columnIndex) {
                    return getColumnImageExecute(element, columnIndex);
                }

                /**
                     * DOC amaumont Comment method "getColumnImageExecute".
                     * 
                     * @param element
                     * @param columnIndex
                     * @return
                     */
                private Image getColumnImageExecute(Object element, int columnIndex) {
                    if (getDataMapTable() instanceof AbstractInOutTable) {
                        AbstractInOutTableEntry entry = (AbstractInOutTableEntry) element;
                        TableViewerCreatorColumnNotModifiable column = newTableViewerCreator.getColumns().get(columnIndex);
                        if (column.getId().equals(ID_NAME_COLUMN)) {
                            if (entry.getMetadataColumn().isKey()) {
                                return imageKey;
                            } else {
                                return imageEmpty;
                            }
                        }
                    }
                    return null;
                }
            });
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer#initModelListeners()
             */
        @Override
        protected void initModelListeners() {
            super.initModelListeners();
            getExtendedTableModel().addAfterOperationListListener(100, new IListenableListListener<IColumnEntry>() {

                @Override
                public void handleEvent(ListenableListEvent<IColumnEntry> event) {
                    if (tableViewerCreator.getTable() != null && !tableViewerCreator.getTable().isDisposed()) {
                        if (event.type == TYPE.ADDED) {
                            Collection<IColumnEntry> addedObjects = event.addedObjects;
                            for (IColumnEntry tableEntry : addedObjects) {
                                mapperManager.getProblemsManager().checkProblemsForTableEntry(tableEntry, false);
                            }
                        }
                    }
                }
            });
        }
    };
    tableViewerCreatorForColumns = this.extendedTableViewerForColumns.getTableViewerCreator();
    this.extendedTableViewerForColumns.setCommandStack(mapperManager.getCommandStack());
    tableForEntries = tableViewerCreatorForColumns.getTable();
    GridData tableEntriesGridData = new GridData(GridData.FILL_BOTH);
    tableEntriesGridData.grabExcessVerticalSpace = true;
    tableEntriesGridData.minimumHeight = tableForEntries.getHeaderHeight() + tableForEntries.getItemHeight();
    // tableEntriesGridData.heightHint = 50;
    // tableEntriesGridData.grabExcessVerticalSpace = false;
    tableForEntries.setLayoutData(tableEntriesGridData);
    addTablesListeners();
}
Also used : ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) Table(org.eclipse.swt.widgets.Table) Color(org.eclipse.swt.graphics.Color) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) DefaultTableLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider) GridData(org.eclipse.swt.layout.GridData) AbstractInOutTableEntry(org.talend.designer.dbmap.model.tableentry.AbstractInOutTableEntry)

Example 3 with AbstractInOutTable

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

the class UIManager method selectDataMapTableView.

/**
     * Select a table view.
     * 
     * @param dataMapTableView
     * @param useNewCommand
     * @param selectAllEntries TODO
     */
public void selectDataMapTableView(final DataMapTableView dataMapTableView, boolean useNewCommand, boolean selectAllEntries) {
    TabFolderEditors tabFolderEditors = mapperUI.getTabFolderEditors();
    // tabFolderEditors.setSelection(TabFolderEditors.INDEX_TAB_METADATA_EDITOR);
    MetadataTableEditorView metadataTableEditorView = null;
    MetadataTableEditorView otherMetadataTableEditorView = null;
    final Zone currentZone = dataMapTableView.getZone();
    List<? extends IDataMapTable> tables = null;
    DataMapTableView previousSelectedTableView = null;
    DataMapTableView newSelectedTableView = null;
    if (currentZone == Zone.INPUTS) {
        metadataTableEditorView = tabFolderEditors.getInputMetaEditor();
        otherMetadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
        tables = mapperManager.getInputTables();
        previousSelectedTableView = this.currentSelectedInputTableView;
        setCurrentSelectedInputTableView((InputDataMapTableView) dataMapTableView);
        newSelectedTableView = dataMapTableView;
    } else if (currentZone == Zone.OUTPUTS) {
        metadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
        otherMetadataTableEditorView = tabFolderEditors.getInputMetaEditor();
        tables = mapperManager.getOutputTables();
        previousSelectedTableView = this.currentSelectedOutputTableView;
        newSelectedTableView = dataMapTableView;
        setCurrentSelectedOutputTableView((OutputDataMapTableView) dataMapTableView);
    }
    updateToolbarButtonsStates(currentZone);
    final AbstractInOutTable abstractDataMapTable = (AbstractInOutTable) mapperManager.retrieveIDataMapTable(dataMapTableView);
    MetadataTableEditor currentMetadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
    final TableViewerCreator dataMapTVCreator = dataMapTableView.getTableViewerCreatorForColumns();
    final TableViewer dataMapTableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
    if (currentMetadataTableEditor == null || currentMetadataTableEditor != null && newSelectedTableView != previousSelectedTableView) {
        if (useNewCommand) {
            DataMapTableViewSelectedCommand command = new DataMapTableViewSelectedCommand(this, previousSelectedTableView, dataMapTableView);
            mapperManager.executeCommand(command);
        }
        currentMetadataTableEditor = new MetadataTableEditor(abstractDataMapTable.getMetadataTable(), abstractDataMapTable.getTitle());
        currentMetadataTableEditor.setModifiedBeanListenable(metadataTableEditorView.getTableViewerCreator());
        final MetadataTableEditorView metadataTableEditorViewFinal = metadataTableEditorView;
        final TableViewerCreator metadataTVCreator = metadataTableEditorViewFinal.getTableViewerCreator();
        final MetadataTableEditor metadataTableEditor = currentMetadataTableEditor;
        modifySelectionChangedListener(currentZone, metadataTableEditorViewFinal, metadataTVCreator, metadataTableEditor, dataMapTableView, previousSelectedTableView);
        // init actions listeners for list which contains metadata
        metadataTableEditor.addAfterOperationListListener(new IListenableListListener() {

            /**
                 * DOC acer Comment method "handleEvent".
                 * 
                 * @param event
                 */
            @Override
            public void handleEvent(ListenableListEvent event) {
                DataMapTableView view = mapperManager.retrieveIDataMapTableView(abstractDataMapTable);
                if (event.type == TYPE.ADDED) {
                    // metadataEditorTableViewer.refresh();
                    List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.addedObjects;
                    lastCreatedInOutColumnEntries.clear();
                    if (event.index != null) {
                        int index = event.index;
                        for (IMetadataColumn metadataColumn : metadataColumns) {
                            lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, index++));
                        }
                    } else if (event.indicesTarget != null) {
                        List<Integer> indicesTarget = event.indicesTarget;
                        int lstSize = indicesTarget.size();
                        for (int i = 0; i < lstSize; i++) {
                            Integer indice = indicesTarget.get(i);
                            IMetadataColumn metadataColumn = metadataColumns.get(i);
                            lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, indice));
                        }
                    } else {
                        //$NON-NLS-1$
                        throw new IllegalStateException(Messages.getString("UIManager.1"));
                    }
                    refreshBackground(false, false);
                    if (event.index != null) {
                        dataMapTableView.changeSize(view.getPreferredSize(true, false, false), true, true);
                        dataMapTableViewer.refresh();
                        dataMapTVCreator.getSelectionHelper().setSelection(event.index);
                    } else if (event.indicesTarget != null) {
                        dataMapTableViewer.refresh();
                        dataMapTableView.changeSize(view.getPreferredSize(false, true, false), true, true);
                        int[] selection = ArrayUtils.toPrimitive((Integer[]) event.indicesTarget.toArray(new Integer[0]));
                        dataMapTVCreator.getSelectionHelper().setSelection(selection);
                    }
                    mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
                }
                if (event.type == TYPE.REMOVED) {
                    // metadataEditorTableViewer.refresh();
                    List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.removedObjects;
                    for (IMetadataColumn metadataColumn : metadataColumns) {
                        ITableEntry metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(abstractDataMapTable.getName(), metadataColumn.getLabel()));
                        mapperManager.removeTableEntry(metadataTableEntry);
                    }
                    dataMapTableViewer.refresh();
                    dataMapTableView.resizeAtExpandedSize();
                    resizeTablesZoneViewAtComputedSize(dataMapTableView.getZone());
                    moveScrollBarZoneAtSelectedTable(dataMapTableView.getZone());
                    refreshBackground(true, false);
                    mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
                }
                if (event.type == TYPE.SWAPED) {
                    List<Integer> listIndexTarget = event.indicesTarget;
                    abstractDataMapTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
                    // dataMapTableViewer.refresh();
                    refreshBackground(true, false);
                }
            }
        });
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
        metadataTableEditorView.setMetadataTableEditor(metadataTableEditor);
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
        metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
        dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(false);
        metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setSelection(dataMapTableViewer.getTable().getSelectionIndices());
        dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(true);
        // disable highlight for other DataMapTableView and highlight selected DataMapTableView
        for (IDataMapTable table : tables) {
            DataMapTableView otherDataMapTableView = mapperManager.retrieveIDataMapTableView(table);
            otherDataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
        }
        dataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
    }
    if (selectAllEntries) {
        dataMapTVCreator.getTable().selectAll();
        selectAllLinks(dataMapTableView);
        metadataTableEditorView.getTableViewerCreator().getTable().selectAll();
        metadataTableEditorView.getToolBar().updateEnabledStateOfButtons();
        if (currentZone == Zone.OUTPUTS) {
            dataMapTableView.getTableViewerCreatorForWhereFilters().getTable().selectAll();
            dataMapTableView.getTableViewerCreatorForOtherFilters().getTable().selectAll();
        }
    }
    if (otherMetadataTableEditorView != null) {
        otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
}
Also used : TabFolderEditors(org.talend.designer.dbmap.ui.tabs.TabFolderEditors) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) OutputsZone(org.talend.designer.dbmap.ui.visualmap.zone.OutputsZone) InputsZone(org.talend.designer.dbmap.ui.visualmap.zone.InputsZone) Zone(org.talend.designer.dbmap.ui.visualmap.zone.Zone) ToolbarInputZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarInputZone) ToolbarOutputZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarOutputZone) ToolbarZone(org.talend.designer.dbmap.ui.visualmap.zone.toolbar.ToolbarZone) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) Point(org.eclipse.swt.graphics.Point) DataMapTableViewSelectedCommand(org.talend.designer.dbmap.ui.commands.DataMapTableViewSelectedCommand) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) List(java.util.List) ArrayList(java.util.ArrayList) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView) TableViewer(org.eclipse.jface.viewers.TableViewer) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)

Example 4 with AbstractInOutTable

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

the class UIManager method refreshInOutTableAndMetaTable.

/**
     * DOC amaumont Comment method "refreshInOutTableAndMetaTable".
     * 
     * @param currentModifiedTableEntry can be null
     */
private void refreshInOutTableAndMetaTable(AbstractInOutTableEntry currentModifiedTableEntry) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedTableEntry);
    IMetadataTable metadataTableTarget = ((AbstractInOutTable) dataMapTableView.getDataMapTable()).getMetadataTable();
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedTableEntry);
    MetadataTableEditorView metadataEditorView = getMetadataEditorView(dataMapTableView.getZone());
    if (metadataEditorView != null && metadataEditorView.getMetadataTableEditor() != null && metadataEditorView.getMetadataTableEditor().getMetadataTable() == metadataTableTarget) {
        metadataEditorView.getTableViewerCreator().getTableViewer().refresh(currentModifiedTableEntry.getMetadataColumn());
        metadataEditorView.getTableViewerCreator().refreshTableEditorControls();
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)

Example 5 with AbstractInOutTable

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

the class UIManager method processColumnNameChanged.

/**
     * DOC amaumont Comment method "processNewProcessColumnName".
     * 
     * @param previousColumnName TODO
     * @param dataMapTableView
     * @param renamingDependentEntries TODO
     * @param text
     * @param entry
     */
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry, boolean renamingDependentEntries) {
    mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
    Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
    boolean atLeastOneLinkHasBeenRemoved = false;
    for (DataMapTableView view : tableViews) {
        IDataMapTable dataMapTable = view.getDataMapTable();
        List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
        for (IColumnEntry entry : metadataTableEntries) {
            if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                atLeastOneLinkHasBeenRemoved = true;
            }
        }
        if (dataMapTable instanceof OutputTable) {
            List<FilterTableEntry> constraintWhereEntries = ((OutputTable) dataMapTable).getWhereFilterEntries();
            for (FilterTableEntry entry : constraintWhereEntries) {
                if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
            List<FilterTableEntry> constraintOtherEntries = ((OutputTable) dataMapTable).getOtherFilterEntries();
            for (FilterTableEntry entry : constraintOtherEntries) {
                if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
        }
    }
    mapperManager.getUiManager().refreshBackground(false, false);
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
    TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
    TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
    mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
    refreshSqlExpression();
    if (!renamingDependentEntries) {
        AbstractInOutTable currentTable = (AbstractInOutTable) currentModifiedITableEntry.getParent();
        if (currentTable instanceof InputTable) {
            InputTable currentInputTable = (InputTable) currentTable;
            String physicalTableName = currentInputTable.getTableName();
            String alias = currentInputTable.getAlias();
            InputTable physicalInputTable = null;
            List<InputTable> inputTables = mapperManager.getInputTables();
            if (alias != null) {
                for (InputTable table : inputTables) {
                    if (table.equals(physicalTableName)) {
                        physicalInputTable = table;
                    }
                }
            } else {
                physicalInputTable = currentInputTable;
            }
            if (physicalInputTable == null) {
                List<IOConnection> incomingConnections = mapperManager.getComponent().getMapperMain().getIoInputConnections();
                IOConnection connectionFound = null;
                for (IOConnection connection : incomingConnections) {
                    if (connection.getName().equals(physicalTableName)) {
                        connectionFound = connection;
                    }
                }
                IMetadataColumn metadataColumn = connectionFound.getTable().getColumn(previousColumnName);
                if (metadataColumn != null) {
                    metadataColumn.setLabel(newColumnName);
                }
            }
            for (InputTable table : inputTables) {
                if ((// Physical table parent
                alias != null && table.getAlias() == null && table.getName().equals(physicalTableName) || // Alias table
                alias == null && table.getAlias() != null && table.getTableName().equals(physicalTableName))) {
                    TableEntryLocation location = new TableEntryLocation(table.getName(), previousColumnName);
                    DataMapTableView aliasTableView = mapperManager.retrieveDataMapTableView(location);
                    ITableEntry aliasTableEntry = mapperManager.retrieveTableEntry(location);
                    if (aliasTableEntry != null) {
                        processColumnNameChanged(previousColumnName, newColumnName, aliasTableView, aliasTableEntry, true);
                    }
                }
            }
        }
    }
// if (atLeastOneLinkHasBeenRemoved) {
// new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
//
// public void run() {
// TableViewerCreator tableViewerCreatorForColumns = dataMapTableView
// .getTableViewerCreatorForColumns();
// boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(),
// Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
// Messages.getString("UIManager.propagateMessage")); //$NON-NLS-1$
// if (propagate) {
// TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), previousColumnName);
// TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), newColumnName);
// mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
// refreshSqlExpression();
// }
// }
// }).start();
// }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation)

Aggregations

AbstractInOutTable (org.talend.designer.dbmap.model.table.AbstractInOutTable)7 AbstractMetadataTableEditorView (org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)3 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)3 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)3 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)3 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)3 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)3 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)3 OutputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IListenableListListener (org.talend.commons.utils.data.list.IListenableListListener)2 ListenableListEvent (org.talend.commons.utils.data.list.ListenableListEvent)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 IOConnection (org.talend.designer.dbmap.external.connection.IOConnection)2 InputTable (org.talend.designer.dbmap.model.table.InputTable)2 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)2 TableViewer (org.eclipse.jface.viewers.TableViewer)1