Search in sources :

Example 1 with InputColumnTableEntry

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

the class ProblemsAnalyser method checkKeysProblems.

/**
     * DOC amaumont Comment method "checkKeysProblems".
     * 
     * @param incomingConnections
     * @param inputTables
     */
private void checkKeysProblems(ArrayList<InputTable> inputTables) {
    ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
    if (!mapperManager.isAdvancedMap()) {
        for (InputTable table : inputTables) {
            if (table.isMainConnection()) {
                continue;
            }
            String tableName = table.getName();
            List<IColumnEntry> columnEntries = table.getColumnEntries();
            for (IColumnEntry entry : columnEntries) {
                InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
                String columnName = entry.getName();
                if (mapperManager.checkEntryHasInvalidUncheckedKey(inputEntry)) {
                    String description = //$NON-NLS-1$
                    "Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
                    " input entry should be checked or expression should be removed. ";
                    addProblem(new Problem(null, description, ProblemStatus.WARNING));
                }
                if (mapperManager.checkEntryHasInvalidCheckedKey(inputEntry)) {
                    String description = //$NON-NLS-1$
                    "Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
                    " input entry should be unchecked or expression should be filled. ";
                    addProblem(new Problem(null, description, ProblemStatus.WARNING));
                }
            }
        }
    }
}
Also used : ILanguage(org.talend.designer.mapper.language.ILanguage) InputTable(org.talend.designer.mapper.model.table.InputTable) Problem(org.talend.core.model.process.Problem) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 2 with InputColumnTableEntry

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

the class EntryContentProposal method getDescription.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.fieldassist.IContentProposal#getDescription()
     */
public String getDescription() {
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    String separator = " - ";
    if (entry instanceof InputColumnTableEntry) {
        InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
        IMetadataColumn metadataColumn = inputEntry.getMetadataColumn();
        //$NON-NLS-1$ //$NON-NLS-2$
        sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(metadataColumn.getLabel()).append(//$NON-NLS-1$
        "' ");
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        sb.append(Messages.getString("EntryContentProposal.properties"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(metadataColumn.getLabel());
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(metadataColumn.isKey());
        if (!MapperMain.isStandAloneMode()) {
            sb.append(AbstractLanguage.CARRIAGE_RETURN);
            sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(//$NON-NLS-1$
            format(metadataColumn.getTalendType()));
        }
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.length"));
        if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) {
            sb.append(format(metadataColumn.getLength()));
        }
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.precision"));
        if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) {
            sb.append(format(metadataColumn.getPrecision()));
        }
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
        format(metadataColumn.getDefault()));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
        format(metadataColumn.getComment()));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
    } else if (entry instanceof VarTableEntry) {
        //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
        sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append(format(entry.getExpression()));
    } else if (entry instanceof GlobalMapEntry) {
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        sb.append("GlobalMap ");
        //$NON-NLS-1$ 
        sb.append(Messages.getString("EntryContentProposal.properties"));
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.columnTitle.globalMapKey")).append("' :");
        sb.append(entry.getName());
        sb.append(AbstractLanguage.CARRIAGE_RETURN);
        //$NON-NLS-1$
        sb.append(separator).append(Messages.getString("EntryContentProposal.columnTitle.Expr")).append("' :");
        sb.append(entry.getExpression());
    }
    return sb.toString();
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 3 with InputColumnTableEntry

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

