コード例 #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();
 }