svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.geocoding.extension / src / org / gvsig / geocoding / gui / address / AddressComposedPanel.java @ 32526
History | View | Annotate | Download (19.5 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 developer
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.geocoding.gui.address; |
29 |
|
30 |
import java.awt.Color; |
31 |
import java.io.File; |
32 |
import java.util.ArrayList; |
33 |
import java.util.Iterator; |
34 |
import java.util.List; |
35 |
import java.util.Vector; |
36 |
|
37 |
import javax.swing.ImageIcon; |
38 |
import javax.swing.JComboBox; |
39 |
import javax.swing.JLabel; |
40 |
import javax.swing.JPanel; |
41 |
import javax.swing.JScrollPane; |
42 |
import javax.swing.JTabbedPane; |
43 |
import javax.swing.JTable; |
44 |
import javax.swing.table.DefaultTableCellRenderer; |
45 |
import javax.swing.table.DefaultTableModel; |
46 |
import javax.swing.table.TableColumn; |
47 |
|
48 |
import org.gvsig.andami.PluginServices; |
49 |
import org.gvsig.fmap.dal.exception.DataException; |
50 |
import org.gvsig.fmap.dal.feature.Feature; |
51 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
52 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
53 |
import org.gvsig.geocoding.GeocodingTags; |
54 |
import org.gvsig.geocoding.address.Address; |
55 |
import org.gvsig.geocoding.address.ComposedAddress; |
56 |
import org.gvsig.geocoding.address.Literal; |
57 |
import org.gvsig.geocoding.address.impl.DefaultComposedAddress; |
58 |
import org.gvsig.geocoding.address.impl.DefaultLiteral; |
59 |
import org.gvsig.geocoding.extension.GeocodingController; |
60 |
import org.slf4j.Logger; |
61 |
import org.slf4j.LoggerFactory; |
62 |
|
63 |
/**
|
64 |
* Address composed panel
|
65 |
*
|
66 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
67 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
68 |
*/
|
69 |
public class AddressComposedPanel extends AbstractAddressPanel { |
70 |
|
71 |
private static final long serialVersionUID = 1L; |
72 |
private Logger log = LoggerFactory.getLogger(AddressComposedPanel.class); |
73 |
|
74 |
private GeocodingController control = null; |
75 |
|
76 |
private JLabel jLabTypeBetween; |
77 |
private JLabel jLabTypeCross; |
78 |
private JPanel jPanAddressBetween; |
79 |
private JPanel jPanAddressCross; |
80 |
private JPanel jPanBetween; |
81 |
private JPanel jPanCross; |
82 |
private JScrollPane jScrollAddressBetween; |
83 |
private JScrollPane jScrollAddressCross; |
84 |
private JTabbedPane jTabbedComposed; |
85 |
private JTable jTableAddressBetween; |
86 |
private JTable jTableAddressCross; |
87 |
private JLabel jLabIdCross; |
88 |
private JPanel jPanIdCross; |
89 |
private JComboBox jComboIdCross; |
90 |
private JLabel jLabIdBetween; |
91 |
private JPanel jPanIdBetween; |
92 |
private JComboBox jComboIdBetween; |
93 |
|
94 |
/**
|
95 |
* Constructor
|
96 |
*/
|
97 |
public AddressComposedPanel(GeocodingController control, Literal literal) {
|
98 |
|
99 |
this.control = control;
|
100 |
initComponents(); |
101 |
|
102 |
setImages(); |
103 |
setMesages(); |
104 |
|
105 |
// create table model
|
106 |
|
107 |
if (control.getGmodel().isSimple()) {
|
108 |
createSimpleTablesModels(literal); |
109 |
} else {
|
110 |
List<String> descs = control.getGmodel() |
111 |
.getListDescriptorSelectedTable(); |
112 |
createTableTablesModels(literal, descs); |
113 |
jComboIdCross.setModel(createFieldsComboModel(descs)); |
114 |
jComboIdBetween.setModel(createFieldsComboModel(descs)); |
115 |
} |
116 |
} |
117 |
|
118 |
/**
|
119 |
* Set images in the panel
|
120 |
*/
|
121 |
private void setImages() { |
122 |
String baseDir = PluginServices.getPluginServices(this) |
123 |
.getClassLoader().getBaseDir(); |
124 |
|
125 |
jLabTypeCross.setIcon(new ImageIcon(baseDir + File.separator + "images" |
126 |
+ File.separator + "intersect.png")); |
127 |
jLabTypeBetween.setIcon(new ImageIcon(baseDir + File.separator |
128 |
+ "images" + File.separator + "double_intersect.png")); |
129 |
} |
130 |
|
131 |
/**
|
132 |
* Set strings in the panel
|
133 |
*/
|
134 |
private void setMesages() { |
135 |
PluginServices ps = PluginServices.getPluginServices(this);
|
136 |
|
137 |
String element = ps.getText("xelement"); |
138 |
|
139 |
DefaultTableModel cmodel = (DefaultTableModel) jTableAddressCross |
140 |
.getModel(); |
141 |
String value1 = ps.getText("xvalue1"); |
142 |
String value2 = ps.getText("xvalue2"); |
143 |
Object[] headers = { element, value1, value2 }; |
144 |
cmodel.setColumnIdentifiers(headers); |
145 |
jTableAddressCross.setModel(cmodel); |
146 |
|
147 |
DefaultTableModel bmodel = (DefaultTableModel) jTableAddressBetween |
148 |
.getModel(); |
149 |
String value11 = ps.getText("xmainvalue"); |
150 |
String value22 = ps.getText("xvalue2"); |
151 |
String value33 = ps.getText("xvalue3"); |
152 |
Object[] bheaders = { element, value11, value22, value33 }; |
153 |
bmodel.setColumnIdentifiers(bheaders); |
154 |
jTableAddressBetween.setModel(bmodel); |
155 |
|
156 |
// tabs
|
157 |
String titleCross = ps.getText("xcross"); |
158 |
jTabbedComposed.setTitleAt(0, titleCross);
|
159 |
String titleBetween = ps.getText("xbetween"); |
160 |
jTabbedComposed.setTitleAt(1, titleBetween);
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* Initialize components
|
165 |
*/
|
166 |
private void initComponents() { |
167 |
java.awt.GridBagConstraints gridBagConstraints; |
168 |
|
169 |
jTabbedComposed = new javax.swing.JTabbedPane();
|
170 |
jPanCross = new javax.swing.JPanel();
|
171 |
jLabTypeCross = new javax.swing.JLabel();
|
172 |
jPanAddressCross = new javax.swing.JPanel();
|
173 |
jScrollAddressCross = new javax.swing.JScrollPane();
|
174 |
jTableAddressCross = new javax.swing.JTable();
|
175 |
jPanBetween = new javax.swing.JPanel();
|
176 |
jLabTypeBetween = new javax.swing.JLabel();
|
177 |
jPanAddressBetween = new javax.swing.JPanel();
|
178 |
jScrollAddressBetween = new javax.swing.JScrollPane();
|
179 |
jTableAddressBetween = new javax.swing.JTable();
|
180 |
jLabIdCross = new JLabel(); |
181 |
jComboIdCross = new JComboBox(); |
182 |
jPanIdCross = new JPanel(); |
183 |
jLabIdBetween = new JLabel(); |
184 |
jComboIdBetween = new JComboBox(); |
185 |
jPanIdBetween = new JPanel(); |
186 |
|
187 |
setLayout(new java.awt.GridBagLayout());
|
188 |
|
189 |
jPanCross.setLayout(new java.awt.GridBagLayout());
|
190 |
|
191 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
192 |
gridBagConstraints.gridx = 0;
|
193 |
gridBagConstraints.gridy = 0;
|
194 |
gridBagConstraints.insets = new java.awt.Insets(3, 15, 5, 10); |
195 |
jPanCross.add(jLabTypeCross, gridBagConstraints); |
196 |
|
197 |
jPanAddressCross.setLayout(new java.awt.GridBagLayout());
|
198 |
|
199 |
jPanIdCross.setLayout(new java.awt.GridBagLayout());
|
200 |
|
201 |
if (!control.getGmodel().isSimple()) {
|
202 |
jLabIdCross.setText("Field ID");
|
203 |
jLabIdCross |
204 |
.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
205 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
206 |
gridBagConstraints.gridx = 0;
|
207 |
gridBagConstraints.gridy = 0;
|
208 |
gridBagConstraints.insets = new java.awt.Insets(4, 10, 4, 5); |
209 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
210 |
gridBagConstraints.weightx = 1.0;
|
211 |
jPanIdCross.add(jLabIdCross, gridBagConstraints); |
212 |
|
213 |
jComboIdCross.setModel(new javax.swing.DefaultComboBoxModel(
|
214 |
new String[] { "" })); |
215 |
jComboIdCross.setMinimumSize(new java.awt.Dimension(200, 20)); |
216 |
jComboIdCross.setName("jComboId");
|
217 |
|
218 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
219 |
gridBagConstraints.gridx = 1;
|
220 |
gridBagConstraints.gridy = 0;
|
221 |
gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4); |
222 |
jPanIdCross.add(jComboIdCross, gridBagConstraints); |
223 |
|
224 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
225 |
gridBagConstraints.gridx = 0;
|
226 |
gridBagConstraints.gridy = 0;
|
227 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
228 |
gridBagConstraints.weightx = 1.0;
|
229 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0); |
230 |
jPanAddressCross.add(jPanIdCross, gridBagConstraints); |
231 |
} |
232 |
|
233 |
jTableAddressCross.setModel(new javax.swing.table.DefaultTableModel(
|
234 |
new Object[][] { { null, null, null }, { null, null, null }, |
235 |
{ null, null, null } }, new String[] { "Elements", |
236 |
"Values address 1 ", "Values address 2" }) { |
237 |
Class[] types = new Class[] { java.lang.String.class, |
238 |
java.lang.String.class, java.lang.String.class }; |
239 |
boolean[] canEdit = new boolean[] { false, true, true }; |
240 |
|
241 |
public Class getColumnClass(int columnIndex) { |
242 |
return types[columnIndex];
|
243 |
} |
244 |
|
245 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
246 |
return canEdit[columnIndex];
|
247 |
} |
248 |
}); |
249 |
|
250 |
jScrollAddressCross.setViewportView(jTableAddressCross); |
251 |
|
252 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
253 |
gridBagConstraints.gridx = 0;
|
254 |
gridBagConstraints.gridy = 2;
|
255 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
256 |
gridBagConstraints.weightx = 1.0;
|
257 |
gridBagConstraints.weighty = 1.0;
|
258 |
jPanAddressCross.add(jScrollAddressCross, gridBagConstraints); |
259 |
|
260 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
261 |
gridBagConstraints.gridx = 1;
|
262 |
gridBagConstraints.gridy = 0;
|
263 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
264 |
gridBagConstraints.weightx = 1.0;
|
265 |
gridBagConstraints.weighty = 1.0;
|
266 |
gridBagConstraints.insets = new java.awt.Insets(10, 15, 10, 10); |
267 |
jPanCross.add(jPanAddressCross, gridBagConstraints); |
268 |
|
269 |
jTabbedComposed.addTab("tab1", jPanCross);
|
270 |
|
271 |
jPanBetween.setLayout(new java.awt.GridBagLayout());
|
272 |
|
273 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
274 |
gridBagConstraints.gridx = 0;
|
275 |
gridBagConstraints.gridy = 0;
|
276 |
gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 10); |
277 |
jPanBetween.add(jLabTypeBetween, gridBagConstraints); |
278 |
|
279 |
jPanAddressBetween.setLayout(new java.awt.GridBagLayout());
|
280 |
|
281 |
jPanIdBetween.setLayout(new java.awt.GridBagLayout());
|
282 |
|
283 |
if (!control.getGmodel().isSimple()) {
|
284 |
jLabIdBetween.setText("Field ID");
|
285 |
jLabIdBetween |
286 |
.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
287 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
288 |
gridBagConstraints.gridx = 0;
|
289 |
gridBagConstraints.gridy = 0;
|
290 |
gridBagConstraints.insets = new java.awt.Insets(4, 10, 4, 5); |
291 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
292 |
gridBagConstraints.weightx = 1.0;
|
293 |
jPanIdBetween.add(jLabIdBetween, gridBagConstraints); |
294 |
|
295 |
jComboIdBetween.setModel(new javax.swing.DefaultComboBoxModel(
|
296 |
new String[] { "" })); |
297 |
jComboIdBetween.setMinimumSize(new java.awt.Dimension(200, 20)); |
298 |
jComboIdBetween.setName("jComboId");
|
299 |
|
300 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
301 |
gridBagConstraints.gridx = 1;
|
302 |
gridBagConstraints.gridy = 0;
|
303 |
gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4); |
304 |
jPanIdBetween.add(jComboIdBetween, gridBagConstraints); |
305 |
|
306 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
307 |
gridBagConstraints.gridx = 0;
|
308 |
gridBagConstraints.gridy = 0;
|
309 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
310 |
gridBagConstraints.weightx = 1.0;
|
311 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0); |
312 |
jPanAddressBetween.add(jPanIdBetween, gridBagConstraints); |
313 |
} |
314 |
|
315 |
jTableAddressBetween |
316 |
.setModel(new javax.swing.table.DefaultTableModel(
|
317 |
new Object[][] { { null, null, null, null }, |
318 |
{ null, null, null, null }, |
319 |
{ null, null, null, null } }, new String[] { |
320 |
"Elements", "Values main address", |
321 |
"Values address 2", "values address 3" }) { |
322 |
Class[] types = new Class[] { java.lang.String.class, |
323 |
java.lang.String.class, java.lang.String.class, |
324 |
java.lang.String.class }; |
325 |
boolean[] canEdit = new boolean[] { false, true, true, true }; |
326 |
|
327 |
public Class getColumnClass(int columnIndex) { |
328 |
return types[columnIndex];
|
329 |
} |
330 |
|
331 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
332 |
return canEdit[columnIndex];
|
333 |
} |
334 |
}); |
335 |
|
336 |
jScrollAddressBetween.setViewportView(jTableAddressBetween); |
337 |
|
338 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
339 |
gridBagConstraints.gridx = 0;
|
340 |
gridBagConstraints.gridy = 1;
|
341 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
342 |
gridBagConstraints.weightx = 1.0;
|
343 |
gridBagConstraints.weighty = 1.0;
|
344 |
jPanAddressBetween.add(jScrollAddressBetween, gridBagConstraints); |
345 |
|
346 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
347 |
gridBagConstraints.gridx = 1;
|
348 |
gridBagConstraints.gridy = 0;
|
349 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
350 |
gridBagConstraints.weightx = 1.0;
|
351 |
gridBagConstraints.weighty = 1.0;
|
352 |
gridBagConstraints.insets = new java.awt.Insets(10, 15, 10, 10); |
353 |
jPanBetween.add(jPanAddressBetween, gridBagConstraints); |
354 |
|
355 |
jTabbedComposed.addTab("tab2", jPanBetween);
|
356 |
|
357 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
358 |
gridBagConstraints.gridx = 0;
|
359 |
gridBagConstraints.gridy = 0;
|
360 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
361 |
gridBagConstraints.weightx = 1.0;
|
362 |
gridBagConstraints.weighty = 1.0;
|
363 |
add(jTabbedComposed, gridBagConstraints); |
364 |
} |
365 |
|
366 |
/**
|
367 |
* Create a simple tables models from literal components
|
368 |
*
|
369 |
* @param lit
|
370 |
*/
|
371 |
private void createSimpleTablesModels(Literal lit) { |
372 |
|
373 |
DefaultTableCellRenderer render = new DefaultTableCellRenderer(); |
374 |
render.setBackground(new Color(255, 253, 224)); |
375 |
|
376 |
// Cross tab
|
377 |
DefaultTableModel modelcross = (DefaultTableModel) jTableAddressCross |
378 |
.getModel(); |
379 |
TableColumn colcross0 = jTableAddressCross.getColumnModel()
|
380 |
.getColumn(0);
|
381 |
colcross0.setCellRenderer(render); |
382 |
|
383 |
// fill elements
|
384 |
super.clearTableModel(modelcross);
|
385 |
|
386 |
for (String key : lit.keySet()) { |
387 |
|
388 |
Object[] row = { key, "", "" }; |
389 |
modelcross.addRow(row); |
390 |
|
391 |
} |
392 |
jTableAddressCross.setModel(modelcross); |
393 |
|
394 |
// Between tab
|
395 |
DefaultTableModel modelbetween = (DefaultTableModel) jTableAddressBetween |
396 |
.getModel(); |
397 |
// first column
|
398 |
TableColumn colbetween0 = jTableAddressBetween.getColumnModel()
|
399 |
.getColumn(0);
|
400 |
colbetween0.setCellRenderer(render); |
401 |
|
402 |
// fill elements
|
403 |
super.clearTableModel(modelbetween);
|
404 |
|
405 |
for (String key : lit.keySet()) { |
406 |
Object[] row = { key, "", "", "" }; |
407 |
modelbetween.addRow(row); |
408 |
} |
409 |
jTableAddressBetween.setModel(modelbetween); |
410 |
|
411 |
} |
412 |
|
413 |
/**
|
414 |
* Create a table tables models from literal components
|
415 |
*
|
416 |
* @param lit
|
417 |
*/
|
418 |
private void createTableTablesModels(Literal lit, List<String> descs) { |
419 |
|
420 |
DefaultTableCellRenderer render = new DefaultTableCellRenderer(); |
421 |
render.setBackground(new Color(255, 253, 224)); |
422 |
|
423 |
// Croos tab
|
424 |
DefaultTableModel modelcross = (DefaultTableModel) jTableAddressCross |
425 |
.getModel(); |
426 |
|
427 |
// first column
|
428 |
TableColumn columncross0 = jTableAddressCross.getColumnModel()
|
429 |
.getColumn(0);
|
430 |
columncross0.setCellRenderer(render); |
431 |
|
432 |
// fill elements
|
433 |
super.clearTableModel(modelcross);
|
434 |
|
435 |
// Put combos in the column 1
|
436 |
super.putCombosInTable(jTableAddressCross, descs, 1); |
437 |
|
438 |
// Put combos in the column 2
|
439 |
super.putCombosInTable(jTableAddressCross, descs, 2); |
440 |
|
441 |
// put the elements in the column 0
|
442 |
for (String key : lit.keySet()) { |
443 |
Object[] row = { key, "", "" }; |
444 |
modelcross.addRow(row); |
445 |
} |
446 |
jTableAddressCross.setModel(modelcross); |
447 |
|
448 |
// Between tab
|
449 |
DefaultTableModel modelbetween = (DefaultTableModel) jTableAddressBetween |
450 |
.getModel(); |
451 |
|
452 |
// first column
|
453 |
TableColumn columnbetween0 = jTableAddressBetween.getColumnModel()
|
454 |
.getColumn(0);
|
455 |
columnbetween0.setCellRenderer(render); |
456 |
|
457 |
// fill elements
|
458 |
super.clearTableModel(modelbetween);
|
459 |
|
460 |
// Put combos in the column 1
|
461 |
super.putCombosInTable(jTableAddressBetween, descs, 1); |
462 |
|
463 |
// Put combos in the column 2
|
464 |
super.putCombosInTable(jTableAddressBetween, descs, 2); |
465 |
|
466 |
// Put combos in the column 3
|
467 |
super.putCombosInTable(jTableAddressBetween, descs, 3); |
468 |
|
469 |
// put the elements in the column 0
|
470 |
for (String key : lit.keySet()) { |
471 |
// insert
|
472 |
Object[] row = { key, "", "", "" }; |
473 |
modelbetween.addRow(row); |
474 |
} |
475 |
jTableAddressBetween.setModel(modelbetween); |
476 |
} |
477 |
|
478 |
/**
|
479 |
* get address from user interface
|
480 |
*
|
481 |
* @param model
|
482 |
* @return
|
483 |
*/
|
484 |
public Address getSimpleAddress() {
|
485 |
|
486 |
jTableAddressCross.validate(); |
487 |
jTableAddressBetween.validate(); |
488 |
jTableAddressCross.setRowSelectionInterval(0, 0); |
489 |
jTableAddressBetween.setRowSelectionInterval(0, 0); |
490 |
int n = jTabbedComposed.getSelectedIndex();
|
491 |
DefaultTableModel model = null; |
492 |
if (n == 0) { |
493 |
jTableAddressCross.setRowSelectionInterval(0, 0); |
494 |
model = (DefaultTableModel) jTableAddressCross.getModel();
|
495 |
} |
496 |
if (n == 1) { |
497 |
jTableAddressBetween.setRowSelectionInterval(0, 0); |
498 |
model = (DefaultTableModel) jTableAddressBetween.getModel();
|
499 |
} |
500 |
|
501 |
ComposedAddress address = new DefaultComposedAddress();
|
502 |
Literal mainLiteral = new DefaultLiteral();
|
503 |
Literal literal2 = new DefaultLiteral();
|
504 |
Literal literal3 = new DefaultLiteral();
|
505 |
List<Literal> intersectionLiterals = new ArrayList<Literal>(); |
506 |
Vector vec = model.getDataVector();
|
507 |
// get main and secon address
|
508 |
for (int i = 0; i < vec.size(); i++) { |
509 |
Vector vecc = (Vector) vec.elementAt(i); |
510 |
String key = (String) vecc.elementAt(0); |
511 |
String value = (String) vecc.elementAt(1); |
512 |
String value2 = (String) vecc.elementAt(2); |
513 |
mainLiteral.put(key, value); |
514 |
literal2.put(key, value2); |
515 |
} |
516 |
address.setMainLiteral(mainLiteral); |
517 |
intersectionLiterals.add(literal2); |
518 |
// get third address if exist
|
519 |
int num = ((Vector) vec.elementAt(0)).size(); |
520 |
if (num == 4) { |
521 |
for (int i = 0; i < vec.size(); i++) { |
522 |
Vector vecc = (Vector) vec.elementAt(i); |
523 |
String key = (String) vecc.elementAt(0); |
524 |
String value3 = (String) vecc.elementAt(3); |
525 |
literal3.put(key, value3); |
526 |
} |
527 |
intersectionLiterals.add(literal3); |
528 |
} |
529 |
|
530 |
address.setIntersectionLiterals(intersectionLiterals); |
531 |
|
532 |
return address;
|
533 |
} |
534 |
|
535 |
/**
|
536 |
* Get the addres from table
|
537 |
*
|
538 |
* @param model
|
539 |
* @param row
|
540 |
* @return
|
541 |
*/
|
542 |
public Address getTableAddress(DefaultTableModel model, int row) { |
543 |
|
544 |
jTableAddressCross.validate(); |
545 |
jTableAddressCross.setRowSelectionInterval(0, 0); |
546 |
jTableAddressBetween.validate(); |
547 |
jTableAddressBetween.setRowSelectionInterval(0, 0); |
548 |
|
549 |
// save in the gmodel the descriptor of identifier field
|
550 |
int n = jTabbedComposed.getSelectedIndex();
|
551 |
if (n == 0) { |
552 |
String desc = (String) jComboIdCross.getModel().getSelectedItem(); |
553 |
control.getGmodel().setIdMasiveTable(desc); |
554 |
} else {
|
555 |
String desc = (String) jComboIdBetween.getModel().getSelectedItem(); |
556 |
control.getGmodel().setIdMasiveTable(desc); |
557 |
} |
558 |
|
559 |
// Get store from Gmodel and the feature
|
560 |
FeatureStore store = control.getGmodel().getSelectedTableStore(); |
561 |
FeatureSet features = null;
|
562 |
Feature feature = null;
|
563 |
try {
|
564 |
features = store.getFeatureSet(); |
565 |
Iterator<Feature> it = features.iterator(row);
|
566 |
feature = it.next(); |
567 |
} catch (DataException e) {
|
568 |
log.error("Get the feature of FeatureStore", e);
|
569 |
} |
570 |
|
571 |
// Create the address
|
572 |
ComposedAddress address = new DefaultComposedAddress();
|
573 |
Literal mainLiteral = new DefaultLiteral();
|
574 |
Literal literal2 = new DefaultLiteral();
|
575 |
Literal literal3 = new DefaultLiteral();
|
576 |
List<Literal> intersectionLiterals = new ArrayList<Literal>(); |
577 |
Vector vec = model.getDataVector();
|
578 |
|
579 |
for (int i = 0; i < vec.size(); i++) { |
580 |
Vector vecc = (Vector) vec.elementAt(i); |
581 |
String key = (String) vecc.elementAt(0); |
582 |
String fieldName1 = (String) vecc.elementAt(1); |
583 |
String fieldName2 = (String) vecc.elementAt(2); |
584 |
Object obj1 = feature.get(fieldName1);
|
585 |
Object obj2 = feature.get(fieldName2);
|
586 |
String value1 = obj1.toString();
|
587 |
String value2 = obj2.toString();
|
588 |
mainLiteral.put(key, value1); |
589 |
literal2.put(key, value2); |
590 |
} |
591 |
|
592 |
address.setMainLiteral(mainLiteral); |
593 |
intersectionLiterals.add(literal2); |
594 |
|
595 |
// get third address if exist
|
596 |
int num = ((Vector) vec.elementAt(0)).size(); |
597 |
if (num == 4) { |
598 |
for (int i = 0; i < vec.size(); i++) { |
599 |
Vector vecc = (Vector) vec.elementAt(i); |
600 |
String key = (String) vecc.elementAt(0); |
601 |
String fieldName3 = (String) vecc.elementAt(3); |
602 |
Object obj3 = feature.get(fieldName3);
|
603 |
String value3 = obj3.toString();
|
604 |
literal3.put(key, value3); |
605 |
} |
606 |
intersectionLiterals.add(literal3); |
607 |
} |
608 |
address.setIntersectionLiterals(intersectionLiterals); |
609 |
|
610 |
return address;
|
611 |
} |
612 |
|
613 |
} |