com.sas.swing.adapters
Class JTableClipboardAdapter

com.sas.swing.adapters.JTableClipboardAdapter
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener
Direct Known Subclasses:
TableViewClipboardAdapter

public class JTableClipboardAdapter
implements java.awt.event.ActionListener

JTableClipboardAdapter enables Cut-Copy-Paste Clipboard functionality on JTables. The clipboard data format used by the adapter is compatible with the clipboard format used by Excel. This provides for clipboard interoperability between enabled JTables and Excel. Security access to the system clipboard must be available in order for this adapter to work.


Field Summary
protected static java.awt.datatransfer.Clipboard clipboard
           
protected static java.text.DateFormat df
           
static java.lang.String RB_KEY
           
protected  java.awt.datatransfer.StringSelection stringSelection
           
protected  javax.swing.JTable table
           
static int UPDATE_MODE
           
static int VALIDATE_MODE
           
 
Constructor Summary
JTableClipboardAdapter(javax.swing.JTable table)
          The JTableClipboardAdapter is constructed with a JTable on which it enables Cut-Copy-Paste and acts as a Clipboard listener.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method is activated on the Keystrokes we are listening to in this implementation.
protected  void append(java.lang.StringBuffer sbf, java.lang.Object value, boolean appendFlag)
           
protected  void copyCellsToClipboard(boolean replace, java.lang.String replaceString)
           
 void copySelectedCells()
           
 void cutSelectedCells()
           
protected  void displayCutError(java.lang.Object value, int row, int col)
           
protected  void displayPasteError(java.lang.Object value, int row, int col)
           
protected static java.awt.datatransfer.Clipboard getClipboard()
           
 javax.swing.JTable getTable()
          Public Accessor methods for the Table on which this adapter acts.
 com.sas.util.transforms.TransformInterface getTransform()
          Returns the TransformInterface that is used to convert the value from the model into text to be displayed.
protected static java.util.List parseContents(java.lang.String textGrid)
           
 void pasteSelectedCells()
           
protected  java.lang.Object replaceNull(java.lang.Object value)
           
protected  boolean setOrValidateValue(java.lang.Object value, int row, int col, int validateUpdateMode)
           
 void setTable(javax.swing.JTable table)
           
 void setTransform(com.sas.util.transforms.TransformInterface newTransform)
          Sets the new transform to use for converting values from the model into displayable text.
protected  java.lang.Object transform(java.lang.Object value)
           
 

Field Detail

clipboard

protected static java.awt.datatransfer.Clipboard clipboard

stringSelection

protected java.awt.datatransfer.StringSelection stringSelection

table

protected javax.swing.JTable table

df

protected static java.text.DateFormat df

VALIDATE_MODE

public static final int VALIDATE_MODE
See Also:
Constant Field Values

UPDATE_MODE

public static final int UPDATE_MODE
See Also:
Constant Field Values

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

JTableClipboardAdapter

public JTableClipboardAdapter(javax.swing.JTable table)
The JTableClipboardAdapter is constructed with a JTable on which it enables Cut-Copy-Paste and acts as a Clipboard listener.

Method Detail

getClipboard

protected static java.awt.datatransfer.Clipboard getClipboard()

getTable

public javax.swing.JTable getTable()
Public Accessor methods for the Table on which this adapter acts.


setTable

public void setTable(javax.swing.JTable table)

setTransform

public void setTransform(com.sas.util.transforms.TransformInterface newTransform)
Sets the new transform to use for converting values from the model into displayable text. By default, the renderer uses the com.sas.util.transforms.ObjectToStringTransform class.

Parameters:
newTransform - the new transform to use

getTransform

public com.sas.util.transforms.TransformInterface getTransform()
Returns the TransformInterface that is used to convert the value from the model into text to be displayed. By default, the renderer uses the com.sas.util.transforms.ObjectToStringTransform class.

Returns:
the transform to use for converting values into displayable text

copySelectedCells

public void copySelectedCells()

cutSelectedCells

public void cutSelectedCells()

copyCellsToClipboard

protected void copyCellsToClipboard(boolean replace,
                                    java.lang.String replaceString)

append

protected void append(java.lang.StringBuffer sbf,
                      java.lang.Object value,
                      boolean appendFlag)

setOrValidateValue

protected boolean setOrValidateValue(java.lang.Object value,
                                     int row,
                                     int col,
                                     int validateUpdateMode)

transform

protected java.lang.Object transform(java.lang.Object value)

replaceNull

protected java.lang.Object replaceNull(java.lang.Object value)

pasteSelectedCells

public void pasteSelectedCells()

parseContents

protected static java.util.List parseContents(java.lang.String textGrid)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method is activated on the Keystrokes we are listening to in this implementation. Here it listens for Copy and Paste ActionCommands. Selections comprising non-adjacent cells result in invalid selection and then copy action cannot be performed. Paste is done by aligning the upper left corner of the selection with the 1st element in the current selection of the JTable.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

displayCutError

protected void displayCutError(java.lang.Object value,
                               int row,
                               int col)

displayPasteError

protected void displayPasteError(java.lang.Object value,
                                 int row,
                                 int col)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.