mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-15 22:05:00 -05:00
0c674849d8
* use more GlazedLists stuff (EventList, AutoCompleteSupport) and remove obsolete classes (SimpleListModel, TextCompletion) * don't use SearchResultCache in EpisodeListClient (was only done for better ui interactions) * removed caching from ResourceManager * some improvements based on FindBugs warnings * use args4j for improved argument parsing * updated ant build script * more general MessageBus/Handler (use Object as message type instead of string) * ChecksumComputationService is not a singleton anymore * TemporaryFolder is always recreated if it is deleted by the user, or another instance shutting down * Notifications flicker less when one window is removed and the others are layouted * lots of other refactoring
51 lines
1.1 KiB
Java
51 lines
1.1 KiB
Java
|
|
package net.sourceforge.tuned;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import ca.odell.glazedlists.EventList;
|
|
import ca.odell.glazedlists.event.ListEvent;
|
|
import ca.odell.glazedlists.event.ListEventListener;
|
|
|
|
|
|
public class ListChangeSynchronizer<E> implements ListEventListener<E> {
|
|
|
|
private final List<E> target;
|
|
|
|
|
|
public ListChangeSynchronizer(EventList<E> source, List<E> target) {
|
|
this.target = target;
|
|
source.addListEventListener(this);
|
|
}
|
|
|
|
|
|
public void listChanged(ListEvent<E> listChanges) {
|
|
EventList<E> source = listChanges.getSourceList();
|
|
|
|
// update target list
|
|
while (listChanges.next()) {
|
|
int index = listChanges.getIndex();
|
|
int type = listChanges.getType();
|
|
|
|
switch (type) {
|
|
case ListEvent.INSERT:
|
|
target.add(index, source.get(index));
|
|
break;
|
|
case ListEvent.UPDATE:
|
|
target.set(index, source.get(index));
|
|
break;
|
|
case ListEvent.DELETE:
|
|
target.remove(index);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static <E> ListChangeSynchronizer<E> syncEventListToList(EventList<E> source, List<E> target) {
|
|
return new ListChangeSynchronizer<E>(source, target);
|
|
}
|
|
|
|
}
|