/** * Creates a new checkpoint for {@link AbstractModel#revert()} to revert to, if called, and clears * the dirty state (including that of added inner {@link AbstractModel}-s). */ public void checkpoint() { provider.checkpoint(); for (AbstractModel<?> model : models) { model.checkpoint(); } }
/** * Make this {@link AbstractModel}'s dirty value depend on the inner {@link AbstractModel}-s, if * there are any. */ private void updateDirtyDelegate() { List<ValueModel<Boolean>> values = new ArrayList<ValueModel<Boolean>>(); values.add(provider.dirty()); for (AbstractModel<?> model : models) { values.add(model.dirty()); } dirty.setDelegate(new ReducingCondition(new OrFunction(), values)); }
/** * Reverts this {@link AbstractModel} to the value it was originally provided with (via {@link * AbstractModel#setValue(Object)}) or the value when {@link AbstractModel#checkpoint()} was last * called. */ public void revert() { provider.revert(); // revert inner models before checkpoint()-ing, otherwise the inner // models will revert to the checkpoint we just made (and not their // "original" value, which would have been overwritten by the // checkpoint). for (AbstractModel<?> model : models) { model.revert(); } checkpoint(); }
public AbstractModel(Class<T> beanModelClass) { // TODO: could read the .class from the generic parameter? // TODO: should get this from an injected provider in the future if ever // go the GWT-way since it this specific implementation won't work with // GWT provider = new ReflectionBeanModelProvider<T>(beanModelClass); // auto-commit so models can be bound to other models and are // automatically updated instantly provider.setAutoCommit(true); validationTree.add(getFormValidator()); validationTree.addValidationHandler(validationMonitor); }
public void unbind() { if (bound) { bound = false; unbindModels(); onUnbind(); dirty.setDelegate(provider.dirty()); handlerRegistry.dispose(); binder.dispose(); validationBinder.dispose(); validationTree.dispose(); } }
public void setValue(T value) { provider.setValue(value); }
public T getValue() { return provider.getValue(); }