1 package tim.prune.correlate;
3 import java.util.ArrayList;
4 import javax.swing.table.AbstractTableModel;
5 import tim.prune.I18nManager;
6 import tim.prune.data.MediaFile;
10 * Class to act as the table model for the selection table in the correlation functions.
11 * Can be used by both photo correlation and audio correlation
13 public class MediaSelectionTableModel extends AbstractTableModel
15 /** Text for first column heading */
16 private String _firstColumnHeading = null;
17 /** Text for last column heading */
18 private String _lastColumnHeading = null;
20 private ArrayList<MediaSelectionTableRow> _list = new ArrayList<MediaSelectionTableRow>();
25 * @param inFirstColumnKey key for first column heading
26 * @param inLastColumnKey key for last column heading
28 public MediaSelectionTableModel(String inFirstColumnKey, String inLastColumnKey)
30 _firstColumnHeading = I18nManager.getText(inFirstColumnKey);
31 _lastColumnHeading = I18nManager.getText(inLastColumnKey);
35 * @return the column count, always 4
37 public int getColumnCount() {
42 * Get the name of the column
43 * @param inColNum column number
46 public String getColumnName(int inColNum)
48 if (inColNum == 0) return _firstColumnHeading;
49 else if (inColNum == 1) return I18nManager.getText("fieldname.timestamp");
50 else if (inColNum == 2) return I18nManager.getText("dialog.correlate.select.timediff");
51 return _lastColumnHeading;
56 * @return the row count
58 public int getRowCount()
65 * Get the selected row from the table
66 * @param inRowIndex row index
67 * @return table row object
69 public MediaSelectionTableRow getRow(int inRowIndex)
71 return _list.get(inRowIndex);
76 * Get the value of the specified cell
77 * @param inRowIndex row index
78 * @param inColumnIndex column index
79 * @return value of specified cell
81 public Object getValueAt(int inRowIndex, int inColumnIndex)
83 // MAYBE: only show time of photos (not date) if dates all identical
84 MediaSelectionTableRow row = _list.get(inRowIndex);
85 if (inColumnIndex == 0) return row.getMedia().getFile().getName();
86 else if (inColumnIndex == 1) return row.getMedia().getTimestamp().getText();
87 else if (inColumnIndex == 2) return row.getTimeDiff().getDescription();
88 return (row.getTimeDiff().getIsPositive() ? I18nManager.getText("dialog.about.yes") :
89 I18nManager.getText("dialog.about.no"));
101 * Add a media object to the list
102 * @param inMedia item to add
103 * @param inTimeDiff time difference
105 public void addMedia(MediaFile inMedia, long inTimeDiff)
107 _list.add(new MediaSelectionTableRow(inMedia, inTimeDiff));