public Object getElementAt(int index) { return list.get(index); }
public int indexOf(Object o) { return listenableList.indexOf(o); }
public int lastIndexOf(Object o) { return listenableList.lastIndexOf(o); }
/** * Set or change the listenable list which content is reflected by this list model.<br> * May trigger DELETED events (if there was already a non-empty underlying list) and ADDED events (if the list being set is not empty). * @param list */ public void setList(ListenableList<T> list) { ListenableList<T> oldList = this.list; if (oldList != null) { this.list = null; oldList.removeCollectionListener(listener); if (!oldList.isEmpty()) { fireIntervalRemoved(this, 0, oldList.size() - 1); } } this.list = list; if (list == null) return; list.addCollectionListener(listener); if (!list.isEmpty()) { fireIntervalAdded(this, 0, list.size() - 1); } }
@SuppressWarnings("unchecked") void add(T t, ListenableCollection<T> source, ListenableCollection<T> recipient) { if ((recipient instanceof List) && (source instanceof SortedSet)) { ListenableList<T> recipientList = (ListenableList<T>)recipient; Comparator<T> comparator = (Comparator<T>) ((SortedSet)source).comparator(); int i; if (comparator != null) { i = Collections.binarySearch(recipientList, t, comparator); } else { // Assume T is comparable i = Collections.binarySearch((List)recipientList, t); } if (i >= 0) { recipientList.set(i, t); } else { recipientList.add(-i - 1, t); } } else { recipient.add(t); } } @SuppressWarnings("unchecked")
public Object getSelectedItem() { if (selectedItem != null && !getList().contains(selectedItem)) selectedItem = null; return selectedItem; } @SuppressWarnings("unchecked")
Runnable worker = new Runnable() { public void run() { for (;!Thread.interrupted();) { U value; synchronized (it) { if (!it.hasNext()) break; value = it.next(); } try { V mappedValue = mapper.adapt(value); synchronized (out) { out.add(mappedValue); } } catch (Throwable th) { synchronized (errorsOut) { errorsOut.add(new Pair<U, Throwable>(value, th)); } } //Thread.yield(); } }};
results.clear(); resultArea.setText(""); generateAction.setEnabled(false);
@SuppressWarnings("unchecked") //@Override public void setSelectedItem(Object anItem) { if (getList().contains(anItem)) selectedItem = (T)anItem; else selectedItem = null; } }
public T get(int index) { return listenableList.get(index); }