the class InputDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    boolean isMainConnection = ((InputTable) getDataMapTable()).isMainConnection();
    TableViewerCreatorColumn column = null;
    if (!isMainConnection) {
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        //$NON-NLS-1$
        column.setTitle(Messages.getString("InputDataMapTableView.columnTitle.Expr"));
        column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
        expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS }, false);
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

            public String get(InputColumnTableEntry bean) {
                return bean.getExpression();
            }

            public void set(InputColumnTableEntry bean, String value) {
                // System.out.println("value='" + value + "'");
                bean.setExpression(value);
                InputTable inputTable = getInputTable();
                boolean tableHasAtLeastOneHashKey = mapperManager.isTableHasAtLeastOneHashKey(inputTable);
                if (!tableHasAtLeastOneHashKey) {
                    IUIMatchingMode matchingMode = inputTable.getMatchingMode();
                    if (matchingMode != TMAP_MATCHING_MODE.ALL_ROWS) {
                        inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
                        refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
                    }
                } else {
                    IUIMatchingMode matchingMode = inputTable.getMatchingMode();
                    if (matchingMode == TMAP_MATCHING_MODE.ALL_ROWS) {
                        IUIMatchingMode newMatchModel = previousMatchingModeSelected == null || previousMatchingModeSelected == TMAP_MATCHING_MODE.ALL_ROWS ? TMAP_MATCHING_MODE.UNIQUE_MATCH : previousMatchingModeSelected;
                        inputTable.setMatchingMode(newMatchModel);
                        refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
                    }
                    mapperManager.getUiManager().setStatusBarValues(STATUS.EMPTY, null);
                }
                mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true, true);
                if (!mapperManager.isCheckSyntaxEnabled()) {
                    mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreatorForColumns);
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            mapperManager.getProblemsManager().checkLookupExpressionProblem();
                        }
                    });
                }
            }
        });
        column.setModifiable(!mapperManager.componentIsReadOnly());
        //$NON-NLS-1$
        column.setDefaultInternalValue("");
        column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
        column.setImageProvider(new IColumnImageProvider<InputColumnTableEntry>() {

            public Image getImage(InputColumnTableEntry bean) {
                if (bean.getExpression() != null && !bean.getExpression().trim().equals("")) {
                    //$NON-NLS-1$
                    if (mapperManager.isAdvancedMap()) {
                        return ImageProviderMapper.getImage(ImageInfo.LOOKUP_KEY_ICON);
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            }
        });
    }
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    column.setTitle(DataMapTableView.COLUMN_NAME);
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

        public String get(InputColumnTableEntry bean) {
            return bean.getMetadataColumn().getLabel();
        }

        public void set(InputColumnTableEntry bean, String value) {
            bean.getMetadataColumn().setLabel(value);
        }
    });
    column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
    if (isMainConnection && PluginChecker.isTraceDebugPluginLoaded() && mapperManager.isTracesActive()) {
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        column.setTitle("Preview");
        column.setId(DataMapTableView.PREVIEW_COLUMN);
        column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {

            public String get(InputColumnTableEntry bean) {
                IMetadataColumn metadataColumn = bean.getMetadataColumn();
                if (metadataColumn != null) {
                    String label = metadataColumn.getLabel();
                    TraceData preview = bean.getPreviewValue();
                    if (preview != null && preview.getData() != null) {
                        return preview.getData().get(label);
                    }
                }
                return "";
            }

            public void set(InputColumnTableEntry bean, String value) {
            // do nothing
            }
        });
    }
}
Also used : Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) IUIMatchingMode(org.talend.designer.mapper.model.table.IUIMatchingMode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) InputTable(org.talend.designer.mapper.model.table.InputTable) TraceData(org.talend.core.model.process.TraceData) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 4 with InputColumnTableEntry

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

the class UIManager method getTableEntryPosition.

/**
     * DOC amaumont Comment method "getTableEntryPosition".
     * 
     * @param manager TODO
     * @param tableEntry
     * @param forceRecalculate TODO
     * @return
     */
