svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / streetsmap / ui / PanelQuerysBuilder.java @ 26594
History | View | Annotate | Download (17.9 KB)
1 |
package es.logex.gvsig.streetsmap.ui; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.Container; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.FocusTraversalPolicy; |
7 |
import java.awt.GridBagConstraints; |
8 |
import java.awt.GridBagLayout; |
9 |
import java.awt.Insets; |
10 |
import java.awt.event.ActionEvent; |
11 |
import java.awt.event.MouseAdapter; |
12 |
import java.awt.event.MouseEvent; |
13 |
import java.util.ArrayList; |
14 |
import java.util.List; |
15 |
|
16 |
import javax.swing.DefaultComboBoxModel; |
17 |
import javax.swing.JButton; |
18 |
|
19 |
import javax.swing.AbstractAction; |
20 |
import javax.swing.WindowConstants; |
21 |
import javax.swing.border.LineBorder; |
22 |
import javax.swing.ImageIcon; |
23 |
import javax.swing.JFrame; |
24 |
import javax.swing.JLabel; |
25 |
import javax.swing.JList; |
26 |
import javax.swing.JPanel; |
27 |
import javax.swing.JScrollPane; |
28 |
import javax.swing.JTextField; |
29 |
import javax.swing.ListModel; |
30 |
import javax.swing.SwingConstants; |
31 |
import javax.swing.SwingUtilities; |
32 |
import javax.swing.event.DocumentEvent; |
33 |
import javax.swing.event.DocumentListener; |
34 |
import javax.swing.event.ListDataEvent; |
35 |
import javax.swing.event.ListDataListener; |
36 |
import javax.swing.event.ListSelectionEvent; |
37 |
import javax.swing.event.ListSelectionListener; |
38 |
|
39 |
import es.logex.gvsig.streetsmap.query.QueryResultData; |
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
/**
|
46 |
* This code was edited or generated using CloudGarden's Jigloo
|
47 |
* SWT/Swing GUI Builder, which is free for non-commercial
|
48 |
* use. If Jigloo is being used commercially (ie, by a corporation,
|
49 |
* company or business for any purpose whatever) then you
|
50 |
* should purchase a license for each developer using Jigloo.
|
51 |
* Please visit www.cloudgarden.com for details.
|
52 |
* Use of Jigloo implies acceptance of these licensing terms.
|
53 |
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
|
54 |
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
|
55 |
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
|
56 |
*/
|
57 |
/**
|
58 |
*
|
59 |
*/
|
60 |
public class PanelQuerysBuilder extends JPanel { |
61 |
|
62 |
/**
|
63 |
*
|
64 |
*/
|
65 |
private static final long serialVersionUID = -7321705961922465828L; |
66 |
|
67 |
|
68 |
private AbstractAction actionZoomToExtent; |
69 |
private JPanel jPanel2; |
70 |
private JLabel lblIconSearch; |
71 |
private JPanel panelHeader; |
72 |
private JLabel lblBuscar; |
73 |
|
74 |
private AbstractAction actionSearch; |
75 |
private PanelQuerysActionsDelegate panelQuerysClient = null; |
76 |
|
77 |
|
78 |
private JList listResultsQuery; |
79 |
private JButton btnZoomToSelected; |
80 |
private JPanel PanelItemsQuery; |
81 |
private JTextField txtMunicipio; |
82 |
private JTextField txtCalleVia; |
83 |
private JTextField txtNumeroPol; |
84 |
private JLabel lblNumero; |
85 |
private JLabel lblCalleVia; |
86 |
private JLabel Municipio; |
87 |
private JButton btnSearch; |
88 |
private JPanel PanelBotonesQuerysBuilder; |
89 |
private JScrollPane jScrollPane1; |
90 |
|
91 |
/**
|
92 |
* Con propositos de Test
|
93 |
* JPanel inside a new JFrame.
|
94 |
*/
|
95 |
public static void main(String[] args) { |
96 |
JFrame frame = new JFrame(); |
97 |
//frame.getContentPane().add(new NewJPanel());
|
98 |
// Construir un juego de prueba
|
99 |
frame.getContentPane().add(new PanelQuerysBuilder(
|
100 |
new PanelQuerysActionsDelegate()
|
101 |
{ |
102 |
|
103 |
public void DoExtent(QueryResultData newExtent) { |
104 |
System.out.println("DoExtent:" + newExtent.getCaption()+"/"+newExtent.getUserData().toString()); |
105 |
} |
106 |
|
107 |
public List<QueryResultData> DoSearch(String municipio, String calle, String numpolicia) { |
108 |
System.out.println("QueryData:"+municipio+","+calle+","+numpolicia); |
109 |
List<QueryResultData> simulatedResults = new ArrayList<QueryResultData>(); |
110 |
for(int i=0; i<15; i++) |
111 |
{ |
112 |
|
113 |
simulatedResults.add(new QueryResultData()
|
114 |
{ |
115 |
|
116 |
public String getCaption() { |
117 |
return "Valor resultado de la busqueda"; |
118 |
} |
119 |
|
120 |
public Object getUserData() { |
121 |
return "10,10;20,30"; |
122 |
} |
123 |
|
124 |
}); |
125 |
|
126 |
} |
127 |
return simulatedResults;
|
128 |
} |
129 |
|
130 |
} |
131 |
)); |
132 |
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
133 |
frame.pack(); |
134 |
frame.setVisible(true);
|
135 |
} |
136 |
|
137 |
public PanelQuerysBuilder() {
|
138 |
super();
|
139 |
initGUI(); |
140 |
} |
141 |
|
142 |
public PanelQuerysBuilder(PanelQuerysActionsDelegate queryClient) {
|
143 |
this();
|
144 |
panelQuerysClient = queryClient; |
145 |
//SwingUtilities.getWindowAncestor(this).pack();
|
146 |
} |
147 |
|
148 |
private void initGUI() { |
149 |
try {
|
150 |
GridBagLayout thisLayout = new GridBagLayout(); |
151 |
setPreferredSize(new Dimension(400, 300)); |
152 |
thisLayout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.4, 0.0, 0.6, 0.0, 0.1}; |
153 |
thisLayout.rowHeights = new int[] {7, 45, 7, 7, 7, 7, 7, 7}; |
154 |
thisLayout.columnWeights = new double[] {0.0, 0.1, 0.0}; |
155 |
thisLayout.columnWidths = new int[] {7, 7, 7}; |
156 |
this.setLayout(thisLayout);
|
157 |
this.setAutoscrolls(true); |
158 |
this.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false)); |
159 |
{ |
160 |
jScrollPane1 = new JScrollPane(); |
161 |
this.add(jScrollPane1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); |
162 |
jScrollPane1.setPreferredSize(new java.awt.Dimension(380, 194)); |
163 |
jScrollPane1.getVerticalScrollBar().setVisibleAmount(100);
|
164 |
jScrollPane1.getVerticalScrollBar().setVisible(false);
|
165 |
jScrollPane1.getHorizontalScrollBar().setEnabled(true);
|
166 |
{ |
167 |
ListModel jList1Model =
|
168 |
new DefaultComboBoxModel( |
169 |
new String[] { "Item One", "Item Two" }); |
170 |
jList1Model.addListDataListener(new ListDataListener() |
171 |
{ |
172 |
|
173 |
public void contentsChanged(ListDataEvent e) { |
174 |
// TODO Auto-generated method stub
|
175 |
|
176 |
} |
177 |
|
178 |
public void intervalAdded(ListDataEvent e) { |
179 |
if(listResultsQuery.getModel().getSize()>0) |
180 |
{ |
181 |
listResultsQuery.setEnabled(true);
|
182 |
} |
183 |
else
|
184 |
|
185 |
{ |
186 |
listResultsQuery.setEnabled(false);
|
187 |
|
188 |
} |
189 |
|
190 |
} |
191 |
|
192 |
public void intervalRemoved(ListDataEvent e) { |
193 |
if(listResultsQuery.getModel().getSize()>0) |
194 |
{ |
195 |
listResultsQuery.setEnabled(true);
|
196 |
} |
197 |
else
|
198 |
|
199 |
{ |
200 |
listResultsQuery.setEnabled(false);
|
201 |
|
202 |
} |
203 |
|
204 |
} |
205 |
|
206 |
}); |
207 |
listResultsQuery = new JList(); |
208 |
jScrollPane1.setViewportView(listResultsQuery); |
209 |
//jScrollPane1.add(listResultsQuery);
|
210 |
listResultsQuery.setModel(jList1Model); |
211 |
listResultsQuery.setPreferredSize(new java.awt.Dimension(383, 441)); |
212 |
listResultsQuery.setAutoscrolls(true);
|
213 |
listResultsQuery.setVisibleRowCount(10);
|
214 |
listResultsQuery.setEnabled(false);
|
215 |
listResultsQuery.addMouseListener(new MouseAdapter() { |
216 |
public void mouseClicked(MouseEvent evt) { |
217 |
if(evt.getClickCount() == 2 && evt.getButton() == 1) |
218 |
{ |
219 |
if(actionZoomToExtent.isEnabled())
|
220 |
{ |
221 |
actionZoomToExtent.actionPerformed(new ActionEvent(this, 0, "double click on results")); |
222 |
} |
223 |
} |
224 |
} |
225 |
}); |
226 |
listResultsQuery.addListSelectionListener(new ListSelectionListener() { |
227 |
public void valueChanged( |
228 |
ListSelectionEvent evt) {
|
229 |
if (listResultsQuery.getSelectedValue() != null) { |
230 |
actionZoomToExtent.setEnabled(true);
|
231 |
|
232 |
} else {
|
233 |
actionZoomToExtent.setEnabled(false);
|
234 |
} |
235 |
|
236 |
} |
237 |
}); |
238 |
} |
239 |
} |
240 |
{ |
241 |
PanelBotonesQuerysBuilder = new JPanel(); |
242 |
this.add(PanelBotonesQuerysBuilder, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); |
243 |
GridBagLayout PanelBotonesQuerysBuilderLayout = new GridBagLayout(); |
244 |
PanelBotonesQuerysBuilderLayout.columnWidths = new int[] {215, 87, 7, 7}; |
245 |
PanelBotonesQuerysBuilderLayout.rowHeights = new int[] {7}; |
246 |
PanelBotonesQuerysBuilderLayout.columnWeights = new double[] {10.0, 0.0, 0.1, 0.1}; |
247 |
PanelBotonesQuerysBuilderLayout.rowWeights = new double[] {0.1}; |
248 |
PanelBotonesQuerysBuilder.setLayout(PanelBotonesQuerysBuilderLayout); |
249 |
{ |
250 |
btnSearch = new JButton(); |
251 |
PanelBotonesQuerysBuilder.add(btnSearch, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0)); |
252 |
btnSearch.setText("Buscar");
|
253 |
btnSearch.setAction(getActionSearch()); |
254 |
} |
255 |
{ |
256 |
btnZoomToSelected = new JButton(); |
257 |
PanelBotonesQuerysBuilder.add(btnZoomToSelected, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0)); |
258 |
btnZoomToSelected.setText("Encuadrar");
|
259 |
btnZoomToSelected.setAction(getActionZoomToExtent()); |
260 |
btnZoomToSelected.setToolTipText("Pulsa aqui para activar el mapa");
|
261 |
} |
262 |
} |
263 |
{ |
264 |
PanelItemsQuery = new JPanel(); |
265 |
this.add(PanelItemsQuery, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); |
266 |
this.add(getPanelHeader(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); |
267 |
GridBagLayout PanelItemsQueryLayout = new GridBagLayout(); |
268 |
PanelItemsQueryLayout.columnWidths = new int[] {7, 7, 20, 7, 7}; |
269 |
PanelItemsQueryLayout.rowHeights = new int[] {7, 7, 7, 7}; |
270 |
PanelItemsQueryLayout.columnWeights = new double[] {0.1, 2.0, 0.1, 0.1, 0.0}; |
271 |
PanelItemsQueryLayout.rowWeights = new double[] {0.5, 0.0, 0.5, 0.0}; |
272 |
PanelItemsQuery.setPreferredSize(new java.awt.Dimension(400,38)); |
273 |
PanelItemsQuery.setLayout(PanelItemsQueryLayout); |
274 |
PanelItemsQuery.setSize(400, 32); |
275 |
{ |
276 |
Municipio = new JLabel(); |
277 |
PanelItemsQuery.add(Municipio, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
278 |
Municipio.setText("Municipio");
|
279 |
} |
280 |
{ |
281 |
lblCalleVia = new JLabel(); |
282 |
PanelItemsQuery.add(lblCalleVia, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); |
283 |
lblCalleVia.setText("Calle o Via");
|
284 |
} |
285 |
{ |
286 |
lblNumero = new JLabel(); |
287 |
PanelItemsQuery.add(lblNumero, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
288 |
lblNumero.setText("Nº");
|
289 |
} |
290 |
{ |
291 |
txtNumeroPol = new JTextField(); |
292 |
PanelItemsQuery.add(txtNumeroPol, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); |
293 |
txtNumeroPol.setToolTipText("Introduce el numero de patio a localizar");
|
294 |
} |
295 |
{ |
296 |
txtCalleVia = new JTextField(); |
297 |
txtCalleVia.getDocument().addDocumentListener(new SyncButtonsQueryDocumentListener());
|
298 |
PanelItemsQuery.add(txtCalleVia, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); |
299 |
txtCalleVia.setToolTipText("Introduce el nombre de la calle o via a buscar");
|
300 |
} |
301 |
{ |
302 |
txtMunicipio = new JTextField(); |
303 |
txtMunicipio.getDocument().addDocumentListener(new SyncButtonsQueryDocumentListener());
|
304 |
PanelItemsQuery.add(txtMunicipio, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); |
305 |
txtMunicipio.setToolTipText("Introduce el nombre del municipio a buscar");
|
306 |
} |
307 |
PanelItemsQuery.setFocusCycleRoot(true);
|
308 |
PanelItemsQuery.setFocusTraversalPolicy(new FocusTraversalPolicy() |
309 |
{ |
310 |
|
311 |
@Override
|
312 |
public Component getComponentAfter( |
313 |
Container container, Component component) { |
314 |
if(component == txtMunicipio)
|
315 |
{ |
316 |
return txtCalleVia;
|
317 |
} |
318 |
if(component == txtCalleVia)
|
319 |
{ |
320 |
return txtNumeroPol;
|
321 |
} |
322 |
if(component == txtNumeroPol)
|
323 |
{ |
324 |
return txtMunicipio;
|
325 |
} |
326 |
return component;
|
327 |
} |
328 |
|
329 |
@Override
|
330 |
public Component getComponentBefore( |
331 |
Container container, Component component) { |
332 |
if(component == txtMunicipio)
|
333 |
{ |
334 |
return txtNumeroPol;
|
335 |
} |
336 |
if(component == txtCalleVia)
|
337 |
{ |
338 |
return txtMunicipio;
|
339 |
} |
340 |
if(component == txtNumeroPol)
|
341 |
{ |
342 |
return txtCalleVia;
|
343 |
} |
344 |
return component;
|
345 |
} |
346 |
|
347 |
@Override
|
348 |
public Component getDefaultComponent( |
349 |
Container container) {
|
350 |
return txtMunicipio;
|
351 |
} |
352 |
|
353 |
@Override
|
354 |
public Component getFirstComponent( |
355 |
Container container) {
|
356 |
return txtMunicipio;
|
357 |
} |
358 |
|
359 |
@Override
|
360 |
public Component getLastComponent( |
361 |
Container container) {
|
362 |
return txtNumeroPol;
|
363 |
} |
364 |
|
365 |
} |
366 |
); |
367 |
|
368 |
} |
369 |
((DefaultComboBoxModel)listResultsQuery.getModel()).removeAllElements();
|
370 |
} catch (Exception e) { |
371 |
e.printStackTrace(); |
372 |
} |
373 |
} |
374 |
|
375 |
private String DoSearch() { |
376 |
// Protegerse de la reentrancia, por su pulsan el boton de nuevo
|
377 |
// Mientras hay una peticion en curso
|
378 |
this.actionSearch.setEnabled(false); |
379 |
try
|
380 |
{ |
381 |
List<QueryResultData> queryResults = panelQuerysClient.DoSearch(
|
382 |
txtMunicipio.getText(), txtCalleVia.getText(), txtNumeroPol |
383 |
.getText()); |
384 |
DefaultComboBoxModel listModel = (DefaultComboBoxModel) listResultsQuery |
385 |
.getModel(); |
386 |
listModel.removeAllElements(); |
387 |
for (QueryResultData query : queryResults) {
|
388 |
|
389 |
listModel.addElement(new ResultsItem(query));
|
390 |
|
391 |
} |
392 |
return "Search Done"; |
393 |
} |
394 |
finally
|
395 |
{ |
396 |
this.actionSearch.setEnabled(true); |
397 |
} |
398 |
} |
399 |
/**
|
400 |
* @return the actionSearch
|
401 |
* @uml.property name="actionSearch"
|
402 |
*/
|
403 |
private AbstractAction getActionSearch() { |
404 |
if (actionSearch == null) { |
405 |
actionSearch = new AbstractAction("Buscar", null) { |
406 |
|
407 |
private static final long serialVersionUID = 0L; |
408 |
|
409 |
public void actionPerformed(ActionEvent evt) { |
410 |
if (panelQuerysClient != null) { |
411 |
SwingWorker worker = new SwingWorker()
|
412 |
{ |
413 |
public Object construct() |
414 |
{ |
415 |
return DoSearch();
|
416 |
} |
417 |
}; |
418 |
worker.start(); |
419 |
} |
420 |
} |
421 |
}; |
422 |
|
423 |
actionSearch.setEnabled(false);
|
424 |
} |
425 |
return actionSearch;
|
426 |
} |
427 |
|
428 |
private Object DoZoomToExtent() { |
429 |
this.actionZoomToExtent.setEnabled(false); |
430 |
this.listResultsQuery.setEnabled(false); |
431 |
this.actionSearch.setEnabled(false); |
432 |
try
|
433 |
{ |
434 |
ListModel listModel = listResultsQuery.getModel();
|
435 |
ResultsItem resItem = (ResultsItem) listModel.getElementAt(listResultsQuery.getSelectedIndex()); |
436 |
panelQuerysClient.DoExtent(resItem.resultsData); |
437 |
return "Zoom Done"; |
438 |
} |
439 |
finally
|
440 |
{ |
441 |
this.actionZoomToExtent.setEnabled(true); |
442 |
this.actionSearch.setEnabled(calcQueryTextLength()>0); |
443 |
this.listResultsQuery.setEnabled(listResultsQuery.getModel().getSize() > 0); |
444 |
} |
445 |
} |
446 |
/**
|
447 |
* @return the actionZoomToExtent
|
448 |
* @uml.property name="actionZoomToExtent"
|
449 |
*/
|
450 |
private AbstractAction getActionZoomToExtent() { |
451 |
if (actionZoomToExtent == null) { |
452 |
actionZoomToExtent = new AbstractAction("Encuadrar", null) { |
453 |
|
454 |
/**
|
455 |
*
|
456 |
*/
|
457 |
private static final long serialVersionUID = -6096784899381443861L; |
458 |
|
459 |
/* (non-Javadoc)
|
460 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
461 |
*/
|
462 |
public void actionPerformed(ActionEvent e) { |
463 |
if (panelQuerysClient != null) { |
464 |
if (panelQuerysClient != null) { |
465 |
SwingWorker worker = new SwingWorker()
|
466 |
{ |
467 |
public Object construct() |
468 |
{ |
469 |
return DoZoomToExtent();
|
470 |
} |
471 |
}; |
472 |
worker.start(); |
473 |
} |
474 |
} |
475 |
|
476 |
|
477 |
} |
478 |
}; |
479 |
actionZoomToExtent.setEnabled(false);
|
480 |
} |
481 |
|
482 |
return actionZoomToExtent;
|
483 |
} |
484 |
|
485 |
/**
|
486 |
* @return
|
487 |
*/
|
488 |
private JLabel getLblBuscar() { |
489 |
if(lblBuscar == null) { |
490 |
lblBuscar = new JLabel(); |
491 |
lblBuscar.setIcon(new ImageIcon(getClass().getClassLoader().getResource("es/logex/gvsig/streetsmap/ui/callejero50.gif"))); |
492 |
lblBuscar.setText("Callejeros WPS - Busqueda");
|
493 |
lblBuscar.setFont(new java.awt.Font("Dialog",1,16)); |
494 |
lblBuscar.setBackground(new java.awt.Color(255,165,0)); |
495 |
lblBuscar.setHorizontalAlignment(SwingConstants.LEFT);
|
496 |
lblBuscar.setOpaque(false);
|
497 |
lblBuscar.setPreferredSize(new java.awt.Dimension(294, 43)); |
498 |
|
499 |
} |
500 |
return lblBuscar;
|
501 |
} |
502 |
|
503 |
private JPanel getPanelHeader() { |
504 |
if(panelHeader == null) { |
505 |
panelHeader = new JPanel(); |
506 |
GridBagLayout jPanel1Layout = new GridBagLayout(); |
507 |
jPanel1Layout.rowWeights = new double[] {0.1}; |
508 |
jPanel1Layout.rowHeights = new int[] {7}; |
509 |
jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; |
510 |
jPanel1Layout.columnWidths = new int[] {7, 20}; |
511 |
panelHeader.setLayout(jPanel1Layout); |
512 |
panelHeader.setName("PanelHeader");
|
513 |
panelHeader.add(getJPanel2(), new GridBagConstraints(-1, -2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
514 |
panelHeader.add(getLblIconSearch(), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); |
515 |
} |
516 |
return panelHeader;
|
517 |
} |
518 |
|
519 |
private int calcQueryTextLength() { |
520 |
int curDocLen;
|
521 |
curDocLen = txtCalleVia.getText().length() |
522 |
+ txtMunicipio.getText().length(); |
523 |
return curDocLen;
|
524 |
} |
525 |
|
526 |
private JLabel getLblIconSearch() { |
527 |
if(lblIconSearch == null) { |
528 |
lblIconSearch = new JLabel(); |
529 |
|
530 |
lblIconSearch.setIcon(new ImageIcon(getClass().getClassLoader().getResource("es/logex/gvsig/streetsmap/ui/search.gif"))); |
531 |
|
532 |
} |
533 |
return lblIconSearch;
|
534 |
} |
535 |
|
536 |
private JPanel getJPanel2() { |
537 |
if(jPanel2 == null) { |
538 |
jPanel2 = new JPanel(); |
539 |
jPanel2.add(getLblBuscar()); |
540 |
} |
541 |
return jPanel2;
|
542 |
} |
543 |
|
544 |
class SyncButtonsQueryDocumentListener implements DocumentListener { |
545 |
|
546 |
public void changedUpdate(DocumentEvent e) { |
547 |
// Do nothing
|
548 |
|
549 |
} |
550 |
|
551 |
public void insertUpdate(DocumentEvent e) { |
552 |
syncButtonQueryEnabled(e, e.getLength()); |
553 |
|
554 |
} |
555 |
|
556 |
public void removeUpdate(DocumentEvent e) { |
557 |
syncButtonQueryEnabled(e, e.getLength() * -1);
|
558 |
|
559 |
} |
560 |
|
561 |
private void syncButtonQueryEnabled(DocumentEvent e, int lenAltered) { |
562 |
int curDocLen = 0; |
563 |
curDocLen = calcQueryTextLength(); |
564 |
if (curDocLen > 0) { |
565 |
actionSearch.setEnabled(true);
|
566 |
} else {
|
567 |
actionSearch.setEnabled(false);
|
568 |
} |
569 |
|
570 |
} |
571 |
|
572 |
} |
573 |
|
574 |
/*
|
575 |
*
|
576 |
*/
|
577 |
/**
|
578 |
* @author jcelda
|
579 |
*/
|
580 |
class ResultsItem { |
581 |
private QueryResultData resultsData = null; |
582 |
|
583 |
public ResultsItem(QueryResultData queryResultsData) {
|
584 |
resultsData = queryResultsData; |
585 |
} |
586 |
|
587 |
public QueryResultData getValue() {
|
588 |
return resultsData;
|
589 |
} |
590 |
|
591 |
public String toString() { |
592 |
if (resultsData != null) { |
593 |
return resultsData.getCaption();
|
594 |
} else {
|
595 |
return super.toString(); |
596 |
} |
597 |
} |
598 |
} |
599 |
|
600 |
} |