JIDE 3.5.15

com.jidesoft.list
Class ListTransferHandler

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by com.jidesoft.list.ListTransferHandler
All Implemented Interfaces:
Serializable

public class ListTransferHandler
extends TransferHandler

The default TransferHandler for JList.

Since:
3.3.5
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.TransferHandler
TransferHandler.DropLocation, TransferHandler.TransferSupport
 
Field Summary
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
 
Constructor Summary
ListTransferHandler()
          The constructor.
ListTransferHandler(String property)
          The constructor.
 
Method Summary
 boolean canImport(JComponent c, DataFlavor[] flavors)
           
protected  String convertElementToString(JList list, int rowIndex, Object value)
          Converts the element to string.
protected  Object convertStringToElement(JList list, int rowIndex, String text)
          Converts the string to element.
protected  Transferable createTransferable(JComponent c)
          Create a Transferable to use as the source for a data transfer.
protected  void exportDone(JComponent c, Transferable data, int action)
           
 int getSourceActions(JComponent c)
           
 boolean importData(JComponent comp, Transferable t)
           
protected  boolean importString(JComponent c, String str, boolean isLocal)
          Imports from the string.
 boolean isAcceptImport()
          Gets the flag indicating if importing data is accepted in this TransferHandler.
 void setAcceptImport(boolean acceptImport)
          Sets the flag indicating if importing data is accepted in this TransferHandler.
protected  boolean updateRow(JList list, int rowIndex, Object content)
          Deletes a row in the designated row index at the list.
 
Methods inherited from class javax.swing.TransferHandler
canImport, exportAsDrag, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListTransferHandler

public ListTransferHandler(String property)
The constructor.

Parameters:
property - the property

ListTransferHandler

public ListTransferHandler()
The constructor.

Method Detail

createTransferable

protected Transferable createTransferable(JComponent c)
Create a Transferable to use as the source for a data transfer.

Overrides:
createTransferable in class TransferHandler
Parameters:
c - The component holding the data to be transferred. This argument is provided to enable sharing of TransferHandlers by multiple components.
Returns:
The representation of the data to be transferred.

importData

public boolean importData(JComponent comp,
                          Transferable t)
Overrides:
importData in class TransferHandler

canImport

public boolean canImport(JComponent c,
                         DataFlavor[] flavors)
Overrides:
canImport in class TransferHandler

importString

protected boolean importString(JComponent c,
                               String str,
                               boolean isLocal)
Imports from the string.

Parameters:
c - the component
str - the string
isLocal - the flag indicating if it's imported from inside or outside of the same window/frame/dialog of the list
Returns:
true if string is imported. Otherwise false.

updateRow

protected boolean updateRow(JList list,
                            int rowIndex,
                            Object content)
Deletes a row in the designated row index at the list.

To implement DnD behavior for a non-DefaultListModel, please implement this method to remove the row.

Parameters:
list - the list
rowIndex - the row index
content - the row content
Returns:
true if row deleted correctly. Otherwise false.

convertElementToString

protected String convertElementToString(JList list,
                                        int rowIndex,
                                        Object value)
Converts the element to string.

Parameters:
list - the list
rowIndex - the row index
value - the value to convert
Returns:
the converted string.

convertStringToElement

protected Object convertStringToElement(JList list,
                                        int rowIndex,
                                        String text)
Converts the string to element.

Parameters:
list - the list
rowIndex - the row index
text - the string to convert
Returns:
the converted element.

getSourceActions

public int getSourceActions(JComponent c)
Overrides:
getSourceActions in class TransferHandler

exportDone

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

isAcceptImport

public boolean isAcceptImport()
Gets the flag indicating if importing data is accepted in this TransferHandler.

Returns:
true if importing data is accepted. Otherwise false.
See Also:
setAcceptImport(boolean)

setAcceptImport

public void setAcceptImport(boolean acceptImport)
Sets the flag indicating if importing data is accepted in this TransferHandler.

By default, the flag is false to avoid accepting data importing.

Parameters:
acceptImport - the flag

JIDE 3.5.15