Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
com.jgoodies.binding.beans.Model
com.jgoodies.binding.value.AbstractValueModel
com.jgoodies.binding.value.AbstractVetoableValueModel
public abstract class AbstractVetoableValueModel
extends AbstractValueModel
#proposedChange
is invoked. In this method
implementors define how to accept or reject value changes.
Implementors may veto against a proposed change based on the application
state or by asking the user, and may also perform additional operations
during the check, for example to save editor contents. Here's an example:
public class CheckPendingEditValueModel extends AbstractVetoableValueModel { public CheckPendingEditValueModel(ValueModel subject) { super(subject); } public boolean proposedChange(Object oldValue, Object proposedNewValue) { if (equals(oldValue, proposedNewValue)) return true; int option = JOptionPane.showConfirmDialog( Application.getDefaultParentFrame(), "Do you want to save the editor contents."); if (option == JOptionPane.YES_OPTION) model.save(); return option != JOptionPane.CANCEL_OPTION; } }
Field Summary |
Fields inherited from class com.jgoodies.binding.value.AbstractValueModel | |
PROPERTYNAME_VALUE |
Constructor Summary | |
|
Method Summary | |
Object |
|
abstract boolean |
|
void |
|
Methods inherited from class com.jgoodies.binding.value.AbstractValueModel | |
addValueChangeListener , booleanValue , doubleValue , fireValueChange , fireValueChange , fireValueChange , fireValueChange , fireValueChange , fireValueChange , fireValueChange , floatValue , getString , intValue , longValue , removeValueChangeListener , setValue , setValue , setValue , setValue , setValue , toString |
protected AbstractVetoableValueModel(ValueModel subject)
Constructs an AbstractVetoableValueModel for the given ValueModel.
- Parameters:
subject
- the underlying (or wrapped) ValueModel
public final Object getValue()
Returns this model's current subject value.
- Specified by:
- getValue in interface ValueModel
- Returns:
- this model's current subject value.
public abstract boolean proposedChange(Object oldValue, Object proposedNewValue)
Checks and answers whether the proposed value change shall be accepted or rejected. Implementors may perform additional operations, for example to save a pending editor content.
- Parameters:
oldValue
- the value before the changeproposedNewValue
- the new value if the change is accepted
- Returns:
- true to accept the proposed value, false to veto against it.
public final void setValue(Object newValue)
Sets the given value as new subject value if and only if 1) the new value differs from the old value and 2) the proposed change is accepted as checked byproposedChange(oldValue, newValue)
.
- Specified by:
- setValue in interface ValueModel
- Parameters:
newValue
- the value to set