JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table
Class ComponentHandler

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--com.klg.jclass.table.JCSeries
                          |
                          +--com.klg.jclass.table.ComponentHandler
All Implemented Interfaces:
Cloneable, Collection, ComponentModel, EventListener, FocusListener, JCScrollListener, KeyListener, List, Moveable, RandomAccess, Serializable, SeriesModel
Direct Known Subclasses:
ComponentHandlerNew, ComponentHandlerOld

public abstract class ComponentHandler
extends JCSeries
implements ComponentModel, Serializable, JCScrollListener, FocusListener, KeyListener

ComponentHandler controls the placement of components within table and ensures that traverse from a component to table or table to component flows across and down the cells or to the left and up for reverse traversal.

See Also:
Serialized Form

Field Summary
protected  boolean adjustBoundsRequired
           
protected  boolean controlDown
           
protected  boolean needsSetParent
           
protected  boolean shiftDown
           
protected  com.klg.jclass.table.JCTable table
           
 
Fields inherited from class com.klg.jclass.table.JCSeries
last_index
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ComponentHandler()
          Creates a new ComponentHandler instance.
ComponentHandler(com.klg.jclass.table.JCTable table)
          Creates new ComponentHandler instance linked to table.
 
Method Summary
 void addComponentsToParent()
          Ensures that all components are added to their appropriate CellArea.
protected  void addKeyAndFocusListeners(Component c, KeyListener keyListener, FocusListener focusListener)
          Add key and focus listeners to component if it is focusable, otherwise add them the first child which is focusable
protected abstract  void addListeners(Component c, KeyListener keyListener, FocusListener focusListener)
           
 void afterScroll(com.klg.jclass.table.JCScrollEvent e)
          Controls the visibility of components when scrolled.
 com.klg.jclass.table.JCCellPosition findPosition(Component c)
          Determines the cell position of the given component.
abstract  void focusGained(FocusEvent event)
          Adds a KeyListener to the component when table is managing component focus.
abstract  void focusLost(FocusEvent event)
          Removes TraverseHandler as a key listener on the component when it loses focus.
protected  int getDirectionFromKeyEvent(KeyEvent event)
          Compute the direction from a KeyEvent.
 com.klg.jclass.table.JCTable getTable()
          Returns the JCTable.
protected  com.klg.jclass.table.JCCellPosition getTablePosition(Component component)
          Get the position of the component within the table.
 boolean isParentSetRequired()
          Returns true if one or more components have not been added to table yet.
abstract  void keyPressed(KeyEvent event)
          Tracks TAB/SHIFT-TAB and keypad arrow keys to control navigation when a component has focus.
 void keyReleased(KeyEvent event)
          Required by KeyListener but not implemented.
 void keyTyped(KeyEvent event)
          Required by KeyListener but not implemented.
 void reconfigureComponents()
          Reconfigure components such that components in visible cells are visible and components in invisible cells are invisible.
 void removeCellComponents()
          Remove components when a span is added.
 void scroll(com.klg.jclass.table.JCScrollEvent e)
          Required by JCScrollListener but not implemented.
 void setDefault(Object value)
          Overrides setDefault in order to add key and focus listeners.
 void setParentSetRequired(boolean value)
          Flags that one or more components do not have a parent yet.
 void setTable(com.klg.jclass.table.JCTable table)
          Sets the JCTable.
 boolean setValue(int row, int column, Object value)
          Overrides setValue in order to add key and focus listeners.
 void traverseNext(com.klg.jclass.table.JCCellPosition cur_pos, int type)
          Traverses to the next cell when a TAB or SHIFT-TAB is detected on the component.
protected  boolean updateTable(Component component)
          Update table to reflect that the passed in component in its cell is now the new current cell (it has focus).
 
Methods inherited from class com.klg.jclass.table.JCSeries
getCellRanges, getDefault, getSeriesValues, getUniqueValues, getValue, moveColumns, moveRows, remapColumns, remapRows, remove, setValue, setValue, shiftColumn, shiftRow, swapColumns, swapRows
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.klg.jclass.table.SeriesModel
getCellRanges, getDefault, getSeriesValues, getUniqueValues, getValue, setValue, setValue
 
Methods inherited from interface com.klg.jclass.table.Moveable
moveColumns, moveRows, remapColumns, remapRows, shiftColumn, shiftRow, swapColumns, swapRows
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

table

protected com.klg.jclass.table.JCTable table

adjustBoundsRequired

protected boolean adjustBoundsRequired

needsSetParent

protected boolean needsSetParent

shiftDown

protected boolean shiftDown

controlDown

protected boolean controlDown
Constructor Detail

ComponentHandler

public ComponentHandler()
Creates a new ComponentHandler instance. setTable must be called to connect the handler to table.


ComponentHandler

public ComponentHandler(com.klg.jclass.table.JCTable table)
Creates new ComponentHandler instance linked to table.

Parameters:
table - The table for this component handler
Method Detail

getTable

public com.klg.jclass.table.JCTable getTable()
Returns the JCTable.

Specified by:
getTable in interface ComponentModel
Returns:
The table for this component handler

setTable

public void setTable(com.klg.jclass.table.JCTable table)
Sets the JCTable.

Specified by:
setTable in interface ComponentModel
Parameters:
table - The new table for this component handler

isParentSetRequired

public boolean isParentSetRequired()
Returns true if one or more components have not been added to table yet.

Specified by:
isParentSetRequired in interface ComponentModel
Returns:
Whether one or more components have not been added to table yet.
See Also:
setParentSetRequired(boolean)

