@@ -0,0 +1,3467 @@
+/*%0A * Copyright (c) 2006-2015 DMDirc Developers%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in%0A * all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A * SOFTWARE.%0A */%0A%0Apackage com.dmdirc.addons.ui_swing.components;%0A%0Aimport com.google.common.collect.HashBasedTable;%0Aimport com.google.common.collect.Lists;%0Aimport com.google.common.collect.Table;%0A%0Aimport java.util.List;%0Aimport java.util.function.BiFunction;%0A%0Aimport javax.swing.event.TableModelListener;%0Aimport javax.swing.table.TableModel;%0A%0A/**%0A * A Swing %7B@link TableModel%7D that uses a Guava %7B@link Table%7D as a backing store.%0A */%0Apublic class TableTableModel implements TableModel %7B%0A%0A    private final List%3CString%3E headers;%0A    private final Table%3CInteger, Integer, String%3E table;%0A    private final BiFunction%3CInteger, Integer, Boolean%3E editableFunction;%0A%0A    /**%0A     * Creates a new table model.%0A     *%0A     * @param headers          The headers to use for the table.%0A     * @param table            The table backing this table.%0A     * @param editableFunction The function to decide if a cell will be editable%0A     */%0A    public TableTableModel(final Iterable%3CString%3E headers,%0A            final Table%3CInteger, Integer, String%3E table,%0A            final BiFunction%3CInteger, Integer, Boolean%3E editableFunction) %7B%0A        this.headers = Lists.newArrayList(headers);%0A        this.table = HashBasedTable.create(table);%0A        this.editableFunction = editableFunction;%0A    %7D%0A%0A    @Override%0A    public int getRowCount() %7B%0A        return table.rowKeySet().size();%0A    %7D%0A%0A    @Override%0A    public int getColumnCount() %7B%0A        return table.columnKeySet().size();%0A    %7D%0A%0A    @Override%0A    public String getColumnName(final int columnIndex) %7B%0A        return headers.get(columnIndex);%0A    %7D%0A%0A    @Override%0A    public Class%3C?%3E getColumnClass(final int columnIndex) %7B%0A        return String.class;%0A    %7D%0A%0A    @Override%0A    public boolean isCellEditable(final int rowIndex, final int columnIndex) %7B%0A        return editableFunction.apply(rowIndex, columnIndex);%0A    %7D%0A%0A    @Override%0A    public Object getValueAt(final int rowIndex, final int columnIndex) %7B%0A        return table.get(rowIndex, columnIndex);%0A    %7D%0A%0A    @Override%0A    public void setValueAt(final Object aValue, final int rowIndex, final int columnIndex) %7B%0A        table.put(rowIndex, columnIndex, (String) aValue);%0A    %7D%0A%0A    @Override%0A    public void addTableModelListener(final TableModelListener l) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void removeTableModelListener(final TableModelListener l) %7B%0A%0A    %7D%0A%7D%0A

Add a JTable model that uses a Guava Table.