JIDE 3.5.15

com.jidesoft.grid
Class CellEditorManager

java.lang.Object
  extended by com.jidesoft.grid.CellEditorManager

public class CellEditorManager
extends Object

A global object that can register cell editor with a type and a EditorContext.


Nested Class Summary
static interface CellEditorManager.CellEditorCustomizer
          A cell editor customizer interface.
 
Constructor Summary
CellEditorManager()
           
 
Method Summary
static void addCellEditorCustomizer(CellEditorManager.CellEditorCustomizer cellEditorCustomizer)
          Adds a cell editor customizer.
static void addRegistrationListener(RegistrationListener l)
          Adds a listener to the list that's notified each time a change to the manager occurs.
static void clear()
           
static CellEditorManager.CellEditorCustomizer[] getCellEditorCustomizers()
          Gets all the cell editor customizers in an array.
static CellEditor getEditor(Class<?> clazz)
          Gets the registered editor using default context.
static CellEditor getEditor(Class<?> clazz, EditorContext context)
          Gets the registered editor.
static EditorContext[] getEditorContexts(Class<?> clazz)
          Gets the available EditorContext registered with the class.
static RegistrationListener[] getRegistrationListeners()
          Returns an array of all the registration listeners registered on this manager.
static void initDefaultEditor()
          Initial the default editors.
static boolean isAutoInit()
          Checks the value of autoInit.
static void registerEditor(Class<?> clazz, CellEditor editor)
          Deprecated. use registerEditor(Class, CellEditorFactory). JTable don't support sharing the same instance of CellEditor. If you use this method to register a cell editor instance, it may cause problem when you try to edit two tables simultaneous. If you register a CellEditorFactory, a new cell editor will be created every time which avoids the problem of sharing cell editor.
static void registerEditor(Class<?> clazz, CellEditor editor, EditorContext context)
          Deprecated. use registerEditor(Class, CellEditorFactory, EditorContext) JTable don't support sharing the same instance of CellEditor. If you use this method to register a cell editor instance, it may cause problem when you try to edit two tables simultaneous. If you register a CellEditorFactory, a new cell editor will be created every time which avoids the problem of sharing cell editor.
static void registerEditor(Class<?> clazz, CellEditorFactory editorFactory)
          Registers a editor with a class and default context.
static void registerEditor(Class<?> clazz, CellEditorFactory editorFactory, EditorContext context)
          Registers a editorFactory with a class and a context.
static void removeCellEditorCustomizer(CellEditorManager.CellEditorCustomizer cellEditorCustomizer)
          Removes a cell editor Customizer that was added before.
static void removeRegistrationListener(RegistrationListener l)
          Removes a listener from the list that's notified each time a change to the manager occurs.
static void resetInit()
          If initDefaultEditor() is called once, calling it again will have no effect because an internal flag is set.
static void setAutoInit(boolean autoInit)
          Sets autoInit to true or false.
static void unregisterAllEditors()
          Unregisters all the editors which registered before.
static void unregisterAllEditors(Class<?> clazz)
          Unregisters all editors which register with the class.
static void unregisterEditor(Class<?> clazz)
          Unregisters the editor which registers with the class and the default context.
static void unregisterEditor(Class<?> clazz, EditorContext context)
          Unregisters the editor which registers with the class and the context.
static void updateUI()
          Updates the UI of the registered cell editors when LookAndFeel changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellEditorManager

public CellEditorManager()
Method Detail

registerEditor

@Deprecated
public static void registerEditor(Class<?> clazz,
                                             CellEditor editor,
                                             EditorContext context)
Deprecated. use registerEditor(Class, CellEditorFactory, EditorContext) JTable don't support sharing the same instance of CellEditor. If you use this method to register a cell editor instance, it may cause problem when you try to edit two tables simultaneous. If you register a CellEditorFactory, a new cell editor will be created every time which avoids the problem of sharing cell editor.

Registers a editor with a class and a context.

Parameters:
clazz - the type
editor - the editor
context - the editor context

registerEditor

@Deprecated
public static void registerEditor(Class<?> clazz,
                                             CellEditor editor)
Deprecated. use registerEditor(Class, CellEditorFactory). JTable don't support sharing the same instance of CellEditor. If you use this method to register a cell editor instance, it may cause problem when you try to edit two tables simultaneous. If you register a CellEditorFactory, a new cell editor will be created every time which avoids the problem of sharing cell editor.

Registers a editor with a class and default context. If no context is specified, this editor will be used as default editor for that type.

Parameters:
clazz - the type
editor - the editor

registerEditor

public static void registerEditor(Class<?> clazz,
                                  CellEditorFactory editorFactory,
                                  EditorContext context)
Registers a editorFactory with a class and a context.

Parameters:
clazz - the type
editorFactory - the editor factory
context - the editor context

