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

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

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

Editor using a ComboBox for selecting one of several objects supplied to the editor at creation time. A label provider is used for toString conversion.

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

Nested Class Summary
 class ObjectComboEditor.ToStringLabelProvider
          Simple Labelprovider just using the toString method of any supplied object.
 
Field Summary
protected  boolean _allowNull
          if true allow null as a possible selection.
protected  org.eclipse.swt.widgets.Combo _combo
          combox widget.
protected  java.util.List<? extends java.lang.Object> _itemList
          object list for selection.
protected  org.eclipse.jface.viewers.ILabelProvider _labelProvider
          label provider used.
protected  java.lang.String _nullText
          the text displayed for null.
protected  java.lang.Object _oldVal
          old value.
protected  java.lang.String[] _stringItems
          list of items displayed.
 
Fields inherited from class de.jaret.util.ui.table.editor.CellEditorBase
_column, _row, _table
 
Constructor Summary
ObjectComboEditor(java.util.List<? extends java.lang.Object> list, org.eclipse.jface.viewers.ILabelProvider labelProvider, boolean allowNull, java.lang.String nullText)
          Construct a new ObjectComboEditor with a list of selectabel Objects and an ILabelprovider.
 
Method Summary
 void dispose()
          Dispose whatever resouces have been allocated.
 void focusGained(org.eclipse.swt.events.FocusEvent arg0)
           Nothing to do on gaining focus.
 void focusLost(org.eclipse.swt.events.FocusEvent arg0)
           Store and end editing when focus is taken away.
 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.
protected  void initItems()
           
 void stopEditing(boolean storeInput)
          End editing.
 
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

_combo

protected org.eclipse.swt.widgets.Combo _combo
combox widget.


_oldVal

protected java.lang.Object _oldVal
old value.


_stringItems

protected java.lang.String[] _stringItems
list of items displayed.


_labelProvider

protected org.eclipse.jface.viewers.ILabelProvider _labelProvider
label provider used.


_allowNull

protected boolean _allowNull
if true allow null as a possible selection.


_nullText

protected java.lang.String _nullText
the text displayed for null.


_itemList

protected java.util.List<? extends java.lang.Object> _itemList
object list for selection.

Constructor Detail

ObjectComboEditor

public ObjectComboEditor(java.util.List<? extends java.lang.Object> list,
                         org.eclipse.jface.viewers.ILabelProvider labelProvider,
                         boolean allowNull,
                         java.lang.String nullText)
Construct a new ObjectComboEditor with a list of selectabel Objects and an ILabelprovider.

Parameters:
list - list of Objects that may be selected.
labelProvider - label provider to be used or null. In the latter case a simple toString label provider will be used.
allowNull - if true null will always be a possible value in the comboBox
nullText - string to be displyed for the null value if allowed
Method Detail

initItems

protected void initItems()

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)

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.

dispose

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

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

focusGained

public void focusGained(org.eclipse.swt.events.FocusEvent arg0)
Nothing to do on gaining focus.

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

focusLost

public void focusLost(org.eclipse.swt.events.FocusEvent arg0)
Store and end editing when focus is taken away.

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

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.


Copyright © 2012. All Rights Reserved.