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