Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.geocoding.extension / src / org / gvsig / geocoding / gui / address / AbstractAddressPanel.java @ 32526

History | View | Annotate | Download (3.12 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 Prodevelop S.L. main development
26
 */
27
package org.gvsig.geocoding.gui.address;
28

    
29
import java.util.List;
30

    
31
import javax.swing.DefaultCellEditor;
32
import javax.swing.DefaultComboBoxModel;
33
import javax.swing.JComboBox;
34
import javax.swing.JPanel;
35
import javax.swing.JTable;
36
import javax.swing.table.DefaultTableModel;
37
import javax.swing.table.TableColumn;
38

    
39
import org.gvsig.geocoding.address.Address;
40

    
41
/**
42
 * Abstract panel of geocoding style to insert the address relates with the
43
 * style
44
 * 
45
 * @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
46
 * @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
47
 */
48
public class AbstractAddressPanel extends JPanel {
49

    
50
        private static final long serialVersionUID = 1L;
51

    
52
        /**
53
         * get address from user interface
54
         * 
55
         * @param model
56
         * @return
57
         */
58
        public Address getSimpleAddress() {
59
                return null;
60
        };
61

    
62
        /**
63
         * Get the addres from table
64
         * 
65
         * @param model
66
         * @param row
67
         * @return
68
         */
69
        public Address getTableAddress(int row) {
70

    
71
                return null;
72
        }
73

    
74
        /**
75
         * Create fields combo model to number
76
         * 
77
         * @param descs
78
         * @return
79
         */
80
        protected DefaultComboBoxModel createFieldsComboModel(List<String> descs) {
81
                DefaultComboBoxModel model = new DefaultComboBoxModel();
82
                for (String desc : descs) {
83
                        model.addElement(desc);
84
                }
85
                return model;
86
        }
87

    
88
        /**
89
         * Put combos in cells of the one table
90
         * 
91
         * @param table
92
         * @param descs
93
         */
94
        public void putCombosInTable(JTable table, List<String> descs, int col) {
95
                TableColumn column = table.getColumnModel().getColumn(col);
96
                JComboBox combo = new JComboBox();
97
                DefaultComboBoxModel modelcombo = new DefaultComboBoxModel();
98
                for (String desc : descs) {
99
                        modelcombo.addElement(desc);
100
                }
101
                combo.setModel(modelcombo);
102
                DefaultCellEditor dce = new DefaultCellEditor(combo);
103
                dce.setClickCountToStart(2);
104
                column.setCellEditor(dce);
105
        }
106

    
107
        /**
108
         * Clear all rows of the TableModel
109
         * 
110
         * @param model
111
         */
112
        public void clearTableModel(DefaultTableModel model) {
113
                int n = model.getRowCount();
114
                for (int i = n - 1; i > -1; i--) {
115
                        model.removeRow(i);
116
                }
117
        }
118

    
119
}