content: package spacecraftEditor.listEditors;
  
  import javax.swing.table.AbstractTableModel;
  
  /**
   * 
   * FOX 1 Telemetry Decoder
   * @author chris.e.thompson g0kla/ac2cz
   *
   * Copyright (C) 2015 amsat.org
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   *
   */
  @SuppressWarnings("serial")
  public abstract class CsvTableModel extends AbstractTableModel {
  	protected String[] columnNames = null;
  	@SuppressWarnings("rawtypes")
  	protected Class[] columnClass = null;
  	public int[] columnWidths;
  	protected String[][] data = null;
  	public int[] filterColumns;
  
  	public CsvTableModel() {
  		initColumns();
  	}
  	
  	protected abstract void initColumns();
  
  	public void setData(String[][] d) { 
  		data = d;
  		fireTableDataChanged();
  	}
  
  	public int getColumnCount() {
  		return columnNames.length;
  	}
  
  	public int getRowCount() {
  		if (data != null)
  			return data.length;
  		else 
  			return 0;
  	}
  
  	public String getColumnName(int col) {
  		return columnNames[col];
  	}
  
  	public Object getValueAt(int row, int col) {
  		return data[row][col];
  	}
  
  	@SuppressWarnings({ "unchecked", "rawtypes" })
  	public Class getColumnClass(int c) {
  		return columnClass[c];
  	}
  
  	/*
  	 * Don't need to implement this method unless your table's
  	 * editable.
  	 */
  	public boolean isCellEditable(int row, int col) {
  		//Note that the data/cell address is constant,
  		//no matter where the cell appears onscreen.
  
  		return true;
  	}
  
  	/*
  	 * Don't need to implement this method unless your table's
  	 * data can change.
  	 */
  	public void setValueAt(Object value, int row, int col) {
  		if (columnClass[col] == Double.class)
  			data[row][col] = "0";
  		else
  			data[row][col] = String.valueOf(value);
  
  		fireTableCellUpdated(row, col);
  	}
  
  }
  