Class ListEditor<T,​E extends Editor<? super T>>

  • Type Parameters:
    T - The type of data being managed
    E - The type of Editor
    All Implemented Interfaces:
    CompositeEditor<java.util.List<T>,​T,​E>, Editor<java.util.List<T>>, HasEditorDelegate<java.util.List<T>>, ValueAwareEditor<java.util.List<T>>
    Direct Known Subclasses:
    HasDataEditor

    public class ListEditor<T,​E extends Editor<? super T>>
    extends java.lang.Object
    implements CompositeEditor<java.util.List<T>,​T,​E>
    Manages a list of objects and their associated Editors.

    The ListEditor will have no backing list until setValue(List) is called with a non-null value.

    • Constructor Detail

      • ListEditor

        protected ListEditor​(EditorSource<E> source)
        Create a ListEditor backed by an EditorSource.
        Parameters:
        source - the EditorSource which will create sub-Editors
    • Method Detail

      • of

        public static <T,​E extends Editor<? super T>> ListEditor<T,​E> of​(EditorSource<E> source)
        Create a ListEditor backed by an EditorSource.
        Type Parameters:
        T - The type of data being managed
        E - The type of Editor
        Parameters:
        source - the EditorSource which will create sub-Editors
        Returns:
        a new instance of ListEditor
      • flush

        public void flush()
        Description copied from interface: ValueAwareEditor
        Indicates that the Editor cycle is finished. This method will be called in a depth-first order by the EditorDriver, so Editors do not generally need to flush their sub-editors.
        Specified by:
        flush in interface ValueAwareEditor<T>
      • getEditors

        public java.util.List<E> getEditors()
        Returns an unmodifiable, live view of the Editors managed by the ListEditor.

        The returned list will be live until the next call to setValue(List) and shouldn't be used after that. Editors might (or might not) be reused after a call to setValue(List).

        If there is no backing list, an empty list will be returned.

        Returns:
        a List of Editors of type E
      • getList

        public java.util.List<T> getList()
        Returns a live view of the ListEditor's backing data.

        The structure of the List may be mutated arbitrarily, subject to the limitations of the backing List, but the elements themselves should not be mutated except through getEditors() to avoid data inconsistency.

        Returns null if there is no backing list, and edits cannot be made.

         ListEditor<Foo, MyFooEditor> listEditor = ListEditor.of(...);
         listEditor.setValue(listOfFoo); // Usually called by EditorDriver
         listEditor.getList().set(1, new Foo());
         listEditor.getEditors().get(1).getFooFieldEditor().setValue(....);
         
        Returns:
        a live view of the ListEditor's backing data, or null if there is no backing list.
      • onPropertyChange

        public void onPropertyChange​(java.lang.String... paths)
        Description copied from interface: ValueAwareEditor
        Notifies the Editor that one or more value properties have changed. Not all backing services support property-based notifications.
        Specified by:
        onPropertyChange in interface ValueAwareEditor<T>
        Parameters:
        paths - a list of String paths
      • setValue

        public void setValue​(java.util.List<T> value)
        Sets the ListEditor's backing data.

        If a null is passed in, the ListEditor will have no backing list and edits cannot be made.

        Specified by:
        setValue in interface ValueAwareEditor<T>
        Parameters:
        value - a List of data objects of type T