JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table
Class EditTraverseHandlerAbstract

java.lang.Object
  |
  +--com.klg.jclass.table.EditTraverseHandlerAbstract
All Implemented Interfaces:
EditTraverseHandler, EventListener, FocusListener, JCCellEditorListener, Serializable
Direct Known Subclasses:
EditTraverseHandlerNew, EditTraverseHandlerOld

public abstract class EditTraverseHandlerAbstract
extends Object
implements EditTraverseHandler, FocusListener, JCCellEditorListener, Serializable

EditTraverseHandlerOld controls the cell traversal and editor display/commit/cancel logic for JDK's prior to 1.4. It also fires TraverseCell and EditCell events as required.

See Also:
Serialized Form

Field Summary
protected  Component component
           
protected  int edit_column
           
protected  int edit_row
           
protected  com.klg.jclass.cell.JCCellEditor editor
           
protected  com.klg.jclass.table.JCTable table
           
 
Fields inherited from interface com.klg.jclass.table.EditTraverseHandler
DOWN, HORIZONTAL, LEFT, RIGHT, UP, VERTICAL
 
Constructor Summary
EditTraverseHandlerAbstract(com.klg.jclass.table.JCTable table)
          Constructor that requires a table
 
Method Summary
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)
           
protected  boolean cancel()
          Cancels the current edit on the given table, if an edit is in progress
 boolean cancel(boolean hide)
          Cancels the current edit on the given table, if an edit is in progress
 void checkAndReparentEditor()
          Check to see if editor component needs reparenting.
protected  boolean commit()
          Commits the current edit on the given table, if an edit is in progress
 boolean commit(boolean hide)
          Commits the current edit on the table.
protected  boolean commit(boolean hide, boolean stop)
          Commits the current edit on the table.
protected  void commitAndTraverse(int direction)
          Commits the edit and attempts a traversal in the given direction.
 void editingCanceled(com.klg.jclass.cell.JCCellEditorEvent event)
          The JCCellEditor calls cancelEdit() to cancel and undo an edit; for example, when the user presses Esc.
 void editingStopped(com.klg.jclass.cell.JCCellEditorEvent event)
          The JCCellEditor posts EditingStopped when it is done editing.
abstract  void focusGained(FocusEvent event)
          Reset the old focus owner for this focus period
abstract  void focusLost(FocusEvent event)
          Sets the table as a focused component when the editor loses permanent focus.
 com.klg.jclass.cell.JCCellEditor getCellEditor()
          Returns the current cell editor.
 int getEditColumn()
          Get the column of the current cell being edited.
 int getEditRow()
          Get the row of the current cell being edited.
 Component getFocusableChild(Component c)
          Return the component if it is focusable, otherwise the first kid which is focusable.
 void initializeEditor(AWTEvent e, com.klg.jclass.table.TableCellInfoModel cellInfo, Object o)
          Initialize the editor based on a cellInfo object and data.
protected  boolean isValidCell(int row, int column)
          Returns true the given row and column is a valid cell.
 void move(int direction, int value)
          Move the component.
protected  void removeEditor()
          Removes the edit component from table.
 void repositionEditor()
          Repositions the editor.
 void setCellEditor(com.klg.jclass.cell.JCCellEditor ed)
          Sets the cell editor.
 void setFocusOnEditor()
          Set focus on the component if it is focusable or to the first focusable child.
protected  void setFocusOnEditor(Component editComponent)
          Set focus on the component if it is focusable or to the first focusable child.
 void setHeight(int value)
          Sets the height of the edit component.
protected  boolean setValues(com.klg.jclass.table.CellArea area, int row, int column, Rectangle size)
          Sets the bounds of the editor for the given cell.
protected  boolean setValues(int row, int column, Rectangle size)
          Set attributes, first determining cell's editability.
 void setWidth(int value)
          Sets the width of the edit component.
