Class RearrangingTransferHandler<T extends Component,V>

java.lang.Object
javax.swing.TransferHandler
com.illumon.iris.gui.widget.dragndrop.RearrangingTransferHandler<T,V>
Type Parameters:
T - The component type for the instance
V - The Value type that is being transferred
All Implemented Interfaces:
Serializable

public abstract class RearrangingTransferHandler<T extends Component,V> extends TransferHandler
A generalized TransferHandler that supports moving data to itself as well as another indexable component.
See Also:
  • Field Details

    • DATA_FLAVOR

      protected static final javax.activation.ActivationDataFlavor DATA_FLAVOR
    • myself

      protected final T extends Component myself
      A reference to the component this transfer handler is attached to.
    • log

      protected final com.fishlib.io.logger.Logger log
  • Constructor Details

    • RearrangingTransferHandler

      public RearrangingTransferHandler(T myself, IntFunction<V[]> arrayFactory, com.fishlib.io.logger.Logger log)
      Create a RearangingTransferHandler.
      Parameters:
      myself - The Component that this transfer handler will be attached to
      arrayFactory - a factory method for creating arrays of the underlying type
      log - a logger
  • Method Details

    • importData

      public boolean importData(TransferHandler.TransferSupport support)
      Overrides:
      importData in class TransferHandler
    • canImport

      public boolean canImport(TransferHandler.TransferSupport support)
      Overrides:
      canImport in class TransferHandler
    • doRearrange

      protected void doRearrange(SourceAndIndices data, TransferHandler.TransferSupport support)
      If the source and target for the DnD operation is the same object we will do the entire rearrange operation in one go, and forego the cleanup step.
      Parameters:
      data - the data to import
      support - the support object3
    • exportDone

      protected void exportDone(JComponent source, Transferable data, int action)
      Overrides:
      exportDone in class TransferHandler
    • addItem

      protected abstract void addItem(V o, int i)
      Add an item to the backing collection.
      Parameters:
      o - the item to add
      i - the index to add it at
    • removeItem

      protected abstract void removeItem(int index)
      Remove the item from the backing collection at the specified index.
      Parameters:
      index - the index to remove
    • getValueAt

      protected abstract V getValueAt(int index)
      Get the value at the specified index in the backing collection.
      Parameters:
      index - the index
      Returns:
      the value at 'index'
    • getDropLocation

      protected abstract int getDropLocation(TransferHandler.TransferSupport support)
      Get an integer index for the drop location of the backing collection given the support object.
      Parameters:
      support - the support object
      Returns:
      the drop location in the backing collection
    • getItemCount

      protected abstract int getItemCount()
      Get the count of items contained within the collection being transferred to.
      Returns:
      the number of items in the collection being transferred to