| Line | Hits | Source |
|---|---|---|
| 1 | /******************************************************************************* | |
| 2 | *InternetCafe is a software solution that helps the management of Cybercafes | |
| 3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
| 4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
| 5 | ||
| 6 | * This program is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU General Public License | |
| 8 | * as published by the Free Software Foundation; either version 2 | |
| 9 | * of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 19 | *******************************************************************************/ | |
| 20 | ||
| 21 | package base.jdbs.ui; | |
| 22 | ||
| 23 | import java.util.Date; | |
| 24 | import java.util.Observable; | |
| 25 | import java.util.Observer; | |
| 26 | ||
| 27 | import javax.swing.table.AbstractTableModel; | |
| 28 | ||
| 29 | import org.apache.log4j.Logger; | |
| 30 | ||
| 31 | import base.jdbs.BackupDescriptor; | |
| 32 | import base.jdbs.ConfigurationManager; | |
| 33 | import base.util.FileUtil; | |
| 34 | ||
| 35 | @SuppressWarnings("serial") | |
| 36 | 0 | public class BackupDescriptorTableModel extends AbstractTableModel implements Observer { |
| 37 | ||
| 38 | 0 | private static final transient Logger logger = Logger.getLogger(BackupDescriptorTableModel.class.getName()); |
| 39 | ||
| 40 | 0 | private String[] columnNames = {"Id","Name","Space (Kb)","Creation","Expiration","CRC32","MD5","Security"}; |
| 41 | ||
| 42 | public static final int BACKUP_ID_COLUMN = 0; | |
| 43 | ||
| 44 | public static final int BACKUP_NAME_COLUMN = 1; | |
| 45 | ||
| 46 | public static final int BACKUP_OCCUPIED_SPACE_COLUMN = 2; | |
| 47 | ||
| 48 | public static final int BACKUP_CREATION_DATE_COLUMN = 3; | |
| 49 | ||
| 50 | public static final int BACKUP_EXPIRATION_DATE_COLUMN = 4; | |
| 51 | ||
| 52 | public static final int BACKUP_CRC32_COLUMN = 5; | |
| 53 | ||
| 54 | public static final int BACKUP_MD5_COLUMN = 6; | |
| 55 | ||
| 56 | public static final int BACKUP_SECURITY_LEVEL_COLUMN = 7; | |
| 57 | ||
| 58 | public BackupDescriptorTableModel() { | |
| 59 | 0 | super(); |
| 60 | 0 | ConfigurationManager.getInstance().getRepository().addObserver(this); |
| 61 | 0 | } |
| 62 | ||
| 63 | public int getColumnCount() { | |
| 64 | 0 | return columnNames.length; |
| 65 | } | |
| 66 | ||
| 67 | public int getRowCount() { | |
| 68 | 0 | return ConfigurationManager.getInstance().getRepository().getBackupDescriptor().length; |
| 69 | } | |
| 70 | ||
| 71 | public String getColumnName(int column) { | |
| 72 | 0 | return columnNames[column]; |
| 73 | } | |
| 74 | ||
| 75 | public Object getValueAt(int row, int column) { | |
| 76 | 0 | if (row < 0 || column < 0) |
| 77 | 0 | return null; |
| 78 | 0 | Object result = null; |
| 79 | 0 | BackupDescriptor backupDescriptor = ConfigurationManager.getInstance().getRepository().getBackupDescriptor()[row]; |
| 80 | 0 | switch (column) { |
| 81 | case BACKUP_ID_COLUMN: | |
| 82 | 0 | result = backupDescriptor.getBackup().getGuId(); |
| 83 | 0 | break; |
| 84 | case BACKUP_NAME_COLUMN: | |
| 85 | 0 | result = backupDescriptor.getBackup().getName(); |
| 86 | 0 | break; |
| 87 | case BACKUP_OCCUPIED_SPACE_COLUMN: | |
| 88 | 0 | result = FileUtil.fileSizeInKB(backupDescriptor.getBackupFile()); |
| 89 | 0 | break; |
| 90 | case BACKUP_CREATION_DATE_COLUMN: | |
| 91 | 0 | result = backupDescriptor.getBackup().getCreationDate(); |
| 92 | 0 | break; |
| 93 | case BACKUP_EXPIRATION_DATE_COLUMN: | |
| 94 | 0 | result = backupDescriptor.getBackup().getExpirationDate(); |
| 95 | 0 | break; |
| 96 | case BACKUP_CRC32_COLUMN: | |
| 97 | 0 | result = backupDescriptor.getCrc32ChecksumValue(); |
| 98 | 0 | break; |
| 99 | case BACKUP_MD5_COLUMN: | |
| 100 | 0 | result = backupDescriptor.getMd5DigestValue(); |
| 101 | 0 | break; |
| 102 | case BACKUP_SECURITY_LEVEL_COLUMN: | |
| 103 | 0 | result = backupDescriptor.getBackup().getSecurityLevel(); |
| 104 | break; | |
| 105 | } | |
| 106 | 0 | return result; |
| 107 | } | |
| 108 | ||
| 109 | @SuppressWarnings("unchecked") | |
| 110 | public Class getColumnClass(int column) { | |
| 111 | 0 | Class result = null; |
| 112 | 0 | switch (column) { |
| 113 | case BACKUP_ID_COLUMN: | |
| 114 | 0 | result = String.class; |
| 115 | 0 | break; |
| 116 | case BACKUP_NAME_COLUMN: | |
| 117 | 0 | result = String.class; |
| 118 | 0 | break; |
| 119 | case BACKUP_OCCUPIED_SPACE_COLUMN: | |
| 120 | 0 | result = Long.class; |
| 121 | 0 | break; |
| 122 | case BACKUP_CREATION_DATE_COLUMN: | |
| 123 | 0 | result = Date.class; |
| 124 | 0 | break; |
| 125 | case BACKUP_EXPIRATION_DATE_COLUMN: | |
| 126 | 0 | result = Date.class; |
| 127 | 0 | break; |
| 128 | case BACKUP_CRC32_COLUMN: | |
| 129 | 0 | result = String.class; |
| 130 | 0 | break; |
| 131 | case BACKUP_MD5_COLUMN: | |
| 132 | 0 | result = String.class; |
| 133 | 0 | break; |
| 134 | case BACKUP_SECURITY_LEVEL_COLUMN: | |
| 135 | 0 | result = String.class; |
| 136 | break; | |
| 137 | } | |
| 138 | 0 | return result; |
| 139 | } | |
| 140 | ||
| 141 | public void update(Observable arg0, Object arg1) { | |
| 142 | 0 | this.fireTableDataChanged(); |
| 143 | 0 | } |
| 144 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |