JIDE 3.5.15

com.jidesoft.grid
Class JideTableTransferHandler

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by com.jidesoft.grid.JideTableTransferHandler
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ContextSensitiveTableTransferHandler

public class JideTableTransferHandler
extends TransferHandler

Default TransferHandler for JideTable which supports import data by default.

This transfer handler does not support drag to insert column feature, i.e., DropMode.INSERT_COLS and DropMode.ON_OR_INSERT_COLS.

Since:
3.3.4
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
JideTableTransferHandler()
           
JideTableTransferHandler(String property)
           
 
Method Summary
 boolean canImport(JComponent c, DataFlavor[] flavors)
           
protected  String convertElementToString(JTable table, int rowIndex, int columnIndex, Object value)
          Converts the element to string.
protected  Object convertStringToElement(JTable table, int rowIndex, int columnIndex, 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.
protected  boolean insertRow(JTable table, int rowIndex, Vector<Object> rowData)
          Deprecated. no longer get invoked.
 boolean isAcceptImport()
          Gets the flag indicating if importing data is accepted in this TransferHandler.
protected  boolean removeRow(JTable table, int rowIndex)
          Deprecated. no longer get invoked
 void setAcceptImport(boolean acceptImport)
          Sets the flag indicating if importing data is accepted in this TransferHandler.
 
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

JideTableTransferHandler

public JideTableTransferHandler(String property)

JideTableTransferHandler

public JideTableTransferHandler()
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 table
Returns:
true if string is imported. Otherwise false.

insertRow

@Deprecated
protected boolean insertRow(JTable table,
                                       int rowIndex,
                                       Vector<Object> rowData)
Deprecated. no longer get invoked.

Inserts a row in the designated row index at the table.

The method importString(javax.swing.JComponent, String, boolean) relies on this method to insert a new row if necessary.

To implement DnD behavior for a non-DefaultTableModel, please implement this method to insert a row.

Parameters:
table - the table
rowIndex - the row index
rowData - the row data
Returns:
true if row inserted correctly. Otherwise false.

removeRow

@Deprecated
protected boolean removeRow(JTable table,
                                       int rowIndex)
Deprecated. no longer get invoked

Deletes a row in the designated row index at the table.

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

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

convertElementToString

protected String convertElementToString(JTable table,
                                        int rowIndex,
                                        int columnIndex,
                                        Object value)
Converts the element to string.

Parameters:
table - the table
rowIndex - the row index
columnIndex - the column index
value - the value to convert
Returns:
the converted string.

convertStringToElement

protected Object convertStringToElement(JTable table,
                                        int rowIndex,
                                        int columnIndex,
                                        String text)
Converts the string to element.

Parameters:
table - the table
rowIndex - the row index
columnIndex - the column 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