Search in sources :

Example 1 with TableEntryProperties

use of org.talend.designer.mapper.ui.visualmap.TableEntryProperties 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;
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) Table(org.eclipse.swt.widgets.Table) AbstractDataMapTable(org.talend.designer.mapper.model.table.AbstractDataMapTable) StyledText(org.eclipse.swt.custom.StyledText) TableItem(org.eclipse.swt.widgets.TableItem) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) Rectangle(org.eclipse.swt.graphics.Rectangle) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) TableEntryProperties(org.talend.designer.mapper.ui.visualmap.TableEntryProperties) Point(org.eclipse.swt.graphics.Point) OutputTable(org.talend.designer.mapper.model.table.OutputTable) InputTable(org.talend.designer.mapper.model.table.InputTable) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) Display(org.eclipse.swt.widgets.Display)

Example 2 with TableEntryProperties

use of org.talend.designer.mapper.ui.visualmap.TableEntryProperties in project tdi-studio-se by Talend.

the class TableEntriesManager method getTableEntryProperties.

/**
     * DOC amaumont Comment method "getTableEntryProperties".
     * 
     * @param dataMapTableEntry
     * @return
     */
TableEntryProperties getTableEntryProperties(ITableEntry dataMapTableEntry) {
    TableEntryProperties tableEntryProperties = dataMapTableEntryToProperties.get(dataMapTableEntry);
    if (tableEntryProperties == null) {
        tableEntryProperties = new TableEntryProperties();
        dataMapTableEntryToProperties.put(dataMapTableEntry, tableEntryProperties);
    }
    return tableEntryProperties;
}
Also used : TableEntryProperties(org.talend.designer.mapper.ui.visualmap.TableEntryProperties)

Aggregations

TableEntryProperties (org.talend.designer.mapper.ui.visualmap.TableEntryProperties)2 StyledText (org.eclipse.swt.custom.StyledText)1 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Display (org.eclipse.swt.widgets.Display)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1 Text (org.eclipse.swt.widgets.Text)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)1 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)1 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)1 AbstractDataMapTable (org.talend.designer.mapper.model.table.AbstractDataMapTable)1 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)1 InputTable (org.talend.designer.mapper.model.table.InputTable)1 OutputTable (org.talend.designer.mapper.model.table.OutputTable)1 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)1 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)1 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)1 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)1