setParentSetRequired

public void setParentSetRequired(boolean value)
Flags that one or more components do not have a parent yet. The appropriate container for components will not be present before table is realized.

Specified by:
setParentSetRequired in interface ComponentModel
Parameters:
value - The new value of parentSetRequired which tells us whether one or more components do not have a parent yet.

addKeyAndFocusListeners

protected void addKeyAndFocusListeners(Component c,
                                       KeyListener keyListener,
                                       FocusListener focusListener)
Add key and focus listeners to component if it is focusable, otherwise add them the first child which is focusable

Parameters:
c - The component to which to add the listeners
keyListener - The key listener to add
focusListener - The focusListener to add

addListeners

protected abstract void addListeners(Component c,
                                     KeyListener keyListener,
                                     FocusListener focusListener)

setDefault

public void setDefault(Object value)
Overrides setDefault in order to add key and focus listeners.

Specified by:
setDefault in interface SeriesModel
Overrides:
setDefault in class JCSeries
Parameters:
value - The component value on which to add listeners.

setValue

public boolean setValue(int row,
                        int column,
                        Object value)
Overrides setValue in order to add key and focus listeners. Setting a null value removes an existing component at this location.

Specified by:
setValue in interface SeriesModel
Overrides:
setValue in class JCSeries
Parameters:
row - The row at which the new component is to be added
column - The column at which the new component is to be added
value - The new component value
Returns:
Whether setValue succeeded.

addComponentsToParent

public void addComponentsToParent()
Ensures that all components are added to their appropriate CellArea.

Specified by:
addComponentsToParent in interface ComponentModel

removeCellComponents

public void removeCellComponents()
Remove components when a span is added. Any components not contained in the span will re-added in CellAreaRenderer.

Specified by:
removeCellComponents in interface ComponentModel

findPosition

public com.klg.jclass.table.JCCellPosition findPosition(Component c)
Determines the cell position of the given component.

Specified by:
findPosition in interface ComponentModel
Parameters:
c - The component whose position we want to find
Returns:
An object which contains the cell position of the component

scroll

public void scroll(com.klg.jclass.table.JCScrollEvent e)
Required by JCScrollListener but not implemented.

Specified by:
scroll in interface JCScrollListener
Parameters:
e - The event which causes the scroll
See Also:
JCScrollEvent.setValue(int)

afterScroll

public void afterScroll(com.klg.jclass.table.JCScrollEvent e)
Controls the visibility of components when scrolled.

Specified by:
afterScroll in interface JCScrollListener
Parameters:
e - The event which caused the scroll

reconfigureComponents

public void reconfigureComponents()
Reconfigure components such that components in visible cells are visible and components in invisible cells are invisible.

Specified by:
reconfigureComponents in interface ComponentModel

getTablePosition

protected com.klg.jclass.table.JCCellPosition getTablePosition(Component component)
Get the position of the component within the table. If the component is not found, trying querying the parent. This is because the event which caused this query could have originated from a child of a component which is not itself focusable.

Parameters:
component - The component whose position we are interested in finding
Returns:
The position of the cell within the table
See Also:
EditTraverseHandler.getFocusableChild(java.awt.Component)

focusGained

public abstract void focusGained(FocusEvent event)
Adds a KeyListener to the component when table is managing component focus. Cancels any edit and cause a traversal to the underlying cell.

Specified by:
focusGained in interface FocusListener
Parameters:
event - The focus event which caused foucs to be gained.

focusLost

public abstract void focusLost(FocusEvent event)
Removes TraverseHandler as a key listener on the component when it loses focus.

Specified by:
focusLost in interface FocusListener
Parameters:
event - The focus event which caused foucs to be lost.

updateTable

protected boolean updateTable(Component component)
Update table to reflect that the passed in component in its cell is now the new current cell (it has focus). The new and old cells must be repainted to reflect this change.

Parameters:
component - The component that has received the focus.
Returns:
Whether the component is allowed to get focus.

getDirectionFromKeyEvent

protected int getDirectionFromKeyEvent(KeyEvent event)
Compute the direction from a KeyEvent.

Parameters:
event - The given key event
Returns:
The computed direction. One of JCTableEnum.TRAVERSE_LEFT, JCTableEnum.TRAVERSE_RIGHT, JCTableEnum.TRAVERSE_UP, JCTableEnum.TRAVERSE_DOWN or JCTableEnum.NOVALUE (on error).

keyPressed

public abstract void keyPressed(KeyEvent event)
Tracks TAB/SHIFT-TAB and keypad arrow keys to control navigation when a component has focus.

Specified by:
keyPressed in interface KeyListener
Parameters:
event - The event from the key press

keyReleased

public void keyReleased(KeyEvent event)
Required by KeyListener but not implemented.

Specified by:
keyReleased in interface KeyListener
Parameters:
event - The event from the key release

keyTyped

public void keyTyped(KeyEvent event)
Required by KeyListener but not implemented.

Specified by:
keyTyped in interface KeyListener
Parameters:
event - The event from the key being typed

traverseNext

public void traverseNext(com.klg.jclass.table.JCCellPosition cur_pos,
                         int type)
Traverses to the next cell when a TAB or SHIFT-TAB is detected on the component.

Parameters:
cur_pos - The current cell position
type - The desired direction in which to move, one of JCTableEnum.TRAVERSE_UP, JCTableEnum.TRAVERSE_DOWN, JCTableEnum.TRAVERSE_LEFT, JCTableEnum.TRAVERSE_RIGHT.

Copyright © 2004 Quest Software Inc..
All rights reserved.