List of usage examples for com.vaadin.event.dd DragAndDropEvent DragAndDropEvent
public DragAndDropEvent(Transferable transferable, TargetDetails dropTargetDetails)
From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java
License:Apache License
/** * Simulates a drag and drop event.//from w w w . j av a2s . 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: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;/* w ww . jav a2s . c o m*/ 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); } } 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."); } }