/************************************************************************** /* This class implements the TableModel for the FreeSpace-data of Linux /* filesystems. /* /* Copyright (c) 2004 by Bernhard Bablok (mail@bablokb.de) /* /* 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 2 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; see the file COPYING. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ import javax.swing.table.*; /** This class implements the TableModel for the FreeSpace-data of Linux filesystems. This is a quick-and-dirty hack. @version $Revision: 1.2 $ @author $Author: bablokb $ */ public class FreeSpaceTableModel extends AbstractTableModel { private final static int COLUMN_COUNT = 5; ////////////////////////////////////////////////////////////////////////////// /** Storage for the data. */ private final Object[][] iData; ////////////////////////////////////////////////////////////////////////////// /** Default constructor - builds the FreeSpace data-source. */ public FreeSpaceTableModel() { iData = new Object[14][COLUMN_COUNT]; // "Medium" "FSType" "Size" // "Blocks" "Free" iData[0] = new Object[] { "64MB-USB", "ext2", new Integer(64000), new Integer(61973), new Integer(58760) }; iData[1] = new Object[] { "64MB-USB", "ext3", new Integer(64000), new Integer(61973), new Integer(54646) }; iData[2] = new Object[] { "64MB-USB", "minix", new Integer(64000), new Integer(63320), new Integer(63319) }; iData[3] = new Object[] { "64MB-USB", "vfat", new Integer(64000), new Integer(63858), new Integer(63858) }; iData[4] = new Object[] { "64MB-USB", "reiserfs", new Integer(64000), new Integer(63992), new Integer(31152) }; iData[5] = new Object[] { "64MB-USB", "jfs", new Integer(64000), new Integer(62768), new Integer(62628) }; iData[6] = new Object[] { "64MB-USB", "xfs", new Integer(64000), new Integer(59200), new Integer(59136) }; iData[7] = new Object[] { "DVD-RAM", "ext2", new Integer(4473408), new Integer(4403064), new Integer(4179376) }; iData[8] = new Object[] { "DVD-RAM", "ext3", new Integer(4473408), new Integer(4403064), new Integer(4146568) }; iData[9] = new Object[] { "DVD-RAM", "minix", new Integer(4473408), null, null }; iData[10] = new Object[] { "DVD-RAM", "vfat", new Integer(4473408), null, null }; iData[11] = new Object[] { "DVD-RAM", "reiserfs", new Integer(4473408), new Integer(4473264), new Integer(4440424) }; iData[12] = new Object[] { "DVD-RAM", "jfs", new Integer(4473408), new Integer(4454636), new Integer(4453960) }; iData[13] = new Object[] { "DVD-RAM", "xfs", new Integer(4473408), null, null }; } ////////////////////////////////////////////////////////////////////////////// /** Returns the number of rows in the table model. @return the row count. */ public int getRowCount() { return iData.length; } ////////////////////////////////////////////////////////////////////////////// /** Returns the number of columns in the table model. @return the column count. */ public int getColumnCount() { return COLUMN_COUNT; } ////////////////////////////////////////////////////////////////////////////// /** Returns the class of the data in the specified column. @param column the column (zero-based index). @return the column class. */ public Class getColumnClass(final int column) { if (column > 1) return Integer.class; else return String.class; } ////////////////////////////////////////////////////////////////////////////// /** Returns the name of the specified column. @param column the column (zero-based index). @return the column name. */ public String getColumnName(final int column) { if (column == 0) return "Medium"; else if (column == 1) return "FSType"; else if (column == 2) return "Size"; else if (column == 3) return "Blocks"; else if (column == 4) return "Free"; else return null; } ////////////////////////////////////////////////////////////////////////////// /** Returns the data value at the specified row and column. @param row the row index (zero based). @param column the column index (zero based). @return the value. */ public Object getValueAt(final int row, final int column) { return iData[row][column]; } }