com.vaadin.client.extensions.

Class DropTargetExtensionConnector

    • Field Detail

      • STYLE_SUFFIX_DRAG_CENTER

        protected static final String STYLE_SUFFIX_DRAG_CENTER

        Style name suffix for dragging data over the center of the drop target.

        See Also:

        Constant Field Values

      • STYLE_SUFFIX_DRAG_TOP

        protected static final String STYLE_SUFFIX_DRAG_TOP

        Style name suffix for dragging data over the top part of the drop target.

        See Also:

        Constant Field Values

      • STYLE_SUFFIX_DRAG_BOTTOM

        protected static final String STYLE_SUFFIX_DRAG_BOTTOM

        Style name suffix for dragging data over the bottom part of the drop target.

        See Also:

        Constant Field Values

      • STYLE_SUFFIX_DROPTARGET

        protected static final String STYLE_SUFFIX_DROPTARGET

        Style name suffix for indicating that the element is drop target.

        See Also:

        Constant Field Values

    • Constructor Detail

      • DropTargetExtensionConnector

        public DropTargetExtensionConnector()
    • Method Detail

      • extend

        protected void extend​(ServerConnector target)

        Description copied from class: AbstractExtensionConnector

        Called when the extension is attached to its parent. This method is only called once as an extension cannot be moved from one parent to another.

        Specified by:

        extend in class AbstractExtensionConnector

        Parameters:

        target - The connector this extension extends

      • getDropTargetElement

        protected com.google.gwt.dom.client.Element getDropTargetElement()

        Finds the drop target element within the widget. By default, returns the topmost element.

        Returns:

        the drop target element in the parent widget.

      • onDragEnter

        protected void onDragEnter​(elemental.events.Event event)

        Event handler for the dragenter event.

        Override this method in case custom handling for the dragstart event is required. If the drop is allowed, the event should prevent default.

        Parameters:

        event - browser event to be handled

      • onDragOver

        protected void onDragOver​(elemental.events.Event event)

        Event handler for the dragover event.

        Override this method in case custom handling for the dragover event is required. If the drop is allowed, the event should prevent default.

        Parameters:

        event - browser event to be handled

      • onDragLeave

        protected void onDragLeave​(elemental.events.Event event)

        Event handler for the dragleave event.

        Override this method in case custom handling for the dragleave event is required.

        Parameters:

        event - browser event to be handled

      • onDrop

        protected void onDrop​(elemental.events.Event event)

        Event handler for the drop event.

        Override this method in case custom handling for the drop event is required. If the drop is allowed, the event should prevent default.

        Parameters:

        event - browser event to be handled

      • isDropAllowedByCriteriaScript

        protected boolean isDropAllowedByCriteriaScript​(com.google.gwt.dom.client.NativeEvent event)

        Checks if a criteria script exists and, if yes, executes it. This method is protected, so subclasses as e.g. GridDropTargetConnector can override it to add additional script parameters.

        Parameters:

        event - browser event (dragEnter, dragOver, drop) that should be evaluated by the criteria script

        Returns:

        true if no script was given or if the script returned true, false otherwise.

      • sendDropEventToServer

        protected void sendDropEventToServer​(List<String> types,
                                             Map<String,​String> data,
                                             String dropEffect,
                                             com.google.gwt.dom.client.NativeEvent dropEvent)

        Initiates a server RPC for the drop event.

        Parameters:

        types - List of data types from DataTransfer.types object.

        data - Map containing all types and corresponding data from the DataTransfer object.

        dropEffect - The desired drop effect.

      • addDropTargetStyle

        protected void addDropTargetStyle()

        Add class name for the drop target element indicating that data can be dropped onto it. The class name has the following format:

             [primaryStyleName]-droptarget
         
        The added class name is update automatically by the framework when the primary style name changes.

      • removeDropTargetStyle

        protected void removeDropTargetStyle()

        Remove class name from the drop target element indication that data can be dropped onto it.

      • addDragOverStyle

        protected void addDragOverStyle​(com.google.gwt.dom.client.NativeEvent event)

        Add class that indicates that the component is a target while data is being dragged over it.

        This is triggered on dragenter and dragover events pending if the drop is possible. The drop is possible if the drop effect for the target and source do match and the drop criteria script evaluates to true or is not set.

        Parameters:

        event - the dragenter or dragover event that triggered the indication.

      • removeDragOverStyle

        protected void removeDragOverStyle​(com.google.gwt.dom.client.NativeEvent event)

        Remove the drag over indicator class name from the target element.

        This is triggered on drop, dragleave and dragover events pending on whether the drop has happened or if it is not possible. The drop is not possible if the drop effect for the source and target don't match or if there is a drop criteria script that evaluates to false.

        Parameters:

        event - the event that triggered the removal of the indicator