Пример #1
0
  /**
   * 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();
    }
  }
Пример #2
0
  /**
   * 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));
  }
Пример #3
0
  /**
   * 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();
  }
Пример #4
0
  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);
  }
Пример #5
0
  public void unbind() {
    if (bound) {
      bound = false;

      unbindModels();

      onUnbind();

      dirty.setDelegate(provider.dirty());
      handlerRegistry.dispose();
      binder.dispose();
      validationBinder.dispose();
      validationTree.dispose();
    }
  }
Пример #6
0
 public void setValue(T value) {
   provider.setValue(value);
 }
Пример #7
0
 public T getValue() {
   return provider.getValue();
 }