Search in sources :

Example 36 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class CompleteDropTargetListener method updateExpressionsOfInsertedEntries.

/**
     * DOC amaumont Comment method "updateExpressionsOfInsertedEntries".
     * 
     * @param uiManager
     * @param currentLanguage
     * @param metadataEditorView
     * @param currentIndex
     * @param sourceEntriesOfEntriesBeingAdded
     * @param targetTableIsConstraintsTable
     * @param tableViewerCreatorTarget
     * @param metadataColumnsBeingAdded
     * @param metadataEditorEvent
     */
@SuppressWarnings("unchecked")
private void updateExpressionsOfInsertedEntries(IDbLanguage currentLanguage, MetadataTableEditorView metadataEditorView, int currentIndex, ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded, boolean targetTableIsConstraintsTable, TableViewerCreator tableViewerCreatorTarget, ArrayList<IMetadataColumn> metadataColumnsBeingAdded) // , MetadataEditorEvent metadataEditorEvent
{
    UIManager uiManager = getUiManager();
    if (metadataEditorView != null && !targetTableIsConstraintsTable) {
        metadataEditorView.getMetadataTableEditor().addAll(currentIndex, metadataColumnsBeingAdded);
        // metadataEditorEvent.indexStartInsert = currentIndex;
        // IAction action = MetadataEditorActionFactory.getInstance().getAction(metadataEditorView,
        // metadataEditorEvent);
        // action.run(metadataEditorEvent);
        Zone zoneTarget = getMapperManager().retrieveDataMapTableView(tableViewerCreatorTarget.getTable()).getZone();
        List<IColumnEntry> lastCreatedTableEntries = uiManager.getLastCreatedInOutColumnEntries();
        for (int i = 0; i < lastCreatedTableEntries.size(); i++) {
            ITableEntry tableEntrySource = sourceEntriesOfEntriesBeingAdded.get(i);
            ITableEntry dataMapTableEntry = lastCreatedTableEntries.get(i);
            if (zoneTarget == Zone.INPUTS) {
                setDefaultOperator((InputColumnTableEntry) dataMapTableEntry);
            }
            DataMapTableView dataMapTableView = getMapperManager().retrieveIDataMapTableView(tableEntrySource.getParent());
            Zone zoneSource = dataMapTableView.getZone();
            String location = null;
            if (zoneSource == Zone.OUTPUTS) {
                location = tableEntrySource.getExpression();
            } else {
                location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
            }
            if (location != null) {
                //$NON-NLS-1$
                dataMapTableEntry.setExpression(location + " ");
            }
        }
    }
    tableViewerCreatorTarget.getTableViewer().refresh();
    List<ITableEntry> refreshedTableEntriesList = tableViewerCreatorTarget.getInputList();
    for (ITableEntry tableEntry : refreshedTableEntriesList) {
        uiManager.parseExpression(tableEntry.getExpression(), tableEntry, false, true, false);
    }
}
Also used : Zone(org.talend.designer.dbmap.ui.visualmap.zone.Zone) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) UIManager(org.talend.designer.dbmap.managers.UIManager) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) Point(org.eclipse.swt.graphics.Point)

Example 37 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class UIManager method processColumnNameChanged.

/**
     * DOC amaumont Comment method "processNewProcessColumnName".
     * 
     * @param previousColumnName TODO
     * @param dataMapTableView
     * @param text
     * @param entry
     */
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry) {
    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;
            }
        }
        // for the input/output table expression filter
        if (dataMapTable instanceof AbstractInOutTable) {
            ExpressionFilterEntry expressionFilterEntry = ((AbstractInOutTable) dataMapTable).getExpressionFilter();
            if (expressionFilterEntry != null && expressionFilterEntry.getExpression() != null) {
                if (parseExpression(expressionFilterEntry.getExpression(), expressionFilterEntry, true, true, false).isAtLeastOneLinkRemoved()) {
                    atLeastOneLinkHasBeenRemoved = true;
                }
            }
        }
    }
    mapperManager.getUiManager().refreshBackground(false, false);
    dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
    if (atLeastOneLinkHasBeenRemoved) {
        new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {

            public void run() {
                TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
                boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(), //$NON-NLS-1$
                Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
                Messages.getString("UIManager.propagateMessage"));
                if (propagate) {
                    TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
                    TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
                    mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
                }
            }
        }).start();
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading)

Example 38 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class UIManager method modifySelectionChangedListener.

