View Javadoc

1   // %1126721330432:hoplugins.transfers.ui.model%
2   package hoplugins.transfers.ui.model;
3   
4   import hoplugins.Commons;
5   
6   import hoplugins.transfers.vo.Bookmark;
7   
8   import java.util.List;
9   
10  import javax.swing.table.AbstractTableModel;
11  
12  
13  /***
14   * TableModel representing team bookmarks.
15   *
16   * @author <a href=mailto:nethyperon@users.sourceforge.net>Boy van der Werf</a>
17   */
18  public class TeamBookmarksTableModel extends AbstractTableModel {
19      //~ Instance fields ----------------------------------------------------------------------------
20  
21      private List values;
22      private String[] colNames = new String[2];
23  
24      //~ Constructors -------------------------------------------------------------------------------
25  
26      /***
27       * Creates a TeamBookmarksTableModel.
28       *
29       * @param values List of values to show in table.
30       */
31      public TeamBookmarksTableModel(List values) {
32          super();
33  
34          this.colNames[0] = Commons.getModel().getResource().getProperty("ID"); //$NON-NLS-1$
35          this.colNames[1] = Commons.getModel().getResource().getProperty("Name"); //$NON-NLS-1$
36  
37          this.values = values;
38      }
39  
40      //~ Methods ------------------------------------------------------------------------------------
41  
42      /*** {@inheritDoc} */
43      public final int getColumnCount() {
44          return colNames.length;
45      }
46  
47      /*** {@inheritDoc} */
48      public final String getColumnName(int column) {
49          return colNames[column];
50      }
51  
52      /*** {@inheritDoc} */
53      public final int getRowCount() {
54          return values.size();
55      }
56  
57      /*** {@inheritDoc} */
58      public final Object getValueAt(int rowIndex, int columnIndex) {
59          final Bookmark bookmark = (Bookmark) values.get(rowIndex);
60  
61          switch (columnIndex) {
62              case 0:
63                  return Integer.toString(bookmark.getId());
64  
65              case 1:
66                  return bookmark.getName();
67  
68              default:
69                  return ""; //$NON-NLS-1$
70          }
71      }
72  }