root / trunk / libraries / libGDBMS / src / test / java / com / hardcode / gdbms / gui / GDBMSTableModel.java @ 10627
History | View | Annotate | Download (1.44 KB)
1 |
/*
|
---|---|
2 |
* Created on 12-oct-2004
|
3 |
*/
|
4 |
package com.hardcode.gdbms.gui; |
5 |
|
6 |
import javax.swing.table.AbstractTableModel; |
7 |
|
8 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
9 |
import com.hardcode.gdbms.engine.data.DataSource; |
10 |
|
11 |
|
12 |
/**
|
13 |
* DOCUMENT ME!
|
14 |
*
|
15 |
* @author Fernando Gonz?lez Cort?s
|
16 |
*/
|
17 |
public class GDBMSTableModel extends AbstractTableModel { |
18 |
private DataSource source; |
19 |
|
20 |
/**
|
21 |
* Crea un nuevo GDBMSTableModel.
|
22 |
*/
|
23 |
public GDBMSTableModel() {
|
24 |
} |
25 |
|
26 |
/**
|
27 |
* Crea un nuevo GDBMSTableModel.
|
28 |
*
|
29 |
* @param ds DOCUMENT ME!
|
30 |
*/
|
31 |
public GDBMSTableModel(DataSource ds) { |
32 |
source = ds; |
33 |
} |
34 |
|
35 |
/**
|
36 |
* DOCUMENT ME!
|
37 |
*
|
38 |
* @param ds DOCUMENT ME!
|
39 |
*/
|
40 |
public void setDataSource(DataSource ds) { |
41 |
source = ds; |
42 |
} |
43 |
|
44 |
/**
|
45 |
* @see javax.swing.table.TableModel#getColumnCount()
|
46 |
*/
|
47 |
public int getColumnCount() { |
48 |
try {
|
49 |
return source.getFieldCount();
|
50 |
} catch (ReadDriverException e) {
|
51 |
return 0; |
52 |
} |
53 |
} |
54 |
|
55 |
/**
|
56 |
* @see javax.swing.table.TableModel#getRowCount()
|
57 |
*/
|
58 |
public int getRowCount() { |
59 |
try {
|
60 |
return (int) source.getRowCount(); |
61 |
} catch (ReadDriverException e) {
|
62 |
return 0; |
63 |
} |
64 |
} |
65 |
|
66 |
/**
|
67 |
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
68 |
*/
|
69 |
public Object getValueAt(int arg0, int arg1) { |
70 |
try {
|
71 |
return source.getFieldValue(arg0, arg1);
|
72 |
} catch (Exception e) { |
73 |
e.printStackTrace(); |
74 |
|
75 |
return e.getMessage();
|
76 |
} |
77 |
} |
78 |
|
79 |
/**
|
80 |
* DOCUMENT ME!
|
81 |
*
|
82 |
* @return Returns the source.
|
83 |
*/
|
84 |
public DataSource getDataSource() { |
85 |
return source;
|
86 |
} |
87 |
} |