View Javadoc

1   // Copyright (C) 2004, Brian Enigma <enigma at netninja.com>
2   // This file is part of iGallery.
3   //
4   // iGallery is free software; you can redistribute it and/or modify
5   // it under the terms of the GNU General Public License as published by
6   // the Free Software Foundation; either version 2 of the License, or
7   // (at your option) any later version.
8   //
9   // iGallery is distributed in the hope that it will be useful,
10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  // GNU General Public License for more details.
13  //
14  // You should have received a copy of the GNU General Public License
15  // along with Foobar; if not, write to the Free Software
16  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  package org.ninjasoft.igallery.swingui;
18  
19  import java.util.*;
20  import javax.swing.event.*;
21  import javax.swing.table.TableModel;
22  import org.ninjasoft.igallery.data.*;
23  
24  /***
25   * Table model to represent the iPhoto albums
26   * @author enigma
27   */
28  public class IPhotoTableModel implements TableModel {
29      Vector listeners = new Vector();
30      Vector albumList = new Vector();
31      
32      public void setAlbumList(Vector list) {
33          TableModelEvent e = new TableModelEvent(this);
34          this.albumList = list;
35          for (Iterator i = listeners.iterator(); i.hasNext(); )
36              ((TableModelListener) i.next()).tableChanged(e);
37      }
38      
39  	public void addTableModelListener(TableModelListener l) {
40  		listeners.add(l);
41  	}
42  	public Class getColumnClass(int i) {
43  		if (i == 0)
44              return String.class;
45          return Integer.class;
46  	}
47  	public int getColumnCount() {
48  		return 2;
49  	}
50  	public String getColumnName(int i) {
51          if (i==0)
52              return "Name";
53          return "Photo Count";
54  	}
55  	public int getRowCount() {
56          return albumList.size();
57  	}
58  	public Object getValueAt(int row, int column) {
59          IPhotoAlbum album = (IPhotoAlbum) albumList.get(row);
60          if (column == 0)
61              return album.getName();
62          return new Integer(album.getPictureCount());
63  	}
64  	public boolean isCellEditable(int arg0, int arg1) {
65  		return false;
66  	}
67  	public void removeTableModelListener(TableModelListener l) {
68  		listeners.remove(l);
69  	}
70  	public void setValueAt(Object arg0, int arg1, int arg2) {
71  		
72  	}
73  }