public void processComponent(final String propertyName, final JComponent component) {
final OriginalValueHolder originalValueHolder = new OriginalValueHolder();
final DirtyOverlay overlay = new DirtyOverlay(getFormModel(), propertyName, originalValueHolder);
final ValueHolder reset = new ValueHolder(Boolean.FALSE);
getFormModel().getValueModel(propertyName).addValueChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (reset.getValue() == Boolean.TRUE) {
originalValueHolder.reset();
reset.setValue(Boolean.FALSE);
overlay.setVisible(false);
return;
}
if (!originalValueHolder.isInitialized()) {
originalValueHolder.setOriginalValue(evt.getOldValue());
}
Object oldValue = originalValueHolder.getValue();
Object newValue = evt.getNewValue();
overlay.setVisible(getValueChangeDetector().hasValueChanged(oldValue, newValue)
&& !getFormModel().getFieldMetadata(propertyName).isReadOnly());
}
});
getFormModel().getFormObjectHolder().addValueChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
// reset original value, new "original" value is in the form
// model as the form object has changed
reset.setValue(Boolean.TRUE);
}
});
InterceptorOverlayHelper.attachOverlay(overlay.getControl(), component, OverlayHelper.NORTH_WEST, 5, 0);
overlay.setVisible(false);