com.nqadmin.swingSet
Class SSTableKeyAdapter

java.lang.Object
  extended by java.awt.event.KeyAdapter
      extended by com.nqadmin.swingSet.SSTableKeyAdapter
All Implemented Interfaces:
java.awt.event.KeyListener, java.io.Serializable, java.util.EventListener

public class SSTableKeyAdapter
extends java.awt.event.KeyAdapter
implements java.io.Serializable

SSTableKeyAdapter.java

SwingSet - Open Toolkit For Making Swing Controls Database-Aware

 Key adapter for JTable & SSDataGrid that manages cut & paste functionality
 between a table and either another table or a spreadsheet.

Version:
$Revision: 1.8 $
Author:
$Author: prasanth $
See Also:
Serialized Form

Field Summary
protected  boolean allowInsertion
          Indicates whether or not row insertions are allowed via cut/copy & paste.
protected  boolean forSSDataGrid
          Indicates row used for insertion in SSDataGrid.
protected  int offMask
          Off state for copying or pasting.
protected  int onMask
          On state for copying or pasting.
 
Constructor Summary
SSTableKeyAdapter(javax.swing.JTable _jTable)
          Constructs a KeyAdapter for the JTable.
 
Method Summary
protected  java.lang.Object getObjectToSet(javax.swing.JTable _jTable, int _column, java.lang.String _value)
          Takes the column number and string value to be set for that column and converts the string in to appropriate class.
protected  void init(javax.swing.JTable _jTable)
          Adds the key listener for the specified JTable.
 void keyReleased(java.awt.event.KeyEvent ke)
          Invoked when a key is released.
 void setAllowInsertion(boolean _allowInsertion)
          Sets allowInsertion indicator.
 void setForSSDataGrid(boolean _forSSDataGrid)
          Sets forSSDataGrid indicator.
 
Methods inherited from class java.awt.event.KeyAdapter
keyPressed, keyTyped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

onMask

protected int onMask
On state for copying or pasting.


offMask

protected int offMask
Off state for copying or pasting.


allowInsertion

protected boolean allowInsertion
Indicates whether or not row insertions are allowed via cut/copy & paste.


forSSDataGrid

protected boolean forSSDataGrid
Indicates row used for insertion in SSDataGrid.

Constructor Detail

SSTableKeyAdapter

public SSTableKeyAdapter(javax.swing.JTable _jTable)
Constructs a KeyAdapter for the JTable.

Parameters:
_jTable - JTable for which copy and paste support should be added.
Method Detail

setAllowInsertion

public void setAllowInsertion(boolean _allowInsertion)
Sets allowInsertion indicator. Set true if new rows can be added to JTable via cut/copy & paste - otherwise false. False by default.

Parameters:
_allowInsertion - true if new rows can be added when pasting data from clipboard, else false.

setForSSDataGrid

public void setForSSDataGrid(boolean _forSSDataGrid)
Sets forSSDataGrid indicator. True if the key adapter is used for SSDataGrid -- otherwise false. False by default.

Parameters:
_forSSDataGrid - - true if this key adapter is used for SSDataGrid, else false.

init

protected void init(javax.swing.JTable _jTable)
Adds the key listener for the specified JTable.


keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Invoked when a key is released.

Specified by:
keyReleased in interface java.awt.event.KeyListener
Overrides:
keyReleased in class java.awt.event.KeyAdapter

getObjectToSet

protected java.lang.Object getObjectToSet(javax.swing.JTable _jTable,
                                          int _column,
                                          java.lang.String _value)
                                   throws java.lang.Exception
Takes the column number and string value to be set for that column and converts the string in to appropriate class. The class is found by calling the getColumnClass() method of the JTable.

Parameters:
_jTable - JTable containing target object
_column - the column number for which new value has to be set.
_value - string representation of the new value.
Returns:
returns the value as a column class object.
Throws:
java.lang.Exception