Search in sources :

Example 41 with DataMapTableView

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

the class UIManager method moveSelectTableUp.

/**
     * 
     * DOC amaumont Comment method "moveSelectTableUp".
     * 
     * @param currentSelectedTableView
     * @param tablesView
     * @param indexStartMovedAuthorized
     */
private void moveSelectTableUp(DataMapTableView currentSelectedTableView, List<DataMapTableView> tablesView, int indexStartMovedAuthorized) {
    int indexCurrentTable = tablesView.indexOf(currentSelectedTableView);
    if (indexCurrentTable < indexStartMovedAuthorized) {
        return;
    }
    FormData formDataCurrent = (FormData) currentSelectedTableView.getLayoutData();
    DataMapTableView beforePreviousTableView = null;
    if (indexCurrentTable - 2 >= 0) {
        beforePreviousTableView = tablesView.get(indexCurrentTable - 2);
        formDataCurrent.top.control = beforePreviousTableView;
    } else {
        formDataCurrent.top.control = null;
    }
    DataMapTableView previousTableView = null;
    if (indexCurrentTable - 1 >= 0) {
        previousTableView = tablesView.get(indexCurrentTable - 1);
        FormData formDataPrevious = (FormData) previousTableView.getLayoutData();
        formDataPrevious.top.control = currentSelectedTableView;
    }
    if (indexCurrentTable + 1 <= tablesView.size() - 1) {
        DataMapTableView nextTableView = tablesView.get(indexCurrentTable + 1);
        FormData formDataNext = (FormData) nextTableView.getLayoutData();
        formDataNext.top.control = previousTableView;
    }
    tableManager.swapWithPreviousTable(currentSelectedTableView.getDataMapTable());
    currentSelectedTableView.getParent().layout();
    parseAllExpressions(currentSelectedTableView, false);
    parseAllExpressions(previousTableView, false);
    checkProblemsForMovedTables(currentSelectedTableView, previousTableView);
}
Also used : FormData(org.eclipse.swt.layout.FormData) 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) Point(org.eclipse.swt.graphics.Point)

Example 42 with DataMapTableView

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

the class UIManager method registerCustomPaint.

public void registerCustomPaint() {
    List<DataMapTableView> tablesView = mapperManager.getUiManager().getOutputsTablesView();
    tablesView.addAll(mapperManager.getUiManager().getInputsTablesView());
    for (DataMapTableView view : tablesView) {
        view.getTableViewerCreatorForColumns().setUseCustomItemColoring(false);
    }
}
Also used : 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)

Example 43 with DataMapTableView

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

the class CompleteDropTargetTableListener method retrieveInsertionIndicator.

private InsertionIndicator retrieveInsertionIndicator() {
    DataMapTableView dataMapTableViewTarget = getMapperManager().retrieveDataMapTableView(draggableTargetControl);
    TablesZoneView targetTablesZoneView = getUiManager().getTablesZoneView(dataMapTableViewTarget);
    InsertionIndicator insertionIndicator = targetTablesZoneView.getInsertionIndicator();
    return insertionIndicator;
}
Also used : DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView)

Example 44 with DataMapTableView

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

the class CompleteDropTargetTableListener method drop.

