use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class CompleteDropTargetTableListener 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(ILanguage 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) {
((InputColumnTableEntry) dataMapTableEntry).getMetadataColumn().setKey(true);
}
DataMapTableView dataMapTableView = getMapperManager().retrieveAbstractDataMapTableView(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);
}
}
use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class VarsTable method initFromExternalData.
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
if (externalMapperTable != null) {
List<ExternalDbMapEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
if (metadataTableEntries != null) {
for (ExternalDbMapEntry externalMapperTableEntry : metadataTableEntries) {
IColumnEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getOperator());
// mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
addColumnEntry(varTableEntry);
}
}
} else {
setMinimized(true);
}
}
use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry 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.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class ProblemsManager method checkLookupExpressionProblem.
public boolean checkLookupExpressionProblem() {
if (mapperManager.isBigDataProcess()) {
List<DataMapTableView> inputsTablesView = mapperManager.getUiManager().getInputsTablesView();
List<DataMapTableView> lookupTables = new ArrayList<DataMapTableView>();
List<IColumnEntry> entityWithoutProblem = new ArrayList<IColumnEntry>();
DataMapTableView firstLookup = null;
for (int i = 0; i < inputsTablesView.size(); i++) {
DataMapTableView inputTableView = inputsTablesView.get(i);
InputTable dataMapTable = (InputTable) inputTableView.getDataMapTable();
boolean mainConnection = dataMapTable.isMainConnection();
if (mainConnection) {
continue;
}
if (firstLookup == null) {
firstLookup = inputTableView;
} else {
lookupTables.add(inputTableView);
}
}
if (firstLookup == null || lookupTables.isEmpty()) {
return false;
}
List<List<IColumnEntry>> otherLookupEntities = new ArrayList<List<IColumnEntry>>();
for (DataMapTableView otherLookup : lookupTables) {
otherLookupEntities.add(new ArrayList<IColumnEntry>(otherLookup.getDataMapTable().getColumnEntries()));
}
List<IColumnEntry> lookupEntity = firstLookup.getDataMapTable().getColumnEntries();
for (IColumnEntry firstLookupEntity : lookupEntity) {
String expression = firstLookupEntity.getExpression();
if (expression == null || expression.trim().equals("")) {
continue;
}
//$NON-NLS-1$//$NON-NLS-2$
expression = expression.replaceAll("\\s*", "").trim();
Map<List<IColumnEntry>, IColumnEntry> entitiesFound = new HashMap<List<IColumnEntry>, IColumnEntry>();
for (List<IColumnEntry> tableEntities : otherLookupEntities) {
for (IColumnEntry entityInOtherLookup : tableEntities) {
String expressionInOtherLookup = entityInOtherLookup.getExpression();
if (expressionInOtherLookup == null || expressionInOtherLookup.trim().equals("")) {
continue;
}
//$NON-NLS-1$//$NON-NLS-2$
expressionInOtherLookup = expressionInOtherLookup.replaceAll("\\s*", "").trim();
// only match the first one
if (expression.equals(expressionInOtherLookup)) {
entitiesFound.put(tableEntities, entityInOtherLookup);
break;
}
}
}
if (entitiesFound.size() == otherLookupEntities.size()) {
for (List<IColumnEntry> tableEntities : entitiesFound.keySet()) {
entityWithoutProblem.add(entitiesFound.get(tableEntities));
entityWithoutProblem.add(firstLookupEntity);
tableEntities.remove(entitiesFound.get(tableEntities));
}
}
}
// add back the first lookup table
lookupTables.add(firstLookup);
if (entityWithoutProblem.isEmpty()) {
// no common expressions in lookup tables , then show red background color for all
for (DataMapTableView lookupTable : lookupTables) {
List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
for (IColumnEntry entity : columnEntries) {
if (entity.getExpression() == null || entity.getExpression().trim().equals("")) {
continue;
}
addLookupProblem(entity);
}
lookupTable.getTableViewerCreatorForColumns().refresh();
}
} else {
for (DataMapTableView lookupTable : lookupTables) {
boolean needRefresh = false;
List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
for (IColumnEntry entity : columnEntries) {
if (entity.getExpression() == null || entity.getExpression().trim().equals("") || entityWithoutProblem.contains(entity)) {
if (entity.getProblems() != null) {
needRefresh = entity.getProblems().remove(lookupProblem);
if (entity.getProblems().isEmpty()) {
entity.setProblems(null);
}
}
} else {
addLookupProblem(entity);
needRefresh = true;
}
}
if (needRefresh) {
lookupTable.getTableViewerCreatorForColumns().refresh();
}
}
}
return true;
}
return false;
}
use of org.talend.designer.abstractmap.model.tableentry.IColumnEntry in project tdi-studio-se by Talend.
the class TableEntriesManager method remove.
public void remove(ITableEntry dataMapTableEntry) {
if (dataMapTableEntry != null) {
mapperManager.removeLinksOf(dataMapTableEntry);
tableEntries.remove(TableEntriesManager.buildLocation(dataMapTableEntry));
dataMapTableEntryToProperties.remove(dataMapTableEntry);
IDataMapTable dataMapTable = dataMapTableEntry.getParent();
if (dataMapTableEntry instanceof IColumnEntry) {
dataMapTableEntry.getParent().removeColumnEntry((IColumnEntry) dataMapTableEntry);
} else if (dataMapTableEntry instanceof GlobalMapEntry) {
if (dataMapTable instanceof OutputTable) {
((InputTable) dataMapTable).removeGlobalMapEntry((GlobalMapEntry) dataMapTableEntry);
}
} else if (dataMapTableEntry instanceof FilterTableEntry) {
if (dataMapTable instanceof OutputTable) {
((OutputTable) dataMapTable).removeFilterEntry((FilterTableEntry) dataMapTableEntry);
}
} else if (dataMapTableEntry instanceof ExpressionFilterEntry) {
// nothing
} else {
String exceptionMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
throw new IllegalArgumentException(exceptionMessage);
}
}
}
Aggregations