use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class DropContextAnalyzer method analyzeCursorOverExpressionCell.
/**
* .
*/
@SuppressWarnings("unchecked")
private void analyzeCursorOverExpressionCell() {
boolean targetTableIsGlobalMapTable = targetTableIsGlobalMapTable(dataMapTableViewTarget);
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentTableTarget);
TableViewerCreator tableViewerCreator = null;
if (targetTableIsGlobalMapTable) {
tableViewerCreator = dataMapTableView.getTableViewerCreatorForGlobalMap();
} else {
tableViewerCreator = dataMapTableView.getTableViewerCreatorForColumns();
}
Point pointCursor = currentTableTarget.toControl(event.x, event.y);
if (tableViewerCreator.getTable() != currentTableTarget) {
isCursorOverExpressionCell = false;
return;
}
int maxY = (WindowSystem.isWIN32() && currentTableTarget.getHeaderVisible() ? currentTableTarget.getHeaderHeight() : 0) + (currentTableTarget.getItemCount() * (currentTableTarget.getItemHeight() + currentTableTarget.getBorderWidth() + (WindowSystem.isGTK() ? 2 : 0)));
if (pointCursor.y < 0 || pointCursor.y >= maxY) {
isCursorOverExpressionCell = false;
return;
}
// searching current column index
int currentColumnIndex = 0;
TableColumn[] columns = currentTableTarget.getColumns();
for (int i = 0, width = 0; i < columns.length; i++) {
TableColumn column = columns[i];
int widthColumn = column.getWidth();
if (pointCursor.x >= width && pointCursor.x <= width + widthColumn) {
currentColumnIndex = i;
break;
}
width += widthColumn;
}
if (pointCursor.y < currentTableTarget.getHeaderHeight()) {
isCursorOverHeader = true;
} else {
isCursorOverHeader = false;
}
List<TableViewerCreatorColumnNotModifiable> viewerColumns = tableViewerCreator.getColumns();
TableViewerCreatorColumnNotModifiable viewerColumn = viewerColumns.get(currentColumnIndex);
if (DataMapTableView.ID_EXPRESSION_COLUMN.equals(viewerColumn.getId())) {
isCursorOverExpressionCell = true;
} else {
isCursorOverExpressionCell = false;
}
}
Aggregations