01: package net.sourceforge.squirrel_sql.plugins.mssql.util;
02:
03: /*
04: * Copyright (C) 2004 Ryan Walberg <generalpf@yahoo.com>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20:
21: import java.util.ArrayList;
22: import javax.swing.table.AbstractTableModel;
23: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
24:
25: public class DatabaseObjectInfoTableModel extends AbstractTableModel {
26:
27: private static final long serialVersionUID = -1879428906496726350L;
28:
29: private ArrayList<IDatabaseObjectInfo> _objectInfo;
30:
31: public DatabaseObjectInfoTableModel() {
32: _objectInfo = new ArrayList<IDatabaseObjectInfo>();
33: }
34:
35: public void addElement(IDatabaseObjectInfo oi) {
36: _objectInfo.add(oi);
37: int size = _objectInfo.size();
38: fireTableRowsInserted(size, size);
39: }
40:
41: public boolean removeElement(IDatabaseObjectInfo oi) {
42: int index = _objectInfo.indexOf(oi);
43: if (index != -1) {
44: _objectInfo.remove(oi);
45: fireTableRowsDeleted(index, index);
46: }
47: return (index != -1);
48: }
49:
50: public int getColumnCount() {
51: /* one column for the object name, another column for the object's owner. */
52: return 2;
53: }
54:
55: public int getRowCount() {
56: return _objectInfo.size();
57: }
58:
59: public Object getValueAt(int rowIndex, int columnIndex) {
60: switch (columnIndex) {
61: case 0:
62: return _objectInfo.get(rowIndex);
63: case 1:
64: return _objectInfo.get(rowIndex).getSchemaName();
65: default:
66: return null;
67: }
68: }
69:
70: /*public boolean isCellEditable(int rowIndex, int columnIndex) {
71: return (columnIndex == 0);
72: }*/
73:
74: public ArrayList<IDatabaseObjectInfo> getContents() {
75: return _objectInfo;
76: }
77:
78: }
|