Exemple #1
0
  /**
   * Sets the ListEditor's backing data.
   *
   * <p>If a null is passed in, the ListEditor will have no backing list and edits cannot be made.
   *
   * @param value a List of data objects of type T
   */
  public void setValue(List<T> value) {
    if (list == null && value == null) {
      // fast exit
      return;
    }
    if (list != null && list.isSameValue(value)) {
      // setting the same value as the one being edited
      list.refresh();
      return;
    }

    if (list != null) {
      // Having entire value reset, so dump the wrapper gracefully
      list.detach();
    }
    if (value == null) {
      list = null;
    } else {
      list = new ListEditorWrapper<T, E>(value, chain, editorSource);
      list.attach();
    }
  }
Exemple #2
0
 /**
  * Returns an unmodifiable, live view of the Editors managed by the ListEditor.
  *
  * <p>The returned list will be live until the next call to {@link #setValue(List)} and shouldn't
  * be used after that. Editors might (or might not) be reused after a call to {@link
  * #setValue(List)}.
  *
  * <p>If there is no backing list, an empty list will be returned.
  *
  * @return a List of {@link Editor Editors} of type E
  */
 public List<E> getEditors() {
   if (list == null) {
     return Collections.emptyList();
   }
   return Collections.unmodifiableList(list.getEditors());
 }
Exemple #3
0
 public void flush() {
   if (list != null) {
     list.flush();
   }
 }
Exemple #4
0
 public String getPathElement(E subEditor) {
   return "[" + list.getEditors().indexOf(subEditor) + "]";
 }