Search in sources :

Example 1 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperManager method retrieveTableViewerCreator.

public TableViewerCreator retrieveTableViewerCreator(ITableEntry dataMapTableEntry) {
    DataMapTableView view = retrieveDataMapTableView(dataMapTableEntry);
    TableViewerCreator tableViewerCreator = null;
    if (view != null) {
        if (dataMapTableEntry instanceof AbstractInOutTableEntry || dataMapTableEntry instanceof VarTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForColumns();
        } else if (dataMapTableEntry instanceof FilterTableEntry) {
            tableViewerCreator = view.getTableViewerCreatorForFilters();
        }
    }
    return tableViewerCreator;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 2 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperManager method removeRejectOutput.

public void removeRejectOutput() {
    List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
    Iterator<DataMapTableView> iterator = outputsTablesView.iterator();
    DataMapTableView outputTable = null;
    DataMapTableView toRemove = null;
    while (iterator.hasNext()) {
        outputTable = iterator.next();
        if (outputTable.getDataMapTable() instanceof OutputTable && ((OutputTable) outputTable.getDataMapTable()).isErrorRejectTable()) {
            toRemove = outputTable;
            iterator.remove();
            break;
        }
    }
    if (toRemove != null) {
        uiManager.removeOutputTableView(toRemove);
        uiManager.updateToolbarButtonsStates(Zone.OUTPUTS);
        IProcess process = getAbstractMapComponent().getProcess();
        process.removeUniqueConnectionName(toRemove.getDataMapTable().getName());
    }
}
Also used : DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 3 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperManager method replaceLocation.

/**
     * 
     * DOC amaumont Comment method "replaceLocation".
     * 
     * @param previousLocation
     * @param newLocation
     * @param dataMapExpressionParser
     * @param table
     * @param entry
     * @return true if expression of entry has changed
     */
private boolean replaceLocation(final TableEntryLocation previousLocation, final TableEntryLocation newLocation, DataMapExpressionParser dataMapExpressionParser, IDataMapTable table, ITableEntry entry) {
    if (entry.getExpression() == null || entry.getExpression().trim().length() == 0) {
        return false;
    }
    boolean expressionHasChanged = false;
    String currentExpression = entry.getExpression();
    TableEntryLocation[] tableEntryLocations = dataMapExpressionParser.parseTableEntryLocations(currentExpression);
    // loop on all locations of current expression
    for (TableEntryLocation currentLocation : tableEntryLocations) {
        if (currentLocation.equals(previousLocation)) {
            currentExpression = dataMapExpressionParser.replaceLocation(currentExpression, previousLocation, newLocation);
            expressionHasChanged = true;
        }
    }
    if (expressionHasChanged) {
        entry.setExpression(currentExpression);
        DataMapTableView dataMapTableView = retrieveAbstractDataMapTableView(table);
        TableViewerCreator tableViewerCreator = null;
        if (entry instanceof IColumnEntry || entry instanceof FilterTableEntry) {
            if (entry instanceof IColumnEntry) {
                tableViewerCreator = dataMapTableView.getTableViewerCreatorForColumns();
            } else if (entry instanceof FilterTableEntry) {
                tableViewerCreator = dataMapTableView.getTableViewerCreatorForFilters();
            }
            tableViewerCreator.getTableViewer().refresh(entry);
        } else if (entry instanceof ExpressionFilterEntry) {
            dataMapTableView.getExpressionFilterText().setText(currentExpression);
        }
        uiManager.parseExpression(currentExpression, entry, false, true, false);
        return true;
    }
    return false;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) 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)

Example 4 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperManager method addRejectOutput.

