1 package tim.prune.correlate;
3 import java.util.ArrayList;
4 import javax.swing.table.AbstractTableModel;
6 import tim.prune.I18nManager;
7 import tim.prune.data.Photo;
10 * Class to act as table model for the photo selection table
12 public class PhotoSelectionTableModel extends AbstractTableModel
14 private ArrayList<PhotoSelectionTableRow> _list = new ArrayList<PhotoSelectionTableRow>();
18 * @return the column count, always 4
20 public int getColumnCount()
27 * Get the name of the column
28 * @param inColNum column number
31 public String getColumnName(int inColNum)
33 if (inColNum == 0) return I18nManager.getText("dialog.correlate.photoselect.photoname");
34 else if (inColNum == 1) return I18nManager.getText("fieldname.timestamp");
35 else if (inColNum == 2) return I18nManager.getText("dialog.correlate.photoselect.timediff");
36 return I18nManager.getText("dialog.correlate.photoselect.photolater");
41 * @return the row count
43 public int getRowCount()
50 * Get the selected row from the table
51 * @param inRowIndex row index
52 * @return table row object
54 public PhotoSelectionTableRow getRow(int inRowIndex)
56 return _list.get(inRowIndex);
61 * Get the value of the specified cell
62 * @param inRowIndex row index
63 * @param inColumnIndex column index
64 * @return value of specified cell
66 public Object getValueAt(int inRowIndex, int inColumnIndex)
68 // MAYBE: only show time of photos (not date) if dates all identical
69 PhotoSelectionTableRow row = _list.get(inRowIndex);
70 if (inColumnIndex == 0) return row.getPhoto().getFile().getName();
71 else if (inColumnIndex == 1) return row.getPhoto().getTimestamp().getText();
72 else if (inColumnIndex == 2) return row.getTimeDiff().getDescription();
73 return (row.getTimeDiff().getIsPositive() ? I18nManager.getText("dialog.about.yes") :
74 I18nManager.getText("dialog.about.no"));
87 * Add a photo to the list
88 * @param inPhoto photo to add
89 * @param inTimeDiff time difference
91 public void addPhoto(Photo inPhoto, long inTimeDiff)
93 _list.add(new PhotoSelectionTableRow(inPhoto, inTimeDiff));