001 // License: GPL. For details, see LICENSE file. 002 package org.openstreetmap.josm.gui.history; 003 004 import java.util.ArrayList; 005 import java.util.List; 006 007 import javax.swing.table.AbstractTableModel; 008 009 /** 010 * Simple model storing "diff cells" in a list. Could probably have used a DefaultTableModel instead.. 011 * 012 * {@link NodeListDiffTableCellRenderer} 013 */ 014 class DiffTableModel extends AbstractTableModel { 015 private List<TwoColumnDiff.Item> rows; 016 017 public void setRows(List<TwoColumnDiff.Item> rows) { 018 this.rows = rows; 019 } 020 021 public DiffTableModel(List<TwoColumnDiff.Item> rows) { 022 this.rows = rows; 023 } 024 public DiffTableModel() { 025 this.rows = new ArrayList<TwoColumnDiff.Item>(); 026 } 027 @Override 028 public int getRowCount() { 029 return rows.size(); 030 } 031 032 @Override 033 public int getColumnCount() { 034 return 1; 035 } 036 037 @Override 038 public TwoColumnDiff.Item getValueAt(int rowIndex, int columnIndex) { 039 return rows.get(rowIndex); 040 } 041 }