Perhaps knocking up a some reusable utility methods along these lines would
be enough?
public static ListIterator<T> getListIterator(Sequence<T> sequence) {...}
public static Iterator<T> getIterator(Sequence<T> sequence) {...}
public static Iterable<T> getIterable(Sequence<T> sequence) {...}
I'm not aware of anything like this within Pivot, but may be wrong.
Chris
On 16 June 2011 02:30, Edvin Syse <[email protected]> wrote:
> When I delete a domain object in my app, I check a tab pane to see if it
> contains any tabs that edits the deleted object and close them. I find
> myself writing code like this (Page is the domain object in this example):
>
> // Delete the page from RDBMS
> deletePage(page);
>
> // Put tabs to remove in another list to avoid
> ConcurrentModificationException
> List<Component> remove = new ArrayList<Component>();
>
> // Search for tabs to remove
> for (Component tab : tabs.getTabs()) {
> if (tab instanceof DomainObjectHolder) {
> DomainObjectHolder holder = (DomainObjectHolder) tab;
> if (page.equals(holder.getDomainObject()))
> remove.add(tab);
> }
> }
>
> // Remove the tabs
> for (Component tab : remove)
> tabs.getTabs().remove(tab);
>
> If tabs.getTabs() could give me a ListIterator, this would be a lot
> smoother, by maybe there is another Pivot way of doing this?
>
> -- Edvin
>
>