public Point getTableEntryPosition(ITableEntry tableEntry, boolean forceRecalculate) {
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
    int entriesSize = 0;
    int minHeight = dataMapTableView.getTableViewerCreatorForColumns().getTable().getHeaderHeight() + dataMapTableView.getTableViewerCreatorForColumns().getTable().getItemHeight();
    TableItem[] tableItems = new TableItem[0];
    if (tableEntry instanceof InputColumnTableEntry || tableEntry instanceof OutputColumnTableEntry) {
        tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
        AbstractInOutTable abstractInOutTable = (AbstractInOutTable) dataMapTableView.getDataMapTable();
        if (dataMapTableView.getZone() == Zone.OUTPUTS) {
            OutputTable outputTable = (OutputTable) abstractInOutTable;
            List<IColumnEntry> oldOuputEntries = outputTable.getDataMapTableEntries();
            entriesSize = oldOuputEntries.size();
        }
        if (dataMapTableView.getZone() == Zone.INPUTS) {
            InputTable inputTable = (InputTable) abstractInOutTable;
            List<IColumnEntry> oldOuputEntries = inputTable.getDataMapTableEntries();
            entriesSize = oldOuputEntries.size();
        }
    }
    Rectangle tableViewBounds = dataMapTableView.getBounds();
    Point pointFromTableViewOrigin = null;
    Display display = dataMapTableView.getDisplay();
    Point returnedPoint = new Point(0, 0);
    TableEntryProperties tableEntryProperties = null;
    int itemIndex = 0;
    if (tableEntry instanceof IColumnEntry || tableEntry instanceof FilterTableEntry || tableEntry instanceof GlobalMapEntry) {
        tableEntryProperties = mapperManager.getTableEntryProperties(tableEntry);
        returnedPoint = tableEntryProperties.position;
        if (forceRecalculate || returnedPoint == null) {
            int y;
            TableItem tableItem = mapperManager.retrieveTableItem(tableEntry);
            boolean isOutputEntry = tableEntry instanceof OutputColumnTableEntry;
            boolean isIntputEntry = tableEntry instanceof InputColumnTableEntry;
            boolean checked = false;
            for (int i = 0; i < tableItems.length; i++) {
                if (tableItems[i].getData() == tableEntry) {
                    itemIndex = i;
                    break;
                }
            }
            boolean allIsNull = false;
            if (tableItem == null && (isIntputEntry || isOutputEntry)) {
                if (tableItems.length > 0) {
                    tableItem = tableItems[0];
                    checked = true;
                } else {
                    allIsNull = true;
                }
            }
            if (!allIsNull) {
                Table table = tableItem.getParent();
                // FIX for issue 1225 ("1" parameter added)
                Rectangle boundsTableItem = tableItem.getBounds(1);
                y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
                if (isOutputEntry || isIntputEntry) {
                    if (entriesSize != tableItems.length) {
                        y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
                    }
                }
                if (checked) {
                    y = boundsTableItem.y + dataMapTableView.getBorderWidth();
                    checked = false;
                }
                int x = 0;
                if (y < 0) {
                    y = 0;
                }
                Point point = new Point(x, y);
                pointFromTableViewOrigin = display.map(tableItem.getParent(), dataMapTableView, point);
            } else {
                Text columnFilterText = dataMapTableView.getColumnNameFilterText();
                Point point = new Point(-dataMapTableView.getBorderWidth() - 19, minHeight);
                pointFromTableViewOrigin = display.map(columnFilterText, dataMapTableView, point);
            }
        }
    } else if (tableEntry instanceof ExpressionFilterEntry) {
        StyledText expressionFilterText = dataMapTableView.getExpressionFilterText();
        //            dataMapTableView.getex
        Point point = new Point(-dataMapTableView.getBorderWidth() - 19, 16);
        pointFromTableViewOrigin = display.map(expressionFilterText, dataMapTableView, point);
    } else {
        //$NON-NLS-1$
        throw new IllegalStateException("Case not found");
    }
    if (pointFromTableViewOrigin.y > tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION) {
        pointFromTableViewOrigin.y = tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION;
    }
    returnedPoint = convertPointToReferenceOrigin(getReferenceComposite(), pointFromTableViewOrigin, dataMapTableView);
    if (tableEntryProperties != null) {
        tableEntryProperties.position = returnedPoint;
    }
    return returnedPoint;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) Table(org.eclipse.swt.widgets.Table) AbstractDataMapTable(org.talend.designer.mapper.model.table.AbstractDataMapTable) StyledText(org.eclipse.swt.custom.StyledText) TableItem(org.eclipse.swt.widgets.TableItem) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) Rectangle(org.eclipse.swt.graphics.Rectangle) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) 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) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) TableEntryProperties(org.talend.designer.mapper.ui.visualmap.TableEntryProperties) Point(org.eclipse.swt.graphics.Point) OutputTable(org.talend.designer.mapper.model.table.OutputTable) InputTable(org.talend.designer.mapper.model.table.InputTable) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) Display(org.eclipse.swt.widgets.Display)

Example 5 with InputColumnTableEntry

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

the class UIManager method checkTargetInputKey.

/**
     * 
     * DOC amaumont Comment method "checkTargetInputKey".
     * 
     * @param currentModifiedTableEntry
     * @param inputDataMapTableView
     * @param checkInputKeyAutomatically
     * @param appliedOrCanceled TODO
     */
private void checkTargetInputKey(ITableEntry currentModifiedTableEntry, boolean checkInputKeyAutomatically, boolean appliedOrCanceled) {
    // check key
    if (checkInputKeyAutomatically && currentModifiedTableEntry instanceof InputColumnTableEntry) {
        IMetadataColumn metadataColumn = ((InputColumnTableEntry) currentModifiedTableEntry).getMetadataColumn();
        if (!metadataColumn.isKey()) {
            metadataColumn.setKey(true);
            refreshInOutTableAndMetaTable((AbstractInOutTableEntry) currentModifiedTableEntry);
        }
    }
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Aggregations

InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)13 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)6 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 InputTable (org.talend.designer.mapper.model.table.InputTable)5 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)4 VarTableEntry (org.talend.designer.mapper.model.tableentry.VarTableEntry)4 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)4 ArrayList (java.util.ArrayList)3 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)3 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)3 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)3 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)3 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)3 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Point (org.eclipse.swt.graphics.Point)2 ECodeLanguage (org.talend.core.language.ECodeLanguage)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 ILanguage (org.talend.designer.mapper.language.ILanguage)2