java.lang.Object
io.jmix.ui.widget.client.addon.dragdroplayouts.ui.VDragDropUtil

public final class VDragDropUtil extends Object
Utility class for Drag and Drop operations
Since:
0.5.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.vaadin.client.ui.dd.VTransferable
    createLayoutTransferableFromMouseDown(com.google.gwt.dom.client.NativeEvent event, com.google.gwt.user.client.ui.Widget root, com.google.gwt.user.client.ui.Widget target)
    Creates a transferable from a mouse down event.
    static int
    findSlotIndex(com.google.gwt.user.client.ui.WidgetCollection children, com.vaadin.client.ui.orderedlayout.Slot slot)
    Finds a slots index in a collection of slots and captions
    static com.vaadin.shared.ui.dd.HorizontalDropLocation
    getHorizontalDropLocation(com.google.gwt.dom.client.Element element, int clientX, double leftRightRatio)
    Get the horizontal drop location in an ordered layout
    static com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout
    getSlotLayout(com.vaadin.client.ui.orderedlayout.Slot slot)
    Returns the parent layout that the slot belongs to
    static com.google.gwt.user.client.ui.Widget
    getTransferableWidget(com.google.gwt.user.client.ui.Widget w)
     
    static com.vaadin.shared.ui.dd.VerticalDropLocation
    getVerticalDropLocation(com.google.gwt.dom.client.Element element, int clientY, double topBottomRatio)
    Get the vertical drop location in a ordered layout
    static com.vaadin.shared.ui.dd.VerticalDropLocation
    getVerticalDropLocation(com.google.gwt.dom.client.Element element, int offsetHeight, int clientY, double topBottomRatio)
    Get the vertical drop location in a ordered layout
    static boolean
    isCaption(com.google.gwt.user.client.ui.Widget w)
    Resolve if widget is a Vaadin Caption
    static boolean
    isCaptionOrCaptionless(com.google.gwt.user.client.ui.Widget w)
    Does the same as isCaption(Widget) but also returns true for Vaadin widgets that do not have a caption like Button and Link
    static boolean
    isDraggingEnabled(com.vaadin.client.ComponentConnector layout, com.google.gwt.user.client.ui.Widget w)
    Is dragging enabled for a component container
    static void
    listenToStateChangeEvents(com.vaadin.client.ui.AbstractConnector connector, com.google.gwt.user.client.ui.Widget widget)
    Adds a listener for listening for changes to DragAndDropAwareState's.
    static int
    measureMarginLeft(com.google.gwt.dom.client.Element element)
    Measures the left margin of an element
    static int
    measureMarginTop(com.google.gwt.dom.client.Element element)
    Measures the top margin of an element
    static com.vaadin.client.UIDL
    removeDragDropCriteraFromUIDL(com.vaadin.client.UIDL uidl)
    Removes the Drag and drop fake paintable from an UIDL
    static void
    updateDropHandlerFromUIDL(com.vaadin.client.UIDL uidl, com.vaadin.client.ComponentConnector connector, VDDAbstractDropHandler dropHandler)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getVerticalDropLocation

      public static com.vaadin.shared.ui.dd.VerticalDropLocation getVerticalDropLocation(com.google.gwt.dom.client.Element element, int clientY, double topBottomRatio)
      Get the vertical drop location in a ordered layout
      Parameters:
      element - The target element or cell
      clientY - The client y-coordinate
      topBottomRatio - The ratio how the cell has been divided
      Returns:
      The drop location
    • getVerticalDropLocation

      public static com.vaadin.shared.ui.dd.VerticalDropLocation getVerticalDropLocation(com.google.gwt.dom.client.Element element, int offsetHeight, int clientY, double topBottomRatio)
      Get the vertical drop location in a ordered layout
      Parameters:
      element - The target element or cell
      offsetHeight - The height of the cell
      clientY - The width of the cell
      topBottomRatio - The ratio of the cell
      Returns:
      The location of the drop
    • getHorizontalDropLocation

      public static com.vaadin.shared.ui.dd.HorizontalDropLocation getHorizontalDropLocation(com.google.gwt.dom.client.Element element, int clientX, double leftRightRatio)
      Get the horizontal drop location in an ordered layout
      Parameters:
      element - The target element or cell
      clientX - The x-coordinate of the drop
      leftRightRatio - The ratio of how the cell has been divided
      Returns:
      the drop location relative to the cell
    • createLayoutTransferableFromMouseDown

      public static com.vaadin.client.ui.dd.VTransferable createLayoutTransferableFromMouseDown(com.google.gwt.dom.client.NativeEvent event, com.google.gwt.user.client.ui.Widget root, com.google.gwt.user.client.ui.Widget target)
      Creates a transferable from a mouse down event. Returns null if creation was not successful.
      Parameters:
      event - The mouse down event
      root - The root layout from where the component is dragged
      Returns:
      A transferable or NULL if something failed
    • isCaption

      public static boolean isCaption(com.google.gwt.user.client.ui.Widget w)
      Resolve if widget is a Vaadin Caption
      Parameters:
      w - Widget to check
      Returns:
      True if the widget is a caption widget, false otherwise
    • isCaptionOrCaptionless

      public static boolean isCaptionOrCaptionless(com.google.gwt.user.client.ui.Widget w)
      Does the same as isCaption(Widget) but also returns true for Vaadin widgets that do not have a caption like Button and Link
      Parameters:
      w - The widget to check
      Returns:
      True if the widget is a caption widget, false otherwise
    • getTransferableWidget

      public static com.google.gwt.user.client.ui.Widget getTransferableWidget(com.google.gwt.user.client.ui.Widget w)
    • isDraggingEnabled

      public static boolean isDraggingEnabled(com.vaadin.client.ComponentConnector layout, com.google.gwt.user.client.ui.Widget w)
      Is dragging enabled for a component container
      Parameters:
      layout - The component container to check
      Returns:
    • removeDragDropCriteraFromUIDL

      public static com.vaadin.client.UIDL removeDragDropCriteraFromUIDL(com.vaadin.client.UIDL uidl)
      Removes the Drag and drop fake paintable from an UIDL
      Parameters:
      uidl - The uidl which contains a dragdrop paintable (-ac)
      Returns:
      UIDL stripped of the paintable
    • measureMarginLeft

      public static int measureMarginLeft(com.google.gwt.dom.client.Element element)
      Measures the left margin of an element
      Parameters:
      element - The element to measure
      Returns:
      Left margin in pixels
    • measureMarginTop

      public static int measureMarginTop(com.google.gwt.dom.client.Element element)
      Measures the top margin of an element
      Parameters:
      element - The element to measure
      Returns:
      Top margin in pixels
    • listenToStateChangeEvents

      public static void listenToStateChangeEvents(com.vaadin.client.ui.AbstractConnector connector, com.google.gwt.user.client.ui.Widget widget)
      Adds a listener for listening for changes to DragAndDropAwareState's.

      Preferrable add this to a layout connector's init() method.

      Parameters:
      connector - The connector to attach to.
      widget - The layout widget returned by Connector.getWidget()
    • updateDropHandlerFromUIDL

      public static void updateDropHandlerFromUIDL(com.vaadin.client.UIDL uidl, com.vaadin.client.ComponentConnector connector, VDDAbstractDropHandler dropHandler)
    • getSlotLayout

      public static com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout getSlotLayout(com.vaadin.client.ui.orderedlayout.Slot slot)
      Returns the parent layout that the slot belongs to
      Parameters:
      slot - the slot
      Returns:
      the layout
    • findSlotIndex

      public static int findSlotIndex(com.google.gwt.user.client.ui.WidgetCollection children, com.vaadin.client.ui.orderedlayout.Slot slot)
      Finds a slots index in a collection of slots and captions
      Parameters:
      children - the children.
      slot - the slot to find.
      Returns:
      the index of the slot