Example usage for com.vaadin.event.dd DropHandler drop

List of usage examples for com.vaadin.event.dd DropHandler drop

Introduction

In this page you can find the example usage for com.vaadin.event.dd DropHandler drop.

Prototype

public void drop(DragAndDropEvent event);

Source Link

Document

Drop method is called when the end user has finished the drag operation on a DropTarget and DragAndDropEvent has passed AcceptCriterion defined by #getAcceptCriterion() method.

Usage

From source file:com.constellio.app.ui.pages.management.updates.UpdateManagerViewImpl.java

@Override
public void drop(DragAndDropEvent event) {
    DropHandler childDropHandler = ComponentTreeUtils.getFirstChild((Component) panel, DropHandler.class);
    if (panel instanceof DropHandler) {
        ((DropHandler) panel).drop(event);
    } else if (childDropHandler != null) {
        childDropHandler.drop(event);
    }/*from   w ww  . j  av a2s.  c  om*/
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates a drag and drop event./* w ww  .  j av a2s.c o  m*/
 * @param sourceName
 * @param sourcePropertyName
 * @param targetPropertyName
 * @param targetPropertyValue
 */

public void dragAndDropHighLevel(String sourceName, String sourcePropertyName, String sourcePropertyValue,
        String targetName, String targetPropertyName, String targetPropertyValue) throws Exception {
    FocXMLLayout navigationLayout = getCurrentCentralPanel();

    if (navigationLayout != null) {

        FVTableWrapperLayout sourceWrapper = (FVTableWrapperLayout) findComponent(navigationLayout, sourceName);
        ITableTree sourceTableOrTree = sourceWrapper == null ? null : sourceWrapper.getTableOrTree();
        Object sourceItemId = null;

        if (sourceTableOrTree != null) {
            FocObject sourceObject = sourceTableOrTree.getTableTreeDelegate()
                    .selectByFocProperty(sourcePropertyName, sourcePropertyValue);

            if (sourceObject != null) {
                sourceItemId = sourceObject.getReference().getLong();
            } else {
                String message = "Could not find source row PROPERTY=" + sourcePropertyName + " VALUE="
                        + sourcePropertyValue;
                getLogger().addFailure(message);
                Globals.logString(message);
                sourceTableOrTree.getTableTreeDelegate().debug_ListOfColumns();
            }
        }

        FocXMLGuiComponent targetComponent = findComponent(navigationLayout, targetName);
        if (targetComponent instanceof FVTableWrapperLayout) {
            FVTableWrapperLayout targetWrapper = (FVTableWrapperLayout) findComponent(navigationLayout,
                    targetName);
            ITableTree targetTableOrTree = targetWrapper == null ? null : targetWrapper.getTableOrTree();
            Object targetItemId = null;

            if (targetTableOrTree != null) {
                if (targetPropertyName != null && targetPropertyValue != null) {
                    FocObject targetObject = targetTableOrTree.getTableTreeDelegate()
                            .selectByFocProperty(targetPropertyName, targetPropertyValue);

                    if (targetObject != null) {
                        targetItemId = targetObject.getReference().getLong();
                    }
                }
            }

            dragAndDropLowLevel(sourceTableOrTree, sourceItemId, targetTableOrTree, targetItemId);
        } else if (targetComponent instanceof DropTarget) {
            DataBoundTransferable dbt = buildDragTransferable(sourceTableOrTree, sourceItemId);
            DropTarget dropTarget = (DropTarget) targetComponent;
            DropHandler dropHandler = dropTarget.getDropHandler();

            HashMap<String, Object> rawVariables = new HashMap<String, Object>();

            TargetDetailsImpl details = new TargetDetailsImpl(rawVariables, dropTarget);
            DragAndDropEvent dde = new DragAndDropEvent(dbt, details);
            if (dropHandler != null) {
                dropHandler.drop(dde);
            }
        }
    }
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

private void dragAndDropLowLevel(ITableTree source, Object sourceItemId, ITableTree target, Object targetItemId)
        throws Exception {
    DataBoundTransferable dbt = buildDragTransferable(source, sourceItemId);

    if (dbt != null && target != null) {
        DropHandler dropHandler = null;
        AbstractSelectTargetDetails astd = null;

        if (target instanceof FVTable) {
            FVTable targetTable = (FVTable) target;
            dropHandler = targetTable.getDropHandler();

            HashMap<String, Object> rawVariables = new HashMap<String, Object>();
            rawVariables.put("itemIdOver", null);
            astd = targetTable.translateDropTargetDetails(rawVariables);
        } else if (target instanceof FVTreeTable) {
            FVTreeTable targetTree = (FVTreeTable) target;
            dropHandler = targetTree.getDropHandler();

            if (targetItemId != null) {
                HashMap<String, Object> rawVariables = new HashMap<String, Object>();
                rawVariables.put("itemIdOver", null);
                astd = targetTree.translateDropTargetDetails(rawVariables);
                astd.setData("itemIdOver", targetItemId);
            }//w  w  w.  jav  a 2 s .c om
        }

        DragAndDropEvent dde = new DragAndDropEvent(dbt, astd);
        if (dropHandler != null) {
            dropHandler.drop(dde);
            getLogger().addInfo("Drag and drop successful");
        }
    } else {
        getLogger().addFailure("Drag and drop failure.");
    }
}