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));
}
}
}
}
}
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();
}
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
}
});
}
}
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;
}
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);
}
}
}
Aggregations