http://www.eteks.com

com.eteks.jeks
Class JeksCellEditor

java.lang.Object
  |
  +--javax.swing.AbstractCellEditor
        |
        +--javax.swing.DefaultCellEditor
              |
              +--com.eteks.jeks.JeksCellEditor
All Implemented Interfaces:
javax.swing.CellEditor, java.io.Serializable, javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor

public class JeksCellEditor
extends javax.swing.DefaultCellEditor

Cell editor for computed and default cells. This editor enables to edit the definition of an expression if the edited value is an instance of JeksExpression.

Since:
Jeks 1.0
Version:
1.0
Author:
Emmanuel Puybaret
See Also:
Serialized Form

Constructor Summary
JeksCellEditor(JeksExpressionParser parser)
          Creates a cell editor.
 
Method Summary
 java.lang.Object getCellEditorValue()
          Returns the table model value edited by this editor.
 java.lang.Object getEditedValue(java.lang.Object value)
          Returns value as an editable object.
 java.lang.Object getModelValue(java.lang.String data, javax.swing.table.TableModel model, JeksCell editingCell)
          Returns an object of the same wrapping class as the string data.
 java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
          Returns the component used to edit cell values.
 boolean stopCellEditing()
           
 
Methods inherited from class javax.swing.DefaultCellEditor
cancelCellEditing, getClickCountToStart, getComponent, getTreeCellEditorComponent, isCellEditable, setClickCountToStart, shouldSelectCell
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, removeCellEditorListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, removeCellEditorListener
 

Constructor Detail

JeksCellEditor

public JeksCellEditor(JeksExpressionParser parser)
Creates a cell editor.
Parameters:
parser - the parser used to parse and compile the cells starting with an assignment operator.
Method Detail

getCellEditorValue

public java.lang.Object getCellEditorValue()
Returns the table model value edited by this editor.
Overrides:
getCellEditorValue in class javax.swing.DefaultCellEditor

stopCellEditing

public boolean stopCellEditing()
Overrides:
stopCellEditing in class javax.swing.DefaultCellEditor

getTableCellEditorComponent

public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table,
                                                      java.lang.Object value,
                                                      boolean isSelected,
                                                      int row,
                                                      int column)
Returns the component used to edit cell values. Overrides getTableCellEditorComponent () to use the value returned by getEditedValue (value) in the editor instead of the table model value itself.
Overrides:
getTableCellEditorComponent in class javax.swing.DefaultCellEditor

getEditedValue

public java.lang.Object getEditedValue(java.lang.Object value)
Returns value as an editable object. If value is an instance of JeksExpression the definition of the expression is returned, if value is a number or a date its localized string representation is returned, otherwise the object value itself is returned.
Parameters:
value - a value of the table model.

getModelValue

public java.lang.Object getModelValue(java.lang.String data,
                                      javax.swing.table.TableModel model,
                                      JeksCell editingCell)
Returns an object of the same wrapping class as the string data. This method tries to create an instance of one of the following classes in this order: Long, Double, Date, Boolean or the string itself. If the string starts with an assignment operator (equal sign =), it tries to compile the expression to create a JeksExpression instance.
Parameters:
data - a string.
model - the edited table model.
editingCell - the current editing cell.
Returns:
an instance of either classes : Long, Double, Date, Boolean, String or JeksExpression.

&cp; 1998-2003 eTeks - All rights reserved