use of org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class OutputDataMapTableView method initColumnsOfTableColumns.
@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
IOConnection connection = ((OutputTable) getDataMapTable()).getConnection();
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.VARS }, false);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
public String get(OutputColumnTableEntry bean) {
return bean.getExpression();
}
public void set(OutputColumnTableEntry bean, String value) {
bean.setExpression(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
tableViewerCreatorForColumns.getTableViewer().refresh(bean);
}
});
column.setModifiable(!mapperManager.componentIsReadOnly());
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle(DataMapTableView.COLUMN_NAME);
column.setId(DataMapTableView.ID_NAME_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
public String get(OutputColumnTableEntry bean) {
return bean.getMetadataColumn().getLabel();
}
public void set(OutputColumnTableEntry bean, String value) {
bean.getMetadataColumn().setLabel(value);
}
});
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
if (PluginChecker.isTraceDebugPluginLoaded() && mapperManager.isTracesActive() && connection != null) {
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle("Preview");
column.setId(DataMapTableView.PREVIEW_COLUMN);
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
public String get(OutputColumnTableEntry 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(OutputColumnTableEntry bean, String value) {
// do nothing
}
});
}
configureCellModifier(tableViewerCreatorForColumns);
}
use of org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkZoonTarget.
private boolean checkZoonTarget() {
IDataMapTable dataMapTable = dataMapTableViewTarget.getDataMapTable();
if (zoneTarget == Zone.OUTPUTS) {
OutputTable outputTable = (OutputTable) dataMapTable;
if (outputTable.isErrorRejectTable()) {
if (currentTableTarget != null && event != null) {
if (event.item instanceof TableItem) {
Object data = event.item.getData();
if (data instanceof OutputColumnTableEntry) {
String label = ((OutputColumnTableEntry) data).getName();
if (mapperManager.ERROR_REJECT_MESSAGE.equals(label) || mapperManager.ERROR_REJECT_STACK_TRACE.equals(label)) {
return false;
}
}
}
}
}
boolean useRepositoryMeta = (outputTable.isRepository()) || (outputTable.getId() != null && !"".equals(outputTable.getId()));
// for join table if main table use repository metadata
if (!useRepositoryMeta && outputTable.getIsJoinTableOf() != null && !"".equals(outputTable.getIsJoinTableOf())) {
OutputTable mainTable = mapperManager.getOutputTableByName(outputTable.getIsJoinTableOf());
if (mainTable != null) {
useRepositoryMeta = mainTable.getId() != null && !"".equals(mainTable.getId());
}
}
if (useRepositoryMeta && currentStyledTextTarget != null) {
return true;
}
if (useRepositoryMeta && isCursorOverHeader || useRepositoryMeta && !isCursorOverExpressionCell) {
return false;
}
}
return true;
}
use of org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry 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.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class MapperManager method addNewColumnEntry.
/**
* This method is called when "addMetadataTableEditorEntry" is called (event on list of MetadataEditor) , so if you
* want keep synchronisation between inputs/outputs DataMaps and MetadataEditors don't call this method.
*
* @param dataMapTableView
* @param metadataColumn, can be null if added in VarsTable
* @param index
*/
public IColumnEntry addNewColumnEntry(DataMapTableView dataMapTableView, IMetadataColumn metadataColumn, Integer index) {
IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
IColumnEntry dataMapTableEntry = null;
if (dataMapTableView.getZone() == Zone.INPUTS) {
dataMapTableEntry = new InputColumnTableEntry(abstractDataMapTable, metadataColumn);
} else if (dataMapTableView.getZone() == Zone.OUTPUTS) {
String expression = metadataColumn.getExpression();
if (expression != null && !"".equals(expression)) {
dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn, expression);
} else {
dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn);
}
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
}
tableEntriesManager.addTableEntry(dataMapTableEntry, index);
return dataMapTableEntry;
}
use of org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class UIManager method selectLinkedMetadataEditorEntries.
/**
* DOC amaumont Comment method "selectTableEntries".
*
* @param view
* @param selectedTableEntries
* @param selectionIndices
*/
public void selectLinkedMetadataEditorEntries(DataMapTableView view, int[] selectionIndices) {
MetadataTableEditorView metadataTableEditorView = null;
MetadataTableEditorView otherMetadataTableEditorView = null;
if (view.getZone() == Zone.INPUTS) {
metadataTableEditorView = getInputMetaEditorView();
otherMetadataTableEditorView = getOutputMetaEditorView();
} else if (view.getZone() == Zone.OUTPUTS) {
metadataTableEditorView = getOutputMetaEditorView();
otherMetadataTableEditorView = getInputMetaEditorView();
}
if (metadataTableEditorView != null) {
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
metadataTableEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selectionIndices);
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
if (otherMetadataTableEditorView != null) {
otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
TableViewerCreator tableViewerCreatorForColumns = view.getTableViewerCreatorForColumns();
if (tableViewerCreatorForColumns != null) {
final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
if (tableViewerForEntries.getSelection() != null) {
List<ITableEntry> extractSelectedTableEntries = extractSelectedTableEntries(tableViewerForEntries.getSelection());
for (ITableEntry entry : extractSelectedTableEntries) {
if (entry instanceof OutputColumnTableEntry) {
if (((OutputColumnTableEntry) entry).getMetadataColumn().isCustom() && view.getZone() == Zone.OUTPUTS) {
metadataTableEditorView.getExtendedToolbar().getRemoveButton().getButton().setEnabled(false);
break;
}
}
}
}
}
}
Aggregations