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 instanceV- The Value type that is being transferred
- All Implemented Interfaces:
Serializable
A generalized
TransferHandler that supports moving data to itself as well as another indexable
component.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.TransferHandler
TransferHandler.DropLocation, TransferHandler.TransferSupport -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final javax.activation.ActivationDataFlavorprotected final com.fishlib.io.logger.Loggerprotected final TA reference to the component this transfer handler is attached to.Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE -
Constructor Summary
ConstructorsConstructorDescriptionRearrangingTransferHandler(T myself, IntFunction<V[]> arrayFactory, com.fishlib.io.logger.Logger log) Create a RearangingTransferHandler. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidAdd an item to the backing collection.booleancanImport(TransferHandler.TransferSupport support) protected voiddoRearrange(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.protected voidexportDone(JComponent source, Transferable data, int action) protected abstract intGet an integer index for the drop location of the backing collection given the support object.protected abstract intGet the count of items contained within the collection being transferred to.protected abstract VgetValueAt(int index) Get the value at the specified index in the backing collection.booleanprotected abstract voidremoveItem(int index) Remove the item from the backing collection at the specified index.Methods inherited from class javax.swing.TransferHandler
canImport, createTransferable, exportAsDrag, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, getSourceActions, getVisualRepresentation, importData, setDragImage, setDragImageOffset
-
Field Details
-
DATA_FLAVOR
protected static final javax.activation.ActivationDataFlavor DATA_FLAVOR -
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 toarrayFactory- a factory method for creating arrays of the underlying typelog- a logger
-
-
Method Details
-
importData
- Overrides:
importDatain classTransferHandler
-
canImport
- Overrides:
canImportin classTransferHandler
-
doRearrange
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 importsupport- the support object3
-
exportDone
- Overrides:
exportDonein classTransferHandler
-
addItem
Add an item to the backing collection.- Parameters:
o- the item to addi- 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
Get the value at the specified index in the backing collection.- Parameters:
index- the index- Returns:
- the value at 'index'
-
getDropLocation
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
-