Search in sources :

Example 36 with TableViewerCreator

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;
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) Point(org.eclipse.swt.graphics.Point) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point)

Aggregations

TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)36 ArrayList (java.util.ArrayList)14 List (java.util.List)14 Point (org.eclipse.swt.graphics.Point)14 TableViewerCreatorColumnNotModifiable (org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable)11 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)11 HashMap (java.util.HashMap)10 Map (java.util.Map)10 CCombo (org.eclipse.swt.custom.CCombo)8 IElementParameter (org.talend.core.model.process.IElementParameter)8 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)8 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)6 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)6 TableViewer (org.eclipse.jface.viewers.TableViewer)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 ILineSelectionListener (org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)4 LineSelectionEvent (org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)4 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)4