@Test public void testGetColumnIndex() { EventList<TableColumn> columns = new BasicEventList<>(); columns.add(createColumn("name")); columns.add(createColumn("age")); DefaultTableColumnModel defaultModel = watcher.createDefaultModel(columns); EventTableColumnModel eventModel = watcher.createEventModel(columns); assertEquals(0, defaultModel.getColumnIndex("name")); assertEquals(0, eventModel.getColumnIndex("name")); assertEquals(1, defaultModel.getColumnIndex("age")); assertEquals(1, eventModel.getColumnIndex("age")); try { defaultModel.getColumnIndex("this is absent"); fail("failed to throw IllegalArgumentException for an unknown TableColumn identifier"); } catch (IllegalArgumentException e) { } try { eventModel.getColumnIndex("this is absent"); fail("failed to throw IllegalArgumentException for an unknown TableColumn identifier"); } catch (IllegalArgumentException e) { } }
@Override 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(); } }
EventTableColumnModel implements TableColumnModel, PropertyChangeListener, ListSelectionListener, ListEventListener<T> { @Override 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(); } } }
EventTableColumnModel implements TableColumnModel, PropertyChangeListener, ListSelectionListener, ListEventListener<T> { @Override 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(); } } EventTableColumnModel(EventList<T> source); }
EventTableColumnModel implements TableColumnModel, PropertyChangeListener, ListSelectionListener, ListEventListener<T> { @Override 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(); } } EventTableColumnModel(EventList<T> source); @Override void addColumn(TableColumn column); @Override void removeColumn(TableColumn column); @Override void moveColumn(int columnIndex, int newIndex); @Override void setColumnMargin(int newMargin); @Override int getColumnMargin(); @Override int getColumnCount(); @Override Enumeration<TableColumn> getColumns(); @Override int getColumnIndex(Object identifier); @Override TableColumn getColumn(int columnIndex); @Override int getColumnIndexAtX(int x); @Override int getTotalColumnWidth(); @Override void setColumnSelectionAllowed(boolean flag); @Override boolean getColumnSelectionAllowed(); @Override int[] getSelectedColumns(); @Override int getSelectedColumnCount(); @Override void setSelectionModel(ListSelectionModel newModel); @Override ListSelectionModel getSelectionModel(); @Override void addColumnModelListener(TableColumnModelListener listener); @Override void removeColumnModelListener(TableColumnModelListener listener); @Override void propertyChange(PropertyChangeEvent evt); @Override void valueChanged(ListSelectionEvent e); @Override void listChanged(ListEvent<T> listChanges); void dispose(); }
EventTableColumnModel implements TableColumnModel, PropertyChangeListener, ListSelectionListener, ListEventListener<T> { @Override 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(); } } EventTableColumnModel(EventList<T> source); @Override void addColumn(TableColumn column); @Override void removeColumn(TableColumn column); @Override void moveColumn(int columnIndex, int newIndex); @Override void setColumnMargin(int newMargin); @Override int getColumnMargin(); @Override int getColumnCount(); @Override Enumeration<TableColumn> getColumns(); @Override int getColumnIndex(Object identifier); @Override TableColumn getColumn(int columnIndex); @Override int getColumnIndexAtX(int x); @Override int getTotalColumnWidth(); @Override void setColumnSelectionAllowed(boolean flag); @Override boolean getColumnSelectionAllowed(); @Override int[] getSelectedColumns(); @Override int getSelectedColumnCount(); @Override void setSelectionModel(ListSelectionModel newModel); @Override ListSelectionModel getSelectionModel(); @Override void addColumnModelListener(TableColumnModelListener listener); @Override void removeColumnModelListener(TableColumnModelListener listener); @Override void propertyChange(PropertyChangeEvent evt); @Override void valueChanged(ListSelectionEvent e); @Override void listChanged(ListEvent<T> listChanges); void dispose();  }