use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class ExternalDataConverter method prepareInputTables.
public ArrayList<InputTable> prepareInputTables(List<IOConnection> inputConnections, ExternalMapperData externalData) {
ArrayList<InputTable> inputDataMapTables = new ArrayList<InputTable>();
ArrayList<IOConnection> remainingConnections = new ArrayList<IOConnection>(inputConnections);
// case externalData IS NOT initialized
if (externalData == null || externalData.getInputTables().size() == 0) {
for (IOConnection connection : inputConnections) {
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(null);
if (EConnectionType.FLOW_MAIN != connection.getConnectionType()) {
inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
}
if (connection.getTable() == null) {
inputTable.setReadOnly(true);
}
inputDataMapTables.add(inputTable);
}
} else {
// case externalData IS initialized
Map<String, IOConnection> nameToInputConnection = new HashMap<String, IOConnection>();
for (IOConnection connection : inputConnections) {
nameToInputConnection.put(connection.getName(), connection);
}
for (ExternalMapperTable persistentTable : externalData.getInputTables()) {
IOConnection connection = nameToInputConnection.get(persistentTable.getName());
if (connection != null) {
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(persistentTable);
inputDataMapTables.add(inputTable);
remainingConnections.remove(connection);
// remove table settings in main ,set false in case the value is true in previous version
if (EConnectionType.FLOW_MAIN == connection.getConnectionType()) {
inputTable.setActivateCondensedTool(false);
// bug TDI-8027
inputTable.setPersistent(false);
}
if (connection.getTable() == null) {
inputTable.setReadOnly(true);
}
}
}
for (IOConnection connection : remainingConnections) {
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(null);
inputDataMapTables.add(inputTable);
// remove table settings in main ,set false in case the value is true in previous version
if (EConnectionType.FLOW_MAIN == connection.getConnectionType()) {
inputTable.setActivateCondensedTool(false);
// bug TDI-8027
inputTable.setPersistent(false);
} else {
inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
}
if (connection.getTable() == null) {
inputTable.setReadOnly(true);
}
}
}
// sort for put table with main connection at top position of the list
Collections.sort(inputDataMapTables, new Comparator<InputTable>() {
public int compare(InputTable o1, InputTable o2) {
if (o1.isMainConnection()) {
return -1;
} else if (o2.isMainConnection()) {
return 1;
}
return 0;
}
});
return inputDataMapTables;
}
use of org.talend.designer.mapper.model.table.InputTable 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.table.InputTable in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkDropIsValid.
/**
* DOC amaumont Comment method "checkDropHasValidTarget".
*/
private boolean checkDropIsValid() {
isInputToInput = false;
mapOneToOneAuthorized = true;
if (targetIsExpressionFilterText() || (targetTableIsFiltersTable() || targetTableIsGlobalMapTable() || draggedData.getTransferableEntryList().size() <= 1)) {
mapOneToOneAuthorized = false;
}
if (invalidKeyPressed) {
return false;
}
/*
* INPUT => INPUT
*/
if (zoneSource == Zone.INPUTS && zoneTarget == Zone.INPUTS) {
isInputToInput = true;
mapOneToOneAuthorized = false;
List<InputTable> inputTables = mapperManager.getInputTables();
int indexTableSource = inputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTableTarget = inputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (currentTableTarget != null) {
if (indexTableSource >= indexTableTarget) {
/*
* INPUT => INPUT && index of table source >= index of table target
*/
return false;
} else {
return true;
}
} else if (currentStyledTextTarget != null) {
if (indexTableSource > indexTableTarget) {
/*
* INPUT => INPUT && index of table source > index of table target
*/
return false;
} else {
return true;
}
} else {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("DropContextAnalyzer.notFound"));
}
}
/*
* OUTPUT => OUTPUT
*/
if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
isOutputToOutput = true;
mapOneToOneAuthorized = true;
List<OutputTable> outputTables = mapperManager.getOutputTables();
int indexSourceOutputTable = outputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTargetOutputTable = outputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (indexSourceOutputTable == indexTargetOutputTable) {
/*
* INPUT => INPUT && index of table source >= index of table target
*/
return false;
} else {
// OUTPUT => OUTPUT
return checkZoonTarget();
}
}
if (currentTableTarget != null) {
TableItem tableItemTarget = getTableItemFromPosition(new Point(event.x, event.y));
if (zoneSource == Zone.VARS && zoneTarget == Zone.VARS && tableItemTarget != null) {
if (tableItemSource == tableItemTarget || !dropVarsEntryIsValid(tableItemTarget)) {
/*
* VAR => VAR && (item source == item target || item target is invalid)
*/
return false;
}
}
}
if (zoneSource == Zone.VARS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
/*
* VAR => INPUT OUTPUT => OUTPUT OUTPUT => INPUT OUTPUT => VAR
*/
return false;
}
return checkZoonTarget();
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class MapperUI method createInputZoneWithTables.
private void createInputZoneWithTables(MapperModel mapperModel, final Display display) {
inputsZone = new InputsZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
inputsZone.createHeaderZoneComponents();
sc1 = new ScrolledComposite(inputsZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
// this.dropTargetOperationListener.addControl(sc1);
GridData sc1GridData = new GridData(GridData.FILL_BOTH);
sc1.setLayoutData(sc1GridData);
sc1.setBackgroundMode(SWT.INHERIT_DEFAULT);
sc1.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
// System.out.println("sc1 controlMoved");
}
public void controlResized(ControlEvent e) {
// System.out.println("sc1 controlResized");
onSashResized(display);
}
});
// add for auto scroll
new DragNDrop(mapperManager, sc1, true, true);
inputTablesZoneView = new InputTablesZoneView(sc1, getBorder(), mapperManager);
// this.dropTargetOperationListener.addControl(inputTablesZoneView);
inputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
sc1.setExpandHorizontal(true);
sc1.setContent(inputTablesZoneView);
sc1MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc1);
inputTablesZoneView.initInsertionIndicator();
Control previousControl = null;
List<InputTable> tables = mapperModel.getInputDataMapTables();
Boolean minimizeStateOfTables = getMinimizedButtonState(tables);
if (minimizeStateOfTables != null) {
inputsZone.getToolbar().setMinimizeButtonState(minimizeStateOfTables.booleanValue());
}
for (InputTable inputTable : tables) {
InputDataMapTableView dataMapTableView = new InputDataMapTableView(inputTablesZoneView, SWT.BORDER, inputTable, mapperManager);
FormData formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.top = new FormAttachment(previousControl);
dataMapTableView.setLayoutData(formData);
previousControl = dataMapTableView;
boolean tableIsMinimized = inputTable.isMinimized();
dataMapTableView.minimizeTable(tableIsMinimized);
dataMapTableView.registerStyledExpressionEditor(getTabFolderEditors().getStyledTextHandler());
dataMapTableView.loaded();
// dataMapTableView.fillMinimumSize(false);
}
inputTablesZoneView.setSize(inputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
sc1MSListener.addMouseWheelListener(sc1);
}
use of org.talend.designer.mapper.model.table.InputTable 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;
}
Aggregations