| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 /* Copyright (C) 2005 Simon David Rycroft 2 3 This program is free software; you can redistribute it and/or 4 modify it under the terms of the GNU General Public License 5 as published by the Free Software Foundation; either version 2 6 of the License, or (at your option) any later version. 7 8 This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License 14 along with this program; if not, write to the Free Software 15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 16 17 import java.io.*; 18 import java.util.Vector; 19 import javax.swing.*; 20 import javax.swing.table.*; 21 22 public class TableData extends AbstractTableModel 23 { 24 Vector myTable; 25 int colCount; 26 String [] headers = {"Filename","Size - Kb"}; 27 int totalFileSize; 28 29 public TableData(String file, String size){ 30 31 myTable = new Vector(); 32 colCount = 2; 33 totalFileSize =0; 34 headers[0] = file; 35 headers[1] = size; 36 } 37 38 public String getColumnName(int i){ 39 if(i==1 && totalFileSize !=0) 40 { 41 double totalFileSizeMB = totalFileSize/ 10485.76; 42 totalFileSizeMB = (double)Math.round(totalFileSizeMB)/100; 43 return headers[i]+" ("+totalFileSizeMB+"Mb)"; 44 } 45 else 46 return headers[i]; 47 } 48 49 public int getColumnCount(){ 50 return colCount; 51 } 52 53 public int getRowCount() 54 { 55 return myTable.size();} 56 57 public int getTotalFileSize() 58 { 59 return totalFileSize;} 60 61 public Object getValueAt(int row, int col) 62 { 63 return ((Object[])myTable.elementAt(row))[col];} 64 65 66 public void formatTable(String [][] data, int dataLength) 67 { 68 totalFileSize =0; 69 myTable = new Vector(); 70 int j=0; 71 while (j<dataLength) 72 { 73 Object[] row = new Object[colCount]; 74 for (int k=0; k < colCount; k++) 75 { 76 if(k==1) 77 { 78 try{ 79 int thisFileSize = Integer.parseInt(data[j][k]); 80 totalFileSize += thisFileSize; 81 thisFileSize /=102.4; 82 double thisFileKb = (double)thisFileSize/10; 83 row[k] = new Double(thisFileKb);} 84 catch(NumberFormatException nfe){;} 85 } 86 else 87 row[k] = data[j][k]; 88 } 89 myTable.addElement(row); 90 j++; 91 } 92 fireTableChanged(null); 93 } 94 } 95 96 97
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |