Example usage for com.vaadin.event.dd TargetDetailsImpl TargetDetailsImpl

List of usage examples for com.vaadin.event.dd TargetDetailsImpl TargetDetailsImpl

Introduction

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

Prototype

public TargetDetailsImpl(Map<String, Object> rawDropData, DropTarget dropTarget) 

Source Link

Usage

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

License:Apache License

/**
 * Simulates a drag and drop event.//from w ww.j  a  v a 2s  .  co 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:org.peergreen.vaadin.diagram.Diagram.java

License:Apache License

@Override
public TargetDetails translateDropTargetDetails(Map<String, Object> clientVariables) {
    return new TargetDetailsImpl(clientVariables, this);
}