Class ComponentAdapter
- java.lang.Object
-
- com.bc.ceres.swing.binding.ComponentAdapter
-
public abstract class ComponentAdapter extends Object
A component adapter provides the GUI components used to edit a bound property value.Clients may derive their own component adapters by implementing this abstract class.
The actual binding is established by calling
BindingContext.bind(String, ComponentAdapter)
. The returned binding may be undone later by callingBindingContext.unbind(Binding)
.- Since:
- Ceres 0.6
- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Constructor Description ComponentAdapter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
adjustComponents()
Called by the framework either if a binding is established by callingBindingContext.bind(String, ComponentAdapter)
, ifBindingContext.adjustComponents()
is called, or if a property-change event occurs in the associatedPropertyContainer
of theBindingContext
.abstract void
bindComponents()
Called by the framework in order to bind the GUI components to the bound property.Binding
getBinding()
Gets the binding which is using this adapter.abstract JComponent[]
getComponents()
Gets the components participating in the binding.void
setBinding(Binding binding)
Sets the binding which is using this adapter.abstract void
unbindComponents()
Called by the framework in order to unbind the GUI components from the bound property.
-
-
-
Method Detail
-
getBinding
public Binding getBinding()
Gets the binding which is using this adapter.- Returns:
- The binding.
-
setBinding
public final void setBinding(Binding binding)
Sets the binding which is using this adapter.Clients shall never call this method directly, it is called by the framework.
- Parameters:
binding
- The binding.- Throws:
IllegalStateException
- if the binding has already been set.
-
getComponents
public abstract JComponent[] getComponents()
Gets the components participating in the binding.- Returns:
- The array of components. Must not be empty.
-
bindComponents
public abstract void bindComponents()
Called by the framework in order to bind the GUI components to the bound property.The frameworks called this method immediately after
setBinding(Binding)
has been called.Most implementations will register a change listener in the editor component which convert the input value and set the bound property by calling
getBinding().setPropertyValue(value)
.- See Also:
adjustComponents()
,unbindComponents()
-
unbindComponents
public abstract void unbindComponents()
Called by the framework in order to unbind the GUI components from the bound property.Most implementations will deregister any registered change listeners from the editor component.
- See Also:
bindComponents()
,adjustComponents()
-
adjustComponents
public abstract void adjustComponents()
Called by the framework either- if a binding is established by calling
BindingContext.bind(String, ComponentAdapter)
, - if
BindingContext.adjustComponents()
is called, or - if a property-change event occurs in the associated
PropertyContainer
of theBindingContext
.
Most implementations adjusts the editor component with the value retrieved by
getBinding().getPropertyValue()
. Note that changes to the UI component shall be made on the EDT. Consider usingSwingUtilities.invokeLater()
.- See Also:
bindComponents()
,unbindComponents()
- if a binding is established by calling
-
-