JIDE 3.5.15

com.jidesoft.grid
Class CellRendererManager

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

public class CellRendererManager
extends Object

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


Nested Class Summary
static interface CellRendererManager.CellRendererCustomizer
          A cell editor customizer interface.
 
Constructor Summary
CellRendererManager()
           
 
Method Summary
static void addCellRendererCustomizer(CellRendererManager.CellRendererCustomizer CellRendererCustomizer)
          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 CellRendererManager.CellRendererCustomizer[] getCellRendererCustomizers()
          Gets all the cell editor customizers in an array.
static EditorContext[] getEditorContexts(Class<?> clazz)
          Gets the available EditorContexts registered with the class.
static RegistrationListener[] getRegistrationListeners()
          Returns an array of all the registration listeners registered on this manager.
static TableCellRenderer getRenderer(Class<?> clazz)
          Gets the registered renderer using default context.
static TableCellRenderer getRenderer(Class<?> clazz, EditorContext context)
          Gets the registered renderer.
static void initDefaultRenderer()
          Initials the default renderers.
static boolean isAutoInit()
          Checks the value of autoInit.
static void registerRenderer(Class<?> clazz, TableCellRenderer renderer)
          Registers a renderer with a class and default context.
static void registerRenderer(Class<?> clazz, TableCellRenderer renderer, EditorContext context)
          Registers a renderer with a class and a context.
static void removeCellRendererCustomizer(CellRendererManager.CellRendererCustomizer CellRendererCustomizer)
          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 initDefaultRenderer() 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 unregisterAllRenderers()
          Unregisters all the renderers which registered before.
static void unregisterAllRenderers(Class<?> clazz)
          Unregisters all renderers which register with the class.
static void unregisterRenderer(Class<?> clazz)
          Unregisters the renderer which registers with the class and the default context.
static void unregisterRenderer(Class<?> clazz, EditorContext context)
          Unregisters the renderer 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

CellRendererManager

public CellRendererManager()
Method Detail

registerRenderer

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

Parameters:
clazz - the type
renderer - the renderer

registerRenderer

public static void registerRenderer(Class<?> clazz,
                                    TableCellRenderer renderer,
                                    EditorContext context)
Registers a renderer with a class and a context.

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

unregisterRenderer

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

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

unregisterRenderer

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

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

unregisterAllRenderers

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

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

unregisterAllRenderers

public static void unregisterAllRenderers()
Unregisters all the renderers which registered before.


getRenderer

public static TableCellRenderer getRenderer(Class<?> clazz,
                                            EditorContext context)
Gets the registered renderer.

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

getRenderer

public static TableCellRenderer getRenderer(Class<?> clazz)
Gets the registered renderer using default context.

Parameters:
clazz - the type
Returns:
the registered renderer

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 toString or fromString, initDefaultRenderer() will be called if it has never be called. By default, autoInit is true.

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

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)

getCellRendererCustomizers

public static CellRendererManager.CellRendererCustomizer[] getCellRendererCustomizers()
Gets all the cell editor customizers in an array.

Returns:
all the cell editor customizers in an array.

addCellRendererCustomizer

public static void addCellRendererCustomizer(CellRendererManager.CellRendererCustomizer CellRendererCustomizer)
Adds a cell editor customizer. It will be called when a cell editor is created in CellRendererFactory 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.


 CellRendererManager.addCellRendererCustomizer(new CellRendererManager.CellRendererCustomizer(){
     public void customize(TableCellRenderer cellRenderer) {
         if(cellRenderer instanceof AbstractComboBox) {
             ((AbstractComboBox) cellRenderer).setButtonVisible(true);
         }
     }
 });
 

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

removeCellRendererCustomizer

public static void removeCellRendererCustomizer(CellRendererManager.CellRendererCustomizer CellRendererCustomizer)
Removes a cell editor Customizer that was added before.

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

getEditorContexts

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

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

initDefaultRenderer

public static void initDefaultRenderer()
Initials the default renderers.


resetInit

public static void resetInit()
If initDefaultRenderer() 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 initDefaultRenderer() in case you unregister all renderers using unregisterAllRenderers().


clear

public static void clear()

JIDE 3.5.15