Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.swing / org.gvsig.raster.swing.impl / src / main / java / org / gvsig / raster / swing / impl / pagedtable / ModelLoaderImpl.java @ 2443

History | View | Annotate | Download (2.77 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program 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
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.raster.swing.impl.pagedtable;
25

    
26
import java.util.ArrayList;
27
import java.util.List;
28

    
29
import javax.swing.table.DefaultTableModel;
30
import javax.swing.table.TableCellEditor;
31
import javax.swing.table.TableCellRenderer;
32

    
33
import org.gvsig.raster.swing.pagedtable.ModelLoader;
34
import org.gvsig.raster.swing.pagedtable.TableModel;
35

    
36
/**
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 */
39
public class ModelLoaderImpl implements ModelLoader {
40
        private DefaultTableModel         tableModel   = null;
41
        private List<TableCellEditor>     editorList   = null;
42
        private List<TableCellRenderer>   renderList   = null;
43
        private String[]                  columnNames  = null;
44
        private int[]                     columnWidths = null;
45
        
46
        public ModelLoaderImpl(DefaultTableModel tableModel) {
47
                this.tableModel = tableModel;
48
                editorList = new ArrayList<TableCellEditor>(tableModel.getColumnCount());
49
                renderList = new ArrayList<TableCellRenderer>(tableModel.getColumnCount());
50
        }
51
        
52
        public TableCellEditor getCellEditorForColumn(int column) {
53
                if(editorList.size() > column)
54
                        return editorList.get(column);
55
                return null;
56
        }
57

    
58
        public TableCellRenderer getRenderForColumn(int column) {
59
                if(renderList.size() > column)
60
                        return renderList.get(column);
61
                return null;
62
        }
63

    
64
        public TableModel getTableModel() {
65
                return (TableModel)tableModel;
66
        }
67

    
68
        public void setCellEditorForColumn(int column, TableCellEditor editor) {
69
                editorList.add(column, editor);
70
        }
71

    
72
        public void setRenderForColumn(int column, TableCellRenderer render) {
73
                renderList.add(column, render);
74
        }
75
        
76
        public String[] getColumnNames() {
77
                return columnNames;
78
        }
79
        
80
        public int[] getColumnWidths() {
81
                return columnWidths;
82
        }
83
        
84
        public void setColumnNames(String[] columnNames) {
85
                this.columnNames = columnNames;
86
        }
87
        
88
        public void setColumnWidths(int[] columnWidths) {
89
                this.columnWidths = columnWidths;
90
        }
91
}