Search in sources :

Example 6 with AbstractUIManager

use of org.talend.designer.abstractmap.managers.AbstractUIManager in project tdi-studio-se by Talend.

the class DefaultDropTargetListener method detectPressedKeys.

/**
     * DOC amaumont Comment method "detectPressedKeys".
     * 
     * @param event
     */
protected void detectPressedKeys(DropTargetEvent event) {
    DNDKeyAnalyzer keyAnalyzer = new DNDKeyAnalyzer(event);
    AbstractUIManager uiManager = mapperManager.getUiManager();
    uiManager.setCtrlPressed(keyAnalyzer.isCtrlPressed());
    uiManager.setShiftPressed(keyAnalyzer.isShiftPressed());
}
Also used : DNDKeyAnalyzer(org.talend.commons.ui.swt.dnd.DNDKeyAnalyzer) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager)

Example 7 with AbstractUIManager

use of org.talend.designer.abstractmap.managers.AbstractUIManager in project tdi-studio-se by Talend.

the class CompleteDropTargetTableListener method dragOver.

@Override
public void dragOver(DropTargetEvent event) {
    super.dragOver(event);
    AbstractUIManager uiManager = mapperManager.getUiManager();
    DraggingInfosPopup draggingInfosPopup = uiManager.getDraggingInfosPopup();
    // System.out.println("\n>>dragOver");
    DraggedData draggedData = TableEntriesTransfer.getInstance().getDraggedData();
    DropContextAnalyzer analyzer = analyzeDropTarget(event, draggedData);
    fillEvent(event, analyzer);
    InsertionIndicator insertionIndicator = retrieveInsertionIndicator();
    if (analyzer.isDropValid()) {
        draggingInfosPopup.setOutputToOutputMode(analyzer.isOutputToOutput());
        if (analyzer.isInputToInput() && !analyzer.isInsertionEntryMode()) {
            draggingInfosPopup.setExpressionContext(true);
            draggingInfosPopup.setInsertionEntryContext(false);
        } else if (analyzer.isCursorOverExpressionCell()) {
            draggingInfosPopup.setExpressionContext(true);
        } else if (analyzer.targetIsExpressionFilterText() || analyzer.targetTableIsFiltersTable()) {
            draggingInfosPopup.setExpressionContext(true);
        } else {
            draggingInfosPopup.setExpressionContext(false);
        }
        draggingInfosPopup.setMapOneToOneMode(analyzer.isMapOneToOneMode(), analyzer.isMapOneToOneAuthorized());
        Point cursorPosition = new Point(event.x, event.y);
        Integer itemIndexWhereInsertFromPosition = getItemIndexFromPosition(cursorPosition);
        if (analyzer.isMapOneToOneMode() && analyzer.isMapOneToOneAuthorized()) {
            int size = draggedData.getTransferableEntryList().size();
            if (itemIndexWhereInsertFromPosition != null) {
                draggableTargetControl.setSelection(itemIndexWhereInsertFromPosition, itemIndexWhereInsertFromPosition + size - 1);
                if (!analyzer.targetIsExpressionFilterText() && !analyzer.targetTableIsFiltersTable() && itemIndexWhereInsertFromPosition + size - 1 >= draggableTargetControl.getItemCount()) {
                    insertionIndicator.updatePosition(draggableTargetControl, draggableTargetControl.getItemCount());
                    insertionIndicator.setVisible(true);
                    draggingInfosPopup.setInsertionEntryContext(true);
                } else {
                    insertionIndicator.setVisible(false);
                    draggingInfosPopup.setInsertionEntryContext(false);
                }
            } else {
                draggableTargetControl.deselectAll();
                insertionIndicator.setVisible(false);
                draggingInfosPopup.setInsertionEntryContext(false);
            }
        } else {
            if (!analyzer.isTableSourceAndTargetAreSame()) {
                draggableTargetControl.deselectAll();
            }
            if (itemIndexWhereInsertFromPosition != null && !analyzer.isInsertionEntryMode()) {
                draggableTargetControl.setSelection(itemIndexWhereInsertFromPosition);
            }
            if (!analyzer.targetIsExpressionFilterText() && !analyzer.targetTableIsFiltersTable()) {
                updateInsertionIndicator(event);
                insertionIndicator.setVisible(analyzer.isInsertionEntryMode());
            }
            draggingInfosPopup.setInsertionEntryContext(analyzer.isInsertionEntryMode());
        }
        draggingInfosPopup.setDropInvalid(false, false);
    } else {
        draggingInfosPopup.setMapOneToOneMode(false, false);
        draggingInfosPopup.setExpressionContext(false);
        draggingInfosPopup.setInsertionEntryContext(false);
        draggingInfosPopup.setDropInvalid(true, analyzer.isInvalidKeyPressed());
    }
}
Also used : DraggingInfosPopup(org.talend.designer.abstractmap.ui.dnd.DraggingInfosPopup) DraggedData(org.talend.designer.abstractmap.ui.dnd.DraggedData) Point(org.eclipse.swt.graphics.Point) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager) Point(org.eclipse.swt.graphics.Point)