protected  void signalError()
          Executes a beep to signal an error.
 boolean traverse(int row, int column, boolean select, AWTEvent event, int traverse_type, boolean show_editor)
          Traverse to the specified cell.
 void traverseInitial()
          Traverses to the top-left cell.
protected  boolean traverseInitial(int row, int column, boolean select, int traverse_type)
          Returns false if the cell is not traversable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected com.klg.jclass.table.JCTable table

editor

protected com.klg.jclass.cell.JCCellEditor editor

component

protected Component component

edit_row

protected int edit_row

edit_column

protected int edit_column
Constructor Detail

EditTraverseHandlerAbstract

public EditTraverseHandlerAbstract(com.klg.jclass.table.JCTable table)
Constructor that requires a table

Parameters:
table - The table for which this EditTraverseHandler is used.
Method Detail

getCellEditor

public com.klg.jclass.cell.JCCellEditor getCellEditor()
Returns the current cell editor.

Specified by:
getCellEditor in interface EditTraverseHandler
Returns:
The current cell editor. Returns null if none.

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)

setCellEditor

public void setCellEditor(com.klg.jclass.cell.JCCellEditor ed)
Sets the cell editor.

Specified by:
setCellEditor in interface EditTraverseHandler
Parameters:
ed - The new cell editor

getEditRow

public int getEditRow()
Get the row of the current cell being edited.

Specified by:
getEditRow in interface EditTraverseHandler
Returns:
The current edit row

getEditColumn

public int getEditColumn()
Get the column of the current cell being edited.

Specified by:
getEditColumn in interface EditTraverseHandler
Returns:
The current edit column

initializeEditor

public void initializeEditor(AWTEvent e,
                             com.klg.jclass.table.TableCellInfoModel cellInfo,
                             Object o)
Initialize the editor based on a cellInfo object and data. Note that this method is overridden in EditTraverseHandlerNew

Parameters:
e - The event which caused the editor to be invoked
cellInfo - The table cell information
o - The data object

traverse

public boolean traverse(int row,
                        int column,
                        boolean select,
                        AWTEvent event,
                        int traverse_type,
                        boolean show_editor)
Traverse to the specified cell.

Specified by:
traverse in interface EditTraverseHandler
Parameters:
row - The row to which to traverse
column - The column to which to traverse
select - Should the cell be selected
event - The event that caused this traverse (null if none)
traverse_type - The type of traversal (right, left, down, up, home, ...)
show_editor - Display the component, if called programatically
Returns:
false if the cell is not traversable

traverseInitial

public void traverseInitial()
Traverses to the top-left cell.

Specified by:
traverseInitial in interface EditTraverseHandler

traverseInitial

protected boolean traverseInitial(int row,
                                  int column,
                                  boolean select,
                                  int traverse_type)
Returns false if the cell is not traversable. This method posts JCTraverseCell events to registered listeners.

Parameters:
row - The row to which to traverse
column - The column to which to traverse
select - Should the cell be selected
traverse_type - The type of traversal (right, left, down, up, home, ...)
Returns:
Whether intial part of traverse succeeded

isValidCell

protected boolean isValidCell(int row,
                              int column)
Returns true the given row and column is a valid cell.

Parameters:
row - The row of the cell
column - The column of the cell
Returns:
Whether cell is valid or not

setValues

protected boolean setValues(int row,
                            int column,
                            Rectangle size)
Set attributes, first determining cell's editability.

Parameters:
row - The row of the cell
column - The column of the cell
size - The size to which the component is set
Returns:
Whether setValues succeeded

setValues

protected boolean setValues(com.klg.jclass.table.CellArea area,
                            int row,
                            int column,
                            Rectangle size)
Sets the bounds of the editor for the given cell.

Parameters:
area - The CellArea of the cell to be resized
row - The row of the cell
column - The column of the cell
size - The size to which the component is set
Returns:
Whether setValues succeeded

checkAndReparentEditor

