[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    API REVIEW: BaseObservableList
From:       martin.sladecek () oracle ! com (Martin Sladecek)
Date:       2012-06-28 8:16:35
Message-ID: 4FEC12E3.3020708 () oracle ! com
[Download RAW message or body]

Hello,
BaseObservableList was already discussed for 2.1, but we decided to 
defer it to some later release at the end. Full discussion here: 
http://mail.openjdk.java.net/pipermail/openjfx-dev/2011-December/000224.html.

Based on the discussion, I reworked it into two new classes: 
BaseObservableList (for simple observable lists that are not necessarily 
modifiable) and it's subclass BaseModifiableObservableList.

*public abstract class BaseObservableList<E> extends AbstractList<E> 
implements ObservableList<E>:*

First of all, it will implement following ObservableList methods:

public final void addListener(InvalidationListener listener)
public final void removeListener(InvalidationListener listener)
public final void addListener(ListChangeListener<? super E> listener)
public final void removeListener(ListChangeListener<? super E> listener)

... and will contain these new methods:

// calls all the listeners of this ObservableList
protected final void callListeners(ListChangeListener.Change<E> change)
// true if there are some registered listeners
protected final boolean hasListeners()

Following methods were part of IterableChangeBuilder in the original 
discussion. Now they will be part of BaseObservableList and can be used 
for creating a Change and firing it, so you don't need to create 
subclasses of ListChangeListener.Change yourself.

protected final void nextUpdate(int pos)
protected final void nextSet(int idx, E old)
protected final void nextReplace(int from, int to, ArrayList removed)
protected final void nextRemove(int idx, List removed)
protected final void nextRemove(int idx, E removed)
protected final void nextPermutation(int from, int to, int[] perm)
protected final void nextAdd(int from, int to)
protected final void endChange()
protected final void beginChange()

All next* methods need to be enclosed in beginChange() / endChange() 
pair. The calls can be also nested and after the outermost endChange() 
call, callListeners() will be called with the newly created Change.

*public abstract class BaseModifiableObservableList<E> extends 
BaseObservableList<E>:
*
This class introduces three new abstract methods:

  protected abstract void doAdd(int index, E element);
  protected abstract E doSet(int index, E element);
  protected abstract E doRemove(int index);

These methods are meant to contain simple list manipulations. The 
BaseModifiableObservableList implementation takes care of Change 
construction (using BaseObservableList methods), but subclasses can 
override this behaviour.

Any comments?

Thanks,
-Martin

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic