root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / gui / GeocodingPanel.java @ 31085
History | View | Annotate | Download (33 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. vsanjaime Programador
|
26 |
*/
|
27 |
package org.gvsig.geocoding.gui; |
28 |
|
29 |
import java.awt.Dimension; |
30 |
import java.awt.GridBagConstraints; |
31 |
import java.awt.event.MouseEvent; |
32 |
import java.awt.event.MouseListener; |
33 |
import java.io.File; |
34 |
import java.util.ArrayList; |
35 |
import java.util.List; |
36 |
import java.util.Set; |
37 |
|
38 |
import javax.swing.ButtonGroup; |
39 |
import javax.swing.DefaultComboBoxModel; |
40 |
import javax.swing.ImageIcon; |
41 |
import javax.swing.JButton; |
42 |
import javax.swing.JComboBox; |
43 |
import javax.swing.JLabel; |
44 |
import javax.swing.JPanel; |
45 |
import javax.swing.JRadioButton; |
46 |
import javax.swing.JScrollPane; |
47 |
import javax.swing.JTable; |
48 |
import javax.swing.JTextField; |
49 |
import javax.swing.ListSelectionModel; |
50 |
import javax.swing.SwingConstants; |
51 |
|
52 |
import org.gvsig.fmap.dal.exception.DataException; |
53 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
54 |
import org.gvsig.fmap.geom.primitive.Point; |
55 |
import org.gvsig.geocoding.export.MasiveExportThread; |
56 |
import org.gvsig.geocoding.extension.GeocodingController; |
57 |
import org.gvsig.geocoding.gui.address.AbstractAddressPanel; |
58 |
import org.gvsig.geocoding.gui.settings.SettingsPanel; |
59 |
import org.gvsig.geocoding.pattern.GeocodingPattern; |
60 |
import org.gvsig.geocoding.pattern.impl.DefaultGeocodingPattern; |
61 |
import org.gvsig.geocoding.result.GeocodingResult; |
62 |
import org.gvsig.geocoding.utils.GeocodingUtils; |
63 |
import org.gvsig.tools.ToolsLocator; |
64 |
import org.gvsig.tools.persistence.PersistenceException; |
65 |
import org.gvsig.tools.persistence.PersistenceManager; |
66 |
import org.gvsig.tools.persistence.PersistenceValidateExceptions; |
67 |
import org.gvsig.tools.persistence.PersistentState; |
68 |
import org.gvsig.utils.XMLEntity; |
69 |
import org.slf4j.Logger; |
70 |
import org.slf4j.LoggerFactory; |
71 |
|
72 |
import org.gvsig.andami.PluginServices; |
73 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
74 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
75 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
76 |
import org.gvsig.app.project.documents.table.FeatureTableDocument; |
77 |
|
78 |
/**
|
79 |
* Main panel of geocoding extension
|
80 |
*
|
81 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
82 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
83 |
*/
|
84 |
|
85 |
public class GeocodingPanel extends JPanel implements SingletonWindow, |
86 |
MouseListener {
|
87 |
|
88 |
private static final long serialVersionUID = 1L; |
89 |
private Logger log = LoggerFactory.getLogger(GeocodingPanel.class); |
90 |
private GeocodingController control = null; |
91 |
|
92 |
private AbstractAddressPanel aPanel = null; |
93 |
|
94 |
private ButtonGroup groupRadio; |
95 |
private JButton jButExit; |
96 |
private JButton jButLoad; |
97 |
private JButton jButNew; |
98 |
private JButton jButEdit; |
99 |
private JButton jButNext; |
100 |
private JButton jButPrevious; |
101 |
private JButton jButSearch; |
102 |
private JButton jButExport; |
103 |
private JComboBox jComboTable; |
104 |
private JComboBox jComboType; |
105 |
private JLabel jLabPatternPath; |
106 |
private JLabel jLabScore; |
107 |
private JLabel jLabType; |
108 |
private JLabel jLabRow; |
109 |
private JPanel jPanButtons; |
110 |
private JPanel jPanGeocodingType; |
111 |
private JPanel jPanPattern; |
112 |
private JPanel jPanResults; |
113 |
private JPanel jPanResultsButtons; |
114 |
private JPanel jPanSettings; |
115 |
private JPanel jPanSimpleTable; |
116 |
private JPanel jPanTable; |
117 |
private JPanel jPanType; |
118 |
private JRadioButton jRadioSimple; |
119 |
private JRadioButton jRadioTable; |
120 |
private JScrollPane jScrollResults; |
121 |
private JTable jTableResults; |
122 |
private JTextField jTextPatternPath; |
123 |
private SettingsPanel settingsPanel;
|
124 |
|
125 |
/**
|
126 |
* Constructor
|
127 |
*
|
128 |
* @param _control
|
129 |
*/
|
130 |
public GeocodingPanel(GeocodingController _control) {
|
131 |
this.control = _control;
|
132 |
this.initComponents();
|
133 |
this.setMesages();
|
134 |
this.setImages();
|
135 |
|
136 |
// pattern null
|
137 |
this.control.getGmodel().setPattern(null); |
138 |
settingsPanel.setMaxResults(10);
|
139 |
settingsPanel.activateComponents(false);
|
140 |
this.jPanGeocodingType.validate();
|
141 |
} |
142 |
|
143 |
/**
|
144 |
* set icons
|
145 |
*/
|
146 |
private void setImages() { |
147 |
PluginServices ps = PluginServices.getPluginServices(this);
|
148 |
if (ps != null) { |
149 |
String baseDir = ps.getClassLoader().getBaseDir();
|
150 |
|
151 |
jButLoad |
152 |
.setIcon(new ImageIcon(baseDir + File.separator + "images" |
153 |
+ File.separator + "icons16" + File.separator |
154 |
+ "open.png"));
|
155 |
jButNew.setIcon(new ImageIcon(baseDir + File.separator + "images" |
156 |
+ File.separator + "icons16" + File.separator + "new.png")); |
157 |
|
158 |
jButEdit |
159 |
.setIcon(new ImageIcon(baseDir + File.separator + "images" |
160 |
+ File.separator + "icons16" + File.separator |
161 |
+ "edit.png"));
|
162 |
|
163 |
jButNext |
164 |
.setIcon(new ImageIcon(baseDir + File.separator + "images" |
165 |
+ File.separator + "icons16" + File.separator |
166 |
+ "next.png"));
|
167 |
|
168 |
jButPrevious.setIcon(new ImageIcon(baseDir + File.separator |
169 |
+ "images" + File.separator + "icons16" + File.separator |
170 |
+ "previous.png"));
|
171 |
|
172 |
jButSearch.setIcon(new ImageIcon(baseDir + File.separator |
173 |
+ "images" + File.separator + "icons16" + File.separator |
174 |
+ "search.png"));
|
175 |
|
176 |
jButExit.setIcon(new ImageIcon(baseDir + File.separator + "images" |
177 |
+ File.separator + "icons16" + File.separator + "out.png")); |
178 |
|
179 |
jButExport.setIcon(new ImageIcon(baseDir + File.separator |
180 |
+ "images" + File.separator + "icons16" + File.separator |
181 |
+ "up.png"));
|
182 |
} |
183 |
} |
184 |
|
185 |
/**
|
186 |
* set labels
|
187 |
*/
|
188 |
private void setMesages() { |
189 |
PluginServices ps = PluginServices.getPluginServices(this);
|
190 |
|
191 |
if (ps != null) { |
192 |
jPanPattern.setBorder(GeocodingUtils.getTitledBorder(ps |
193 |
.getText("pattern")));
|
194 |
|
195 |
this.jButLoad.setToolTipText(ps.getText("butloadpattern")); |
196 |
|
197 |
this.jButNew.setToolTipText(ps.getText("butnewpattern")); |
198 |
|
199 |
this.jButEdit.setToolTipText(ps.getText("buteditpattern")); |
200 |
|
201 |
this.jLabPatternPath.setText(ps.getText("patternpath")); |
202 |
|
203 |
jPanGeocodingType.setBorder(GeocodingUtils.getTitledBorder(ps |
204 |
.getText("gtype")));
|
205 |
|
206 |
this.jRadioSimple.setText(ps.getText("gsimple")); |
207 |
this.jRadioSimple.setToolTipText(ps.getText("gsimpletip")); |
208 |
|
209 |
this.jRadioTable.setText(ps.getText("gtable")); |
210 |
this.jRadioTable.setToolTipText(ps.getText("gtabletip")); |
211 |
|
212 |
jPanType.setBorder(GeocodingUtils.getTitledBorder(ps |
213 |
.getText("atype")));
|
214 |
|
215 |
jPanSettings.setBorder(GeocodingUtils.getTitledBorder(ps |
216 |
.getText("settings")));
|
217 |
|
218 |
jPanResults.setBorder(GeocodingUtils.getTitledBorder(ps |
219 |
.getText("results")));
|
220 |
|
221 |
this.jButPrevious.setToolTipText(ps.getText("previoustip")); |
222 |
this.jButNext.setToolTipText(ps.getText("nexttip")); |
223 |
|
224 |
this.jButExit.setText(ps.getText("exit")); |
225 |
this.jButSearch.setText(ps.getText("search")); |
226 |
this.jButExport.setText(ps.getText("export")); |
227 |
} |
228 |
|
229 |
} |
230 |
|
231 |
/**
|
232 |
* Initialize Panel Components
|
233 |
*/
|
234 |
private void initComponents() { |
235 |
|
236 |
this.setFocusable(true); |
237 |
this.addMouseListener(this); |
238 |
|
239 |
java.awt.GridBagConstraints gridBagConstraints; |
240 |
|
241 |
groupRadio = new javax.swing.ButtonGroup();
|
242 |
jPanPattern = new javax.swing.JPanel();
|
243 |
jLabPatternPath = new javax.swing.JLabel();
|
244 |
jTextPatternPath = new javax.swing.JTextField();
|
245 |
jButLoad = new javax.swing.JButton();
|
246 |
jButNew = new javax.swing.JButton();
|
247 |
jButEdit = new javax.swing.JButton();
|
248 |
jPanGeocodingType = new javax.swing.JPanel();
|
249 |
jPanSimpleTable = new javax.swing.JPanel();
|
250 |
jRadioSimple = new javax.swing.JRadioButton();
|
251 |
jPanTable = new javax.swing.JPanel();
|
252 |
jComboTable = new javax.swing.JComboBox();
|
253 |
jRadioTable = new javax.swing.JRadioButton();
|
254 |
jPanType = new javax.swing.JPanel();
|
255 |
jComboType = new javax.swing.JComboBox();
|
256 |
jLabType = new javax.swing.JLabel();
|
257 |
jLabRow = new javax.swing.JLabel();
|
258 |
jPanSettings = new javax.swing.JPanel();
|
259 |
settingsPanel = new SettingsPanel(control);
|
260 |
jLabScore = new javax.swing.JLabel();
|
261 |
jPanResults = new javax.swing.JPanel();
|
262 |
jScrollResults = new javax.swing.JScrollPane();
|
263 |
jTableResults = new javax.swing.JTable();
|
264 |
jPanResultsButtons = new javax.swing.JPanel();
|
265 |
jButNext = new javax.swing.JButton();
|
266 |
jButPrevious = new javax.swing.JButton();
|
267 |
jPanButtons = new javax.swing.JPanel();
|
268 |
jButExit = new javax.swing.JButton();
|
269 |
jButSearch = new javax.swing.JButton();
|
270 |
jButExport = new javax.swing.JButton();
|
271 |
|
272 |
setLayout(new java.awt.GridBagLayout());
|
273 |
|
274 |
jPanPattern.setBorder(javax.swing.BorderFactory |
275 |
.createTitledBorder("Pattern"));
|
276 |
jPanPattern.setLayout(new java.awt.GridBagLayout());
|
277 |
|
278 |
jLabPatternPath.setText("Name");
|
279 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
280 |
gridBagConstraints.gridx = 0;
|
281 |
gridBagConstraints.gridy = 0;
|
282 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 3); |
283 |
jPanPattern.add(jLabPatternPath, gridBagConstraints); |
284 |
|
285 |
jTextPatternPath.setEditable(false);
|
286 |
jTextPatternPath.setToolTipText("Pattern file");
|
287 |
|
288 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
289 |
gridBagConstraints.gridx = 1;
|
290 |
gridBagConstraints.gridy = 0;
|
291 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
292 |
gridBagConstraints.weightx = 1.0;
|
293 |
jPanPattern.add(jTextPatternPath, gridBagConstraints); |
294 |
|
295 |
jButLoad.setText("");
|
296 |
jButLoad.setToolTipText("Load pattern");
|
297 |
jButLoad.setMaximumSize(new java.awt.Dimension(35, 25)); |
298 |
jButLoad.setMinimumSize(new java.awt.Dimension(30, 25)); |
299 |
jButLoad.setPreferredSize(new java.awt.Dimension(30, 25)); |
300 |
jButLoad.addActionListener(new java.awt.event.ActionListener() {
|
301 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
302 |
evLoadPattern(evt); |
303 |
} |
304 |
}); |
305 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
306 |
gridBagConstraints.gridx = 2;
|
307 |
gridBagConstraints.gridy = 0;
|
308 |
gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 0); |
309 |
jPanPattern.add(jButLoad, gridBagConstraints); |
310 |
|
311 |
jButNew.setText("");
|
312 |
jButNew.setToolTipText("New");
|
313 |
jButNew.setMaximumSize(new java.awt.Dimension(35, 25)); |
314 |
jButNew.setMinimumSize(new java.awt.Dimension(30, 25)); |
315 |
jButNew.setPreferredSize(new java.awt.Dimension(30, 25)); |
316 |
jButNew.addActionListener(new java.awt.event.ActionListener() {
|
317 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
318 |
evNewPattern(evt); |
319 |
} |
320 |
}); |
321 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
322 |
gridBagConstraints.gridx = 3;
|
323 |
gridBagConstraints.gridy = 0;
|
324 |
gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 0); |
325 |
jPanPattern.add(jButNew, gridBagConstraints); |
326 |
|
327 |
jButEdit.setText("");
|
328 |
jButEdit.setToolTipText("Edit");
|
329 |
jButEdit.setMaximumSize(new java.awt.Dimension(35, 25)); |
330 |
jButEdit.setMinimumSize(new java.awt.Dimension(30, 25)); |
331 |
jButEdit.setPreferredSize(new java.awt.Dimension(30, 25)); |
332 |
jButEdit.setEnabled(false);
|
333 |
jButEdit.addActionListener(new java.awt.event.ActionListener() {
|
334 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
335 |
evEditPattern(evt); |
336 |
} |
337 |
}); |
338 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
339 |
gridBagConstraints.gridx = 4;
|
340 |
gridBagConstraints.gridy = 0;
|
341 |
gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2); |
342 |
jPanPattern.add(jButEdit, gridBagConstraints); |
343 |
|
344 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
345 |
gridBagConstraints.gridx = 0;
|
346 |
gridBagConstraints.gridy = 0;
|
347 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
348 |
gridBagConstraints.weightx = 1.0;
|
349 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); |
350 |
add(jPanPattern, gridBagConstraints); |
351 |
|
352 |
jPanGeocodingType.setBorder(javax.swing.BorderFactory |
353 |
.createTitledBorder("Geocoding type"));
|
354 |
jPanGeocodingType.setLayout(new java.awt.GridBagLayout());
|
355 |
jPanSimpleTable.setLayout(new java.awt.GridBagLayout());
|
356 |
|
357 |
groupRadio.add(jRadioSimple); |
358 |
jRadioSimple.setSelected(true);
|
359 |
jRadioSimple.setEnabled(false);
|
360 |
jRadioSimple.setText("Simple geocoding");
|
361 |
jRadioSimple.setToolTipText("Simple geocoding");
|
362 |
jRadioSimple.addActionListener(new java.awt.event.ActionListener() {
|
363 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
364 |
evSimpleGeocoding(evt); |
365 |
} |
366 |
}); |
367 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
368 |
gridBagConstraints.gridx = 0;
|
369 |
gridBagConstraints.gridy = 0;
|
370 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
371 |
gridBagConstraints.weightx = 1.0;
|
372 |
gridBagConstraints.insets = new java.awt.Insets(0, 50, 0, 10); |
373 |
jPanSimpleTable.add(jRadioSimple, gridBagConstraints); |
374 |
|
375 |
jPanTable.setLayout(new java.awt.GridBagLayout());
|
376 |
|
377 |
jComboTable.setModel(new javax.swing.DefaultComboBoxModel(
|
378 |
new String[] { "" })); |
379 |
jComboTable.setMinimumSize(new java.awt.Dimension(150, 18)); |
380 |
jComboTable.setPreferredSize(new java.awt.Dimension(200, 22)); |
381 |
|
382 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
383 |
gridBagConstraints.gridx = 1;
|
384 |
gridBagConstraints.gridy = 0;
|
385 |
jComboTable.setEnabled(false);
|
386 |
jComboTable.addActionListener(new java.awt.event.ActionListener() {
|
387 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
388 |
evChangeTable(evt); |
389 |
} |
390 |
}); |
391 |
jPanTable.add(jComboTable, gridBagConstraints); |
392 |
|
393 |
groupRadio.add(jRadioTable); |
394 |
jRadioTable.setText("Table geocoding");
|
395 |
jRadioTable.setEnabled(false);
|
396 |
jRadioTable.setToolTipText("Table geocoding");
|
397 |
jRadioTable.addActionListener(new java.awt.event.ActionListener() {
|
398 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
399 |
evTableGeocoding(evt); |
400 |
} |
401 |
}); |
402 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
403 |
gridBagConstraints.gridx = 0;
|
404 |
gridBagConstraints.gridy = 0;
|
405 |
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 2); |
406 |
jPanTable.add(jRadioTable, gridBagConstraints); |
407 |
|
408 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
409 |
gridBagConstraints.gridx = 1;
|
410 |
gridBagConstraints.gridy = 0;
|
411 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
412 |
gridBagConstraints.weightx = 1.0;
|
413 |
jPanSimpleTable.add(jPanTable, gridBagConstraints); |
414 |
|
415 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
416 |
gridBagConstraints.gridx = 0;
|
417 |
gridBagConstraints.gridy = 0;
|
418 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
419 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
420 |
jPanGeocodingType.add(jPanSimpleTable, gridBagConstraints); |
421 |
|
422 |
jPanType.setBorder(javax.swing.BorderFactory |
423 |
.createTitledBorder("Search Type"));
|
424 |
jPanType.setLayout(new java.awt.GridBagLayout());
|
425 |
|
426 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
427 |
gridBagConstraints.gridx = 0;
|
428 |
gridBagConstraints.gridy = 1;
|
429 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
430 |
gridBagConstraints.weightx = 1.0;
|
431 |
gridBagConstraints.weighty = 1.0;
|
432 |
gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1); |
433 |
jPanGeocodingType.add(jPanType, gridBagConstraints); |
434 |
|
435 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
436 |
gridBagConstraints.gridx = 0;
|
437 |
gridBagConstraints.gridy = 1;
|
438 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
439 |
gridBagConstraints.weightx = 1.0;
|
440 |
gridBagConstraints.weighty = 0.7;
|
441 |
gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 2); |
442 |
add(jPanGeocodingType, gridBagConstraints); |
443 |
|
444 |
jPanSettings.setBorder(javax.swing.BorderFactory |
445 |
.createTitledBorder("Settings"));
|
446 |
jPanSettings.setLayout(new java.awt.GridBagLayout());
|
447 |
|
448 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
449 |
gridBagConstraints.gridx = 0;
|
450 |
gridBagConstraints.gridy = 0;
|
451 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
452 |
gridBagConstraints.weightx = 1.0;
|
453 |
gridBagConstraints.weighty = 1.0;
|
454 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5); |
455 |
jPanSettings.add(settingsPanel, gridBagConstraints); |
456 |
|
457 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
458 |
gridBagConstraints.gridx = 0;
|
459 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
460 |
gridBagConstraints.weightx = 1.0;
|
461 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
462 |
jPanGeocodingType.add(jPanSettings, gridBagConstraints); |
463 |
|
464 |
jPanResults.setBorder(javax.swing.BorderFactory |
465 |
.createTitledBorder("Results"));
|
466 |
jPanResults.setLayout(new java.awt.GridBagLayout());
|
467 |
jTableResults.setEnabled(false);
|
468 |
jTableResults.setName("jTableResults");
|
469 |
jTableResults.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
470 |
|
471 |
jTableResults.setModel(new TableResultsModel(control));
|
472 |
jTableResults.addMouseListener(this);
|
473 |
|
474 |
jScrollResults.setViewportView(jTableResults); |
475 |
|
476 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
477 |
gridBagConstraints.gridx = 0;
|
478 |
gridBagConstraints.gridy = 0;
|
479 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
480 |
gridBagConstraints.weightx = 1.0;
|
481 |
gridBagConstraints.weighty = 1.0;
|
482 |
jPanResults.add(jScrollResults, gridBagConstraints); |
483 |
|
484 |
jPanResultsButtons.setLayout(new java.awt.GridBagLayout());
|
485 |
|
486 |
jButNext.setText("");
|
487 |
jButNext.setToolTipText("Next register");
|
488 |
jButNext.setEnabled(false);
|
489 |
jButNext.setPreferredSize(new Dimension(35, 25)); |
490 |
jButNext.setMaximumSize(new Dimension(35, 25)); |
491 |
jButNext.addActionListener(new java.awt.event.ActionListener() {
|
492 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
493 |
evNextButton(evt); |
494 |
} |
495 |
}); |
496 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
497 |
gridBagConstraints.gridx = 2;
|
498 |
gridBagConstraints.gridy = 0;
|
499 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; |
500 |
jPanResultsButtons.add(jButNext, gridBagConstraints); |
501 |
|
502 |
jLabRow.setText("");
|
503 |
jLabRow.setEnabled(false);
|
504 |
jLabRow.setHorizontalAlignment(SwingConstants.CENTER);
|
505 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
506 |
gridBagConstraints.gridx = 1;
|
507 |
gridBagConstraints.gridy = 0;
|
508 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5); |
509 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER; |
510 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
511 |
gridBagConstraints.weightx = 1.0;
|
512 |
jPanResultsButtons.add(jLabRow, gridBagConstraints); |
513 |
|
514 |
jButPrevious.setText("");
|
515 |
jButPrevious.setToolTipText("Previous register");
|
516 |
jButPrevious.setEnabled(false);
|
517 |
jButPrevious.setMaximumSize(new Dimension(35, 25)); |
518 |
jButPrevious.setPreferredSize(new Dimension(35, 25)); |
519 |
jButPrevious.addActionListener(new java.awt.event.ActionListener() {
|
520 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
521 |
evPreviousButton(evt); |
522 |
} |
523 |
}); |
524 |
|
525 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
526 |
gridBagConstraints.gridx = 0;
|
527 |
gridBagConstraints.gridy = 0;
|
528 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
529 |
jPanResultsButtons.add(jButPrevious, gridBagConstraints); |
530 |
|
531 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
532 |
gridBagConstraints.gridx = 0;
|
533 |
gridBagConstraints.gridy = 1;
|
534 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
535 |
gridBagConstraints.weightx = 1.0;
|
536 |
gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); |
537 |
jPanResults.add(jPanResultsButtons, gridBagConstraints); |
538 |
|
539 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
540 |
gridBagConstraints.gridx = 0;
|
541 |
gridBagConstraints.gridy = 3;
|
542 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
543 |
gridBagConstraints.weightx = 1.0;
|
544 |
gridBagConstraints.weighty = 1.0;
|
545 |
gridBagConstraints.insets = new java.awt.Insets(1, 2, 1, 2); |
546 |
add(jPanResults, gridBagConstraints); |
547 |
|
548 |
jPanButtons.setLayout(new java.awt.GridBagLayout());
|
549 |
|
550 |
jButExit.setText("Exit");
|
551 |
jButExit.setToolTipText("Exit");
|
552 |
jButExit.addActionListener(new java.awt.event.ActionListener() {
|
553 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
554 |
evExit(evt); |
555 |
} |
556 |
}); |
557 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
558 |
gridBagConstraints.gridx = 2;
|
559 |
gridBagConstraints.gridy = 0;
|
560 |
gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0); |
561 |
jPanButtons.add(jButExit, gridBagConstraints); |
562 |
|
563 |
jButSearch.setText("Search");
|
564 |
jButSearch.setToolTipText("Search");
|
565 |
jButSearch.setEnabled(false);
|
566 |
jButSearch.addActionListener(new java.awt.event.ActionListener() {
|
567 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
568 |
evSearch(evt); |
569 |
} |
570 |
}); |
571 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
572 |
gridBagConstraints.gridx = 0;
|
573 |
gridBagConstraints.gridy = 0;
|
574 |
jPanButtons.add(jButSearch, gridBagConstraints); |
575 |
|
576 |
jButExport.setText("Export");
|
577 |
jButExport.setToolTipText("Export");
|
578 |
jButExport.setEnabled(false);
|
579 |
jButExport.addActionListener(new java.awt.event.ActionListener() {
|
580 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
581 |
evExport(evt); |
582 |
} |
583 |
}); |
584 |
jPanButtons.add(jButExport, new java.awt.GridBagConstraints());
|
585 |
|
586 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
587 |
gridBagConstraints.gridx = 0;
|
588 |
gridBagConstraints.gridy = 4;
|
589 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
590 |
gridBagConstraints.weightx = 1.0;
|
591 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 4, 2); |
592 |
add(jPanButtons, gridBagConstraints); |
593 |
} |
594 |
|
595 |
/**
|
596 |
* Load a pattern from file event
|
597 |
*
|
598 |
* @param evt
|
599 |
*/
|
600 |
private void evLoadPattern(java.awt.event.ActionEvent evt) { |
601 |
/* load the pattern */
|
602 |
boolean ok = control.loadPatternFromXML();
|
603 |
|
604 |
if (ok) {
|
605 |
// update the pattern parameters in GUI
|
606 |
control.updateGeocoGUI(); |
607 |
jButEdit.setEnabled(true);
|
608 |
|
609 |
// enable components
|
610 |
if (control.getPattern() != null) { |
611 |
this.enableComponents();
|
612 |
// insert address panel
|
613 |
insertAddressPanel(); |
614 |
} |
615 |
} |
616 |
} |
617 |
|
618 |
/**
|
619 |
* create new pattern event
|
620 |
*
|
621 |
* @param evt
|
622 |
*/
|
623 |
private void evNewPattern(java.awt.event.ActionEvent evt) { |
624 |
control.launchNewPatternPanel(null);
|
625 |
} |
626 |
|
627 |
/**
|
628 |
* edit current pattern event
|
629 |
*
|
630 |
* @param evt
|
631 |
* @throws PersistenceException
|
632 |
*/
|
633 |
private void evEditPattern(java.awt.event.ActionEvent evt) { |
634 |
|
635 |
GeocodingPattern pat = control.getPattern(); |
636 |
GeocodingPattern copypat = null;
|
637 |
// Copiar del patr?n (Clonar)
|
638 |
try {
|
639 |
XMLEntity xml = pat.getXMLEntity(); |
640 |
copypat = new DefaultGeocodingPattern();
|
641 |
copypat.setXMLEntity(xml); |
642 |
} catch (Exception e) { |
643 |
log.error("Error cloning the pattern", e);
|
644 |
} |
645 |
if (copypat != null) { |
646 |
control.launchNewPatternPanel(copypat); |
647 |
} |
648 |
|
649 |
} |
650 |
|
651 |
/**
|
652 |
* Simple geocoding event
|
653 |
*
|
654 |
* @param evt
|
655 |
*/
|
656 |
private void evSimpleGeocoding(java.awt.event.ActionEvent evt) { |
657 |
control.getGmodel().setSimple(true);
|
658 |
activeTableGUIFeatures(false);
|
659 |
jButExport.setEnabled(false);
|
660 |
// insert address panel
|
661 |
insertAddressPanel(); |
662 |
// clean table results
|
663 |
cleanTableResults(); |
664 |
// clean point on view
|
665 |
control.clearGeocodingPoint(); |
666 |
} |
667 |
|
668 |
/**
|
669 |
* Tables availables event
|
670 |
*
|
671 |
* @param evt
|
672 |
*/
|
673 |
private void evTableGeocoding(java.awt.event.ActionEvent evt) { |
674 |
/* Put the tables names availables in the combo */
|
675 |
DefaultComboBoxModel comboModel = control.getModelgvSIGTables();
|
676 |
if (comboModel == null) { |
677 |
comboModel = new DefaultComboBoxModel(); |
678 |
} |
679 |
/* save in the model table geocoding */
|
680 |
jComboTable.setModel(comboModel); |
681 |
/* enable components */
|
682 |
control.getGmodel().setSimple(false);
|
683 |
jComboTable.setEnabled(true);
|
684 |
jButExport.setEnabled(false);
|
685 |
// save descriptor table in the model
|
686 |
List<String> descs = getListOfDescriptorSelectedTable(); |
687 |
control.getGmodel().setListDescriptorSelectedTable(descs); |
688 |
// insert address panel
|
689 |
insertAddressPanel(); |
690 |
// clean results
|
691 |
cleanTableResults(); |
692 |
// clean point on view
|
693 |
control.clearGeocodingPoint(); |
694 |
|
695 |
} |
696 |
|
697 |
/**
|
698 |
* Table selected event
|
699 |
*
|
700 |
* @param evt
|
701 |
*/
|
702 |
private void evChangeTable(java.awt.event.ActionEvent evt) { |
703 |
|
704 |
// save descriptor table in the model
|
705 |
List<String> descs = getListOfDescriptorSelectedTable(); |
706 |
control.getGmodel().setListDescriptorSelectedTable(descs); |
707 |
// insert address panel
|
708 |
insertAddressPanel(); |
709 |
} |
710 |
|
711 |
/**
|
712 |
* next button
|
713 |
*
|
714 |
* @param evt
|
715 |
*/
|
716 |
private void evNextButton(java.awt.event.ActionEvent evt) { |
717 |
List<Set<GeocodingResult>> results = control.getGmodel() |
718 |
.getAllResults(); |
719 |
int row = control.getGmodel().getNumResultShowed();
|
720 |
int cant = results.size() - 2; |
721 |
if (row <= cant) {
|
722 |
Set<GeocodingResult> res = results.get(row + 1); |
723 |
((TableResultsModel) jTableResults.getModel()).setResultSet(res, |
724 |
control.getPattern().getSettings().getResultsNumber(), |
725 |
control.getPattern().getSettings().getScore()); |
726 |
jLabRow.setText(control.ROW + Integer.toString(row + 2)); |
727 |
control.getGmodel().setNumResultShowed(row + 1);
|
728 |
|
729 |
// Show results position in the gvSIG view
|
730 |
control.showResultsPositionsOnView(res); |
731 |
|
732 |
// select first result element and zoom it
|
733 |
zoomTo(0);
|
734 |
} |
735 |
} |
736 |
|
737 |
/**
|
738 |
* Previous event
|
739 |
*
|
740 |
* @param evt
|
741 |
*/
|
742 |
private void evPreviousButton(java.awt.event.ActionEvent evt) { |
743 |
List<Set<GeocodingResult>> results = control.getGmodel() |
744 |
.getAllResults(); |
745 |
int row = control.getGmodel().getNumResultShowed();
|
746 |
if (row > 0) { |
747 |
Set<GeocodingResult> res = results.get(row - 1); |
748 |
((TableResultsModel) jTableResults.getModel()).setResultSet(res, |
749 |
control.getPattern().getSettings().getResultsNumber(), |
750 |
control.getPattern().getSettings().getScore()); |
751 |
jLabRow.setText(control.ROW + Integer.toString(row));
|
752 |
control.getGmodel().setNumResultShowed(row - 1);
|
753 |
|
754 |
// Show results positions in the gvSIG view
|
755 |
control.showResultsPositionsOnView(res); |
756 |
|
757 |
// Select first result element and zoom it
|
758 |
zoomTo(0);
|
759 |
} |
760 |
} |
761 |
|
762 |
/**
|
763 |
* geocoding search event
|
764 |
*
|
765 |
* @param evt
|
766 |
*/
|
767 |
private void evSearch(java.awt.event.ActionEvent evt) { |
768 |
// clear points in view
|
769 |
control.clearGeocodingPoint(); |
770 |
// clear table results
|
771 |
cleanTableResults(); |
772 |
// GEOCODING PROCESS
|
773 |
control.geocoding(); |
774 |
} |
775 |
|
776 |
/**
|
777 |
* export event
|
778 |
*
|
779 |
* @param evt
|
780 |
*/
|
781 |
private void evExport(java.awt.event.ActionEvent evt) { |
782 |
new MasiveExportThread(control).run();
|
783 |
exit(); |
784 |
} |
785 |
|
786 |
/**
|
787 |
* exit event. Close the panel
|
788 |
*
|
789 |
* @param evt
|
790 |
*/
|
791 |
private void evExit(java.awt.event.ActionEvent evt) { |
792 |
exit(); |
793 |
} |
794 |
|
795 |
/**
|
796 |
* get window info
|
797 |
*/
|
798 |
public WindowInfo getWindowInfo() {
|
799 |
WindowInfo info = new WindowInfo(WindowInfo.RESIZABLE);
|
800 |
info.setMinimumSize(this.getMinimumSize());
|
801 |
info.setWidth(600);
|
802 |
info.setHeight(530);
|
803 |
info.setTitle(PluginServices.getText(this, "geocoding")); |
804 |
info.setX(100);
|
805 |
info.setY(150);
|
806 |
return info;
|
807 |
} |
808 |
|
809 |
/**
|
810 |
* get window profile
|
811 |
*/
|
812 |
public Object getWindowProfile() { |
813 |
return null; |
814 |
} |
815 |
|
816 |
/**
|
817 |
* insert changeable address panel
|
818 |
*
|
819 |
* @param pan
|
820 |
*/
|
821 |
public void insertAddressPanel() { |
822 |
|
823 |
// get the panel depending of on the type of geocoding pattern
|
824 |
this.aPanel = control.getAddressPanelFromPatternStyle();
|
825 |
jPanType.removeAll(); |
826 |
|
827 |
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); |
828 |
gridBagConstraints.gridx = 0;
|
829 |
gridBagConstraints.gridy = 0;
|
830 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
831 |
gridBagConstraints.weightx = 1.0;
|
832 |
gridBagConstraints.weighty = 1.0;
|
833 |
|
834 |
if (aPanel != null) { |
835 |
jPanType.add(this.aPanel, gridBagConstraints);
|
836 |
this.aPanel.validate();
|
837 |
this.setSize(this.getWidth() + 1, this.getHeight()); |
838 |
jPanType.validate(); |
839 |
jPanResults.validate(); |
840 |
jPanPattern.validate(); |
841 |
this.validate();
|
842 |
} |
843 |
|
844 |
this.setSize(this.getWidth() + 1, this.getHeight()); |
845 |
jPanType.validate(); |
846 |
jPanResults.validate(); |
847 |
jPanPattern.validate(); |
848 |
this.validate();
|
849 |
|
850 |
} |
851 |
|
852 |
/**
|
853 |
* Set maximun results parameter
|
854 |
*
|
855 |
* @param results
|
856 |
*/
|
857 |
public void setParamMaxresults(int results) { |
858 |
settingsPanel.setMaxResults(new Integer(results)); |
859 |
} |
860 |
|
861 |
/**
|
862 |
* Set score parameter
|
863 |
*
|
864 |
* @param score
|
865 |
*/
|
866 |
public void setParamScore(double score) { |
867 |
settingsPanel.setScore(new Double(score)); |
868 |
|
869 |
} |
870 |
|
871 |
/**
|
872 |
* get the path pattern
|
873 |
*
|
874 |
* @return
|
875 |
*/
|
876 |
public String getJTextPatternPath() { |
877 |
return jTextPatternPath.getText();
|
878 |
} |
879 |
|
880 |
/**
|
881 |
* Set path pattern
|
882 |
*
|
883 |
* @param path
|
884 |
*/
|
885 |
public void setJTextPatternPath(String path) { |
886 |
this.jTextPatternPath.setText(path);
|
887 |
jButEdit.setEnabled(true);
|
888 |
} |
889 |
|
890 |
/**
|
891 |
* Enable components when load a pattern or create new pattern
|
892 |
*/
|
893 |
public void enableComponents() { |
894 |
jRadioSimple.setEnabled(true);
|
895 |
if (control.getListgvSIGTables().size() > 0) { |
896 |
jRadioTable.setEnabled(true);
|
897 |
} |
898 |
jLabType.setEnabled(true);
|
899 |
jComboType.setEnabled(true);
|
900 |
jLabScore.setEnabled(true);
|
901 |
jTableResults.setEnabled(true);
|
902 |
jButSearch.setEnabled(true);
|
903 |
settingsPanel.activateComponents(true);
|
904 |
} |
905 |
|
906 |
/**
|
907 |
* Active GUI features related with Massive geocoding from table
|
908 |
*
|
909 |
* @param active
|
910 |
*/
|
911 |
public void activeTableGUIFeatures(boolean active) { |
912 |
jComboTable.setEnabled(active); |
913 |
|
914 |
if (!jRadioSimple.isSelected() && active) {
|
915 |
jButNext.setEnabled(active); |
916 |
jButPrevious.setEnabled(active); |
917 |
jLabRow.setEnabled(active); |
918 |
jButExport.setEnabled(active); |
919 |
|
920 |
} else {
|
921 |
jLabRow.setText("");
|
922 |
jButNext.setEnabled(false);
|
923 |
jButPrevious.setEnabled(false);
|
924 |
jButExport.setEnabled(false);
|
925 |
} |
926 |
} |
927 |
|
928 |
/**
|
929 |
* mouse clicked event
|
930 |
*/
|
931 |
public void mouseClicked(MouseEvent e) { |
932 |
// nothing to do
|
933 |
} |
934 |
|
935 |
/**
|
936 |
* mouse entered event
|
937 |
*/
|
938 |
public void mouseEntered(MouseEvent e) { |
939 |
if (control.getPattern() != null) { |
940 |
List<FeatureTableDocument> tables = control.getListgvSIGTables();
|
941 |
if (tables.size() > 0) { |
942 |
if (control.getPattern() != null) { |
943 |
jRadioTable.setEnabled(true);
|
944 |
} |
945 |
} else {
|
946 |
jRadioTable.setEnabled(false);
|
947 |
} |
948 |
} |
949 |
} |
950 |
|
951 |
/**
|
952 |
* mouse exit event
|
953 |
*/
|
954 |
public void mouseExited(MouseEvent e) { |
955 |
// nothing to do
|
956 |
} |
957 |
|
958 |
/**
|
959 |
* Mouse pressed events
|
960 |
*/
|
961 |
public void mousePressed(MouseEvent e) { |
962 |
// nothing to do
|
963 |
} |
964 |
|
965 |
/**
|
966 |
* Mouse released event
|
967 |
*/
|
968 |
public void mouseReleased(MouseEvent e) { |
969 |
// mouse released over Table results
|
970 |
String comp = e.getComponent().getName();
|
971 |
if (comp != null && comp.compareTo("jTableResults") == 0) { |
972 |
|
973 |
int row = jTableResults.getSelectedRow();
|
974 |
int nshow = control.getGmodel().getNumResultShowed();
|
975 |
|
976 |
// one click
|
977 |
// update array selected optional result
|
978 |
control.getGmodel().getExportElements()[nshow] = row; |
979 |
// dynamic zoom
|
980 |
if (row >= 0) { |
981 |
zoomTo(row); |
982 |
} |
983 |
log.debug("List: " + nshow + " Selected: " + row); |
984 |
|
985 |
// double click
|
986 |
if (e.getClickCount() == 2) { |
987 |
jTableResults.clearSelection(); |
988 |
control.clearGeocodingPoint(); |
989 |
// update array selected optional result
|
990 |
control.getGmodel().getExportElements()[nshow] = -1;
|
991 |
log.debug("List: " + nshow + " Selected: -1"); |
992 |
} |
993 |
} |
994 |
} |
995 |
|
996 |
/**
|
997 |
* get selected table
|
998 |
*
|
999 |
* @return
|
1000 |
*/
|
1001 |
public FeatureTableDocument getSelectedTable() {
|
1002 |
return (FeatureTableDocument) jComboTable.getModel().getSelectedItem();
|
1003 |
} |
1004 |
|
1005 |
/**
|
1006 |
* get window model
|
1007 |
*
|
1008 |
* @return
|
1009 |
*/
|
1010 |
public Object getWindowModel() { |
1011 |
return this.getClass().getCanonicalName(); |
1012 |
} |
1013 |
|
1014 |
/**
|
1015 |
* get list of fields descriptors of the selected table
|
1016 |
*
|
1017 |
* @return
|
1018 |
*/
|
1019 |
private List<String> getListOfDescriptorSelectedTable() { |
1020 |
List<String> descs = new ArrayList<String>(); |
1021 |
FeatureTableDocument table = (FeatureTableDocument) jComboTable |
1022 |
.getSelectedItem(); |
1023 |
FeatureStore store = (FeatureStore) table.getStore(); |
1024 |
control.getGmodel().setSelectedTableStore(store); |
1025 |
|
1026 |
try {
|
1027 |
int nDescs = store.getDefaultFeatureType().size();
|
1028 |
for (int i = 0; i < nDescs; i++) { |
1029 |
String desc = store.getDefaultFeatureType()
|
1030 |
.getAttributeDescriptor(i).getName(); |
1031 |
descs.add(desc); |
1032 |
} |
1033 |
} catch (DataException e) {
|
1034 |
log |
1035 |
.error( |
1036 |
"Error getting the fields descriptors of the selected table",
|
1037 |
e); |
1038 |
} |
1039 |
return descs;
|
1040 |
} |
1041 |
|
1042 |
/**
|
1043 |
* get address panel
|
1044 |
*
|
1045 |
* @return
|
1046 |
*/
|
1047 |
public AbstractAddressPanel getAddressPanel() {
|
1048 |
return aPanel;
|
1049 |
} |
1050 |
|
1051 |
/**
|
1052 |
* get table of results
|
1053 |
*
|
1054 |
* @return
|
1055 |
*/
|
1056 |
public JTable getJTableResults() { |
1057 |
return jTableResults;
|
1058 |
} |
1059 |
|
1060 |
/**
|
1061 |
*
|
1062 |
* @param string
|
1063 |
*/
|
1064 |
public void setLabRow(String string) { |
1065 |
jLabRow.setText(string); |
1066 |
|
1067 |
} |
1068 |
|
1069 |
/**
|
1070 |
* Zoom to result position
|
1071 |
*
|
1072 |
* @param row
|
1073 |
*/
|
1074 |
private void zoomTo(int row) { |
1075 |
|
1076 |
// select first result position
|
1077 |
jTableResults.setRowSelectionInterval(row, row); |
1078 |
|
1079 |
TableResultsModel model = (TableResultsModel) jTableResults.getModel(); |
1080 |
// zoom to geom
|
1081 |
Point pto = model.getGeometry(row, 2, 3); |
1082 |
try {
|
1083 |
control.zoomToPoint(pto.getX(), pto.getY()); |
1084 |
} catch (Exception e1) { |
1085 |
log.error("Doing zoom to point", e1);
|
1086 |
} |
1087 |
} |
1088 |
|
1089 |
/**
|
1090 |
* Clean table results
|
1091 |
*/
|
1092 |
public void cleanTableResults() { |
1093 |
jTableResults.setModel(new TableResultsModel(control));
|
1094 |
jTableResults.validate(); |
1095 |
} |
1096 |
|
1097 |
/**
|
1098 |
* disable all components of main panel
|
1099 |
*/
|
1100 |
private void disableComponentsGUI() { |
1101 |
jTextPatternPath.setText("");
|
1102 |
jButEdit.setEnabled(false);
|
1103 |
jRadioSimple.setEnabled(false);
|
1104 |
jRadioTable.setEnabled(false);
|
1105 |
jComboTable.setEnabled(false);
|
1106 |
jTableResults.setEnabled(false);
|
1107 |
jButSearch.setEnabled(false);
|
1108 |
jPanType.removeAll(); |
1109 |
jPanType.validate(); |
1110 |
} |
1111 |
|
1112 |
private void exit() { |
1113 |
control.getGmodel().setSimple(true);
|
1114 |
this.jRadioSimple.setSelected(true); |
1115 |
this.jPanGeocodingType.validate();
|
1116 |
this.validate();
|
1117 |
// close panel
|
1118 |
this.control.getGmodel().setPattern(null); |
1119 |
IWindow[] iws = PluginServices.getMDIManager().getAllWindows();
|
1120 |
for (int i = 0; i < iws.length; i++) { |
1121 |
if (iws[i] instanceof GeocodingPanel) { |
1122 |
PluginServices.getMDIManager().closeWindow(iws[i]); |
1123 |
} |
1124 |
} |
1125 |
// clean point on view
|
1126 |
control.clearGeocodingPoint(); |
1127 |
// clean table results
|
1128 |
this.cleanTableResults();
|
1129 |
// clean panel
|
1130 |
settingsPanel.activateComponents(false);
|
1131 |
disableComponentsGUI(); |
1132 |
activeTableGUIFeatures(false);
|
1133 |
// select radio simple
|
1134 |
jRadioSimple.setSelected(true);
|
1135 |
insertAddressPanel(); |
1136 |
} |
1137 |
|
1138 |
} |