Class VDragDropUtil
java.lang.Object
io.jmix.ui.widget.client.addon.dragdroplayouts.ui.VDragDropUtil
Utility class for Drag and Drop operations
- Since:
- 0.5.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.vaadin.client.ui.dd.VTransferablecreateLayoutTransferableFromMouseDown(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 intfindSlotIndex(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 captionsstatic com.vaadin.shared.ui.dd.HorizontalDropLocationgetHorizontalDropLocation(com.google.gwt.dom.client.Element element, int clientX, double leftRightRatio) Get the horizontal drop location in an ordered layoutstatic com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayoutgetSlotLayout(com.vaadin.client.ui.orderedlayout.Slot slot) Returns the parent layout that the slot belongs tostatic com.google.gwt.user.client.ui.WidgetgetTransferableWidget(com.google.gwt.user.client.ui.Widget w) static com.vaadin.shared.ui.dd.VerticalDropLocationgetVerticalDropLocation(com.google.gwt.dom.client.Element element, int clientY, double topBottomRatio) Get the vertical drop location in a ordered layoutstatic com.vaadin.shared.ui.dd.VerticalDropLocationgetVerticalDropLocation(com.google.gwt.dom.client.Element element, int offsetHeight, int clientY, double topBottomRatio) Get the vertical drop location in a ordered layoutstatic booleanisCaption(com.google.gwt.user.client.ui.Widget w) Resolve if widget is a Vaadin Captionstatic booleanisCaptionOrCaptionless(com.google.gwt.user.client.ui.Widget w) Does the same asisCaption(Widget)but also returns true for Vaadin widgets that do not have a caption likeButtonandLinkstatic booleanisDraggingEnabled(com.vaadin.client.ComponentConnector layout, com.google.gwt.user.client.ui.Widget w) Is dragging enabled for a component containerstatic voidlistenToStateChangeEvents(com.vaadin.client.ui.AbstractConnector connector, com.google.gwt.user.client.ui.Widget widget) Adds a listener for listening for changes toDragAndDropAwareState's.static intmeasureMarginLeft(com.google.gwt.dom.client.Element element) Measures the left margin of an elementstatic intmeasureMarginTop(com.google.gwt.dom.client.Element element) Measures the top margin of an elementstatic com.vaadin.client.UIDLremoveDragDropCriteraFromUIDL(com.vaadin.client.UIDL uidl) Removes the Drag and drop fake paintable from an UIDLstatic voidupdateDropHandlerFromUIDL(com.vaadin.client.UIDL uidl, com.vaadin.client.ComponentConnector connector, VDDAbstractDropHandler dropHandler)
-
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 cellclientY- The client y-coordinatetopBottomRatio- 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 celloffsetHeight- The height of the cellclientY- The width of the celltopBottomRatio- 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 cellclientX- The x-coordinate of the dropleftRightRatio- 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 eventroot- 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 asisCaption(Widget)but also returns true for Vaadin widgets that do not have a caption likeButtonandLink- 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 toDragAndDropAwareState'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
-