+ public class PDBEntryTableModel extends AbstractTableModel
+ {
+ String[] columns = { "Ref Sequence", "PDB Id", "Chain", "Type", "File" };
+
+ private List<CachedPDB> pdbEntries;
+
+ public PDBEntryTableModel(List<CachedPDB> pdbEntries)
+ {
+ this.pdbEntries = new ArrayList<CachedPDB>(pdbEntries);
+ }
+
+ @Override
+ public String getColumnName(int columnIndex)
+ {
+ return columns[columnIndex];
+ }
+
+ @Override
+ public int getRowCount()
+ {
+ return pdbEntries.size();
+ }
+
+ @Override
+ public int getColumnCount()
+ {
+ return columns.length;
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column)
+ {
+ return false;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ Object value = "??";
+ CachedPDB entry = pdbEntries.get(rowIndex);
+ switch (columnIndex)
+ {
+ case 0:
+ value = entry.getSequence();
+ break;
+ case 1:
+ value = entry.getPdbEntry();
+ break;
+ case 2:
+ value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
+ .getPdbEntry().getChainCode();
+ break;
+ case 3:
+ value = entry.getPdbEntry().getType();
+ break;
+ case 4:
+ value = entry.getPdbEntry().getFile();
+ break;
+ }
+ return value;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex)
+ {
+ return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
+ }
+
+ public CachedPDB getPDBEntryAt(int row)
+ {
+ return pdbEntries.get(row);
+ }
+
+ }
+
+ private class CachedPDB
+ {
+ private SequenceI sequence;
+
+ private PDBEntry pdbEntry;
+
+ public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
+ {
+ this.sequence = sequence;
+ this.pdbEntry = pdbEntry;
+ }
+
+ public SequenceI getSequence()
+ {
+ return sequence;
+ }
+
+ public PDBEntry getPdbEntry()
+ {
+ return pdbEntry;
+ }
+
+ }
+
+ private IProgressIndicator progressBar;
+
+ @Override
+ public void setProgressBar(String message, long id)
+ {
+ progressBar.setProgressBar(message, id);
+ }
+
+ @Override
+ public void registerHandler(long id, IProgressIndicatorHandler handler)
+ {
+ progressBar.registerHandler(id, handler);
+ }
+
+ @Override
+ public boolean operationInProgress()
+ {
+ return progressBar.operationInProgress();
+ }