org.tbee.swing.binding
Class BindingUtils
java.lang.Object
org.tbee.swing.binding.BindingUtils
public class BindingUtils
- extends Object
JGoodies binding utility methods.
When creating a binding using this class, a BindingInfo entry is made. This binding info entity can be retrieved using BindingUtils.getBindingInfo(lComponent).
Using this binding info is it possible to write flexible code, for example disable components based on some method in the BM:
// determine enabled state
boolean lEnabled = ( lMyEntity == null
|| ...
|| ...
);
// scan all components
List lComponents = SwingUtilities.flattenComponentTree(lContainer);
for (Component lComponent : lComponents)
{
// get binding info
BindingUtils.BindingInfo lBindingInfo = BindingUtils.getBindingInfo(lComponent);
if (lBindingInfo != null && lMyEntity.getClass().equals(lBindingInfo.boundToClass))
{
// if this component is bound to a blocked property
if (lMyEntity.checkIfPropertyIsDisabled(lBindingInfo.boundToPropertyName))
{
// update the enabled state
lComponent.setEnabled(lEnabled);
}
}
}
TODO: can we use a fluent interface? like BindingUtils.bind(x).property("a").to(comp);
- Author:
- Tom
|
Nested Class Summary |
static class |
BindingUtils.Binding
Implements the fluent interface
example: BindingUtils.bind(iBeanAdapter, Sellorder.PAYMENTAGREEMENT_PROPERTY_ID).to(lPaymentagreementJTextArea);
TODO: this is just a first attempt, it works, but is not riped |
static class |
BindingUtils.BindingInfo
Binding info |
static class |
BindingUtils.DummyEntity
This is a class to serve as a wrapper to catch value changes |
|
Method Summary |
static BindingUtils.Binding |
bind(com.jgoodies.binding.beans.BeanAdapter ba,
String propertyName)
|
static void |
bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
Component component)
also set the name of the component based on the linked bean property |
static void |
bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
Component component,
String componentProperty)
also set the name of the component based on the linked bean property |
static void |
bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
JButtonGroup buttonGroup)
|
static void |
bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
JButtonGroup buttonGroup,
String property)
also set the name of the component based on the linked bean property |
static void |
bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
PropertyChangeListener pcl)
have a PCL react to changes (when there is no property to bind to) |
static void |
bind(Component component1,
String property1,
Component component2,
String property2)
Bind two properties and do not update any |
static void |
bind(com.jgoodies.binding.value.ValueModel valueModel,
Component component)
Bind a property of a component to a valueModel. |
static void |
bind(com.jgoodies.binding.value.ValueModel valueModel,
Component component,
String property)
Bind a property of a component to a valueModel. |
static void |
bind(com.jgoodies.binding.value.ValueModel valueModel,
JButtonGroup buttonGroup,
String property)
Bind a property of a ButtonGroup to a valueModel. |
static void |
bindAndUpdate1(Component component1,
String property1,
Component component2,
String property2)
Bind two properties and updated the first set |
static void |
bindAndUpdate2(Component component1,
String property1,
Component component2,
String property2)
Bind two properties and updated the second set |
static void |
bindComboboxToValueModel(JComboBox jcombobox,
com.jgoodies.binding.value.ValueModel valueModel,
boolean allowNull)
Bind a combobox to a valueModel |
static void |
bindJdbcComboboxToValueModel(JComboBox jcombobox,
com.jgoodies.binding.value.ValueModel valueModel,
boolean allowNull)
Bind a combobox that uses the JdbcComboboxModel to a valueModel |
static BindingUtils.BindingInfo |
getBindingInfo(Component c)
|
static void |
storeBindingInfo(Component component,
com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SOURCECODE_VERSION
public static final String SOURCECODE_VERSION
- Standard variable for determining version of a class file.
- See Also:
- Constant Field Values
BindingUtils
public BindingUtils()
bind
public static void bind(com.jgoodies.binding.value.ValueModel valueModel,
Component component)
- Bind a property of a component to a valueModel.
Catch and show IllegalArgumentExceptions.
- Parameters:
valueModel - component -
bind
public static void bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
Component component)
- also set the name of the component based on the linked bean property
bind
public static void bind(com.jgoodies.binding.value.ValueModel valueModel,
Component component,
String property)
- Bind a property of a component to a valueModel.
- Parameters:
valueModel - component - property - of component
bind
public static void bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
Component component,
String componentProperty)
- also set the name of the component based on the linked bean property
bind
public static void bind(com.jgoodies.binding.value.ValueModel valueModel,
JButtonGroup buttonGroup,
String property)
- Bind a property of a ButtonGroup to a valueModel.
Catch and show IllegalArgumentExceptions.
- Parameters:
valueModel - buttonGroup -
bind
public static void bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
JButtonGroup buttonGroup,
String property)
- also set the name of the component based on the linked bean property
bind
public static void bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
JButtonGroup buttonGroup)
bind
public static void bind(Component component1,
String property1,
Component component2,
String property2)
- Bind two properties and do not update any
bindAndUpdate1
public static void bindAndUpdate1(Component component1,
String property1,
Component component2,
String property2)
- Bind two properties and updated the first set
bindAndUpdate2
public static void bindAndUpdate2(Component component1,
String property1,
Component component2,
String property2)
- Bind two properties and updated the second set
bind
public static void bind(com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty,
PropertyChangeListener pcl)
- have a PCL react to changes (when there is no property to bind to)
bindComboboxToValueModel
public static void bindComboboxToValueModel(JComboBox jcombobox,
com.jgoodies.binding.value.ValueModel valueModel,
boolean allowNull)
- Bind a combobox to a valueModel
- Parameters:
jcombobox - valueModel - allowNull - allow nulls to be set into the value model
bindJdbcComboboxToValueModel
public static void bindJdbcComboboxToValueModel(JComboBox jcombobox,
com.jgoodies.binding.value.ValueModel valueModel,
boolean allowNull)
- Bind a combobox that uses the JdbcComboboxModel to a valueModel
- Parameters:
jcombobox - valueModel - allowNull - allow nulls to be set into the value model
getBindingInfo
public static BindingUtils.BindingInfo getBindingInfo(Component c)
storeBindingInfo
public static void storeBindingInfo(Component component,
com.jgoodies.binding.beans.BeanAdapter beanAdapter,
String beanProperty)
- Parameters:
component - beanAdapter - beanProperty -
bind
public static BindingUtils.Binding bind(com.jgoodies.binding.beans.BeanAdapter ba,
String propertyName)
Copyright © 2011 KnowledgePlaza. All Rights Reserved.