/** * Releases the resources consumed by this {@link JEventListPanel} so that it * may eventually be garbage collected. * * <p><strong><font color="#FF0000">Warning:</font></strong> It is an error * to call any method on a {@link JEventListPanel} after it has been disposed. */ public void dispose() { swingSource.removeListEventListener(sourceChangeHandler); swingSource.dispose(); }
/** @inheritDoc */ public void addColumn(TableColumn column) { swingThreadSource.getReadWriteLock().writeLock().lock(); try { swingThreadSource.add((T) column); } finally { swingThreadSource.getReadWriteLock().writeLock().unlock(); } }
@Override public void addListEventListener(ListEventListener<? super E> listChangeListener) { super.addListEventListener(listChangeListener); // also adjust the table's checked rows if(listChangeListener instanceof DefaultEventTableViewer) { tableChecker = new TableChecker(); super.addListEventListener(tableChecker); } }
/** {@inheritDoc} */ @Override public E remove(int index) { if(!isWritable()) throw new IllegalStateException("Non-writable List cannot be modified"); if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); return (E) source.remove(getSourceIndex(index)); }
/** {@inheritDoc} */ @Override public E get(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot get at " + index + " on list of size " + size()); return (E) source.get(getSourceIndex(index)); }
swingThreadSource.getReadWriteLock().readLock().lock(); for (int i = 0, n = swingThreadSource.size(); i < n; i++) swingThreadSource.get(i).removePropertyChangeListener(this); swingThreadSource.removeListEventListener(this); swingThreadSource.dispose(); swingThreadSource.getReadWriteLock().readLock().unlock();
/** @inheritDoc */ public int getColumnIndex(Object identifier) { if (identifier == null) throw new IllegalArgumentException("identifier is null"); swingThreadSource.getReadWriteLock().readLock().lock(); try { for (int i = 0, n = swingThreadSource.size(); i < n; i++) { if (identifier.equals(swingThreadSource.get(i).getIdentifier())) return i; } throw new IllegalArgumentException("Identifier not found"); } finally { swingThreadSource.getReadWriteLock().readLock().unlock(); } }
/** @inheritDoc */ public TableColumn getColumn(int columnIndex) { swingThreadSource.getReadWriteLock().readLock().lock(); try { return swingThreadSource.get(columnIndex); } finally { swingThreadSource.getReadWriteLock().readLock().unlock(); } }
/** {@inheritDoc} */ @Override public void dispose() { super.dispose(); cacheUpdates.removeListEventListener(updateRunner); }
/** @inheritDoc */ @Override public void moveColumn(int columnIndex, int newIndex) { if (columnIndex < 0 || columnIndex >= getColumnCount()) throw new IllegalArgumentException("columnIndex out of range"); if (newIndex < 0 || newIndex >= getColumnCount()) throw new IllegalArgumentException("newIndex out of range"); // If the column has not yet moved far enough to change positions // post the event anyway, the "draggedDistance" property of the // tableHeader will say how far the column has been dragged. // Here we are really trying to get the best out of an // API that could do with some rethinking. We preserve backward // compatibility by slightly bending the meaning of these methods. if (columnIndex == newIndex) { fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex)); return; } swingThreadSource.getReadWriteLock().writeLock().lock(); try { final boolean selected = selectionModel.isSelectedIndex(columnIndex); swingThreadSource.add(newIndex, swingThreadSource.remove(columnIndex)); // preserve the selection after the move if one existed if (selected) selectionModel.addSelectionInterval(newIndex, newIndex); } finally { swingThreadSource.getReadWriteLock().writeLock().unlock(); } }
/** * Creates a new List that displays and responds to changes in source. * List elements are formatted using the provided {@link ILabelProvider}. */ public EventListViewer(EventList<E> source, List list, ILabelProvider labelProvider) { // lock the source list for reading since we want to prevent writes // from occurring until we fully initialize this EventListViewer source.getReadWriteLock().readLock().lock(); try { swtThreadSource = GlazedListsSWT.swtThreadProxyList(source, list.getDisplay()); this.list = list; this.labelProvider = labelProvider; // Enable the selection lists selection = new SelectionManager<E>(swtThreadSource, new SelectableList()); // setup initial values for(int i = 0, n = swtThreadSource.size(); i < n; i++) { addRow(i, swtThreadSource.get(i)); } // listen for changes swtThreadSource.addListEventListener(this); } finally { source.getReadWriteLock().readLock().unlock(); } }
/** @inheritDoc */ public int getColumnCount() { swingThreadSource.getReadWriteLock().readLock().lock(); try { return swingThreadSource.size(); } finally { swingThreadSource.getReadWriteLock().readLock().unlock(); } }
/** @inheritDoc */ @Override public void removeColumn(TableColumn column) { swingThreadSource.getReadWriteLock().writeLock().lock(); try { swingThreadSource.remove(column); } finally { swingThreadSource.getReadWriteLock().writeLock().unlock(); } }
/** * Creates a new {@link JEventListPanel} hosting the * {@link JComponent}s from the specified source {@link EventList}. */ public JEventListPanel(EventList<E> source, Format<E> format) { this.swingSource = GlazedListsSwing.swingThreadProxyList(source); this.listLayout = new ListLayout(this, format); this.format = format; this.setLayout(listLayout); // populate the initial elements for(int i = 0; i < swingSource.size(); i++) { sourceChangeHandler.insert(i); } // listen for changes to the source swingSource.addListEventListener(sourceChangeHandler); }
/** * Returns the element at the specified position in this list. This unwraps * a {@link CheckWrapped} object from the source if necessary. */ @Override public E get(int index) { if(checkableTableFormat != null) { return super.get(index); } else { CheckWrapped<E> checkWrapped = (CheckWrapped<E>)super.get(index); return checkWrapped.getWrapped(); } }
/** @inheritDoc */ @Override public Enumeration<TableColumn> getColumns() { return new IteratorAsEnumeration<TableColumn>(swingThreadSource.iterator()); }
/** {@inheritDoc} */ @Override public E remove(int visibleIndex) { final E result = get(visibleIndex); super.remove(visibleIndex); return result; }
/** * Provides access to an {@link EventList} that contains items from the * viewed Table that are not currently selected. */ public EventList<E> getDeselected() { swtThreadSource.getReadWriteLock().readLock().lock(); try { return selection.getSelectionList().getDeselected(); } finally { swtThreadSource.getReadWriteLock().readLock().unlock(); } }
swingThreadSource.getReadWriteLock().readLock().lock(); for (int i = 0, n = swingThreadSource.size(); i < n; i++) swingThreadSource.get(i).removePropertyChangeListener(this); swingThreadSource.removeListEventListener(this); swingThreadSource.dispose(); swingThreadSource.getReadWriteLock().readLock().unlock();
/** {@inheritDoc} */ @Override public E remove(int index) { if(!isWritable()) throw new IllegalStateException("Non-writable List cannot be modified"); if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); return (E) source.remove(getSourceIndex(index)); }