Class TransferHandler

java.lang.Object
vaadinx.swing.TransferHandler
All Implemented Interfaces:
Serializable

public class TransferHandler extends Object implements Serializable
Emulator for TransferHandler. Reproduces the Swing transfer-handler API surface against vaadinx.* component types so import-swapped code subclasses it unchanged. The default (un-subclassed) handler exports/imports nothing — the JDK's property-backed cut/copy/paste default is drop-and-WARN per R_vaadin_first (D_drag_and_drop accepted limitations).
See Also:
  • Field Details

  • Constructor Details

    • TransferHandler

      public TransferHandler()
      Convenience handler with no property-backed default behaviour.
    • TransferHandler

      public TransferHandler(String property)
      Property-backed handler. The JDK builds a default Transferable from the named bean property for cut/copy/paste; we store the name for API fidelity but the property-backed default is drop-and-WARN (D_drag_and_drop).
  • Method Details

    • getSourceActions

      public int getSourceActions(JComponent c)
      Bitwise-OR of the actions (COPY, MOVE, LINK) supported when exporting from c. Default NONE; the property-backed ctor reports COPY.
    • createTransferable

      protected Transferable createTransferable(JComponent c)
      Builds the Transferable representing c's current data for export. Default null (nothing to export). Subclasses override.
    • exportDone

      protected void exportDone(JComponent source, Transferable data, int action)
      Invoked after an export completes (successfully or not) with the action that was performed. MOVE is the source's cue to delete the moved data. Default no-op; subclasses override.
    • canImport

      public boolean canImport(TransferHandler.TransferSupport support)
      Whether a drop/paste described by support can be imported. Default false. Subclasses override.
    • canImport

      @Deprecated public boolean canImport(JComponent comp, DataFlavor[] transferFlavors)
      Deprecated.
      array form retained for API compatibility; the TransferHandler.TransferSupport form is canonical.
    • importData

      public boolean importData(TransferHandler.TransferSupport support)
      Performs the import described by support, returning whether it succeeded. Default false. Subclasses override.
    • importData

      @Deprecated public boolean importData(JComponent comp, Transferable t)
      Deprecated.
      component+transferable form retained for API compatibility.
    • exportAsDrag

      public void exportAsDrag(JComponent comp, InputEvent e, int action)
      Initiates a drag of comp's data. In Swing this is called from a component's UI on a drag gesture; here the browser drag gesture drives the Vaadin DragSource which calls createTransferable(JComponent) directly, so this entry point is rarely used by migrated code. Best-effort R_best_effort_behaviour: it records the export so a subsequent programmatic flow sees consistent state, but the actual gesture originates in the browser.
    • exportToClipboard

      public void exportToClipboard(JComponent comp, Clipboard clip, int action)
      Exports comp's data to clip. Bridges to the same WebClipboard the clipboard slice (D_clipboard) installs.
    • getDragImageOffset

      public Point getDragImageOffset()
      Returns:
      a fresh copy, (0, 0) until something sets an offset — as the JDK does
    • setDragImageOffset

      public void setDragImageOffset(Point p)
      Stores the offset; the browser renders its own drag image, which is the effect R_decline_effect_only permits dropping.
      Throws:
      NullPointerException - on a null offset, which is what the JDK's own new Point(p.x, p.y) does to it