Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8091794

Support more derived ObservableList

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • fx2.0.1
    • javafx

      In many development situations, we need more evolved collections. SortedList and FilteredList are needed, even if currently not viewable. But more collections will be useful. Given my program, I am suggesting:

      1) ProxyList: an ObservableList backed by another ObservableList but using its own listeners (fired when changing the backing ObservableList and when changing items of the backing ObservableList):

      public interface ProxyList<E> implements ObservableList<E> {
          public abstract ObservableList<E> getContent();
          public abstract void setContent(final ObservableList<E> newContent);
      }

      2) TransformedList: an ObservableList referencing another ObservableList and a Callback. It is generating items by invoking a Callback on each item of the ObservableList. There is two possible variants (don't know currently if one is preferred): with or without caching in an internal List the generated items (if cached two calls to getItem will return items with same identity and not only same equality; if compute time of Callback is not negligible; if memory and possible resizing time of caching List is unwanted).

      public TransformedList<T,E> implements ObservableList<E> {
          public TransformedList(ObservableList<? extends T> list, Callback<? super T, ? extends E> operator);
      }

      3) ConcatenatedList: an ObservableList of ObservableList exposed as a single unified (read-only) ObservableList.

      public interface ConcatenatedList<E> extends ObservableList<ObservableList<? extends E>> {
          public abstract ObservableList<E> getConcatenated();
      }

      By example, in an IDE, you have an unique table of errors/warnings populated by many validators or compilers, each producing an ObservableList of messages. We need aggregating them by using a ConcatenatedList to populate the single table of errors.
      The ProxyList is useful when building these derived list by allowing an ObservableList to be exposed to clients without constraints, like having always the same ObservableList backing.

      This forum thread can be useful:
      https://forums.oracle.com/forums/thread.jspa?threadID=2319881&tstart=0
      NB: ProxyList is a different solution than binding between two ObservableList, because a ProxyList doesn't contain an ArrayList with references to items, then it doesn't use memory for this array or compute time for adding an item or copying items to another bigger array when it is full.
      Binding two ObservableList is more generic, possible even when the two ObservableList were created by others classes. ProxyList is more efficient (less memory used, less compute work) but need that the class creating the binding own one of the ObservableList (the ProxyList created).

            Unassigned Unassigned
            gsutrajfx Gaja Sutra (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Imported: