Revision 17593 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/WFSParamsPanel.java
WFSParamsPanel.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.gui.panels; |
2 | 2 |
|
3 |
import java.awt.geom.Rectangle2D;
|
|
3 |
import java.awt.Dimension;
|
|
4 | 4 |
import java.util.Map; |
5 |
import java.util.prefs.Preferences; |
|
6 | 5 |
|
7 |
import javax.swing.JOptionPane; |
|
8 | 6 |
import javax.swing.JTabbedPane; |
9 |
import javax.swing.event.ChangeEvent; |
|
10 |
import javax.swing.event.ChangeListener; |
|
11 | 7 |
|
12 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
|
8 |
import org.gvsig.gui.beans.panelGroup.PanelGroupManager; |
|
9 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
|
13 | 10 |
|
14 |
import com.iver.andami.PluginServices;
|
|
11 |
import com.iver.andami.messages.NotificationManager;
|
|
15 | 12 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
16 | 13 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
17 |
import com.iver.cit.gvsig.fmap.layers.FLyrWFS; |
|
18 | 14 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
19 | 15 |
import com.iver.cit.gvsig.gui.WizardPanel; |
20 |
import com.iver.cit.gvsig.gui.dialogs.WFSPropsDialog; |
|
21 | 16 |
import com.iver.cit.gvsig.gui.wizards.WFSWizard; |
22 | 17 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
23 | 18 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
... | ... | |
207 | 202 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
208 | 203 |
*/ |
209 | 204 |
public class WFSParamsPanel extends WizardPanel{ |
210 |
private JTabbedPane jTabbedPane = null; // @jve:decl-index=0:visual-constraint="37,30" |
|
211 |
private WFSSelectFeaturePanel featurePanel = null; |
|
212 |
private WFSSelectFieldsPanel fieldsPanel = null; |
|
213 |
private WFSOptionsPanel optionsPanel = null; |
|
214 |
private WFSFormatPanel formatPanel = null; |
|
215 |
private WFSFilterPanel filterPanel = null; |
|
216 |
private WFSAreaPanel areaPanel = null; |
|
217 |
private WFSWizardData data; |
|
205 |
private TabbedPanel jTabbedPane = null; |
|
218 | 206 |
private WizardListenerSupport listenerSupport; |
219 |
public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
|
220 |
private WFSInfoPanel infoPanel; |
|
221 |
private int indFields; |
|
222 |
private int indFilter; |
|
223 |
private int indArea; |
|
224 |
|
|
207 |
private WFSParamsPanelData data = null; |
|
208 |
//Tab positions |
|
209 |
private int infoTabPosition = 0; |
|
210 |
private int featureTabPosition = 1; |
|
211 |
private int fieldsTabPosition = 2; |
|
212 |
private int optionsPosition = 3; |
|
213 |
private int filterTabPosition = 4; |
|
214 |
private int areaTabPosition = 5; |
|
215 |
|
|
225 | 216 |
/** |
226 | 217 |
* This method initializes jTabbedPane |
227 | 218 |
* |
... | ... | |
232 | 223 |
super(); |
233 | 224 |
initialize(); |
234 | 225 |
} |
226 |
|
|
235 | 227 |
/** |
228 |
* Initilaize the Panel |
|
229 |
*/ |
|
230 |
private void initialize() { |
|
231 |
this.data = new WFSParamsPanelData(this); |
|
232 |
this.setLayout(null); |
|
233 |
this.setVisible(false); |
|
234 |
this.setPreferredSize(new Dimension(510, 427)); |
|
235 |
this.add(getJTabbedPane(), null); |
|
236 |
setListenerSupport(new WizardListenerSupport()); |
|
237 |
} |
|
238 |
|
|
239 |
/** |
|
236 | 240 |
* Returns the tab amount that the WFSParamsPanel currently have |
237 | 241 |
* |
238 | 242 |
* Devuelve el n?mero de solapas que tiene actualmente el WFSParamsPanel |
... | ... | |
240 | 244 |
* @return int |
241 | 245 |
*/ |
242 | 246 |
public int getNumTabs(){ |
243 |
return getJTabbedPane().getTabCount();
|
|
247 |
return getJTabbedPane().getPanelInGUICount();
|
|
244 | 248 |
} |
245 | 249 |
|
246 |
private void initialize() { |
|
247 |
this.setLayout(null); |
|
248 |
this.setVisible(false); |
|
249 |
this.setBounds(0, 0, 510, 427); |
|
250 |
this.add(getJTabbedPane(), null); |
|
251 |
} |
|
252 |
|
|
253 | 250 |
/** |
254 | 251 |
* Sets the focus to the tab next to the current one. |
255 | 252 |
* |
... | ... | |
257 | 254 |
* |
258 | 255 |
*/ |
259 | 256 |
public void avanzaTab(){ |
260 |
int currentPage = currentPage();
|
|
261 |
int nPages = getNumTabs();
|
|
257 |
int currentPage = currentPage();
|
|
258 |
int nPages = getNumTabs();
|
|
262 | 259 |
if (nPages -1 > currentPage){ |
263 | 260 |
getJTabbedPane().setSelectedIndex(nextPageEnabled()); |
264 |
} |
|
261 |
}
|
|
265 | 262 |
} |
266 | 263 |
|
267 | 264 |
/** |
... | ... | |
280 | 277 |
public int getSelectedIndex(){ |
281 | 278 |
return this.getJTabbedPane().getSelectedIndex(); |
282 | 279 |
} |
283 |
|
|
280 |
|
|
284 | 281 |
/** |
285 | 282 |
* @see JTabbedPane#setSelectedIndex(int) |
286 | 283 |
*/ |
... | ... | |
288 | 285 |
this.getJTabbedPane().setSelectedIndex(index); |
289 | 286 |
} |
290 | 287 |
|
291 |
public JTabbedPane getJTabbedPane() {
|
|
288 |
public TabbedPanel getJTabbedPane() {
|
|
292 | 289 |
if (jTabbedPane == null) { |
293 |
jTabbedPane = new JTabbedPane(); |
|
294 |
jTabbedPane.setBounds(4, 4, 502, 415); |
|
295 |
jTabbedPane.addTab(PluginServices.getText(this, "info"), null, getInfoPanel()); |
|
296 |
jTabbedPane.addTab(PluginServices.getText(this, "feature"), null, getFeaturesPanel(), null); |
|
297 |
jTabbedPane.addTab(PluginServices.getText(this, "fields_uppercase_first"),null, getFieldsPanel(), null); |
|
298 |
indFields = jTabbedPane.getTabCount() - 1; |
|
299 |
jTabbedPane.setEnabledAt(indFields, false); |
|
300 |
//jTabbedPane.addTab(PluginServices.getText(this,"formatos"),null,getFormatPanel(),null); |
|
301 |
// indFormat = jTabbedPane.getTabCount() - 1; |
|
302 |
// jTabbedPane.setEnabledAt(indFormat, false); |
|
303 |
jTabbedPane.addTab(PluginServices.getText(this, "options"),null, getOptionsPanel(), null); |
|
304 |
jTabbedPane.addTab(PluginServices.getText(this, "filter"),null, getFilterPanel(), null); |
|
305 |
indFilter = jTabbedPane.getTabCount() - 1; |
|
306 |
jTabbedPane.setEnabledAt(indFilter, false); |
|
307 |
jTabbedPane.addTab(PluginServices.getText(this, "area"),null, getAreaPanel(), null); |
|
308 |
indArea = jTabbedPane.getTabCount() - 1; |
|
309 |
jTabbedPane.setEnabledAt(indArea, false); |
|
310 |
jTabbedPane.addChangeListener(new ChangeListener() { |
|
311 |
// This method is called whenever the selected tab changes |
|
312 |
public void stateChanged(ChangeEvent evt) { |
|
313 |
JTabbedPane pane = (JTabbedPane)evt.getSource(); |
|
314 |
// Get current tab |
|
315 |
int sel = pane.getSelectedIndex(); |
|
316 |
if (sel == 0){ |
|
317 |
refreshInfo(); |
|
318 |
} |
|
319 |
} |
|
320 |
}); |
|
290 |
try{ |
|
291 |
PanelGroupManager manager = PanelGroupManager.getManager(); |
|
292 |
manager.registerPanelGroup(TabbedPanel.class); |
|
293 |
manager.setDefaultType(TabbedPanel.class); |
|
294 |
jTabbedPane = (TabbedPanel) manager.getPanelGroup(null); |
|
295 |
jTabbedPane.addPanel(getInfoPanel()); |
|
296 |
jTabbedPane.addPanel(getFeaturesPanel()); |
|
297 |
jTabbedPane.addPanel(getFieldsPanel()); |
|
298 |
jTabbedPane.addPanel(getOptionsPanel()); |
|
299 |
jTabbedPane.addPanel(getFilterPanel()); |
|
300 |
jTabbedPane.addPanel(getAreaPanel()); |
|
301 |
jTabbedPane.setBounds(4, 4, 502, 415); |
|
302 |
}catch (Exception e){ |
|
303 |
e.printStackTrace(); |
|
304 |
NotificationManager.addError(e); |
|
305 |
} |
|
321 | 306 |
} |
322 | 307 |
return jTabbedPane; |
323 | 308 |
} |
324 | 309 |
|
325 |
private WFSInfoPanel getInfoPanel() { |
|
326 |
if (infoPanel==null) { |
|
327 |
infoPanel = new WFSInfoPanel(); |
|
328 |
} |
|
329 |
return infoPanel; |
|
330 |
} |
|
331 |
|
|
332 | 310 |
/** |
333 |
* |
|
334 |
* @return the selected list |
|
311 |
* @return the information panel |
|
335 | 312 |
*/ |
336 |
private Object getSelectedFeature() {
|
|
337 |
return featurePanel.getSelectedFeature();
|
|
313 |
private WFSInfoPanel getInfoPanel() {
|
|
314 |
return data.getInfoPanel();
|
|
338 | 315 |
} |
339 |
|
|
340 |
|
|
316 |
|
|
341 | 317 |
/** |
342 | 318 |
* This method initializes panelFeatures |
343 | 319 |
* |
344 | 320 |
* @return javax.swing.JPanel |
345 | 321 |
*/ |
346 | 322 |
private WFSSelectFeaturePanel getFeaturesPanel() { |
347 |
if (featurePanel == null) { |
|
348 |
featurePanel = new WFSSelectFeaturePanel(this); |
|
349 |
featurePanel.setLayout(null); |
|
350 |
} |
|
351 |
return featurePanel; |
|
323 |
return data.getFeaturePanel(); |
|
352 | 324 |
} |
353 | 325 |
|
354 | 326 |
/** |
... | ... | |
357 | 329 |
* @return javax.swing.JPanel |
358 | 330 |
*/ |
359 | 331 |
private WFSSelectFieldsPanel getFieldsPanel(){ |
360 |
if (fieldsPanel == null) { |
|
361 |
fieldsPanel = new WFSSelectFieldsPanel(this); |
|
362 |
fieldsPanel.setLayout(null); |
|
363 |
} |
|
364 |
return fieldsPanel; |
|
332 |
return data.getFieldsPanel(); |
|
365 | 333 |
} |
366 |
|
|
367 |
|
|
368 |
|
|
334 |
|
|
369 | 335 |
/** |
370 | 336 |
* This method initializes fieldsPanel |
371 | 337 |
* |
372 | 338 |
* @return javax.swing.JPanel |
373 | 339 |
*/ |
374 | 340 |
private WFSOptionsPanel getOptionsPanel(){ |
375 |
if (optionsPanel == null) { |
|
376 |
optionsPanel = new WFSOptionsPanel(this); |
|
377 |
optionsPanel.setLayout(null); |
|
378 |
} |
|
379 |
return optionsPanel; |
|
341 |
return data.getOptionsPanel(); |
|
380 | 342 |
} |
381 | 343 |
|
382 |
|
|
344 |
|
|
383 | 345 |
/** |
384 | 346 |
* This method initializes filterPanel |
385 | 347 |
* |
386 | 348 |
* @return javax.swing.JPanel |
387 | 349 |
*/ |
388 | 350 |
private WFSFilterPanel getFilterPanel(){ |
389 |
if (filterPanel == null) { |
|
390 |
filterPanel = new WFSFilterPanel(this); |
|
391 |
filterPanel.setVisible(true); |
|
392 |
//filterPanel.setLayout(null); |
|
393 |
} |
|
394 |
return filterPanel; |
|
351 |
return data.getFilterPanel(); |
|
395 | 352 |
} |
396 |
|
|
353 |
|
|
397 | 354 |
/** |
398 | 355 |
* This method initializes areaPanel |
399 | 356 |
* |
400 | 357 |
* @return javax.swing.JPanel |
401 | 358 |
*/ |
402 | 359 |
private WFSAreaPanel getAreaPanel(){ |
403 |
if (areaPanel == null) { |
|
404 |
areaPanel = new WFSAreaPanel(this); |
|
405 |
areaPanel.setVisible(true); |
|
406 |
} |
|
407 |
return areaPanel; |
|
360 |
return data.getAreaPanel(); |
|
408 | 361 |
} |
409 | 362 |
|
410 | 363 |
/** |
411 |
* This method initializes formatPanel |
|
412 |
* |
|
413 |
* @return javax.swing.JPanel |
|
414 |
*/ |
|
415 |
private WFSFormatPanel getFormatPanel(){ |
|
416 |
if (formatPanel == null) { |
|
417 |
formatPanel = new WFSFormatPanel(); |
|
418 |
formatPanel.setLayout(null); |
|
419 |
} |
|
420 |
return formatPanel; |
|
421 |
} |
|
422 |
|
|
423 |
/** |
|
424 | 364 |
* Verifies that the selected parameters are enough to request the coverage |
425 | 365 |
* to the server. |
426 |
* |
|
427 |
* Comprueba que los par?metros seleccionados son suficientes para pedir la |
|
428 |
* cobertura al servidor. |
|
429 |
* |
|
430 | 366 |
* @return boolean |
431 | 367 |
*/ |
432 | 368 |
public boolean isCorretlyConfigured() { |
433 |
if ((featurePanel.getSelectedFeature() != null) && (fieldsPanel.getSelectedFields().length > 0)) { |
|
434 |
return true; |
|
435 |
}else{ |
|
436 |
return false; |
|
437 |
} |
|
369 |
return data.isCorretlyConfigured(); |
|
438 | 370 |
} |
439 | 371 |
|
440 | 372 |
/** |
441 |
* Cleans up the wizard's components but the server's layers list. |
|
442 |
* |
|
443 |
* Limpia todos los componentes del wizard excepto la lista de capas del |
|
444 |
* servidor. |
|
373 |
* Enable or disable the default tabs |
|
445 | 374 |
*/ |
446 |
public void cleanupWizard() { |
|
447 |
jTabbedPane.setEnabledAt(indFields,false); |
|
448 |
// jTabbedPane.setEnabledAt(indFormat,false); |
|
375 |
public void enableDefaultTabs(boolean isEnabled) { |
|
376 |
jTabbedPane.setEnabledAt(fieldsTabPosition, isEnabled); |
|
377 |
jTabbedPane.setEnabledAt(filterTabPosition, isEnabled); |
|
378 |
jTabbedPane.setEnabledAt(areaTabPosition, isEnabled); |
|
449 | 379 |
} |
450 | 380 |
|
451 | 381 |
/** |
452 |
* Refreshes the wizard components data each time a feature |
|
453 |
* is selected. |
|
382 |
* Refresh all the panels with the WFS capabilities |
|
383 |
* information |
|
384 |
*/ |
|
385 |
public void refreshCapabilitiesInfo(){ |
|
386 |
data.refreshCapabilitiesInfo(); |
|
387 |
} |
|
388 |
|
|
389 |
/** |
|
390 |
* Sets the object that holds the wizard data. |
|
454 | 391 |
* |
455 |
* Actualiza los datos de los componentes del wizard cada vez |
|
456 |
* que se selecciona una feature diferente. |
|
392 |
* Establece el objeto que contiene los datos del wizard. |
|
457 | 393 |
* |
458 |
* @param feature |
|
459 |
* Selected feature |
|
394 |
* @param data |
|
460 | 395 |
*/ |
461 |
public void refreshData(WFSLayerNode feature){ |
|
462 |
boolean refreshed = false; |
|
396 |
public void setWizardData(WFSWizardData wizardData) { |
|
397 |
this.data.setWizardData(wizardData); |
|
398 |
} |
|
463 | 399 |
|
464 |
if (feature != null){ |
|
465 |
feature = (WFSLayerNode)data.getFeatureInfo(feature.getName(), feature.getNameSpace()); |
|
466 |
|
|
467 |
// If there is no fields -> disable not necessary tabs |
|
468 |
if (feature.getFields().size() == 0) { |
|
469 |
jTabbedPane.setEnabledAt(indFields, false); |
|
470 |
jTabbedPane.setEnabledAt(indFilter, false); |
|
471 |
jTabbedPane.setEnabledAt(indArea, false); |
|
472 |
isApplicable(false); |
|
473 |
|
|
474 |
return; |
|
400 |
/** |
|
401 |
* Returns the next enabled tab's index. |
|
402 |
* |
|
403 |
* Devuelve el ?ndicie de la siguiente pesta?a habilitada del wizard o -1 si no hay |
|
404 |
* ninguna. |
|
405 |
* |
|
406 |
* @return The index or -1 if there is no one. |
|
407 |
*/ |
|
408 |
public int nextPageEnabled() { |
|
409 |
int currentPage = currentPage(); |
|
410 |
int nPages = getNumTabs(); |
|
411 |
if (currentPage == nPages) |
|
412 |
return -1; |
|
413 |
for (int i=currentPage+1; i<nPages; i++){ |
|
414 |
if (getJTabbedPane().isEnabledAt(i)){ |
|
415 |
return i; |
|
475 | 416 |
} |
476 |
|
|
477 |
refreshed = filterPanel.refresh(feature); |
|
478 |
|
|
479 |
if (refreshed) { |
|
480 |
jTabbedPane.setEnabledAt(indFields, true); |
|
481 |
jTabbedPane.setEnabledAt(indFilter, true); |
|
482 |
jTabbedPane.setEnabledAt(indArea, true); |
|
483 |
fieldsPanel.refresh(feature); |
|
484 |
optionsPanel.refresh(feature); |
|
485 |
} |
|
486 |
else { |
|
487 |
featurePanel.unselectAllFeatures(); |
|
488 |
} |
|
489 | 417 |
} |
490 |
|
|
491 |
if (refreshed) |
|
492 |
listenerSupport.callStateChanged(isCorretlyConfigured()); |
|
418 |
return -1; |
|
493 | 419 |
} |
494 | 420 |
|
495 |
public void refreshInfo(){ |
|
496 |
WFSLayerNode selectedNode = featurePanel.getSelectedFeature(); |
|
497 |
if (selectedNode != null){ |
|
498 |
selectedNode.setSelectedFields(fieldsPanel.getSelectedFields()); |
|
499 |
} |
|
500 |
data.setUserName(optionsPanel.getUserName()); |
|
501 |
data.setBuffer(optionsPanel.getBuffer()); |
|
502 |
data.setTimeOut(optionsPanel.getTimeout()); |
|
503 |
infoPanel.refresh(data,selectedNode); |
|
504 |
} |
|
505 |
|
|
506 | 421 |
/** |
507 |
* Sets the object that holds the wizard data.
|
|
422 |
* Returns the index of the current tab.
|
|
508 | 423 |
* |
509 |
* Establece el objeto que contiene los datos del wizard.
|
|
424 |
* Devuelve el ?ndice de la p?gina actual del wizard.
|
|
510 | 425 |
* |
511 |
* @param data
|
|
426 |
* @return
|
|
512 | 427 |
*/ |
513 |
public void setWizardData(WFSWizardData data) { |
|
514 |
this.data = data; |
|
515 |
//WFSLayerNode selectedNode = (WFSLayerNode)featurePanel.getSelectedFeature(); |
|
516 |
featurePanel.setWizardData(data); |
|
517 |
data.setBuffer(optionsPanel.getBuffer()); |
|
518 |
data.setTimeOut(optionsPanel.getTimeout()); |
|
519 |
infoPanel.refresh(data,null); |
|
428 |
public int currentPage() { |
|
429 |
return getJTabbedPane().getSelectedIndex(); |
|
520 | 430 |
} |
521 | 431 |
|
522 | 432 |
/** |
523 |
* Sets the wizard's data source
|
|
433 |
* Returns the index of the previous enabled tab.
|
|
524 | 434 |
* |
525 |
* Establece el origen de los datos del wizard |
|
526 |
* @param dataSource |
|
435 |
* Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay |
|
436 |
* ninguna. |
|
437 |
* |
|
438 |
* @return The index, or -1 if there is no one. |
|
527 | 439 |
*/ |
528 |
public void setDataSource(WFSWizardData dataSource) { |
|
529 |
this.data = dataSource; |
|
530 |
|
|
440 |
public int previousEnabledPage() { |
|
441 |
int currentPage = currentPage(); |
|
442 |
int j=0; |
|
443 |
if (currentPage == 0) |
|
444 |
j= -1; |
|
445 |
for (int i = currentPage-1; i>-1; i--){ |
|
446 |
if (getJTabbedPane().isEnabledAt(i)){ |
|
447 |
j= i; |
|
448 |
break; |
|
449 |
} |
|
450 |
} |
|
451 |
return j; |
|
531 | 452 |
} |
532 | 453 |
|
533 |
|
|
534 |
/** |
|
535 |
* Returns the next enabled tab's index. |
|
536 |
* |
|
537 |
* Devuelve el ?ndicie de la siguiente pesta?a habilitada del wizard o -1 si no hay |
|
538 |
* ninguna. |
|
539 |
* |
|
540 |
* @return The index or -1 if there is no one. |
|
541 |
*/ |
|
542 |
public int nextPageEnabled() { |
|
543 |
int currentPage = currentPage(); |
|
544 |
int nPages = getNumTabs(); |
|
545 |
if (currentPage == nPages) |
|
546 |
return -1; |
|
547 |
for (int i=currentPage+1; i<nPages; i++){ |
|
548 |
if (getJTabbedPane().isEnabledAt(i)){ |
|
549 |
return i; |
|
550 |
} |
|
551 |
} |
|
552 |
return -1; |
|
553 |
} |
|
554 |
|
|
555 |
/** |
|
556 |
* Returns the index of the current tab. |
|
557 |
* |
|
558 |
* Devuelve el ?ndice de la p?gina actual del wizard. |
|
559 |
* |
|
560 |
* @return |
|
561 |
*/ |
|
562 |
public int currentPage() { |
|
563 |
return getJTabbedPane().getSelectedIndex(); |
|
564 |
} |
|
565 |
|
|
566 |
/** |
|
567 |
* Returns the index of the previous enabled tab. |
|
568 |
* |
|
569 |
* Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay |
|
570 |
* ninguna. |
|
571 |
* |
|
572 |
* @return The index, or -1 if there is no one. |
|
573 |
*/ |
|
574 |
public int previousEnabledPage() { |
|
575 |
int currentPage = currentPage(); |
|
576 |
int j=0; |
|
577 |
if (currentPage == 0) |
|
578 |
j= -1; |
|
579 |
for (int i = currentPage-1; i>-1; i--){ |
|
580 |
if (getJTabbedPane().isEnabledAt(i)){ |
|
581 |
j= i; |
|
582 |
break; |
|
583 |
} |
|
584 |
} |
|
585 |
return j; |
|
586 |
} |
|
587 |
|
|
454 |
/** |
|
455 |
* @return the WFS driver used to retrieve the |
|
456 |
* information |
|
457 |
*/ |
|
588 | 458 |
public FMapWFSDriver getDriver() { |
589 | 459 |
return data.getDriver(); |
590 | 460 |
} |
591 | 461 |
|
592 |
public void setListenerSupport(WizardListenerSupport support) { |
|
593 |
listenerSupport = support; |
|
594 |
} |
|
595 |
|
|
596 |
|
|
597 | 462 |
/* |
598 | 463 |
* (non-Javadoc) |
599 | 464 |
* @see com.iver.cit.gvsig.gui.WizardPanel#initWizard() |
... | ... | |
615 | 480 |
* @see com.iver.cit.gvsig.gui.ILayerPanel#getLayer() |
616 | 481 |
*/ |
617 | 482 |
public FLayer getLayer() { |
618 |
FLyrWFS layer = new FLyrWFS(); |
|
619 |
layer.setName(getFeaturesPanel().getLayerText()); |
|
620 |
layer.setLayerName(getFeaturesPanel().getLayerName()); |
|
621 |
layer.setWfsLayerNode(getLayerNode()); |
|
622 |
layer.setFields(getFieldsPanel().getSelectedFields()); |
|
623 |
layer.setUserName(getOptionsPanel().getUserName()); |
|
624 |
layer.setPassword(getOptionsPanel().getPassword()); |
|
625 |
layer.setNumfeatures(getOptionsPanel().getBuffer()); |
|
626 |
layer.setTimeout(getOptionsPanel().getTimeout()); |
|
627 |
layer.setSrs(getOptionsPanel().getSRS()); |
|
628 |
layer.setNameSapce(getFieldsPanel().getNamespace()); |
|
629 |
|
|
630 |
// Sets the area (bounding box) filter |
|
631 |
Rectangle2D bbox = getAreaPanel().getExtent(); |
|
632 |
|
|
633 |
if (getAreaPanel().hasUserDefinedAnArea()) { |
|
634 |
// If user has written some invalid data in the coordinates text fields of the area tab |
|
635 |
if ((bbox == null) && (getAreaPanel().areThereSomeCoordinatesWritten())) { |
|
636 |
// Notify to user that no filter area will be applied |
|
637 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "no_filter_area_will_be_applied_in_the_load_of_the_layer"), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE); |
|
638 |
} |
|
639 |
} |
|
640 |
|
|
641 |
layer.setBbox(bbox); |
|
642 |
String BboxPropertyName = getFieldsPanel().getGeometryFieldName(); |
|
643 |
|
|
644 |
layer.setBboxPropertyName(BboxPropertyName); |
|
645 |
|
|
646 |
// Set the filter subconsultation that layer is |
|
647 |
layer.setFieldsQuery(getLayerNode().getFilter()); |
|
648 |
layer.setVisualFilterQuery(getFilterPanel().getFilterExpressionFromInterface()); |
|
649 |
layer.setWfsDriver(data.getDriver()); |
|
650 |
return layer; |
|
483 |
return data.getLayer(); |
|
651 | 484 |
} |
652 | 485 |
|
653 |
/** |
|
654 |
* Returns true if there is a field of geometry type selected in this layer |
|
655 |
* |
|
656 |
* @return A boolean value |
|
486 |
/* |
|
487 |
* (non-Javadoc) |
|
488 |
* @see com.iver.cit.gvsig.gui.WizardPanel#addWizardListener(com.iver.cit.gvsig.gui.wizards.WizardListener) |
|
657 | 489 |
*/ |
658 |
public boolean isThereAGeometryFieldSelected() { |
|
659 |
return (getFieldsPanel().getSelectedFields().length > 0); |
|
660 |
} |
|
661 |
|
|
662 |
/** |
|
663 |
* |
|
664 |
* @return |
|
665 |
*/ |
|
666 |
private WFSLayerNode getLayerNode(){ |
|
667 |
WFSLayerNode layerNode = getFeaturesPanel().getWFSLayerNode(); |
|
668 |
layerNode.setSelectedFields(getFieldsPanel().getSelectedFields()); |
|
669 |
|
|
670 |
// If the query is incorrect -> no query (no filter) |
|
671 |
String query = getFilterPanel().getQuery(); |
|
672 |
if (query == null) { |
|
673 |
layerNode.setFilter(""); |
|
674 |
|
|
675 |
// Removes filter expression from the JTextArea |
|
676 |
getFilterPanel().removeFilterExpression(); |
|
677 |
|
|
678 |
// Notify to user that no filter will be applied |
|
679 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "no_filter_will_be_applied_in_the_load_of_the_layer"), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE); |
|
680 |
} |
|
681 |
else { |
|
682 |
layerNode.setFilter(query); |
|
683 |
} |
|
684 |
|
|
685 |
return layerNode; |
|
686 |
} |
|
687 |
|
|
688 |
public void setSelectedFeature(WFSLayerNode layerNode){ |
|
689 |
getFeaturesPanel().setSelectedFeature(layerNode); |
|
690 |
getFieldsPanel().setSelectedFields(layerNode); |
|
691 |
getFilterPanel().refresh(layerNode); |
|
692 |
// getFilterPanel().setFilterExpressionIntoInterface(layerNode.getFilter()); |
|
693 |
} |
|
694 |
|
|
695 |
|
|
696 |
/** |
|
697 |
* @return Returns the data. |
|
698 |
*/ |
|
699 |
public WFSWizardData getData() { |
|
700 |
return data; |
|
701 |
} |
|
702 |
public void setLayerName(String name) { |
|
703 |
getFeaturesPanel().setLayerName(name); |
|
704 |
|
|
705 |
} |
|
706 |
|
|
707 | 490 |
public void addWizardListener(WizardListener listener) { |
708 | 491 |
listenerSupport.addWizardListener(listener); |
709 | 492 |
} |
710 | 493 |
|
711 | 494 |
public void isApplicable(boolean applicable){ |
712 | 495 |
listenerSupport.callStateChanged(applicable); |
713 |
} |
|
496 |
}
|
|
714 | 497 |
|
715 |
|
|
716 |
public void setStatus(WFSStatus status) { |
|
717 |
getOptionsPanel().setStatus(status); |
|
718 |
getFilterPanel().setFilterExpressionIntoInterface(status.getFilterVisualText()); |
|
719 |
} |
|
720 |
|
|
721 | 498 |
/** |
722 |
* Updates the filter fields values with the new values |
|
723 |
*/ |
|
724 |
public void updateWFSFilterFieldValues() { |
|
725 |
this.getFilterPanel().updateFieldValues(); |
|
726 |
} |
|
727 |
|
|
728 |
/** |
|
729 |
* @see WFSFilterPanel#setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean) |
|
730 |
*/ |
|
731 |
public void setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean b) { |
|
732 |
this.getFilterPanel().setWFSFilterPanelIsAsTabForWFSLayersLoad(b); |
|
733 |
} |
|
734 |
|
|
735 |
/** |
|
736 |
* @see WFSFilterPanel#getWFSFilterPanelIsAsTabForWFSLayersLoad() |
|
737 |
*/ |
|
738 |
public boolean getWFSFilterPanelIsAsTabForWFSLayersLoad() { |
|
739 |
return this.getFilterPanel().getWFSFilterPanelIsAsTabForWFSLayersLoad(); |
|
740 |
} |
|
741 |
|
|
742 |
/** |
|
743 |
* @see WFSSelectFieldsPanel#getFieldsSelectedOfSameLayerHasChanged() |
|
744 |
*/ |
|
745 |
public boolean getFieldsSelectedOfSameLayerHasChanged() { |
|
746 |
return this.getFieldsPanel().getFieldsSelectedOfSameLayerHasChanged(); |
|
747 |
} |
|
748 |
|
|
749 |
/** |
|
750 |
* @see WFSSelectFieldsPanel#resetFieldsSelectedOfSameLayerHasChanged() |
|
751 |
*/ |
|
752 |
public void resetFieldsSelectedOfSameLayerHasChanged() { |
|
753 |
this.getFieldsPanel().resetFieldsSelectedOfSameLayerHasChanged(); |
|
754 |
} |
|
755 |
|
|
756 |
/** |
|
757 | 499 |
* @see WFSWizard#doClickOnNextButton() |
758 | 500 |
*/ |
759 | 501 |
public void doClickOnNextButton() { |
760 | 502 |
Object obj = this.getParent(); |
761 |
|
|
503 |
|
|
762 | 504 |
// When we start to connect to a server -> the interface is the dialog WFSWizard |
763 | 505 |
if (obj instanceof WFSWizard) |
764 | 506 |
((WFSWizard)this.getParent()).doClickOnNextButton(); |
765 | 507 |
else { |
766 | 508 |
// When we are modifying a loaded layer -> the interface is the dialog WFSPropsDialog |
767 |
if (obj instanceof WFSPropsDialog) |
|
768 |
this.advanceCurrentTab(); |
|
509 |
// if (obj instanceof WFSPropsDialog)
|
|
510 |
// this.advanceCurrentTab();
|
|
769 | 511 |
} |
770 | 512 |
} |
771 | 513 |
|
... | ... | |
774 | 516 |
*/ |
775 | 517 |
public void advanceCurrentTab() { |
776 | 518 |
int currentTabIndex = this.getJTabbedPane().getSelectedIndex(); |
777 |
|
|
519 |
|
|
778 | 520 |
// Ensure we can select next tab |
779 |
if ((currentTabIndex != -1) && (currentTabIndex < (this.getJTabbedPane().getTabCount() -1)))
|
|
521 |
if ((currentTabIndex != -1) && (currentTabIndex < (this.getJTabbedPane().values().size() -1)))
|
|
780 | 522 |
this.getJTabbedPane().setSelectedIndex(currentTabIndex + 1); |
781 | 523 |
} |
782 | 524 |
|
783 | 525 |
/** |
784 |
* @see WFSFilterPanel#getAllFieldsAndValuesKnownOfCurrentLayer(Map)
|
|
526 |
* @return the listenerSupport
|
|
785 | 527 |
*/ |
786 |
public Map getAllFieldsAndValuesKnownOfCurrentLayer() {
|
|
787 |
return this.getFilterPanel().getAllFieldsAndValuesKnownOfCurrentLayer();
|
|
788 |
} |
|
789 |
|
|
528 |
public WizardListenerSupport getListenerSupport() {
|
|
529 |
return listenerSupport;
|
|
530 |
}
|
|
531 |
|
|
790 | 532 |
/** |
791 |
* @see WFSFilterPanel#setAllFieldsAndValuesKnownOfCurrentLayer(Map) |
|
533 |
* Sets the listenerSupport |
|
534 |
* @param support |
|
792 | 535 |
*/ |
793 |
public void setAllFieldsAndValuesKnownOfCurrentLayer(Map allFieldsAndValuesKnownOfCurrentLayer) {
|
|
794 |
this.getFilterPanel().setAllFieldsAndValuesKnownOfCurrentLayer(allFieldsAndValuesKnownOfCurrentLayer);
|
|
536 |
public void setListenerSupport(WizardListenerSupport support) {
|
|
537 |
listenerSupport = support;
|
|
795 | 538 |
} |
796 |
|
|
797 |
/** |
|
798 |
* @see WFSFilterPanel#getQuery() |
|
799 |
*/ |
|
800 |
public String getFilterQuery() { |
|
801 |
return this.getFilterPanel().getQuery(); |
|
802 |
} |
|
803 |
|
|
804 |
/** |
|
805 |
* @see WFSAreaPanel#setUserHasntDefineAnArea() |
|
806 |
*/ |
|
807 |
public void setUserHasntDefinedAnArea() { |
|
808 |
this.getAreaPanel().setUserHasntDefineAnArea(); |
|
809 |
} |
|
810 |
|
|
811 |
/** |
|
812 |
* @see WFSAreaPanel#updateWFSArea() |
|
813 |
*/ |
|
814 |
public void updateWFSArea() { |
|
815 |
this.getAreaPanel().updateWFSArea(); |
|
816 |
} |
|
817 |
|
|
818 |
/** |
|
819 |
* Removes the previous extents stored and loads the extent of the current active panel |
|
820 |
*/ |
|
821 |
public void reloadWFSAreaPanel() { |
|
822 |
this.getAreaPanel().clearCoordinates(); |
|
823 |
this.getAreaPanel().updateWFSArea(); |
|
824 |
} |
|
825 | 539 |
} |
Also available in: Unified diff