public void checkAndReparentEditor()
Check to see if editor component needs reparenting. Reparenting is needed if the CellArea objects have changed boundaries around the cell the editor is in.

Specified by:
checkAndReparentEditor in interface EditTraverseHandler

setWidth

public void setWidth(int value)
Sets the width of the edit component.

Specified by:
setWidth in interface EditTraverseHandler
Parameters:
value - The new width

setHeight

public void setHeight(int value)
Sets the height of the edit component.

Specified by:
setHeight in interface EditTraverseHandler
Parameters:
value - The new height

repositionEditor

public void repositionEditor()
Repositions the editor.

Specified by:
repositionEditor in interface EditTraverseHandler

move

public void move(int direction,
                 int value)
Move the component.

Specified by:
move in interface EditTraverseHandler
Parameters:
direction - The direction of movement, horizontal or vertical
value - The amount in pixels of movement

signalError

protected void signalError()
Executes a beep to signal an error.


cancel

protected boolean cancel()
Cancels the current edit on the given table, if an edit is in progress

Returns:
Whether cancel succeeded

cancel

public boolean cancel(boolean hide)
Cancels the current edit on the given table, if an edit is in progress

Specified by:
cancel in interface EditTraverseHandler
Parameters:
hide - determines whether the editor is hidden after the commit.
Returns:
Whether cancel succeeded

commit

protected boolean commit()
Commits the current edit on the given table, if an edit is in progress

Returns:
Whether commit succeeded

commit

public boolean commit(boolean hide)
Commits the current edit on the table.

Specified by:
commit in interface EditTraverseHandler
Parameters:
hide - Determines whether the editor is hidden after the commit.
Returns:
Whether commit succeeded

commit

protected boolean commit(boolean hide,
                         boolean stop)
Commits the current edit on the table.

Parameters:
hide - Determines whether the editor is hidden after the commit.
stop - Determines whether the editor should be told to stop editing. Set to false if the editor is originator for the commit to avoid round-trip.
Returns:
Whether commit succeeded

commitAndTraverse

protected void commitAndTraverse(int direction)
Commits the edit and attempts a traversal in the given direction. If the commit fails, the traversal is not performed.

Parameters:
direction - The direction which to traverse

removeEditor

protected void removeEditor()
Removes the edit component from table.


editingStopped

public void editingStopped(com.klg.jclass.cell.JCCellEditorEvent event)
The JCCellEditor posts EditingStopped when it is done editing. The container then will decide whether to call commit() in the editor.

Specified by:
editingStopped in interface JCCellEditorListener
Parameters:
event - The event which caused us to want editing to stop

editingCanceled

public void editingCanceled(com.klg.jclass.cell.JCCellEditorEvent event)
The JCCellEditor calls cancelEdit() to cancel and undo an edit; for example, when the user presses Esc.

Specified by:
editingCanceled in interface JCCellEditorListener
Parameters:
event - The event which caused us to want editing to be canceled

getFocusableChild

public Component getFocusableChild(Component c)
Return the component if it is focusable, otherwise the first kid which is focusable. If no focusable kids, return the component (we need to use something). Note that this method does not recurse into the children's children.

Specified by:
getFocusableChild in interface EditTraverseHandler
Parameters:
c - The component whose focus or children's focus is being investigated
Returns:
The component or child component which is focusable. Note that if no children are focusable, the original component is returned whether it is focusable or not

setFocusOnEditor

public void setFocusOnEditor()
Set focus on the component if it is focusable or to the first focusable child.

Specified by:
setFocusOnEditor in interface EditTraverseHandler

setFocusOnEditor

protected void setFocusOnEditor(Component editComponent)
Set focus on the component if it is focusable or to the first focusable child.

Parameters:
editComponent - The component or child of component on which to set the focus.

focusGained

public abstract void focusGained(FocusEvent event)
Reset the old focus owner for this focus period

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

focusLost

public abstract void focusLost(FocusEvent event)
Sets the table as a focused component when the editor loses permanent focus.

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

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