Frames | No Frames |
1: /* ======================================================================== 2: * JCommon : a free general purpose class library for the Java(tm) platform 3: * ======================================================================== 4: * 5: * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jcommon/index.html 8: * 9: * This library is free software; you can redistribute it and/or modify it 10: * under the terms of the GNU Lesser General Public License as published by 11: * the Free Software Foundation; either version 2.1 of the License, or 12: * (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but 15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17: * License for more details. 18: * 19: * You should have received a copy of the GNU Lesser General Public 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * --------------------------- 28: * ContributorsTableModel.java 29: * --------------------------- 30: * (C) Copyright 2001-2008, by Object Refinery Limited. 31: * 32: * Original Author: David Gilbert (for Object Refinery Limited); 33: * Contributor(s): -; 34: * 35: * $Id: ContributorsTableModel.java,v 1.6 2008/12/18 09:57:32 mungady Exp $ 36: * 37: * Changes 38: * ------- 39: * 10-Dec-2001 : Version 1 (DG); 40: * 28-Feb-2002 : Moved into package com.jrefinery.ui.about. Changed import 41: * statements and updated Javadoc comments (DG); 42: * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG); 43: * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by 44: * Jess Thrysoee (DG); 45: * 46: */ 47: 48: package org.jfree.ui.about; 49: 50: import java.util.List; 51: import java.util.ResourceBundle; 52: 53: import javax.swing.table.AbstractTableModel; 54: 55: import org.jfree.util.ResourceBundleWrapper; 56: 57: /** 58: * A table model containing a list of contributors to a project. 59: * <P> 60: * Used in the ContributorsPanel class. 61: * 62: * @author David Gilbert 63: */ 64: public class ContributorsTableModel extends AbstractTableModel { 65: 66: /** Storage for the contributors. */ 67: private List contributors; 68: 69: /** Localised version of the name column label. */ 70: private String nameColumnLabel; 71: 72: /** Localised version of the contact column label. */ 73: private String contactColumnLabel; 74: 75: /** 76: * Constructs a ContributorsTableModel. 77: * 78: * @param contributors the contributors. 79: */ 80: public ContributorsTableModel(final List contributors) { 81: 82: this.contributors = contributors; 83: 84: final String baseName = "org.jfree.ui.about.resources.AboutResources"; 85: final ResourceBundle resources = ResourceBundleWrapper.getBundle( 86: baseName); 87: this.nameColumnLabel = resources.getString( 88: "contributors-table.column.name"); 89: this.contactColumnLabel = resources.getString( 90: "contributors-table.column.contact"); 91: 92: } 93: 94: /** 95: * Returns the number of rows in the table model. 96: * 97: * @return The number of rows. 98: */ 99: public int getRowCount() { 100: return this.contributors.size(); 101: } 102: 103: /** 104: * Returns the number of columns in the table model. In this case, there 105: * are always two columns (name and e-mail address). 106: * 107: * @return The number of columns in the table model. 108: */ 109: public int getColumnCount() { 110: return 2; 111: } 112: 113: /** 114: * Returns the name of a column in the table model. 115: * 116: * @param column the column index (zero-based). 117: * 118: * @return the name of the specified column. 119: */ 120: public String getColumnName(final int column) { 121: 122: String result = null; 123: 124: switch (column) { 125: 126: case 0: result = this.nameColumnLabel; 127: break; 128: 129: case 1: result = this.contactColumnLabel; 130: break; 131: 132: } 133: 134: return result; 135: 136: } 137: 138: /** 139: * Returns the value for a cell in the table model. 140: * 141: * @param row the row index (zero-based). 142: * @param column the column index (zero-based). 143: * 144: * @return the value. 145: */ 146: public Object getValueAt(final int row, final int column) { 147: 148: Object result = null; 149: final Contributor contributor 150: = (Contributor) this.contributors.get(row); 151: 152: if (column == 0) { 153: result = contributor.getName(); 154: } 155: else if (column == 1) { 156: result = contributor.getEmail(); 157: } 158: return result; 159: 160: } 161: 162: }