@Override public void drop(DragAndDropEvent event) { WrapperTransferable transfrable = (WrapperTransferable) event.getTransferable(); WrapperTargetDetails details = (WrapperTargetDetails) event.getTargetDetails(); System.out.println("transfrable " + transfrable.getClass().getCanonicalName()); System.out.println("transfrable.getDraggedComponent() " + transfrable.getDraggedComponent().getClass().getCanonicalName()); if (transfrable.getDraggedComponent() instanceof Button) { // Calculate the drag coordinate difference int xChange = details.getMouseEvent().getClientX() - transfrable.getMouseDownEvent().getClientX(); int yChange = details.getMouseEvent().getClientY() - transfrable.getMouseDownEvent().getClientY(); // Move the component in the absolute layout AbsoluteLayout.ComponentPosition componentPosition = processModelLayout.getPosition(transfrable.getSourceComponent()); componentPosition.setLeftValue(componentPosition.getLeftValue() + xChange); componentPosition.setTopValue(componentPosition.getTopValue() + yChange); ElementModelLayout elementModelLayout = (ElementModelLayout) ((Button) transfrable.getDraggedComponent()).getParent(); TaskModel elementModel = elementModelLayout.getTaskModel(); elementModel.setX(componentPosition.getLeftValue()); elementModel.setY(componentPosition.getTopValue()); processModel.getTaskModels().put(elementModel.getId(), elementModel); transitionManager.setValue(processModel.getTaskModels(), processModel.getTransitionModels()); setTaskActive(elementModel); } }
@Override public void drop(final DragAndDropEvent event) { if (validate(event)) { final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); // selected software module at the time of file drop is // considered for upload artifactUploadState.getSelectedBaseSwModuleId().ifPresent(selectedSwId -> { // reset the flag hasDirectory = false; final SoftwareModule softwareModule = softwareModuleManagement.get(selectedSwId) .orElse(null); for (final Html5File file : files) { processFile(file, softwareModule); } if (artifactUploadState.getNumberOfFileUploadsExpected().get() > 0) { processBtn.setEnabled(false); } else { // If the upload is not started, it signifies all // dropped files as either duplicate or directory.So // display message accordingly displayCompositeMessage(); } }); } }
private boolean isFilesDropped(final DragAndDropEvent event) { if (event.getTransferable() instanceof WrapperTransferable) { final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); return files != null; } return false; }