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
18 * @param inSize number of photos
20 public PhotoTableModel(int inSize)
22 _photos = new PhotoTableEntry[inSize];
27 * Set the given PhotoTableEntry object in the array
28 * @param inEntry PhotoTableEntry object describing the photo
30 public void addPhotoInfo(PhotoTableEntry inEntry)
32 if (_addIndex < _photos.length && inEntry != null
33 && inEntry.getStatus() != null)
35 _photos[_addIndex] = inEntry;
41 * @return the number of photos in the list whose status has changed
43 public int getNumSaveablePhotos()
49 * @see javax.swing.table.TableModel#getColumnCount()
51 public int getColumnCount()
58 * @see javax.swing.table.TableModel#getRowCount()
60 public int getRowCount()
67 * @see javax.swing.table.TableModel#getValueAt(int, int)
69 public Object getValueAt(int inRowIndex, int inColumnIndex)
71 if (inColumnIndex == 0)
73 return _photos[inRowIndex].getName();
75 else if (inColumnIndex == 1)
77 return _photos[inRowIndex].getStatus();
79 return Boolean.valueOf(_photos[inRowIndex].getSaveFlag());
84 * @return true if cell is editable
86 public boolean isCellEditable(int inRowIndex, int inColumnIndex)
88 // only the save column is editable
89 return inColumnIndex == 2;
94 * Set the given cell value
95 * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
97 public void setValueAt(Object inValue, int inRowIndex, int inColumnIndex)
99 // ignore edits to other columns
100 if (inColumnIndex == 2)
101 _photos[inRowIndex].setSaveFlag(((Boolean) inValue).booleanValue());
106 * @return Class of cell data
108 public Class<?> getColumnClass(int inColumnIndex)
110 if (inColumnIndex < 2) return String.class;
111 return Boolean.class;
116 * Get the name of the column
118 public String getColumnName(int inColNum)
120 if (inColNum == 0) return I18nManager.getText("dialog.saveexif.table.photoname");
121 else if (inColNum == 1) return I18nManager.getText("dialog.saveexif.table.status");
122 return I18nManager.getText("dialog.saveexif.table.save");
127 * Retrieve the object at the given index
128 * @param inIndex index, starting at 0
129 * @return PhotoTableEntry object at this position
131 public PhotoTableEntry getPhotoTableEntry(int inIndex)
133 if (inIndex < 0 || inIndex >= _photos.length)
137 return _photos[inIndex];