de.jaret.util.ui.table.editor
Class DoubleCellEditor

java.lang.Object
  extended by de.jaret.util.ui.table.editor.CellEditorBase
      extended by de.jaret.util.ui.table.editor.DoubleCellEditor
All Implemented Interfaces:
ICellEditor, java.util.EventListener, org.eclipse.swt.events.FocusListener, org.eclipse.swt.internal.SWTEventListener

public class DoubleCellEditor
extends CellEditorBase
implements ICellEditor, org.eclipse.swt.events.FocusListener

Cell Editor for editing double values.

Key bindings: CR, TAB: accept input and leave, ESC leave and reset to value when starting editing. Cursor up/down will roll the value.

Version:
$Id: DoubleCellEditor.java 394 2007-05-01 10:51:25Z olk $
Author:
Peter Kliem

Field Summary
protected  de.jaret.util.ui.DoubleField _doubleField
          doublefield managing the input.
protected  double _oldVal
          old value for restauration.
protected  org.eclipse.swt.widgets.Text _text
          text control wrapped by the doublefield.
 
Fields inherited from class de.jaret.util.ui.table.editor.CellEditorBase
_column, _row, _table
 
Constructor Summary
DoubleCellEditor()
          Default constructor.
 
Method Summary
protected  double convertValue(IRow row, IColumn column)
          Convert the value retrieved from the model.
 void dispose()
          Dispose whatever resouces have been allocated.
 void focusGained(org.eclipse.swt.events.FocusEvent arg0)
           do nothing.
 void focusLost(org.eclipse.swt.events.FocusEvent arg0)
           On losing focus store the value.
 org.eclipse.swt.widgets.Control getEditorControl(JaretTable table, IRow row, IColumn column, char typedKey)
          Provide the Control for editing the value at row/column.
 int getPreferredHeight()
          If the renderer *wishes* to be sized not the height of the cell, this method may be used to announce the preferred height of the control.
 void stopEditing(boolean storeInput)
          End editing.
protected  void storeValue(IRow row, IColumn column)
          Store the value in the model.
 
Methods inherited from class de.jaret.util.ui.table.editor.CellEditorBase
handleClick
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jaret.util.ui.table.editor.ICellEditor
handleClick
 

Field Detail

_text

protected org.eclipse.swt.widgets.Text _text
text control wrapped by the doublefield.


_oldVal

protected double _oldVal
old value for restauration.


_doubleField

protected de.jaret.util.ui.DoubleField _doubleField
doublefield managing the input.

Constructor Detail

DoubleCellEditor

public DoubleCellEditor()
Default constructor.

Method Detail

convertValue

protected double convertValue(IRow row,
                              IColumn column)
Convert the value retrieved from the model.

Parameters:
row - row of the cell
column - column of the cell
Returns:
double value (defaulting to 0.0)

storeValue

protected void storeValue(IRow row,
                          IColumn column)
Store the value in the model. If any error occurs, it will be silently ignored!

Parameters:
row - row
column - column

getEditorControl

public org.eclipse.swt.widgets.Control getEditorControl(JaretTable table,
                                                        IRow row,
                                                        IColumn column,
                                                        char typedKey)
Provide the Control for editing the value at row/column. Important: make shure _not_ to create a new control with every call!

This method may return null indicating that the editor will not supply a control.

Base implementation storing the table and row/col information.

Specified by:
getEditorControl in interface ICellEditor
Overrides:
getEditorControl in class CellEditorBase
Parameters:
table - the table requesting the editor
row - row
column - column
typedKey - the character typed when invoking the editor (may be 0 if the editor was invoked without typing any key)
Returns:
configured Control (parent has to be the table)

getPreferredHeight

public int getPreferredHeight()
If the renderer *wishes* to be sized not the height of the cell, this method may be used to announce the preferred height of the control. A value of -1 signals no preference. default will always return -1.

Specified by:
getPreferredHeight in interface ICellEditor
Overrides:
getPreferredHeight in class CellEditorBase
Returns:
preferred height or -1 for no preference.

focusGained

public void focusGained(org.eclipse.swt.events.FocusEvent arg0)
do nothing.

Specified by:
focusGained in interface org.eclipse.swt.events.FocusListener

focusLost

public void focusLost(org.eclipse.swt.events.FocusEvent arg0)
On losing focus store the value.

Specified by:
focusLost in interface org.eclipse.swt.events.FocusListener

dispose

public void dispose()
Dispose whatever resouces have been allocated.

Specified by:
dispose in interface ICellEditor
Overrides:
dispose in class CellEditorBase

stopEditing

public void stopEditing(boolean storeInput)
End editing.

Specified by:
stopEditing in interface ICellEditor
Parameters:
storeInput - if true the editor shall save the current input.


Copyright © 2012. All Rights Reserved.