JIDE 3.5.15

com.jidesoft.grid
Class EnumCellEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by com.jidesoft.grid.AbstractJideCellEditor
          extended by com.jidesoft.grid.ContextSensitiveCellEditor
              extended by com.jidesoft.grid.ExComboBoxCellEditor
                  extended by com.jidesoft.grid.ListComboBoxCellEditor
                      extended by com.jidesoft.grid.EnumCellEditor
All Implemented Interfaces:
ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, ActionListener, Serializable, EventListener, CellEditor, PopupMenuListener, TableCellEditor

public class EnumCellEditor
extends ListComboBoxCellEditor

A cell editor that based on ListComboBoxCellEditor. It use EnumConverter. For example, in SwingConstants, the following values are defined.

 public static final int CENTER  = 0;
 public static final int TOP     = 1;
 public static final int LEFT    = 2;
 public static final int BOTTOM  = 3;
 public static final int RIGHT   = 4;
 
When you want user to choose one of the value above from a table's cell editor, you don't want to use 0, 1, 2, 3, 4 as the value in combobox as it doesn't mean anything from user point of view. You want user to be able to use meaningful names such as "Center", "Top", "Left", "Bottom", "Right". This is what EnumCellEditor can do it for you. First, you need to define a EnumConverter, then register it with ObjectConverterManager. Then define a EnumCellEditor and register with CellEditorManager. See code example below.
 EnumConverter locationConverter = new EnumConverter("Location", int.class,
       new Object[]{
           new Integer(SwingConstants.CENTER),
           new Integer(SwingConstants.TOP),
           new Integer(SwingConstants.LEFT),
           new Integer(SwingConstants.BOTTOM),
           new Integer(SwingConstants.RIGHT)
       },
       new String[]{
           "Center",
           "Top",
           "Left",
           "Bottom",
           "Right"
       }, new Integer(SwingConstants.HORIZONTAL));
 ObjectConverterManager.registerConverter(locationConverter.getType(), locationConverter,
 locationConverter.getContext());
 EnumCellRenderer locationCellRenderer = new EnumCellRenderer(locationConverter);
 CellRendererManager.registerRenderer(locationConverter.getType(), locationCellRenderer,
 locationCellRenderer.getContext());
 EnumCellEditor locationCellEditor = new EnumCellEditor(locationConverter);
 CellEditorManager.registerEditor(locationConverter.getType(), locationCellEditor, locationCellEditor.getContext());
 
If you want to use the cell editor and renderer you register above, for example in PropertyTable, you just need to define the property make ConverterContext to be locationConverter .getContext() and EditorContext to be locationEditor.getContext().

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.jidesoft.grid.ExComboBoxCellEditor
_comboBox
 
Fields inherited from class com.jidesoft.grid.ContextSensitiveCellEditor
DEFAULT_CELL_EDITOR_BORDER
 
Fields inherited from class com.jidesoft.grid.AbstractJideCellEditor
_clickCountToStart
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
EnumCellEditor(EnumConverter enumConverter)
           
 
Method Summary
 EditorContext getContext()
           
 
Methods inherited from class com.jidesoft.grid.ListComboBoxCellEditor
createExComboBox, createExComboBox, createListComboBox, setConverterContext, setPossibleValues
 
Methods inherited from class com.jidesoft.grid.ExComboBoxCellEditor
actionPerformed, customizeExComboBox, getCellEditorValue, getComboBox, getTableCellEditorComponent, isEditorStyleSupported, popupMenuCanceled, popupMenuWillBecomeInvisible, popupMenuWillBecomeVisible, setCellEditorValue, setConverter, setType, stopCellEditing
 
Methods inherited from class com.jidesoft.grid.ContextSensitiveCellEditor
getConverter, getConverterContext, getEditorContext, getEditorStyle, getType, isUseConverterContext, setEditorContext, setEditorStyle, setUseConverterContext
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell
 

Constructor Detail

EnumCellEditor

public EnumCellEditor(EnumConverter enumConverter)
Method Detail

getContext

public EditorContext getContext()

JIDE 3.5.15