JIDE 3.5.15

com.jidesoft.grid
Class ContextSensitiveCellEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by com.jidesoft.grid.AbstractJideCellEditor
          extended by com.jidesoft.grid.ContextSensitiveCellEditor
All Implemented Interfaces:
ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, Serializable, CellEditor, TableCellEditor
Direct Known Subclasses:
AbstractComboBoxCellEditor, AbstractTableCellEditorRenderer, BooleanCheckBoxCellEditor, ExComboBoxCellEditor, FormattedTextFieldCellEditor, IPAddressCellEditor, MultilineTableCellEditor, SliderCellEditor, SpinnerCellEditor, TextFieldCellEditor, TristateCheckBoxCellEditor

public abstract class ContextSensitiveCellEditor
extends AbstractJideCellEditor
implements TableCellEditor, ConverterContextSupport, EditorContextSupport, EditorStyleSupport

CellEditor which can accept ConverterContext. All CellEditor we built extends this class.

See Also:
Serialized Form

Field Summary
static Border DEFAULT_CELL_EDITOR_BORDER
          Default cell editor border.
 
Fields inherited from class com.jidesoft.grid.AbstractJideCellEditor
_clickCountToStart
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
ContextSensitiveCellEditor()
          Creates a context sensitive cell editor.
ContextSensitiveCellEditor(ConverterContext context)
          Creates a context sensitive cell editor using the converter context.
 
Method Summary
 ObjectConverter getConverter()
          Gets the object converter.
 ConverterContext getConverterContext()
          Gets the converter context.
 EditorContext getEditorContext()
          Gets the editor context.
 int getEditorStyle()
           
 Class<?> getType()
          Gets the class of the value.
 boolean isEditorStyleSupported(int editorStyle)
          Checks if the editor style is supported by the cell editor.
 boolean isUseConverterContext()
          Checks if converter context should be used for editor.
 void setConverter(ObjectConverter converter)
          Sets a new converter for the cell editor.
 void setConverterContext(ConverterContext converterContextForEditor)
          Set the converter context for the cell editor.
 void setEditorContext(EditorContext context)
          Sets the editor context.
 void setEditorStyle(int editorStyle)
          Sets the editor style to the cell editor.
 void setType(Class<?> valueClass)
          Sets the class of the value.
 void setUseConverterContext(boolean useConverterContext)
          Sets if the converter context should be used.
 
Methods inherited from class com.jidesoft.grid.AbstractJideCellEditor
addValidationListener, getClickCountToStart, getDefaultErrorBehavior, getValidationListeners, isAutoStopCellEditing, isCellEditable, isPassEnterKeyToTable, removeValidationListener, setAutoStopCellEditing, setClickCountToStart, setDefaultErrorBehavior, setPassEnterKeyToTable, validate
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, shouldSelectCell, stopCellEditing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableCellEditor
getTableCellEditorComponent
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, getCellEditorValue, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
 

Field Detail

DEFAULT_CELL_EDITOR_BORDER

public static Border DEFAULT_CELL_EDITOR_BORDER
Default cell editor border. It is (0,1,0,1) by default.

Constructor Detail

ContextSensitiveCellEditor

public ContextSensitiveCellEditor()
Creates a context sensitive cell editor.


ContextSensitiveCellEditor

public ContextSensitiveCellEditor(ConverterContext context)
Creates a context sensitive cell editor using the converter context.

Parameters:
context - converter context
Method Detail

getConverterContext

public ConverterContext getConverterContext()
Gets the converter context.

If isUseConverterContext() returns false, this method will always return null. Otherwise, it will return the converter you set by invoking setConverterContext(com.jidesoft.converter.ConverterContext) first, if you don't set any converter context, the same converter context defined in the ContextSensitiveTableModel for the editing cell will be returned.

Specified by:
getConverterContext in interface ConverterContextSupport
Returns:
converter context

getType

public Class<?> getType()
Description copied from interface: ConverterContextSupport
Gets the class of the value.

Specified by:
getType in interface ConverterContextSupport
Returns:
the class of the value.

setType

public void setType(Class<?> valueClass)
Description copied from interface: ConverterContextSupport
Sets the class of the value.

Specified by:
setType in interface ConverterContextSupport

getConverter

public ObjectConverter getConverter()
Gets the object converter.

Returns:
the object converter.

setConverter

public void setConverter(ObjectConverter converter)
Sets a new converter for the cell editor. Not all cell editor will consider this converter. Right now only ListCellEditor will consider this and use it to convert element to string in the JList when converter is not null. Otherwise, it will use whatever converter registered in ObjectConverterManager to do the conversion.

Parameters:
converter - the new converter

isUseConverterContext

public boolean isUseConverterContext()
Checks if converter context should be used for editor.

Returns:
true or false.
See Also:
setUseConverterContext(boolean)

setUseConverterContext

public void setUseConverterContext(boolean useConverterContext)
Sets if the converter context should be used.

Parameters:
useConverterContext - true or false. True to use converter context. Otherwise false.

getEditorContext

public EditorContext getEditorContext()
Gets the editor context.

Specified by:
getEditorContext in interface EditorContextSupport
Returns:
editor context

setEditorContext

public void setEditorContext(EditorContext context)
Sets the editor context.

Specified by:
setEditorContext in interface EditorContextSupport
Parameters:
context - editor context

setConverterContext

public void setConverterContext(ConverterContext converterContextForEditor)
Set the converter context for the cell editor.

By default, this context is null so that the converter context of the cell editor will be the same as the converter context of the cell in the ContextSensitiveTable. You could set this context to a non-null value so that the editor could have different converter context with the cell itself.

While getting converter context, it will first check this method then check isUseConverterContext() to decide if the editor should use the cell's converter context or use null always.

Specified by:
setConverterContext in interface ConverterContextSupport
Parameters:
converterContextForEditor - the converter context
See Also:
getConverterContext()

isEditorStyleSupported

public boolean isEditorStyleSupported(int editorStyle)
Description copied from interface: EditorStyleSupport
Checks if the editor style is supported by the cell editor.

Specified by:
isEditorStyleSupported in interface EditorStyleSupport
Parameters:
editorStyle - the editor style
Returns:
true if it is supported. Otherwise false.

setEditorStyle

public void setEditorStyle(int editorStyle)
Description copied from interface: EditorStyleSupport
Sets the editor style to the cell editor.

Specified by:
setEditorStyle in interface EditorStyleSupport
Parameters:
editorStyle - the editor style

getEditorStyle

public int getEditorStyle()

JIDE 3.5.15