use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class TableEntriesManager method retrieveTableItem.
TableItem retrieveTableItem(ITableEntry dataMapTableEntry) {
DataMapTableView dataMapTableView = this.mapperManager.retrieveAbstractDataMapTableView(dataMapTableEntry.getParent());
TableItem[] tableItems = new TableItem[0];
if (dataMapTableEntry instanceof IColumnEntry) {
tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
} else if (dataMapTableEntry instanceof FilterTableEntry) {
tableItems = dataMapTableView.getTableViewerCreatorForFilters().getTable().getItems();
} else if (dataMapTableEntry instanceof GlobalMapEntry) {
tableItems = dataMapTableView.getTableViewerCreatorForGlobalMap().getTable().getItems();
} else if (dataMapTableEntry instanceof ExpressionFilterEntry) {
return null;
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("TableEntriesManager.exceptionMessage.caseNotFound"));
}
TableItem tableItem = null;
for (int i = 0; i < tableItems.length; i++) {
if (tableItems[i].getData() == dataMapTableEntry) {
tableItem = tableItems[i];
break;
}
}
getTableEntryProperties(dataMapTableEntry).setTableItem(tableItem);
return tableItem;
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class ExternalDataConverter method fillExternalTable.
/**
*
* DOC amaumont Comment method "fillExternalTable".
*
* @param table
* @param externalMapperTable
*/
private void fillExternalTable(InputTable table, ExternalMapperTable externalMapperTable) {
externalMapperTable.setInnerJoin(table.isInnerJoin());
externalMapperTable.setPersistent(table.isPersistent());
externalMapperTable.setActivateExpressionFilter(table.isActivateExpressionFilter());
externalMapperTable.setActivateCondensedTool(table.isActivateCondensedTool());
externalMapperTable.setActivateColumnNameFilter(table.isActivateColumnNameFilter());
externalMapperTable.setId(table.getId());
String expressionFilter = null;
if (table.getExpressionFilter() != null && table.getExpressionFilter().getExpression() != null) {
expressionFilter = table.getExpressionFilter().getExpression();
}
externalMapperTable.setExpressionFilter(expressionFilter);
String matchingMode = null;
if (table.getMatchingMode() != null) {
matchingMode = table.getMatchingMode().toString();
}
externalMapperTable.setMatchingMode(matchingMode);
String lookupMode = null;
if (table.getLookupMode() != null) {
lookupMode = table.getLookupMode().toString();
}
externalMapperTable.setLookupMode(lookupMode);
ArrayList<ExternalMapperTableEntry> globalMapEntries = new ArrayList<ExternalMapperTableEntry>();
for (GlobalMapEntry constraintTableEntry : table.getGlobalMapEntries()) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(constraintTableEntry.getExpression());
externalMapperTableEntry.setName(constraintTableEntry.getName());
globalMapEntries.add(externalMapperTableEntry);
}
externalMapperTable.setGlobalMapKeysValues(globalMapEntries);
fillExternalTableWithCommonsData(table, externalMapperTable);
inputTables.add(externalMapperTable);
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class LinkManager method registerLevelForNewLink.
/**
* DOC amaumont Comment method "registerLevelForNewLink".
*
* @param link
* @param graphicalLinksFromTarget
*/
public void registerLevelForNewLink(IMapperLink link, Set<IMapperLink> graphicalLinksFromTarget) {
boolean hasAlreadyInputTarget = false;
boolean hasAlreadyVarTarget = false;
ITableEntry sourceEntry = link.getPointLinkDescriptor1().getTableEntry();
ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
boolean hasSameZone = sourceEntry.getParent().getClass() == targetEntry.getParent().getClass();
if (hasSameZone) {
boolean isInputTarget = targetEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry || targetEntry instanceof GlobalMapEntry && targetEntry.getParent() instanceof InputTable;
boolean isVarTarget = targetEntry instanceof VarTableEntry;
List<List<IMapperLink>> leveledLinks = null;
if (isInputTarget) {
leveledLinks = getInputLinksForLevels();
}
if (isVarTarget) {
leveledLinks = getVarLinksForLevels();
}
int lstSize = leveledLinks.size();
for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
IMapperLink linkFromLevelsList = linksFromLevelsList.get(0);
ITableEntry sourceTableEntry = linkFromLevelsList.getPointLinkDescriptor1().getTableEntry();
ITableEntry targetTableEntry = linkFromLevelsList.getPointLinkDescriptor2().getTableEntry();
if (targetEntry == targetTableEntry) {
if (sourceTableEntry instanceof InputColumnTableEntry && (targetTableEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry && targetEntry.getParent() instanceof InputTable)) {
hasAlreadyInputTarget = true;
}
if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
hasAlreadyVarTarget = true;
}
if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
linksFromLevelsList.add(link);
link.setLevel(indexOfLeveledLink + 1);
break;
}
}
}
}
if (isInputTarget && !hasAlreadyInputTarget || isVarTarget && !hasAlreadyVarTarget) {
ArrayList<IMapperLink> list = new ArrayList<IMapperLink>();
int firstEmptyIndex = searchFirstEmptyIndexLeveledList(leveledLinks);
link.setLevel(firstEmptyIndex + 1);
list.add(link);
if (firstEmptyIndex < leveledLinks.size()) {
leveledLinks.set(firstEmptyIndex, list);
} else {
leveledLinks.add(list);
}
}
}
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class MapperManager method addNewGlobalMapEntry.
/**
*
* @param dataMapTableView
* @param index
* @param type TODO
* @param metadataColumn, can be null if added in VarsTable
*/
public GlobalMapEntry addNewGlobalMapEntry(DataMapTableView dataMapTableView, ITableEntry tableEntrySource, Integer index) {
IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
GlobalMapEntry dataMapTableEntry = null;
if (dataMapTableView.getZone() == Zone.INPUTS) {
dataMapTableEntry = new GlobalMapEntry(abstractDataMapTable, "\"" + dataMapTableView.findUniqueName("myKey") + "\"", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
null);
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
}
AddGlobalMapEntryCommand command = new AddGlobalMapEntryCommand(tableEntriesManager, dataMapTableEntry, index);
executeCommand(command);
return dataMapTableEntry;
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class InputDataMapTableView method createGlobalMapTable.
protected void createGlobalMapTable() {
this.extendedTableViewerForGlobalMap = new AbstractExtendedTableViewer<GlobalMapEntry>(((InputTable) abstractDataMapTable).getTableGlobalMapEntriesModel(), centerComposite) {
@Override
protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
createGlobalMapColumns(tableViewerCreator);
}
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
* (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
*/
@Override
protected void setTableViewerCreatorOptions(TableViewerCreator<GlobalMapEntry> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setColumnsResizableByDefault(true);
newTableViewerCreator.setShowLineSelection(SHOW_ROW_SELECTION.FULL);
newTableViewerCreator.setBorderVisible(false);
newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
newTableViewerCreator.setKeyboardManagementForCellEdition(true);
newTableViewerCreator.setHorizontalScroll(false);
newTableViewerCreator.setVerticalScroll(false);
// tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
// instanceof
// AbstractInOutTable);
newTableViewerCreator.setFirstColumnMasked(true);
}
};
tableViewerCreatorForGlobalMap = this.extendedTableViewerForGlobalMap.getTableViewerCreator();
if (mapperManager.componentIsReadOnly()) {
tableViewerCreatorForGlobalMap.setReadOnly(true);
}
this.extendedTableViewerForGlobalMap.setCommandStack(mapperManager.getCommandStack());
tableForGlobalMap = tableViewerCreatorForGlobalMap.getTable();
tableForGlobalMapGridData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
tableForGlobalMap.setLayoutData(tableForGlobalMapGridData);
boolean tableGlobalMapVisible = false;
if (abstractDataMapTable instanceof InputTable) {
IUILookupMode lookupMode = ((InputTable) abstractDataMapTable).getLookupMode();
tableGlobalMapVisible = lookupMode == TMAP_LOOKUP_MODE.RELOAD || lookupMode == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD;
}
tableForGlobalMapGridData.exclude = !tableGlobalMapVisible;
tableForGlobalMap.setVisible(tableGlobalMapVisible);
if (!mapperManager.componentIsReadOnly()) {
new DragNDrop(mapperManager, tableForGlobalMap, false, true);
}
tableViewerCreatorForGlobalMap.addCellValueModifiedListener(new ITableCellValueModifiedListener() {
public void cellValueModified(TableCellValueModifiedEvent e) {
unselectAllEntriesIfErrorDetected(e);
}
});
final TableViewer tableViewer = tableViewerCreatorForGlobalMap.getTableViewer();
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
selectThisDataMapTableView();
UIManager uiManager = mapperManager.getUiManager();
uiManager.selectLinks(InputDataMapTableView.this, uiManager.extractSelectedTableEntries(selection), false, false);
}
});
tableForGlobalMap.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
processEnterKeyDown(tableViewerCreatorForGlobalMap, event);
}
});
tableViewerCreatorForGlobalMap.setLabelProvider(new DefaultTableLabelProvider(tableViewerCreatorForGlobalMap) {
@Override
public Color getBackground(Object element, int columnIndex) {
return getBackgroundCellColor(tableViewerCreator, element, columnIndex);
}
@Override
public Color getForeground(Object element, int columnIndex) {
return getForegroundCellColor(tableViewerCreator, element, columnIndex);
}
});
initShowMessageErrorListener(tableForGlobalMap);
}
Aggregations