Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGDBMS / src / com / hardcode / gdbms / gui / IndexedGDBMSTableModel.java @ 1956

History | View | Annotate | Download (1.54 KB)

1
/*
2
 * Created on 12-oct-2004
3
 */
4
package com.hardcode.gdbms.gui;
5

    
6
import com.hardcode.gdbms.engine.data.DataSource;
7
import com.hardcode.gdbms.engine.data.driver.DriverException;
8
import com.hardcode.gdbms.engine.data.indexes.FixedIndexSet;
9

    
10
import javax.swing.table.AbstractTableModel;
11

    
12

    
13
/**
14
 * DOCUMENT ME!
15
 *
16
 * @author Fernando Gonz?lez Cort?s
17
 */
18
public class IndexedGDBMSTableModel extends AbstractTableModel {
19
        private DataSource source;
20
        private FixedIndexSet fis;
21

    
22
        /**
23
         * Crea un nuevo IndexedGDBMSTableModel.
24
         *
25
         * @param ds DOCUMENT ME!
26
         * @param fis DOCUMENT ME!
27
         */
28
        public IndexedGDBMSTableModel(DataSource ds, FixedIndexSet fis) {
29
                source = ds;
30
                this.fis = fis;
31
        }
32

    
33
        /**
34
         * DOCUMENT ME!
35
         *
36
         * @param ds DOCUMENT ME!
37
         */
38
        public void setDataSource(DataSource ds) {
39
                source = ds;
40
        }
41

    
42
        /**
43
         * @see javax.swing.table.TableModel#getColumnCount()
44
         */
45
        public int getColumnCount() {
46
                try {
47
                        return source.getFieldCount();
48
                } catch (DriverException e) {
49
                        return 0;
50
                }
51
        }
52

    
53
        /**
54
         * @see javax.swing.table.TableModel#getRowCount()
55
         */
56
        public int getRowCount() {
57
                try {
58
                        return (int) source.getRowCount();
59
                } catch (DriverException e) {
60
                        return 0;
61
                }
62
        }
63

    
64
        /**
65
         * @see javax.swing.table.TableModel#getValueAt(int, int)
66
         */
67
        public Object getValueAt(int arg0, int arg1) {
68
                try {
69
                        return source.getFieldValue(fis.getIndex(arg0), arg1);
70
                } catch (Exception e) {
71
                        e.printStackTrace();
72

    
73
                        return e.getMessage();
74
                }
75
        }
76

    
77
        /**
78
         * DOCUMENT ME!
79
         *
80
         * @return Returns the source.
81
         */
82
        public DataSource getDataSource() {
83
                return source;
84
        }
85
}