Interface DropTarget<T extends Component>

    • Method Detail

      • configure

        static <T extends ComponentDropTarget<T> configure​(T component,
                                                             boolean active)
        Gives access to the generic drop target API for the given component and either activates or deactivates the drop target.

        This method is a shorthand for calling configure(Component) and setActive(boolean).

        The drop target active state can be changed at any time with setActive(boolean).

        Type Parameters:
        T - the type of the component
        Parameters:
        component - the component to provide drop target API for
        active - true to set the component as an active drop target, false for not
        Returns:
        the drop target API for the component
        See Also:
        create(Component), configure(Component)
      • getDropTargetComponent

        default T getDropTargetComponent()
        Returns the drop target component. This component is used in the drop event as the source, and its element is made as a drop target by default.

        The default implementation of this method returns this. This method exists for type safe access for the drop target component and being able to provide access to drop target API for any component.

        Returns:
        the drop target component
      • getElement

        default Element getElement()
        Returns the element which is made as a drop target in the UI. By default it is the element of the component returned by getDropTargetComponent().
        Specified by:
        getElement in interface HasElement
        Returns:
        the element that is a drop target
      • setActive

        default void setActive​(boolean active)
        Activate or deactivate this drop target. By default, it is not active.
        Parameters:
        active - true to allow drops, false to not
      • isActive

        default boolean isActive()
        Gets whether this drop target is activate or not. By default, it is not.
        Returns:
        true to allow drops, false to not
      • setDropEffect

        default void setDropEffect​(DropEffect dropEffect)
        Sets the drop effect for the current drop target. This is set to the dropEffect on dragenter, dragover and drop events and needs to match the effectAllowed property for the drag operation.

        NOTE: If the drop effect that doesn't match the effectAllowed of the drag source, it DOES NOT prevent drop on IE11 and Safari! For FireFox and Chrome the drop is prevented if the properties don't match.

        Parameters:
        dropEffect - the drop effect to be set or null to not modify
        See Also:
        MDN web docs for more information.
      • getDropEffect

        default DropEffect getDropEffect()
        Returns the drop effect for the current drop target.
        Returns:
        The drop effect of this drop target or null if none set
        See Also:
        setDropEffect(DropEffect)
      • addDropListener

        default Registration addDropListener​(ComponentEventListener<DropEvent<T>> listener)
        Attaches drop listener for the component this maps to. The listener is triggered when the user performs a drop operation on the client side, and the criteria set with setDropEffect(DropEffect) matches a one set for the drag operation (see DragSource.setEffectAllowed(EffectAllowed)).

        NOTE: the drop listener might be triggered for a drop inside another drop target that is inside this drop target component! For this, the setActive(boolean) does not have effect.

        Parameters:
        listener - Listener to handle drop event.
        Returns:
        Handle to be used to remove this listener.