1 44 45 package org.jfree.ui.about; 46 47 import java.util.List ; 48 import java.util.ResourceBundle ; 49 50 import javax.swing.table.AbstractTableModel ; 51 52 import org.jfree.base.Library; 53 54 61 public class LibraryTableModel extends AbstractTableModel { 62 63 64 private Library[] libraries; 65 66 67 private String nameColumnLabel; 68 69 70 private String versionColumnLabel; 71 72 73 private String licenceColumnLabel; 74 75 76 private String infoColumnLabel; 77 78 83 public LibraryTableModel(final List libraries) { 84 85 this.libraries = (Library[]) 86 libraries.toArray(new Library[libraries.size()]); 87 88 final String baseName = "org.jfree.ui.about.resources.AboutResources"; 89 final ResourceBundle resources = ResourceBundle.getBundle(baseName); 90 91 this.nameColumnLabel = resources.getString("libraries-table.column.name"); 92 this.versionColumnLabel = resources.getString("libraries-table.column.version"); 93 this.licenceColumnLabel = resources.getString("libraries-table.column.licence"); 94 this.infoColumnLabel = resources.getString("libraries-table.column.info"); 95 96 } 97 98 103 public int getRowCount() { 104 return this.libraries.length; 105 } 106 107 113 public int getColumnCount() { 114 return 4; 115 } 116 117 124 public String getColumnName(final int column) { 125 126 String result = null; 127 128 switch (column) { 129 130 case 0: result = this.nameColumnLabel; 131 break; 132 133 case 1: result = this.versionColumnLabel; 134 break; 135 136 case 2: result = this.licenceColumnLabel; 137 break; 138 139 case 3: result = this.infoColumnLabel; 140 break; 141 142 } 143 144 return result; 145 146 } 147 148 156 public Object getValueAt(final int row, final int column) { 157 158 Object result = null; 159 final Library library = this.libraries[row]; 160 161 if (column == 0) { 162 result = library.getName(); 163 } 164 else if (column == 1) { 165 result = library.getVersion(); 166 } 167 else if (column == 2) { 168 result = library.getLicenceName(); 169 } 170 else if (column == 3) { 171 result = library.getInfo(); 172 } 173 return result; 174 175 } 176 177 public Library[] getLibraries() { 178 return (Library[]) libraries.clone(); 179 } 180 } 181 | Popular Tags |