svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / dialogs / WFSPropertiesDialogListener.java @ 27940
History | View | Annotate | Download (6.71 KB)
1 |
package com.iver.cit.gvsig.gui.dialogs; |
---|---|
2 |
|
3 |
import java.awt.event.ActionEvent; |
4 |
import java.awt.event.ActionListener; |
5 |
|
6 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
7 |
|
8 |
import com.iver.andami.PluginServices; |
9 |
import com.iver.andami.ui.mdiManager.IWindow; |
10 |
import com.iver.cit.gvsig.gui.panels.WFSAreaPanel; |
11 |
import com.iver.cit.gvsig.gui.panels.WFSFilterPanel; |
12 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
13 |
|
14 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
15 |
*
|
16 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
17 |
*
|
18 |
* This program is free software; you can redistribute it and/or
|
19 |
* modify it under the terms of the GNU General Public License
|
20 |
* as published by the Free Software Foundation; either version 2
|
21 |
* of the License, or (at your option) any later version.
|
22 |
*
|
23 |
* This program is distributed in the hope that it will be useful,
|
24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
26 |
* GNU General Public License for more details.
|
27 |
*
|
28 |
* You should have received a copy of the GNU General Public License
|
29 |
* along with this program; if not, write to the Free Software
|
30 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
31 |
*
|
32 |
* For more information, contact:
|
33 |
*
|
34 |
* Generalitat Valenciana
|
35 |
* Conselleria d'Infraestructures i Transport
|
36 |
* Av. Blasco Ib??ez, 50
|
37 |
* 46010 VALENCIA
|
38 |
* SPAIN
|
39 |
*
|
40 |
* +34 963862235
|
41 |
* gvsig@gva.es
|
42 |
* www.gvsig.gva.es
|
43 |
*
|
44 |
* or
|
45 |
*
|
46 |
* IVER T.I. S.A
|
47 |
* Salamanca 50
|
48 |
* 46005 Valencia
|
49 |
* Spain
|
50 |
*
|
51 |
* +34 963163400
|
52 |
* dac@iver.es
|
53 |
*/
|
54 |
/* CVS MESSAGES:
|
55 |
*
|
56 |
* $Id$
|
57 |
* $Log$
|
58 |
*
|
59 |
*/
|
60 |
|
61 |
/**
|
62 |
* <p>Listener used when user presses any of the buttons of the WFS properties dialog.</p>
|
63 |
*
|
64 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
65 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
66 |
*/
|
67 |
public class WFSPropertiesDialogListener implements ActionListener { |
68 |
public static final String CANCEL_BUTTON_ACTION_COMMAND = "CANCEL"; |
69 |
public static final String APPLY_BUTTON_ACTION_COMMAND = "APPLY"; |
70 |
public static final String ACCEPT_BUTTON_ACTION_COMMAND = "ACCEPT"; |
71 |
|
72 |
private WFSPropertiesDialog dialog = null; |
73 |
|
74 |
/**
|
75 |
* Creates a new WFS properties dialog listener.
|
76 |
*
|
77 |
* @param dialog reference to the WFS properties dialog
|
78 |
*/
|
79 |
public WFSPropertiesDialogListener(WFSPropertiesDialog dialog) {
|
80 |
this.dialog = dialog;
|
81 |
} |
82 |
|
83 |
/* (non-Javadoc)
|
84 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
85 |
*/
|
86 |
public void actionPerformed(ActionEvent e) { |
87 |
// if (e.getActionCommand() == CANCEL_BUTTON_ACTION_COMMAND) {
|
88 |
// dialog.close();
|
89 |
// return;
|
90 |
// }
|
91 |
//
|
92 |
// // Accelerate the response: if there are not changes to apply it closes the dialog
|
93 |
// if ((e.getActionCommand() == ACCEPT_BUTTON_ACTION_COMMAND) && (! dialog.isEnabledApplyButton())) {
|
94 |
// dialog.close();
|
95 |
// return;
|
96 |
// }
|
97 |
//
|
98 |
// //Accept or apply
|
99 |
// try {
|
100 |
// // We can't 'apply' if there is a filter query and it's incorrect
|
101 |
// if (dialog.getFilterQuery() == null)
|
102 |
// return;
|
103 |
//
|
104 |
// // Gets a reference to the old layer
|
105 |
// FLayer oldLayer = (FLayer) dialog.getReference();
|
106 |
// String oldLayerName = oldLayer.getName();
|
107 |
//
|
108 |
// // Gets the layer with the current information:
|
109 |
// FLyrWFS newLayer = dialog.getFLayer();
|
110 |
//
|
111 |
// // Gets the driver
|
112 |
// FMapWFSDriver driver = newLayer.getWfsDriver(); //dialog.getDriver();
|
113 |
//
|
114 |
// // Sets the online resource
|
115 |
// URL host = new URL(dialog.getServerExplorer().getHost());
|
116 |
// String onlineResource = dialog.getServerExplorer().getOnlineResource();
|
117 |
//
|
118 |
// // Tries to get the new layer
|
119 |
// newLayer = new FLyrWFSFactory().getFLyrWFS(newLayer, host, onlineResource, driver, true, false);
|
120 |
//
|
121 |
// // If can load the layer, update all data
|
122 |
// if (newLayer != null) {
|
123 |
// // Removes the last project table if exists
|
124 |
// removeProjectTable((FLyrVect) oldLayer);
|
125 |
//
|
126 |
// // Sets the new layer
|
127 |
// dialog.updateReference(newLayer);
|
128 |
//
|
129 |
// // Replace the old layer entry at the TOC with the new one
|
130 |
// BaseView activeView = (BaseView) PluginServices.getMDIManager().getActiveWindow();
|
131 |
// MapControl mapCtrl = activeView.getMapControl();
|
132 |
// mapCtrl.getMapContext().getLayers().replaceLayer(oldLayerName, newLayer);
|
133 |
// mapCtrl.getMapContext().zoomToExtent(newLayer.getFullExtent());
|
134 |
//
|
135 |
// // Refresh the active window where the new layer is located
|
136 |
// refreshActiveWindow();
|
137 |
//
|
138 |
// // Update data
|
139 |
// if (e.getActionCommand() == APPLY_BUTTON_ACTION_COMMAND) {
|
140 |
// updateFilterAndAreaPanelsData();
|
141 |
//
|
142 |
// // Disable the apply button
|
143 |
// dialog.setEnabledApplyButton(false);
|
144 |
// return;
|
145 |
// }
|
146 |
// }
|
147 |
//
|
148 |
// // Accept button clicked
|
149 |
// if (e.getActionCommand() == ACCEPT_BUTTON_ACTION_COMMAND) {
|
150 |
// dialog.close();
|
151 |
// return;
|
152 |
// }
|
153 |
//
|
154 |
// return;
|
155 |
// } catch (Exception e1) {
|
156 |
// NotificationManager.addError(e1);
|
157 |
// }
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* Removes the associated project table of the <code>flayer</code>.
|
162 |
*
|
163 |
* @param flayer a vector layer
|
164 |
*/
|
165 |
private void removeProjectTable(FLyrVect flayer) { |
166 |
// Remove it
|
167 |
// ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
|
168 |
// ArrayList<ProjectDocument> tables = ext.getProject().getDocumentsByType(ProjectTableFactory.registerName);
|
169 |
//
|
170 |
// for (int i=0 ; i < tables.size() ; i++){
|
171 |
// ProjectTable projectTable = (ProjectTable)tables.get(i);
|
172 |
//
|
173 |
// try {
|
174 |
// if (flayer.getRecordset().equals(projectTable.getAssociatedTable().getRecordset())){
|
175 |
// ext.getProject().delDocument(projectTable);
|
176 |
// }
|
177 |
// } catch (ReadDriverException e) {
|
178 |
// NotificationManager.addError(e);
|
179 |
// }
|
180 |
// }
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* @see WFSFilterPanel#setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean)
|
185 |
*/
|
186 |
private void setWFSFilterPanelIsAsTabForWFSLayersLoad(boolean b) { |
187 |
dialog.setWFSFilterPanelIsAsTabForWFSLayersLoad(b); |
188 |
} |
189 |
|
190 |
/**
|
191 |
* <p>Refresh the active window.</p>
|
192 |
*/
|
193 |
private void refreshActiveWindow() { |
194 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
195 |
|
196 |
if (window instanceof View) |
197 |
((View)window).invalidate();
|
198 |
} |
199 |
|
200 |
/**
|
201 |
* Updates the information of the panels {@linkplain WFSFilterPanel WFSFilterPanel} and {@linkplain WFSAreaPanel WFSAreaPanel}.
|
202 |
*/
|
203 |
private void updateFilterAndAreaPanelsData() { |
204 |
// Restores the private attribute of the area panel: hasUserDefinedAnArea
|
205 |
dialog.setUserHasntDefinedAnArea(); |
206 |
|
207 |
// If we load another layer, or the same but we've selected others fields -> notify it to the WFSFilter panel
|
208 |
if (dialog.getFieldsSelectedOfSameLayerHasChanged()) {
|
209 |
dialog.resetFieldsSelectedOfSameLayerHasChanged(); // reset that field
|
210 |
} |
211 |
|
212 |
// Update the data of the Filter and Area panels
|
213 |
setWFSFilterPanelIsAsTabForWFSLayersLoad(false);
|
214 |
dialog.updateWFSFilterFieldValues(); |
215 |
dialog.updateWFSArea(); |
216 |
} |
217 |
} |