root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / gui / address / AbstractAddressPanel.java @ 27756
History | View | Annotate | Download (2.14 KB)
1 |
package org.gvsig.geocoding.gui.address; |
---|---|
2 |
|
3 |
import java.util.List; |
4 |
|
5 |
import javax.swing.DefaultCellEditor; |
6 |
import javax.swing.DefaultComboBoxModel; |
7 |
import javax.swing.JComboBox; |
8 |
import javax.swing.JPanel; |
9 |
import javax.swing.JTable; |
10 |
import javax.swing.table.DefaultTableModel; |
11 |
import javax.swing.table.TableColumn; |
12 |
|
13 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
14 |
import org.gvsig.geocoding.Address; |
15 |
import org.gvsig.geocoding.gui.newpattern.ComboDesc; |
16 |
|
17 |
public class AbstractAddressPanel extends JPanel { |
18 |
|
19 |
private static final long serialVersionUID = 1L; |
20 |
|
21 |
/**
|
22 |
* get address from user interface
|
23 |
*
|
24 |
* @param model
|
25 |
* @return
|
26 |
*/
|
27 |
public Address getSimpleAddress() {
|
28 |
return null; |
29 |
}; |
30 |
|
31 |
/**
|
32 |
* Get the addres from table
|
33 |
*
|
34 |
* @param model
|
35 |
* @param row
|
36 |
* @return
|
37 |
*/
|
38 |
public Address getTableAddress(int row) { |
39 |
|
40 |
return null; |
41 |
} |
42 |
|
43 |
/**
|
44 |
* Create fields combo model to number
|
45 |
*
|
46 |
* @param descs
|
47 |
* @return
|
48 |
*/
|
49 |
protected DefaultComboBoxModel createFieldsComboModel( |
50 |
List<FeatureAttributeDescriptor> descs) {
|
51 |
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
52 |
for (FeatureAttributeDescriptor desc : descs) {
|
53 |
ComboDesc cDesc = new ComboDesc(desc);
|
54 |
model.addElement(cDesc); |
55 |
} |
56 |
return model;
|
57 |
} |
58 |
|
59 |
/**
|
60 |
* Put combos in cells of the one table
|
61 |
*
|
62 |
* @param table
|
63 |
* @param descs
|
64 |
*/
|
65 |
public void putCombosInTable(JTable table, |
66 |
List<FeatureAttributeDescriptor> descs, int col) { |
67 |
TableColumn column = table.getColumnModel().getColumn(col);
|
68 |
JComboBox combo = new JComboBox(); |
69 |
DefaultComboBoxModel modelcombo = new DefaultComboBoxModel(); |
70 |
for (FeatureAttributeDescriptor desc : descs) {
|
71 |
ComboDesc cDesc = new ComboDesc(desc);
|
72 |
modelcombo.addElement(cDesc); |
73 |
} |
74 |
combo.setModel(modelcombo); |
75 |
DefaultCellEditor dce = new DefaultCellEditor(combo); |
76 |
dce.setClickCountToStart(2);
|
77 |
column.setCellEditor(dce); |
78 |
} |
79 |
|
80 |
/**
|
81 |
* Clear all rows of the TableModel
|
82 |
*
|
83 |
* @param model
|
84 |
*/
|
85 |
public void clearTableModel(DefaultTableModel model) { |
86 |
int n = model.getRowCount();
|
87 |
for (int i = n - 1; i > -1; i--) { |
88 |
model.removeRow(i); |
89 |
} |
90 |
} |
91 |
|
92 |
} |