private void modifySelectionChangedListener(final Zone currentZone, final MetadataTableEditorView metadataTableEditorViewFinal, final TableViewerCreator metadataTVCreator, final MetadataTableEditor metadataTableEditor, final DataMapTableView dataMapTableView, DataMapTableView previousSelectedTableView) {
    final TableViewer tableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
    IModifiedBeanListener<IMetadataColumn> modifiedBeanListener = new IModifiedBeanListener<IMetadataColumn>() {

        public void handleEvent(ModifiedBeanEvent<IMetadataColumn> event) {
            if (AbstractMetadataTableEditorView.ID_COLUMN_NAME.equals(event.column.getId()) && !event.previousValue.equals(event.newValue)) {
                IMetadataColumn modifiedObject = event.bean;
                if (modifiedObject != null) {
                    TableEntryLocation tableEntryLocation = new TableEntryLocation(dataMapTableView.getDataMapTable().getName(), (String) event.previousValue);
                    final ITableEntry dataMapTableEntry = mapperManager.retrieveTableEntry(tableEntryLocation);
                    // see bug 7471,record the modification about the column value
                    String curConnName = null;
                    if (dataMapTableEntry != null) {
                        curConnName = dataMapTableEntry.getParentName();
                    }
                    List<? extends IConnection> curInConns = mapperManager.getAbstractMapComponent().getIncomingConnections();
                    List<? extends IConnection> curOutConns = mapperManager.getAbstractMapComponent().getOutgoingConnections();
                    for (IConnection curInConn : curInConns) {
                        if (curConnName.equals(curInConn.getUniqueName())) {
                            Map<String, String> changedNameInColumns = new HashMap<String, String>();
                            changedNameInColumns.put((String) event.newValue, (String) event.previousValue);
                            changedNameColumns.put(curInConn, changedNameInColumns);
                        }
                    }
                    for (IConnection curOutConn : curOutConns) {
                        if (curConnName.equals(curOutConn.getUniqueName())) {
                            Map<String, String> changedNameOutColumns = new HashMap<String, String>();
                            changedNameOutColumns.put((String) event.newValue, (String) event.previousValue);
                            changedNameColumns.put(curOutConn, changedNameOutColumns);
                        }
                    }
                    processColumnNameChanged((String) event.previousValue, (String) event.newValue, dataMapTableView, dataMapTableEntry);
                    // related tables
                    List<DataMapTableView> relatedOutputsTableView = getRelatedOutputsTableView(dataMapTableView);
                    for (DataMapTableView relatedView : relatedOutputsTableView) {
                        TableEntryLocation relatedEntryLocation = new TableEntryLocation(relatedView.getDataMapTable().getName(), (String) event.previousValue);
                        ITableEntry relatedTableEntry = mapperManager.retrieveTableEntry(relatedEntryLocation);
                        processColumnNameChanged((String) event.previousValue, (String) event.newValue, relatedView, relatedTableEntry);
                    }
                }
                // dataMapTableViewer.refresh(event.bean, true);
                tableViewer.refresh(true);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_KEY.equals(event.column.getId())) {
                tableViewer.refresh(true);
                IColumnEntry entry = dataMapTableView.getDataMapTable().getColumnEntries().get(event.index);
                parseExpression(entry.getExpression(), entry, false, false, false);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_TYPE.equals(event.column.getId()) || AbstractMetadataTableEditorView.ID_COLUMN_NULLABLE.equals(event.column.getId())) {
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        }
    };
    ILineSelectionListener metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        public void handle(LineSelectionEvent e) {
            if (metadataTableEditorViewFinal.getTableViewerCreator() == e.source) {
                if (metadataTableEditorViewFinal.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManager.getUiManager().selectLinkedTableEntries(metadataTableEditor.getMetadataTable(), metadataTVCreator.getTable().getSelectionIndices());
                }
            } else {
            // if (dataMapTableView.getExtendedTableViewerForColumns().isExecuteSelectionEvent()) {
            // int[] selectionIndices =
            // dataMapTableView.getTableViewerCreatorForColumns().getTable().getSelectionIndices();
            // mapperManager.getUiManager().selectLinkedMetadataEditorEntries(dataMapTableView,
            // selectionIndices);
            // }
            }
        }
    };
    // ISelectionChangedListener previousSelectionChangedListener = null;
    ILineSelectionListener previousSelectionChangedListener = null;
    IModifiedBeanListener<IMetadataColumn> previousModifiedBeanListener = null;
    if (currentZone == Zone.INPUTS) {
        previousSelectionChangedListener = inputsSelectionChangedListener;
        previousModifiedBeanListener = inputModifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        previousSelectionChangedListener = outputsSelectionChangedListener;
        previousModifiedBeanListener = outputModifiedBeanListener;
    }
    if (previousSelectionChangedListener != null) {
        // metadataTVCreator.removeSelectionChangedListener(previousSelectionChangedListener);
        metadataTVCreator.getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        if (previousSelectedTableView != null) {
            previousSelectedTableView.getTableViewerCreatorForColumns().getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        }
    }
    if (previousModifiedBeanListener != null) {
        metadataTableEditor.removeModifiedBeanListener(previousModifiedBeanListener);
    }
    if (currentZone == Zone.INPUTS) {
        inputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        inputModifiedBeanListener = modifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        outputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        outputModifiedBeanListener = modifiedBeanListener;
    }
    // metadataTVCreator.addSelectionChangedListener(metadataEditorViewerSelectionChangedListener);
    metadataTVCreator.getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    dataMapTableView.getTableViewerCreatorForColumns().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    metadataTableEditor.addModifiedBeanListener(modifiedBeanListener);
    if (this.commonMetadataDisposeListener == null) {
        this.commonMetadataDisposeListener = new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                if (inputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.INPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(inputsSelectionChangedListener);
                }
                if (outputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.OUTPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(outputsSelectionChangedListener);
                }
                if (inputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.INPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(inputModifiedBeanListener);
                    }
                }
                if (outputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.OUTPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(outputModifiedBeanListener);
                    }
                }
            }
        };
        metadataTVCreator.getTable().addDisposeListener(this.commonMetadataDisposeListener);
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IConnection(org.talend.core.model.process.IConnection) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 39 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class MapperManager method replacePreviousLocationInAllExpressions.

