@Override public TargetDetails convertTargetDetails(com.vaadin.event.dd.TargetDetails targetDetails) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) targetDetails; Map<String, Object> dataDetails = new HashMap<>(); dataDetails.put(Constants.DROP_DETAIL_ABSOLUTE_TOP, details.getAbsoluteTop()); dataDetails.put(Constants.DROP_DETAIL_MOUSE_EVENT, details.getData(Constants.DROP_DETAIL_MOUSE_EVENT)); dataDetails.put(Constants.DROP_DETAIL_RELATIVE_LEFT, details.getRelativeLeft()); dataDetails.put(Constants.DROP_DETAIL_RELATIVE_TOP, details.getRelativeTop()); dataDetails.put(Constants.DROP_DETAIL_COMPONENT_HEIGHT, details.getComponentHeight()); dataDetails.put(Constants.DROP_DETAIL_ABSOLUTE_LEFT, details.getAbsoluteLeft()); dataDetails.put(Constants.DROP_DETAIL_COMPONENT_WIDTH, details.getComponentWidth()); return new DDAbsoluteLayoutTargetDetails(this, dataDetails); }
@Override protected void handleHTML5Drop(DragAndDropEvent event) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event .getTargetDetails(); DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop(); layout.addComponent(resolveComponentFromHTML5Drop(event), "left:" + leftPixelPosition + "px;top:" + topPixelPosition + "px"); }
/** * Called when a component changed location within the layout * * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event .getTargetDetails(); DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component component = transferable.getComponent(); // Get top-left pixel position int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop(); ComponentPosition position = layout.getPosition(component); position.setLeft((float) leftPixelPosition, Sizeable.UNITS_PIXELS); position.setTop((float) topPixelPosition, Sizeable.UNITS_PIXELS); }
DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop();