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