Java Code Examples for com.vaadin.client.ui.dd.VDragEvent#getElementOver()
The following examples show how to use
com.vaadin.client.ui.dd.VDragEvent#getElementOver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VDDPanel.java From cuba with Apache License 2.0 | 6 votes |
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * * @param event * The drag event */ protected void updateDragDetails(VDragEvent event) { Element over = event.getElementOver(); Widget content = WidgetUtil.findWidget(over, null); if (content != null && content != this) { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, content.getClass().getName()); } else { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, this.getClass().getName()); } // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
Example 2
Source File: VDDAccordion.java From cuba with Apache License 2.0 | 6 votes |
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * * @param event * The drag event */ protected void updateDragDetails(VDragEvent event) { if (event.getElementOver() == null) { return; } StackItem tab = WidgetUtil.findWidget(event.getElementOver(), StackItem.class); if (tab != null && getElement().isOrHasChild(tab.getElement())) { Map<String, Object> dropDetails = event.getDropDetails(); int index = getTabPosition(tab); dropDetails.put(Constants.DROP_DETAIL_TO, index); VerticalDropLocation location = getDropLocation(tab, event); dropDetails.put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, location); MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); dropDetails.put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); } }
Example 3
Source File: CalendarWeekDropHandler.java From calendar-component with Apache License 2.0 | 5 votes |
@Override protected void dragAccepted(VDragEvent drag) { deEmphasis(); currentTargetElement = drag.getElementOver(); currentTargetDay = WidgetUtil.findWidget(currentTargetElement, DateCell.class); emphasis(); }
Example 4
Source File: CalendarMonthDropHandler.java From calendar-component with Apache License 2.0 | 5 votes |
@Override protected void dragAccepted(VDragEvent drag) { deEmphasis(); currentTargetElement = drag.getElementOver(); currentTargetDay = WidgetUtil.findWidget(currentTargetElement, SimpleDayCell.class); emphasis(); }
Example 5
Source File: VDDHorizontalSplitPanel.java From cuba with Apache License 2.0 | 5 votes |
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * * @param event * The drag event */ protected void updateDragDetails(VDragEvent event) { Element over = event.getElementOver(); if (over == null) { return; } // Resolve where the drop was made HorizontalDropLocation location = null; Widget content = null; if (firstContainer.isOrHasChild(over)) { location = HorizontalDropLocation.LEFT; content = Util.findWidget(firstContainer, null); } else if (splitter.isOrHasChild(over)) { location = HorizontalDropLocation.CENTER; content = this; } else if (secondContainer.isOrHasChild(over)) { location = HorizontalDropLocation.RIGHT; content = Util.findWidget(secondContainer, null); } event.getDropDetails() .put(Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, location); if (content != null) { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, content.getClass().getName()); } else { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, this.getClass().getName()); } // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
Example 6
Source File: VDDCssLayout.java From cuba with Apache License 2.0 | 5 votes |
private void updatePlaceHolderStyleProperties(VDragEvent drag) { int width = 0; int height = 0; String className = ""; placeHolderElement.setClassName(DRAG_SHADOW_STYLE_NAME); ComponentConnector draggedConnector = (ComponentConnector) drag .getTransferable() .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT); if (draggedConnector != null) { height = Util.getRequiredHeight(draggedConnector.getWidget()); width = Util.getRequiredWidth(draggedConnector.getWidget()); className = draggedConnector.getWidget().getElement() .getClassName(); className = className.replaceAll( VLayoutDragDropMouseHandler.ACTIVE_DRAG_SOURCE_STYLENAME, ""); placeHolderElement.addClassName(className); } else if (drag.getElementOver() != getElement()) { width = 3; height = drag.getElementOver().getOffsetHeight(); } placeHolderElement.getStyle().setWidth(width, Unit.PX); placeHolderElement.getStyle().setHeight(height, Unit.PX); }
Example 7
Source File: VDDVerticalSplitPanel.java From cuba with Apache License 2.0 | 5 votes |
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * * @param event * The drag event */ protected void updateDragDetails(VDragEvent event) { Element over = event.getElementOver(); // Resolve where the drop was made VerticalDropLocation location = null; Widget content = null; if (firstContainer.isOrHasChild(over)) { location = VerticalDropLocation.TOP; content = Util.findWidget(firstContainer, null); } else if (splitter.isOrHasChild(over)) { location = VerticalDropLocation.MIDDLE; content = this; } else if (secondContainer.isOrHasChild(over)) { location = VerticalDropLocation.BOTTOM; content = Util.findWidget(secondContainer, null); } event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, location); if (content != null) { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, content.getClass().getName()); } else { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, this.getClass().getName()); } // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
Example 8
Source File: VDDTabSheet.java From cuba with Apache License 2.0 | 4 votes |
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * * @param event * The drag event */ protected void updateDragDetails(VDragEvent event) { Element element = event.getElementOver(); if (element == null) return; if (tabBar.getElement().isOrHasChild(element)) { Widget w = Util.findWidget(element, null); if (w == tabBar) { // Ove3r the spacer // Add index event.getDropDetails().put(Constants.DROP_DETAIL_TO, tabBar.getWidgetCount() - 1); // Add drop location event.getDropDetails().put( Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, HorizontalDropLocation.RIGHT); } else { // Add index event.getDropDetails().put(Constants.DROP_DETAIL_TO, getTabPosition(w)); // Add drop location HorizontalDropLocation location = VDragDropUtil .getHorizontalDropLocation(DOM.asOld(element), Util.getTouchOrMouseClientX( event.getCurrentGwtEvent()), tabLeftRightDropRatio); event.getDropDetails().put( Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, location); } // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); } }
Example 9
Source File: VDDCssLayout.java From cuba with Apache License 2.0 | 4 votes |
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * * @param event * The drag event */ protected void updateDragDetails(VDragEvent event) { Element over = event.getElementOver(); if (placeHolderElement.isOrHasChild(over)) { // Dragging over the placeholder return; } Widget widget = (Widget) Util.findWidget(over, null); if (widget == null) { // Null check return; } int offset = 0; int index = -1; for (int i = 0; i < getElement().getChildCount(); i++) { Element child = getElement().getChild(i).cast(); if (child.isOrHasChild(placeHolderElement)) { offset--; } else if (child.isOrHasChild(widget.getElement())) { index = i + offset; break; } } event.getDropDetails().put(Constants.DROP_DETAIL_TO, index); /* * The horizontal position within the cell */ event.getDropDetails().put( Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, getHorizontalDropLocation(widget, event)); /* * The vertical position within the cell */ event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, getVerticalDropLocation(widget, event)); // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
Example 10
Source File: VDDFormLayoutDropHandler.java From cuba with Apache License 2.0 | 4 votes |
private Widget getTableRowWidgetFromDragEvent(VDragEvent event) { /** * Find the widget of the row */ Element e = event.getElementOver(); if (getLayout().table.getRowCount() == 0) { /* * Empty layout */ return getLayout(); } /** * Check if element is inside one of the table widgets */ for (int i = 0; i < getLayout().table.getRowCount(); i++) { Element caption = getLayout().table .getWidget(i, getLayout().COLUMN_CAPTION).getElement(); Element error = getLayout().table .getWidget(i, getLayout().COLUMN_ERRORFLAG).getElement(); Element widget = getLayout().table .getWidget(i, getLayout().COLUMN_WIDGET).getElement(); if (caption.isOrHasChild(e) || error.isOrHasChild(e) || widget.isOrHasChild(e)) { return getLayout().table.getWidget(i, getLayout().COLUMN_WIDGET); } } /* * Is the element a element outside the row structure but inside the * layout */ Element rowElement = getLayout().getRowFromChildElement(e, getLayout().getElement()); if (rowElement != null) { Element tableElement = rowElement.getParentElement(); for (int i = 0; i < tableElement.getChildCount(); i++) { Element r = tableElement.getChild(i).cast(); if (r.equals(rowElement)) { return getLayout().table.getWidget(i, getLayout().COLUMN_WIDGET); } } } /* * Element was not found in rows so defaulting to the form layout * instead */ return getLayout(); }