Revision 9392 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/dialogs/WFSPropsDialog.java
WFSPropsDialog.java | ||
---|---|---|
27 | 27 |
import com.iver.cit.gvsig.fmap.layers.FLyrWFSFactory; |
28 | 28 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
29 | 29 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
30 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
31 | 30 |
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel; |
32 | 31 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
33 | 32 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
34 | 33 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
34 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
|
35 | 35 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
36 | 36 |
|
37 | 37 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
... | ... | |
78 | 78 |
* |
79 | 79 |
* $Id$ |
80 | 80 |
* $Log$ |
81 |
* Revision 1.20 2006-12-20 14:21:22 ppiqueras |
|
81 |
* Revision 1.21 2006-12-20 14:50:10 caballero |
|
82 |
* Remodelado Layout |
|
83 |
* |
|
84 |
* Revision 1.20 2006/12/20 14:21:22 ppiqueras |
|
82 | 85 |
* Corregido bug que no actualice vista si el filtro no es correcto |
83 | 86 |
* |
84 | 87 |
* Revision 1.19 2006/12/19 08:27:29 jorpiell |
... | ... | |
158 | 161 |
private CommandListener m_actionListener = null; |
159 | 162 |
private JPanel buttonsPanel = null; |
160 | 163 |
boolean applied = false; |
161 |
|
|
162 | 164 |
|
165 |
|
|
163 | 166 |
public WFSPropsDialog(FLayer layer) { |
164 | 167 |
super(); |
165 | 168 |
initialize(layer); |
166 | 169 |
} |
167 |
|
|
170 |
|
|
168 | 171 |
private void initialize(FLayer layer) { |
169 |
setLayout(null);
|
|
172 |
setLayout(null); |
|
170 | 173 |
setFLayer(layer); |
171 | 174 |
wfsParamsTabbedPane = getParamsPanel(((FLyrWFS) layer).getProperties()); |
172 | 175 |
wfsParamsTabbedPane.addWizardListener(new WizardListener(){ |
... | ... | |
177 | 180 |
|
178 | 181 |
public void error(Exception e) { |
179 | 182 |
} |
180 |
|
|
183 |
|
|
181 | 184 |
}) ; |
182 | 185 |
//wfsParamsTabbedPane.disableDisagregatedLayers(); |
183 | 186 |
this.add(wfsParamsTabbedPane); |
184 | 187 |
this.add(getButtonsPanel(), null); |
185 | 188 |
} |
186 |
|
|
189 |
|
|
187 | 190 |
public JPanel getButtonsPanel() { |
188 | 191 |
if (buttonsPanel == null) { |
189 | 192 |
m_actionListener = new CommandListener(this); |
190 | 193 |
buttonsPanel = new JPanel(); |
191 | 194 |
buttonsPanel.setBounds(5, wfsParamsTabbedPane.getHeight(), 471, 40); |
192 |
buttonsPanel.setLayout(null);
|
|
195 |
buttonsPanel.setLayout(null); |
|
193 | 196 |
buttonsPanel.setName("buttonPanel"); |
194 |
|
|
197 |
|
|
195 | 198 |
buttonsPanel.add(getBtnOk(), null); |
196 | 199 |
buttonsPanel.add(getBtnApply(), null); |
197 | 200 |
buttonsPanel.add(getBtnCancel(), null); |
198 | 201 |
} |
199 | 202 |
return buttonsPanel; |
200 | 203 |
} |
201 |
|
|
202 |
|
|
204 |
|
|
205 |
|
|
203 | 206 |
/** |
204 | 207 |
* With getParamsPanel we have access to the map config TabbedPane. |
205 | 208 |
* If this panel doesn't exist yet (which can occur when an existing project is |
206 | 209 |
* recovered) it is been automatically constructed by connecting to the server, |
207 | 210 |
* reloading the necessary data, filling up the content and setting the selected |
208 | 211 |
* values that were selected when the projet was saved. |
209 |
*
|
|
210 |
*
|
|
212 |
* |
|
213 |
* |
|
211 | 214 |
* Since a connection to the server is needed when rebuiliding the panel, this |
212 | 215 |
* causes a delay for the panel's showing up or a nullPointer error if there is |
213 | 216 |
* no path to the server. |
214 |
*
|
|
215 |
*
|
|
217 |
* |
|
218 |
* |
|
216 | 219 |
* Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n |
217 | 220 |
* del mapa. Si este panel todav?a no existe (como puede ser cuando |
218 | 221 |
* recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando |
219 | 222 |
* al servidor, recuperando los datos necesarios, rellenando el contenido y |
220 | 223 |
* dejando seleccionados los valores que estaban seleccionados cuando se |
221 | 224 |
* guard� el proyecto. |
222 |
*
|
|
223 |
*
|
|
225 |
* |
|
226 |
* |
|
224 | 227 |
* Como para reconstruirse requiere una conexi�n con el servidor esto causa |
225 | 228 |
* un retardo en la aparici�n en el toc o un error de nullPointer si no |
226 | 229 |
* hay conexi�n hasta el servidor. |
227 |
*
|
|
228 |
*
|
|
230 |
* |
|
231 |
* |
|
229 | 232 |
* @return WMSParamsPanel |
230 | 233 |
*/ |
231 | 234 |
public WFSParamsPanel getParamsPanel(HashMap info) { |
... | ... | |
243 | 246 |
toc.setStatus((WFSStatus)info.get("status")); |
244 | 247 |
toc.setVisible(true); |
245 | 248 |
applied = false; |
246 |
return toc;
|
|
249 |
return toc; |
|
247 | 250 |
} |
248 |
return null;
|
|
251 |
return null; |
|
249 | 252 |
} |
250 |
|
|
251 |
|
|
253 |
|
|
254 |
|
|
252 | 255 |
public WindowInfo getWindowInfo() { |
253 | 256 |
if (m_ViewInfo == null){ |
254 | 257 |
m_ViewInfo=new WindowInfo(WindowInfo.MODALDIALOG); |
... | ... | |
283 | 286 |
} |
284 | 287 |
return btnOk; |
285 | 288 |
} |
286 |
|
|
289 |
|
|
287 | 290 |
public JButton getBtnApply() { |
288 | 291 |
if (btnApply == null) { |
289 | 292 |
btnApply = new JButton("apply"); |
... | ... | |
295 | 298 |
} |
296 | 299 |
return btnApply; |
297 | 300 |
} |
298 |
|
|
301 |
|
|
299 | 302 |
public JButton getBtnCancel() { |
300 | 303 |
if (btnCancel == null) { |
301 | 304 |
btnCancel = new JButton("cancel"); |
... | ... | |
306 | 309 |
} |
307 | 310 |
return btnCancel; |
308 | 311 |
} |
309 |
|
|
312 |
|
|
310 | 313 |
public void close() { |
311 |
PluginServices.getMDIManager().closeWindow(this);
|
|
314 |
PluginServices.getMDIManager().closeWindow(this); |
|
312 | 315 |
} |
313 |
|
|
316 |
|
|
314 | 317 |
/** |
315 | 318 |
* Merge two FLayers in one |
316 | 319 |
* @param group1 |
... | ... | |
318 | 321 |
* @return |
319 | 322 |
*/ |
320 | 323 |
private FLayers mergeFLayers(FLayers group1, FLayers group2) |
321 |
{
|
|
324 |
{ |
|
322 | 325 |
FLayer layer; |
323 | 326 |
for(int i = 0; i < group2.getLayersCount(); i++) |
324 | 327 |
{ |
... | ... | |
327 | 330 |
group1.addLayer( layer ); |
328 | 331 |
} |
329 | 332 |
} |
330 |
|
|
333 |
|
|
331 | 334 |
return group1; |
332 | 335 |
} |
333 |
|
|
336 |
|
|
334 | 337 |
private class CommandListener implements ActionListener { |
335 | 338 |
public CommandListener(WFSPropsDialog tp) { |
336 | 339 |
//m_tp = tp; |
337 | 340 |
} |
338 |
|
|
341 |
|
|
339 | 342 |
/* (non-Javadoc) |
340 | 343 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
341 | 344 |
*/ |
... | ... | |
344 | 347 |
close(); |
345 | 348 |
}else{ |
346 | 349 |
String layerName = null; |
347 |
|
|
350 |
|
|
348 | 351 |
// Don't update if the filter is incorrect |
349 | 352 |
if (wfsParamsTabbedPane.getFilterQuery() != null) { |
350 | 353 |
layerName = fLayer.getName(); |
351 | 354 |
View activeView = (View) PluginServices.getMDIManager().getActiveWindow(); |
352 | 355 |
VectorialLegend legend = (VectorialLegend)((FLyrVect)fLayer).getLegend(); |
353 |
FMapWFSDriver driver = wfsParamsTabbedPane.getDriver();
|
|
356 |
FMapWFSDriver driver = wfsParamsTabbedPane.getDriver(); |
|
354 | 357 |
try { |
355 | 358 |
fLayer = wfsParamsTabbedPane.getLayer(); |
356 | 359 |
URL host = new URL(wfsParamsTabbedPane.getData().getHost()); |
... | ... | |
358 | 361 |
fLayer = new FLyrWFSFactory().getFLyrWFS(fLayer,host,onlineResource,driver,true); |
359 | 362 |
if (fLayer != null){ |
360 | 363 |
((FLyrWFS)fLayer).setLegend(legend); |
361 |
|
|
364 |
|
|
362 | 365 |
// Update all fields and values known about the current layer loaded (and selected) |
363 | 366 |
((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer()); |
364 | 367 |
} |
... | ... | |
370 | 373 |
e1.printStackTrace(); |
371 | 374 |
} |
372 | 375 |
} |
373 |
|
|
376 |
|
|
374 | 377 |
if (e.getActionCommand() == "APPLY"){ |
375 | 378 |
// We can't 'apply' if there is a filter query and it's incorrect |
376 |
if (wfsParamsTabbedPane.getFilterQuery() != null) {
|
|
379 |
if (wfsParamsTabbedPane.getFilterQuery() != null) { |
|
377 | 380 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
378 | 381 |
MapControl mapCtrl = vista.getMapControl(); |
379 | 382 |
mapCtrl.getMapContext().getLayers().replaceLayer(layerName, fLayer); |
... | ... | |
386 | 389 |
setWFSFilterPanelIsAsTabForWFSLayersLoad(false); |
387 | 390 |
wfsParamsTabbedPane.resetAttributesSelectedOfSameLayerHasChanged(); // reset that attribute |
388 | 391 |
} |
389 |
|
|
392 |
|
|
390 | 393 |
// Update values associated to the current selected field |
391 | 394 |
wfsParamsTabbedPane.updateWFSFilterFieldValues(); |
392 | 395 |
} |
393 | 396 |
} |
394 |
|
|
397 |
|
|
395 | 398 |
if (e.getActionCommand() == "OK") { |
396 | 399 |
// We can't 'apply' if there is a filter query and it's incorrect |
397 |
if (wfsParamsTabbedPane.getFilterQuery() != null) {
|
|
400 |
if (wfsParamsTabbedPane.getFilterQuery() != null) { |
|
398 | 401 |
if (!applied) { |
399 | 402 |
if (getBtnApply().isEnabled()){ |
400 | 403 |
View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
401 | 404 |
MapControl mapCtrl = vista.getMapControl(); |
402 | 405 |
mapCtrl.getMapContext().getLayers().replaceLayer(layerName, fLayer); |
403 | 406 |
mapCtrl.getMapContext().invalidate(); |
404 |
refreshLayouts();
|
|
407 |
refreshLayouts(); |
|
405 | 408 |
} |
406 |
}
|
|
409 |
} |
|
407 | 410 |
close(); |
408 |
|
|
411 |
|
|
409 | 412 |
// Update all fields and values known about the current layer loaded (and selected) |
410 | 413 |
((FLyrWFS)fLayer).setAllFieldsAndValuesKnown(wfsParamsTabbedPane.getAllFieldsAndValuesKnownOfCurrentLayer()); |
411 | 414 |
} |
... | ... | |
416 | 419 |
private boolean loadLayer(FLayer flayer){ |
417 | 420 |
try { |
418 | 421 |
((FLyrWFS)fLayer).load(); |
419 |
|
|
422 |
|
|
420 | 423 |
if (((FLyrWFS)fLayer).getNumfeatures() == ((FLyrWFS)fLayer).getWfsDriver().getRowCount()) { |
421 | 424 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
422 |
PluginServices.getText(this,"maxFeatures_aviso"));
|
|
425 |
PluginServices.getText(this,"maxFeatures_aviso")); |
|
423 | 426 |
} |
424 | 427 |
} catch (Exception e1) { |
425 | 428 |
e1.printStackTrace(); |
... | ... | |
428 | 431 |
return false; |
429 | 432 |
} |
430 | 433 |
return true; |
431 |
}
|
|
432 |
|
|
434 |
} |
|
435 |
|
|
433 | 436 |
} |
434 |
|
|
437 |
|
|
435 | 438 |
/** |
436 | 439 |
* @see WFSFilterPanel#setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean) |
437 | 440 |
*/ |
438 | 441 |
public void setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean b) { |
439 | 442 |
this.wfsParamsTabbedPane.setWFSFilterPanelIsAsTabForWFSLayersLoad(b); |
440 | 443 |
} |
441 |
|
|
444 |
|
|
442 | 445 |
/** |
443 | 446 |
* @see WFSFilterPanel#getWFSFilterPanelIsAsTabForWFSLayersLoad() |
444 | 447 |
*/ |
445 | 448 |
public boolean getWFSFilterPanelIsAsTabForWFSLayersLoad() { |
446 | 449 |
return this.wfsParamsTabbedPane.getWFSFilterPanelIsAsTabForWFSLayersLoad(); |
447 | 450 |
} |
448 |
|
|
451 |
|
|
449 | 452 |
/** |
450 | 453 |
* Sets all fielsd and values known of current layer to WFSFilterPanel |
451 | 454 |
*/ |
452 | 455 |
public void updateAllFieldsAndValuesKnownOfCurrentLayerToWFSFilterPanel() { |
453 | 456 |
this.wfsParamsTabbedPane.setAllFieldsAndValuesKnownOfCurrentLayer(((FLyrWFS)this.getFLayer()).getAllFieldsAndValuesKnown()); |
454 | 457 |
} |
455 |
|
|
458 |
|
|
456 | 459 |
/** |
457 | 460 |
* Refresh the layouts |
458 | 461 |
* |
459 | 462 |
*/ |
460 |
private void refreshLayouts(){
|
|
463 |
private void refreshLayouts(){ |
|
461 | 464 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows(); |
462 | 465 |
for (int i=0 ; i<windows.length ; i++){ |
463 | 466 |
if (windows[i] instanceof Layout){ |
464 |
((Layout)windows[i]).fullRefresh(); |
|
467 |
((Layout)windows[i]).getLayoutControl().fullRefresh();
|
|
465 | 468 |
} |
466 | 469 |
} |
467 | 470 |
} |
Also available in: Unified diff