// private void showInfos(DropTargetEvent event) {
// System.out.println(event);
// System.out.println("event.feedback=" + event.feedback);
// System.out.println("event.detail=" + event.detail);
// System.out.println("event.operations=" + event.operations);
//
// System.out.println("DND.DROP_DEFAULT=" + DND.DROP_DEFAULT);
// System.out.println("DND.DROP_COPY=" + DND.DROP_COPY);
// System.out.println("DND.DROP_MOVE=" + DND.DROP_MOVE);
// System.out.println("DND.DROP_LINK=" + DND.DROP_LINK);
// System.out.println("DND.DROP_TARGET_MOVE=" + DND.DROP_TARGET_MOVE);
// }
//
@Override
public void drop(DropTargetEvent event) {
    super.drop(event);
    retrieveInsertionIndicator().setVisible(false);
    UIManager uiManager = getUiManager();
    DraggedData draggedData = TableEntriesTransfer.getInstance().getDraggedData();
    DropContextAnalyzer analyzer = analyzeDropTarget(event, draggedData);
    // System.out.println("\n>>drop");
    // System.out.println(event);
    Point cursorPosition = new Point(event.x, event.y);
    // int startInsertAtThisIndex = getItemIndexWhereInsertFromPosition(cursorPosition);
    int startInsertAtThisIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTargetControl, cursorPosition);
    ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
    DataMapTableView dataMapTableViewTarget = getMapperManager().retrieveDataMapTableView(draggableTargetControl);
    Zone zoneTarget = dataMapTableViewTarget.getZone();
    uiManager.selectDataMapTableView(dataMapTableViewTarget, true, false);
    MetadataTableEditorView metadataEditorView = getUiManager().getMetadataEditorView(dataMapTableViewTarget.getZone());
    List<TransferableEntry> transferableEntryList = draggedData.getTransferableEntryList();
    int currentIndex = startInsertAtThisIndex;
    uiManager.clearLastCreatedInOutColumnEntries();
    draggableTargetControl.deselectAll();
    ITableEntry currentEntryTarget = getEntryFromPosition(cursorPosition);
    ArrayList<String> columnsBeingAdded = new ArrayList<String>();
    ArrayList<Integer> columnIndicesToSelect = new ArrayList<Integer>();
    ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded = new ArrayList<ITableEntry>();
    ArrayList<IMetadataColumn> metadataColumnsBeingAdded = new ArrayList<IMetadataColumn>();
    boolean targetTableIsFiltersTable = analyzer.targetTableIsFiltersTable();
    boolean targetTableIsGlobalMapTable = analyzer.targetTableIsGlobalMapTable();
    boolean atLeastOneEntryInserted = false;
    boolean insertionEntryMode = analyzer.isInsertionEntryMode();
    boolean mapEachSourceToNextTargets = analyzer.isMapOneToOneMode();
    TableViewerCreator tableViewerCreatorTarget = null;
    if (!analyzer.targetIsExpressionFilterText()) {
        if (targetTableIsFiltersTable) {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForFilters();
        } else if (targetTableIsGlobalMapTable) {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForGlobalMap();
        } else {
            tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForColumns();
        }
    }
    uiManager.applyActivatedCellEditors(tableViewerCreatorTarget);
    // MapperDropCommand dropCommand = new MapperDropCommand();
    // MetadataEditorEvent metadataEditorEvent = new MetadataEditorEvent(MetadataEditorEvent.TYPE.ADD);
    ITableEntry lastEntryTarget = null;
    for (TransferableEntry transferableEntry : transferableEntryList) {
        ITableEntry tableEntrySource = transferableEntry.getTableEntrySource();
        IMetadataColumn metadataColumnDragged = transferableEntry.getMetadataColumn();
        Zone zoneSourceEntry = (Zone) transferableEntry.getZoneSourceEntry();
        TableEntryLocation tableEntryLocationTarget = new TableEntryLocation(dataMapTableViewTarget.getDataMapTable().getName(), tableEntrySource.getName());
        if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.INPUTS && tableEntrySource.getParentName().equals(tableEntryLocationTarget.tableName)) {
            continue;
        } else if (currentEntryTarget != null && !insertionEntryMode) {
            // set the default operator.
            if (currentEntryTarget instanceof InputColumnTableEntry) {
                ((InputColumnTableEntry) currentEntryTarget).setOperator(Operator.EQUALS.getLiteral());
            }
            boolean overwrite = (lastEntryTarget != currentEntryTarget && analyzer.isOverwriteExpression());
            modifyExistingExpression(currentLanguage, currentEntryTarget, tableEntrySource, overwrite, zoneSourceEntry);
            uiManager.parseExpression(currentEntryTarget.getExpression(), currentEntryTarget, false, true, true);
            int indexOfEntry = tableViewerCreatorTarget.getInputList().indexOf(currentEntryTarget);
            columnIndicesToSelect.add(indexOfEntry);
        } else {
            String columnName = transferableEntry.getTableEntrySource().getName();
            tableEntryLocationTarget = getMapperManager().findUniqueLocation(tableEntryLocationTarget, dataMapTableViewTarget.getDataMapTable());
            columnName = tableEntryLocationTarget.columnName;
            if (currentEntryTarget == null && analyzer.isMapOneToOneMode()) {
                currentIndex = tableViewerCreatorTarget.getInputList().size();
                columnIndicesToSelect.add(currentIndex);
            }
            if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.VARS || zoneSourceEntry == Zone.VARS && zoneTarget == Zone.VARS) {
                columnIndicesToSelect.add(currentIndex);
                currentIndex = insertNewVarEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.VARS && zoneTarget == Zone.OUTPUTS) {
                insertNewOutputEntryFromVarEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.INPUTS && targetTableIsGlobalMapTable) {
                insertNewGlobalMapEntryFromInputEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.INPUTS && zoneTarget != Zone.VARS) {
                insertNewInOutEntryFromInputEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, metadataColumnDragged, columnName);
                atLeastOneEntryInserted = true;
            } else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
            // nothing
            } else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
                insertOutpuEntryCopyToOtherOutput(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
                tableEntrySource, metadataColumnDragged, columnName);
                atLeastOneEntryInserted = true;
            } else {
            // throw new IllegalStateException("Drop case not found !");
            }
            columnsBeingAdded.add(columnName);
        }
        lastEntryTarget = currentEntryTarget;
        if (mapEachSourceToNextTargets && currentEntryTarget != null) {
            currentEntryTarget = getNextEntryTarget(currentEntryTarget, tableViewerCreatorTarget);
        }
    }
    if (!atLeastOneEntryInserted) {
        tableViewerCreatorTarget.getTableViewer().refresh();
    } else {
        updateExpressionsOfInsertedEntries(currentLanguage, metadataEditorView, currentIndex, sourceEntriesOfEntriesBeingAdded, targetTableIsFiltersTable, tableViewerCreatorTarget, // , metadataEditorEvent
        metadataColumnsBeingAdded);
        for (int i = currentIndex; i < currentIndex + sourceEntriesOfEntriesBeingAdded.size(); i++) {
            columnIndicesToSelect.add(i);
        }
    }
    if (zoneTarget == Zone.VARS) {
        dataMapTableViewTarget.resizeAtExpandedSize();
    }
    if (targetTableIsGlobalMapTable) {
        dataMapTableViewTarget.updateGridDataHeightForTableGlobalMap();
        dataMapTableViewTarget.resizeAtExpandedSize();
    }
    uiManager.unselectAllEntriesOfAllTables();
    uiManager.refreshBackground(true, false);
    if (metadataEditorView != null && !targetTableIsFiltersTable) {
        metadataEditorView.getTableViewerCreator().getTableViewer().refresh();
    }
    int[] selection = ArrayUtils.toPrimitive(columnIndicesToSelect.toArray(new Integer[0]));
    tableViewerCreatorTarget.getSelectionHelper().setSelection(selection);
    ISelection iselection = tableViewerCreatorTarget.getTableViewer().getSelection();
    List<ITableEntry> selectedEntries = uiManager.extractSelectedTableEntries(iselection);
    tableViewerCreatorTarget.getTable().deselectAll();
    uiManager.unselectAllOutputMetaDataEntries();
    uiManager.unselectAllInputMetaDataEntries();
    uiManager.parseAllExpressionsForAllTables();
    getMapperManager().getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
    getMapperManager().getProblemsManager().checkLookupExpressionProblem();
    uiManager.selectLinks(dataMapTableViewTarget, selectedEntries, true, false);
    dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
    tableViewerCreatorTarget.getTable().setFocus();
    uiManager.setDragging(false);
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) UIManager(org.talend.designer.mapper.managers.UIManager) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) ISelection(org.eclipse.jface.viewers.ISelection) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) TransferableEntry(org.talend.designer.abstractmap.ui.dnd.TransferableEntry) Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) DraggedData(org.talend.designer.abstractmap.ui.dnd.DraggedData) Point(org.eclipse.swt.graphics.Point) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Point(org.eclipse.swt.graphics.Point) ILanguage(org.talend.designer.mapper.language.ILanguage) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 45 with DataMapTableView

use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView 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

DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)47 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)24 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)24 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)24 Point (org.eclipse.swt.graphics.Point)11 OutputTable (org.talend.designer.mapper.model.table.OutputTable)10 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)9 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)9 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)8 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)7 ArrayList (java.util.ArrayList)6 FormData (org.eclipse.swt.layout.FormData)6 UIManager (org.talend.designer.mapper.managers.UIManager)6 ExpressionFilterEntry (org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry)6 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)5 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)5 TableEntryLocation (org.talend.designer.mapper.model.tableentry.TableEntryLocation)5 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)5 List (java.util.List)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4