public void addRejectOutput() {
    String baseName = ERROR_REJECT;
    IProcess process = getAbstractMapComponent().getProcess();
    String tableName = baseName;
    if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
        final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
        tableName = uniqueName;
        ((IProcess2) process).addUniqueConnectionName(uniqueName);
    } else if (process instanceof IProcess2) {
        tableName = baseName;
        ((IProcess2) process).addUniqueConnectionName(baseName);
    }
    IMetadataTable metadataTable = getNewMetadataTable();
    metadataTable.setTableName(tableName);
    MetadataColumn errorMessageCol = new MetadataColumn();
    errorMessageCol.setLabel(ERROR_REJECT_MESSAGE);
    errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorMessageCol.setNullable(true);
    errorMessageCol.setOriginalDbColumnName(ERROR_REJECT_MESSAGE);
    errorMessageCol.setReadOnly(true);
    errorMessageCol.setCustom(true);
    errorMessageCol.setCustomId(0);
    metadataTable.getListColumns().add(errorMessageCol);
    MetadataColumn errorStackTrace = new MetadataColumn();
    errorStackTrace.setLabel(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorStackTrace.setNullable(true);
    errorStackTrace.setOriginalDbColumnName(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setReadOnly(true);
    errorStackTrace.setCustom(true);
    errorStackTrace.setCustomId(1);
    metadataTable.getListColumns().add(errorStackTrace);
    OutputTable abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
    abstractDataMapTable.setErrorRejectTable(true);
    abstractDataMapTable.initFromExternalData(null);
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView rejectDataMapTableView = uiManager.createNewOutputTableView(null, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
    int sizeList = outputsTablesView.size();
    for (int i = 0; i < sizeList; i++) {
        if (i + 1 < sizeList) {
            FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
            formData.top = new FormAttachment(outputsTablesView.get(i));
        }
    }
    CustomTableManager.addCustomManagementToTable(uiManager.getOutputMetaEditorView(), true);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    uiManager.selectDataMapTableView(rejectDataMapTableView, true, false);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) FormData(org.eclipse.swt.layout.FormData) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IProcess2(org.talend.core.model.process.IProcess2) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) FormAttachment(org.eclipse.swt.layout.FormAttachment) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 5 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.

the class MapperManager method removeSelectedOutput.

public void removeSelectedOutput() {
    DataMapTableView currentSelectedDataMapTableView = uiManager.getCurrentSelectedOutputTableView();
    String append = "";
    OutputTable outputTable = ((OutputTable) currentSelectedDataMapTableView.getDataMapTable());
    List<DataMapTableView> relatedOutputsTableView = null;
    if (outputTable.getIsJoinTableOf() == null) {
        relatedOutputsTableView = uiManager.getRelatedOutputsTableView(currentSelectedDataMapTableView);
        if (relatedOutputsTableView != null && !relatedOutputsTableView.isEmpty()) {
            append = " and it's join table ";
            for (DataMapTableView tableView : relatedOutputsTableView) {
                IDataMapTable retrieveAbstractDataMapTable = this.retrieveAbstractDataMapTable(tableView);
                if (retrieveAbstractDataMapTable != null) {
                    append = append + "'" + retrieveAbstractDataMapTable.getName() + " ' ,";
                }
            }
            append = append.substring(0, append.length() - 1);
        }
    }
    if (currentSelectedDataMapTableView != null) {
        String tableName = currentSelectedDataMapTableView.getDataMapTable().getName();
        if (MessageDialog.openConfirm(currentSelectedDataMapTableView.getShell(), //$NON-NLS-1$
        Messages.getString("MapperManager.removeOutputTableTitle"), Messages.getString("MapperManager.removeOutputTableTitleMessage") + tableName + " '" + append + "?")) {
            //$NON-NLS-1$ //$NON-NLS-2$
            IProcess process = getAbstractMapComponent().getProcess();
            uiManager.removeOutputTableView(currentSelectedDataMapTableView);
            // remove join table
            if (outputTable.getIsJoinTableOf() == null && relatedOutputsTableView != null) {
                for (DataMapTableView view : relatedOutputsTableView) {
                    uiManager.removeOutputTableView(view);
                    process.removeUniqueConnectionName(view.getDataMapTable().getName());
                }
            }
            uiManager.updateToolbarButtonsStates(Zone.OUTPUTS);
            process.removeUniqueConnectionName(currentSelectedDataMapTableView.getDataMapTable().getName());
        }
    }
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Aggregations

DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)47 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)24 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)24 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)24 Point (org.eclipse.swt.graphics.Point)11 OutputTable (org.talend.designer.mapper.model.table.OutputTable)10 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)9 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)9 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)7 ArrayList (java.util.ArrayList)6 FormData (org.eclipse.swt.layout.FormData)6 UIManager (org.talend.designer.mapper.managers.UIManager)6 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)5 List (java.util.List)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4