/**
     * DOC amaumont Comment method "replacePreviousLocationInAllExpressions".
     */
public void replacePreviousLocationInAllExpressions(final TableEntryLocation previousLocation, final TableEntryLocation newLocation) {
    DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
    Collection<IDataMapTable> tablesData = getTablesData();
    for (IDataMapTable table : tablesData) {
        List<IColumnEntry> columnEntries = table.getColumnEntries();
        if (table instanceof AbstractInOutTable) {
            replaceLocation(previousLocation, newLocation, dataMapExpressionParser, table, ((AbstractInOutTable) table).getExpressionFilter());
        }
        for (IColumnEntry entry : columnEntries) {
            replaceLocation(previousLocation, newLocation, dataMapExpressionParser, table, entry);
        }
        if (table instanceof OutputTable) {
            List<FilterTableEntry> constraintEntries = ((OutputTable) table).getFilterEntries();
            for (FilterTableEntry entry : constraintEntries) {
                replaceLocation(previousLocation, newLocation, dataMapExpressionParser, table, entry);
            }
        }
    }
    uiManager.refreshBackground(false, false);
}
Also used : DataMapExpressionParser(org.talend.designer.mapper.utils.DataMapExpressionParser) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 40 with IColumnEntry

use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.

the class ProblemsManager method checkProblemsForAllEntries.

/**
     * 
     * DOC amaumont Comment method "checkProblemsForAllEntries".
     * 
     * @param dataMapTableView
     * @param forceRefreshData
     * @return true if has errors
     */
@SuppressWarnings("unchecked")
public boolean checkProblemsForAllEntries(DataMapTableView dataMapTableView, boolean forceRefreshData) {
    if (forceRefreshData) {
        mapperManager.getAbstractMapComponent().restoreMapperModelFromInternalData();
        checkProblems();
    }
    boolean hasProblemsWasNull = false;
    if (hasProblems == null) {
        hasProblems = Boolean.FALSE;
        hasProblemsWasNull = true;
    }
    if (dataMapTableView.getDataMapTable() instanceof AbstractInOutTable) {
        AbstractInOutTable table = (AbstractInOutTable) dataMapTableView.getDataMapTable();
        if (table.isActivateExpressionFilter()) {
            checkProblemsForTableEntry(table.getExpressionFilter(), false);
        }
    }
    List<IColumnEntry> columnsEntriesList = dataMapTableView.getDataMapTable().getColumnEntries();
    checkProblemsForAllEntries(columnsEntriesList);
    if (refreshTableEntries) {
        dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(true);
    }
    if (dataMapTableView.getZone() == Zone.OUTPUTS) {
        List<ITableEntry> constraintEntriesList = dataMapTableView.getTableViewerCreatorForFilters().getInputList();
        checkProblemsForAllEntries(constraintEntriesList);
        if (refreshTableEntries) {
            dataMapTableView.getTableViewerCreatorForFilters().getTableViewer().refresh(true);
        }
    }
    boolean returnedValue = hasProblems;
    if (hasProblemsWasNull) {
        hasProblems = null;
    }
    return returnedValue;
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry)

Aggregations

IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)42 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)16 FilterTableEntry (org.talend.designer.dbmap.model.tableentry.FilterTableEntry)11 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)10 OutputTable (org.talend.designer.dbmap.model.table.OutputTable)10 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)9 InputTable (org.talend.designer.mapper.model.table.InputTable)8 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)8 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 TableViewer (org.eclipse.jface.viewers.TableViewer)6 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)6 OutputTable (org.talend.designer.mapper.model.table.OutputTable)6 InputTable (org.talend.designer.dbmap.model.table.InputTable)5 TableEntryLocation (org.talend.designer.dbmap.model.tableentry.TableEntryLocation)5 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)4