Logo Search packages:      
Sourcecode: libjgoodies-binding-java version File versions

com::jgoodies::binding::value::ComponentValueModel Class Reference

Inheritance diagram for com::jgoodies::binding::value::ComponentValueModel:

com::jgoodies::binding::value::AbstractValueModel com::jgoodies::binding::beans::Model com::jgoodies::binding::value::ValueModel com::jgoodies::binding::beans::Observable

List of all members.


Detailed Description

A ValueModel that provides relevant GUI state in presentation models. It provides bound properties for the frequently used JComponent state enabled/visible and JTextComponent state editable. ComponentValueModels can be used to set these properties at the presentation model layer; any ComponentValueModel property change will be reflected by components bound to that ComponentValueModel.

The ComponentValueModel is similar to the Swing Action class. If you disable an Action, all buttons and menu items bound to that Action will be disabled. If you disable a ComponentValueModel, all components bound to that ComponentValueModel will be disabled. If you set the ComponentValueModel to invisible, the component bound to it will become invisible. If you set a ComponentValueModel to non-editable, the JTextComponents bound to it will become non-editable.

Since version 1.1, PresentationModels can vend ComponentValueModels using getComponentModel(String) and getBufferedComponentModel(String). Multiple calls to these factory methods return the same ComponentValueModel.

The BasicComponentFactory and the Bindings class check if the ValueModel provided to create/bind a Swing component is a ComponentValueModel. If so, the ComponentValueModel properties will be synchronized with the associated Swing component properties.

It is recommended to use ComponentValueModels only for those models that are bound to view components that require GUI state changes.

Example Code:

 final class AlbumView {

  ...

     private void initComponents() {
         // No state modifications required for the name field.
         nameField = BasicComponentFactory.createTextField(
             presentationModel.getModel(Album.PROPERTYNAME_NAME));
         ...
         // Enablement shall change for the composer field
         composerField = BasicComponentFactory.createTextField(
             presentationModel.getComponentModel(Album.PROPERTYNAME_COMPOSER));
         ...
     }

  ...

 }

 public final class AlbumPresentationModel extends PresentationModel {

  ...

     private void updateComposerEnablement(boolean enabled) {
         getComponentModel(Album.PROPERTYNAME_COMPOSER).setEnabled(enabled);
     }

  ...

 }
 

As of the Binding version 1.1.0 the ComponentValueModel feature is implemented for text components, radio buttons, and check boxes. JLists, JTables, JComboBoxes, and JColorChoosers bound using the Bindings class will ignore ComponentValueModel state. See also Issue 86.

TODO: Add an automatic binding for lists, tables, combos.

Author:
Karsten Lentzsch
Version:
Revision
1.8

See also:
PresentationModel::getComponentModel(String)

PresentationModel::getBufferedComponentModel(String)

BasicComponentFactory

Bindings

Since:
1.1

Definition at line 124 of file ComponentValueModel.java.


Public Member Functions

final synchronized void addPropertyChangeListener (String propertyName, PropertyChangeListener listener)
final synchronized void addPropertyChangeListener (PropertyChangeListener listener)
final void addValueChangeListener (PropertyChangeListener l)
final synchronized void addVetoableChangeListener (String propertyName, VetoableChangeListener listener)
final synchronized void addVetoableChangeListener (VetoableChangeListener listener)
final boolean booleanValue ()
 ComponentValueModel (ValueModel subject)
final double doubleValue ()
final void fireValueChange (float oldValue, float newValue)
final void fireValueChange (double oldValue, double newValue)
final void fireValueChange (long oldValue, long newValue)
final void fireValueChange (int oldValue, int newValue)
final void fireValueChange (boolean oldValue, boolean newValue)
final void fireValueChange (Object oldValue, Object newValue, boolean checkIdentity)
final void fireValueChange (Object oldValue, Object newValue)
final float floatValue ()
final synchronized
PropertyChangeListener[] 
getPropertyChangeListeners (String propertyName)
final synchronized
PropertyChangeListener[] 
getPropertyChangeListeners ()
String getString ()
Object getValue ()
final synchronized
VetoableChangeListener[] 
getVetoableChangeListeners (String propertyName)
final synchronized
VetoableChangeListener[] 
getVetoableChangeListeners ()
final int intValue ()
boolean isEditable ()
boolean isEnabled ()
boolean isVisible ()
final long longValue ()
final synchronized void removePropertyChangeListener (String propertyName, PropertyChangeListener listener)
final synchronized void removePropertyChangeListener (PropertyChangeListener listener)
final void removeValueChangeListener (PropertyChangeListener l)
final synchronized void removeVetoableChangeListener (String propertyName, VetoableChangeListener listener)
final synchronized void removeVetoableChangeListener (VetoableChangeListener listener)
void setEditable (boolean b)
void setEnabled (boolean b)
final void setValue (long l)
final void setValue (int i)
final void setValue (float f)
final void setValue (double d)
final void setValue (boolean b)
void setValue (Object newValue)
void setVisible (boolean b)
String toString ()

Static Public Attributes

static final String PROPERTYNAME_EDITABLE = "editable"
static final String PROPERTYNAME_ENABLED = "enabled"
static final String PROPERTYNAME_VALUE = "value"
static final String PROPERTYNAME_VISIBLE = "visible"

Protected Member Functions

final boolean equals (Object o1, Object o2)
final void fireMultiplePropertiesChanged ()
final void firePropertyChange (String propertyName, long oldValue, long newValue)
final void firePropertyChange (String propertyName, int oldValue, int newValue)
final void firePropertyChange (String propertyName, float oldValue, float newValue)
final void firePropertyChange (String propertyName, double oldValue, double newValue)
final void firePropertyChange (String propertyName, boolean oldValue, boolean newValue)
final void firePropertyChange (String propertyName, Object oldValue, Object newValue, boolean checkIdentity)
final void firePropertyChange (String propertyName, Object oldValue, Object newValue)
final void firePropertyChange (PropertyChangeEvent event)
final void fireVetoableChange (String propertyName, long oldValue, long newValue) throws PropertyVetoException
final void fireVetoableChange (String propertyName, float oldValue, float newValue) throws PropertyVetoException
final void fireVetoableChange (String propertyName, int oldValue, int newValue) throws PropertyVetoException
final void fireVetoableChange (String propertyName, double oldValue, double newValue) throws PropertyVetoException
final void fireVetoableChange (String propertyName, boolean oldValue, boolean newValue) throws PropertyVetoException
final void fireVetoableChange (String propertyName, Object oldValue, Object newValue) throws PropertyVetoException
final void fireVetoableChange (PropertyChangeEvent event) throws PropertyVetoException

Private Attributes

boolean editable
boolean enabled
final ValueModel subject
boolean visible

Classes

class  SubjectValueChangeHandler

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index