1 package tim.prune.save;
3 import javax.swing.table.AbstractTableModel;
5 import tim.prune.I18nManager;
8 * Class to hold table model information for save exif dialog
10 public class PhotoTableModel extends AbstractTableModel
12 private PhotoTableEntry[] _photos = null;
13 private int _addIndex = 0;
17 * Constructor giving list size
19 public PhotoTableModel(int inSize)
21 _photos = new PhotoTableEntry[inSize];
26 * Set the given PhotoTableEntry object in the array
27 * @param inEntry PhotoTableEntry object describing the photo
29 public void addPhotoInfo(PhotoTableEntry inEntry)
31 if (_addIndex < _photos.length && inEntry != null
32 && inEntry.getStatus() != null)
34 _photos[_addIndex] = inEntry;
40 * @return the number of photos in the list whose status has changed
42 public int getNumSaveablePhotos()
48 * @see javax.swing.table.TableModel#getColumnCount()
50 public int getColumnCount()
57 * @see javax.swing.table.TableModel#getRowCount()
59 public int getRowCount()
66 * @see javax.swing.table.TableModel#getValueAt(int, int)
68 public Object getValueAt(int inRowIndex, int inColumnIndex)
70 if (inColumnIndex == 0)
72 return _photos[inRowIndex].getName();
74 else if (inColumnIndex == 1)
76 return _photos[inRowIndex].getStatus();
78 return new Boolean(_photos[inRowIndex].getSaveFlag());
83 * @return true if cell is editable
85 public boolean isCellEditable(int inRowIndex, int inColumnIndex)
87 // only the save column is editable
88 return inColumnIndex == 2;
93 * Set the given cell value
94 * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
96 public void setValueAt(Object inValue, int inRowIndex, int inColumnIndex)
98 // ignore edits to other columns
99 if (inColumnIndex == 2)
100 _photos[inRowIndex].setSaveFlag(((Boolean) inValue).booleanValue());
105 * @return Class of cell data
107 public Class getColumnClass(int inColumnIndex)
109 if (inColumnIndex < 2) return String.class;
110 return Boolean.class;
115 * Get the name of the column
117 public String getColumnName(int inColNum)
119 if (inColNum == 0) return I18nManager.getText("dialog.saveexif.table.photoname");
120 else if (inColNum == 1) return I18nManager.getText("dialog.saveexif.table.status");
121 return I18nManager.getText("dialog.saveexif.table.save");
126 * Retrieve the object at the given index
127 * @param inIndex index, starting at 0
128 * @return PhotoTableEntry object at this position
130 public PhotoTableEntry getPhotoTableEntry(int inIndex)
132 if (inIndex < 0 || inIndex >= _photos.length)
136 return _photos[inIndex];