Java Code Examples for com.vaadin.client.MouseEventDetailsBuilder#buildMouseEventDetails()
The following examples show how to use
com.vaadin.client.MouseEventDetailsBuilder#buildMouseEventDetails() .
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: 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 2
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 3
Source File: VDDHorizontalLayout.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 widget * The container which we are hovering over * @param event * The drag event */ protected void updateDragDetails(Widget widget, VDragEvent event) { if (widget == null) { return; } /* * The horizontal position within the cell{ */ event.getDropDetails().put( Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, getHorizontalDropLocation(widget, event)); /* * The index over which the drag is. Can be used by a client side * criteria to verify that a drag is over a certain index. */ int index = -1; if (widget instanceof Slot) { WidgetCollection captionsAndSlots = getChildren(); index = VDragDropUtil.findSlotIndex(captionsAndSlots, (Slot) widget); } event.getDropDetails().put(Constants.DROP_DETAIL_TO, index); // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
Example 4
Source File: VDDFormLayout.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 widget * The container which we are hovering over * @param event * The drag event */ protected void updateDragDetails(Widget widget, VDragEvent event) { /* * The horizontal position within the cell */ event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, getVerticalDropLocation(VDDFormLayout.getRowFromChildElement( widget.getElement(), VDDFormLayout.this.getElement()), event)); /* * The index over which the drag is. Can be used by a client side * criteria to verify that a drag is over a certain index. */ event.getDropDetails().put(Constants.DROP_DETAIL_TO, "-1"); for (int i = 0; i < table.getRowCount(); i++) { Widget w = table.getWidget(i, COLUMN_WIDGET); if (widget.equals(w)) { event.getDropDetails().put(Constants.DROP_DETAIL_TO, i); } } /* * Add Classname of component over the drag. This can be used by a a * client side criteria to verify that a drag is over a specific class * of component. */ String className = widget.getClass().getName(); event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, className); // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
Example 5
Source File: VDDVerticalLayout.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 widget * The container which we are hovering over * @param event * The drag event */ protected void updateDragDetails(Widget widget, VDragEvent event) { if (widget == null) { return; } /* * The horizontal position within the cell{ */ event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, getVerticalDropLocation(widget, event)); /* * The index over which the drag is. Can be used by a client side * criteria to verify that a drag is over a certain index. */ int index = -1; if (widget instanceof Slot) { WidgetCollection captionsAndSlots = getChildren(); index = VDragDropUtil.findSlotIndex(captionsAndSlots, (Slot) widget); } event.getDropDetails().put(Constants.DROP_DETAIL_TO, index); // 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: VDDHorizontalLayout.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 widget * The container which we are hovering over * @param event * The drag event */ protected void updateDragDetails(Widget widget, VDragEvent event) { if (widget == null) { return; } /* * The horizontal position within the cell{ */ event.getDropDetails().put( Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, getHorizontalDropLocation(widget, event)); /* * The index over which the drag is. Can be used by a client side * criteria to verify that a drag is over a certain index. */ int index = -1; if (widget instanceof Slot) { WidgetCollection captionsAndSlots = getChildren(); index = VDragDropUtil.findSlotIndex(captionsAndSlots, (Slot) widget); } event.getDropDetails().put(Constants.DROP_DETAIL_TO, index); // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
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: 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 9
Source File: VDDVerticalLayout.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 widget * The container which we are hovering over * @param event * The drag event */ protected void updateDragDetails(Widget widget, VDragEvent event) { if (widget == null) { return; } /* * The horizontal position within the cell{ */ event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, getVerticalDropLocation(widget, event)); /* * The index over which the drag is. Can be used by a client side * criteria to verify that a drag is over a certain index. */ int index = -1; if (widget instanceof Slot) { WidgetCollection captionsAndSlots = getChildren(); index = VDragDropUtil.findSlotIndex(captionsAndSlots, (Slot) widget); } event.getDropDetails().put(Constants.DROP_DETAIL_TO, index); // 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: CubaSourceCodeEditorConnector.java From cuba with Apache License 2.0 | 5 votes |
@Override public void contextHelpIconClick(NativeEvent event) { MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event, getWidget().getElement()); getRpcProxy(HasContextHelpServerRpc.class).iconClick(details); }
Example 11
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 12
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 13
Source File: VDDGridLayout.java From cuba with Apache License 2.0 | 4 votes |
/** * Updates the drop details while dragging * * @param event * The drag event */ public void updateDragDetails(VDragEvent event) { CellDetails cd = getCellDetails(event); if (cd != null) { Map<String, Object> ddetails = event.getDropDetails(); // Add row ddetails.put(Constants.DROP_DETAIL_ROW, Integer.valueOf(cd.row)); // Add column ddetails.put(Constants.DROP_DETAIL_COLUMN, Integer.valueOf(cd.column)); // Add horizontal position HorizontalDropLocation hl = getHorizontalDropLocation(cd, event); ddetails.put(Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, hl); // Add vertical position VerticalDropLocation vl = getVerticalDropLocation(cd, event); ddetails.put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, vl); // Check if the cell we are hovering over has content Cell cell = getCell(cd.row, cd.column); ddetails.put(Constants.DROP_DETAIL_EMPTY_CELL, cell != null); // Get class information from child if (cell != null && cell.slot != null) { ComponentConnector child = cell.slot.getChild(); if (child != null) { String className = child.getWidget().getClass().getName(); ddetails.put(Constants.DROP_DETAIL_OVER_CLASS, className); } else { ddetails.put(Constants.DROP_DETAIL_OVER_CLASS, VDDGridLayout.this.getClass().getName()); } } else { ddetails.put(Constants.DROP_DETAIL_OVER_CLASS, VDDGridLayout.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 14
Source File: VDDAbsoluteLayout.java From cuba with Apache License 2.0 | 4 votes |
protected void updateDragDetails(VDragEvent drag) { // Get absolute coordinates int absoluteLeft = drag.getCurrentGwtEvent().getClientX(); int absoluteTop = drag.getCurrentGwtEvent().getClientY(); drag.getDropDetails().put(Constants.DROP_DETAIL_ABSOLUTE_LEFT, absoluteLeft); drag.getDropDetails().put(Constants.DROP_DETAIL_ABSOLUTE_TOP, absoluteTop); // Get relative coordinates int offsetLeft = 0; if (drag.getDragImage() != null) { String offsetLeftStr = drag.getDragImage().getStyle() .getMarginLeft(); offsetLeft = Integer.parseInt( offsetLeftStr.substring(0, offsetLeftStr.length() - 2)); } int relativeLeft = Util .getTouchOrMouseClientX(drag.getCurrentGwtEvent()) - canvas.getAbsoluteLeft() + offsetLeft; int offsetTop = 0; if (drag.getDragImage() != null) { String offsetTopStr = drag.getDragImage().getStyle().getMarginTop(); offsetTop = Integer.parseInt( offsetTopStr.substring(0, offsetTopStr.length() - 2)); } int relativeTop = Util.getTouchOrMouseClientY(drag.getCurrentGwtEvent()) - canvas.getAbsoluteTop() + offsetTop; drag.getDropDetails().put(Constants.DROP_DETAIL_RELATIVE_LEFT, relativeLeft); drag.getDropDetails().put(Constants.DROP_DETAIL_RELATIVE_TOP, relativeTop); // Get component size ComponentConnector widgetConnector = (ComponentConnector) drag .getTransferable() .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT); if (widgetConnector != null) { drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_WIDTH, widgetConnector.getWidget().getOffsetWidth()); drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_HEIGHT, widgetConnector.getWidget().getOffsetHeight()); } else { drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_WIDTH, -1); drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_HEIGHT, -1); } // Add mouse event details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(drag.getCurrentGwtEvent(), getElement()); drag.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
Example 15
Source File: GanttConnector.java From gantt with Apache License 2.0 | 4 votes |
@Override public void stepClicked(String stepUid, NativeEvent event, Element relativeToElement) { MouseEventDetails details = MouseEventDetailsBuilder.buildMouseEventDetails(event, relativeToElement); rpc.stepClicked(stepUid, details); }
Example 16
Source File: GanttConnector.java From gantt with Apache License 2.0 | 4 votes |
@Override public void onMove(String stepUid, String newStepUid, long startDate, long endDate, NativeEvent event, Element relativeToElement) { MouseEventDetails details = MouseEventDetailsBuilder.buildMouseEventDetails(event, relativeToElement); rpc.onMove(stepUid, newStepUid, startDate, endDate, details); }
Example 17
Source File: GanttConnector.java From gantt with Apache License 2.0 | 4 votes |
@Override public void onResize(String stepUid, long startDate, long endDate, NativeEvent event, Element relativeToElement) { MouseEventDetails details = MouseEventDetailsBuilder.buildMouseEventDetails(event, relativeToElement); rpc.onResize(stepUid, startDate, endDate, details); }
Example 18
Source File: AbstractGridExtensionConnector.java From GridExtensionPack with Apache License 2.0 | 2 votes |
/** * Gets a {@link MouseEventDetails} object from native mouse event. * * @param event * native mouse event * @return mouse event details */ protected MouseEventDetails getMouseEventDetails(NativeEvent event) { return MouseEventDetailsBuilder.buildMouseEventDetails(event); }