/** * Creates a new table model that extracts column data from the given * <code>source</code> using the the given <code>tableFormat</code>. * * <p>The <code>eventAdapterFactory</code> is used to create a {@link TableModelEventAdapter}, * which is then used by the created table model to convert list events to table model events.</p> * * <p>The returned table model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread. * To do this programmatically, use {@link SwingUtilities#invokeAndWait(Runnable)} and * wrap the source list (or some part of the source list's pipeline) using * {@link GlazedListsSwing#swingThreadProxyList(EventList)}.</p> * * @param source the EventList that provides the row objects * @param tableFormat the object responsible for extracting column data * from the row objects * @param eventAdapterFactory factory for creating a {@link TableModelEventAdapter} */ public static <E> AdvancedTableModel<E> eventTableModel(EventList<E> source, TableFormat<? super E> tableFormat, TableModelEventAdapter.Factory<E> eventAdapterFactory) { final DefaultEventTableModel<E> result = new DefaultEventTableModel<E>(source, tableFormat); final TableModelEventAdapter<E> eventAdapter = eventAdapterFactory.create(result); result.setEventAdapter(eventAdapter); return result; }
/** * Creates a new table model that extracts column data from the given <code>source</code> * using the the given <code>tableFormat</code>. * * <p>While holding a read lock, this method wraps the source list using * {@link GlazedListsSwing#swingThreadProxyList(EventList)}.</p> * * <p>The <code>eventAdapterFactory</code> is used to create a {@link TableModelEventAdapter}, * which is then used by the created table model to convert list events to table model events.</p> * * <p> * The returned table model is <strong>not thread-safe</strong>. Unless otherwise noted, all * methods are only safe to be called from the event dispatch thread. * </p> * * @param source the EventList that provides the row objects * @param tableFormat the object responsible for extracting column data from the row objects * @param eventAdapterFactory factory for creating a {@link TableModelEventAdapter} */ public static <E> AdvancedTableModel<E> eventTableModelWithThreadProxyList(EventList<E> source, TableFormat<? super E> tableFormat, TableModelEventAdapter.Factory<E> eventAdapterFactory) { final EventList<E> proxySource = createSwingThreadProxyList(source); final DefaultEventTableModel<E> result = new DefaultEventTableModel<E>(proxySource, true, tableFormat); final TableModelEventAdapter<E> eventAdapter = eventAdapterFactory.create(result); result.setEventAdapter(eventAdapter); return result; }