registerEditor

public static void registerEditor(Class<?> clazz,
                                  CellEditorFactory editorFactory)
Registers a editor with a class and default context. If no context is specified, this editor will be used as default editor for that type.

Parameters:
clazz - the type
editorFactory - the editor

unregisterEditor

public static void unregisterEditor(Class<?> clazz,
                                    EditorContext context)
Unregisters the editor which registers with the class and the context.

Parameters:
clazz - the type of which the cell editor will be unregistered.
context - the editor context.

unregisterEditor

public static void unregisterEditor(Class<?> clazz)
Unregisters the editor which registers with the class and the default context.

Parameters:
clazz - the type of which the cell editor will be unregistered.

unregisterAllEditors

public static void unregisterAllEditors(Class<?> clazz)
Unregisters all editors which register with the class.

Parameters:
clazz - the type of which the cell editor will be unregistered.

unregisterAllEditors

public static void unregisterAllEditors()
Unregisters all the editors which registered before.


getEditor

public static CellEditor getEditor(Class<?> clazz,
                                   EditorContext context)
Gets the registered editor.

Parameters:
clazz - the type.
context - the editor context.
Returns:
the registered editor

getEditor

public static CellEditor getEditor(Class<?> clazz)
Gets the registered editor using default context.

Parameters:
clazz - the type.
Returns:
the registered editor

updateUI

public static void updateUI()
Updates the UI of the registered cell editors when LookAndFeel changed. This method will be called automatically since CellEditorManager listens to the UIManager's LookAndFeel change.


isAutoInit

public static boolean isAutoInit()
Checks the value of autoInit.

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

setAutoInit

public static void setAutoInit(boolean autoInit)
Sets autoInit to true or false. If autoInit is true, whenever someone tries to call methods like as getEditor, initDefaultEditor() will be called if it has never be called. By default, autoInit is true.

This might affect the behavior if users provide their own CellEditors and want to overwrite default CellEditors. In this case, instead of depending on autoInit to initialize default CellEditors, you should call initDefaultEditor() first, then call registerCellEditor to add your own CellEditors.

Parameters:
autoInit - true or false.

addRegistrationListener

public static void addRegistrationListener(RegistrationListener l)
Adds a listener to the list that's notified each time a change to the manager occurs.

Parameters:
l - the RegistrationListener

removeRegistrationListener

public static void removeRegistrationListener(RegistrationListener l)
Removes a listener from the list that's notified each time a change to the manager occurs.

Parameters:
l - the RegistrationListener

getRegistrationListeners

public static RegistrationListener[] getRegistrationListeners()
Returns an array of all the registration listeners registered on this manager.

Returns:
all of this registration's RegistrationListeners or an empty array if no registration listeners are currently registered
See Also:
addRegistrationListener(com.jidesoft.utils.RegistrationListener), removeRegistrationListener(com.jidesoft.utils.RegistrationListener)

getCellEditorCustomizers

public static CellEditorManager.CellEditorCustomizer[] getCellEditorCustomizers()
Gets all the cell editor customizers in an array.

Returns:
all the cell editor customizers in an array.

addCellEditorCustomizer

public static void addCellEditorCustomizer(CellEditorManager.CellEditorCustomizer cellEditorCustomizer)
Adds a cell editor customizer. It will be called when a cell editor is created in CellEditorFactory before it is returned from getEditor method.

Here is a typical use case to make all cell editors to be clicked twice before it starts editing.


 CellEditorManager.addCellEditorCustomizer(new CellEditorManager.CellEditorCustomizer(){
     public void customize(CellEditor cellEditor) {
         if(cellEditor instanceof AbstractJideCellEditor) {
             ((AbstractJideCellEditor) cellEditor).setClickCountToStart(2);
         }
         else if(cellEditor instanceof DefaultCellEditor) {
             ((DefaultCellEditor) cellEditor).setClickCountToStart(2);
         }
     }
 });
 

Parameters:
cellEditorCustomizer - the cell editor customer to be added.

removeCellEditorCustomizer

public static void removeCellEditorCustomizer(CellEditorManager.CellEditorCustomizer cellEditorCustomizer)
Removes a cell editor Customizer that was added before.

Parameters:
cellEditorCustomizer - the cell editor customer to be removed.

getEditorContexts

public static EditorContext[] getEditorContexts(Class<?> clazz)
Gets the available EditorContext registered with the class.

Parameters:
clazz - the class.
Returns:
the available EditorContexts.

initDefaultEditor

public static void initDefaultEditor()
Initial the default editors.


resetInit

public static void resetInit()
If initDefaultEditor() is called once, calling it again will have no effect because an internal flag is set. This method will reset the internal flag so that you can call initDefaultEditor() in case you unregister all editors using unregisterAllEditors().


clear

public static void clear()

JIDE 3.5.15