Example 8 with AbstractUIManager

use of org.talend.designer.abstractmap.managers.AbstractUIManager in project tdi-studio-se by Talend.

the class CompleteDropTargetTableListener method configurePopupInfos.

private void configurePopupInfos(DropContextAnalyzer analyzer) {
    AbstractUIManager uiManager = mapperManager.getUiManager();
    DraggingInfosPopup draggingInfosPopup = uiManager.getDraggingInfosPopup();
    if (analyzer.isDropValid()) {
        draggingInfosPopup.setOutputToOutputMode(analyzer.isOutputToOutput());
        if (uiManager.isCtrlPressed()) {
            draggingInfosPopup.setOverwriteMode(true);
        } else {
            draggingInfosPopup.setOverwriteMode(false);
        }
        if (uiManager.isShiftPressed() && analyzer.isMapOneToOneAuthorized()) {
            draggingInfosPopup.setMapOneToOneMode(true, true);
        } else {
            draggingInfosPopup.setMapOneToOneMode(false, analyzer.isMapOneToOneAuthorized());
        }
        if (analyzer.isInputToInput()) {
            draggingInfosPopup.setExpressionContext(true);
            draggingInfosPopup.setInsertionEntryContext(false);
        } else if (analyzer.isCursorOverExpressionCell()) {
            draggingInfosPopup.setExpressionContext(true);
            draggingInfosPopup.setInsertionEntryContext(analyzer.isInsertionEntryMode());
        } else if (analyzer.targetIsExpressionFilterText() || analyzer.targetTableIsFiltersTable()) {
            draggingInfosPopup.setExpressionContext(true);
            draggingInfosPopup.setInsertionEntryContext(false);
        } else {
            draggingInfosPopup.setExpressionContext(false);
            draggingInfosPopup.setInsertionEntryContext(true);
        }
        draggingInfosPopup.setDropInvalid(false, false);
    } else {
        draggingInfosPopup.setExpressionContext(false);
        draggingInfosPopup.setMapOneToOneMode(false, false);
        draggingInfosPopup.setInsertionEntryContext(false);
        draggingInfosPopup.setDropInvalid(true, analyzer.isInvalidKeyPressed());
    }
}
Also used : DraggingInfosPopup(org.talend.designer.abstractmap.ui.dnd.DraggingInfosPopup) AbstractUIManager(org.talend.designer.abstractmap.managers.AbstractUIManager)

Aggregations

AbstractUIManager (org.talend.designer.abstractmap.managers.AbstractUIManager)8 DraggingInfosPopup (org.talend.designer.abstractmap.ui.dnd.DraggingInfosPopup)7 Point (org.eclipse.swt.graphics.Point)4 Rectangle (org.eclipse.swt.graphics.Rectangle)1 DNDKeyAnalyzer (org.talend.commons.ui.swt.dnd.DNDKeyAnalyzer)1 DraggedData (org.talend.designer.abstractmap.ui.dnd.DraggedData)1