root / branches / v10 / extensions / extPublishMapserver / src / org / gvsig / publish / mapserver / gui / wizard / MSWizardController.java @ 21391
History | View | Annotate | Download (12.6 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Iba?ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.publish.mapserver.gui.wizard; |
42 |
|
43 |
import java.awt.event.ActionEvent; |
44 |
import java.io.File; |
45 |
|
46 |
import javax.swing.JFileChooser; |
47 |
import javax.swing.JPanel; |
48 |
|
49 |
import org.gvsig.publish.gui.common.PublishFileChooser; |
50 |
import org.gvsig.publish.gui.common.PublishPanelNull; |
51 |
import org.gvsig.publish.gui.ogcMetadata.OGCCommonMetadataPanel; |
52 |
import org.gvsig.publish.gui.ogcMetadata.OGCWCSPanel; |
53 |
import org.gvsig.publish.gui.ogcMetadata.OGCWFSPanel; |
54 |
import org.gvsig.publish.gui.ogcMetadata.OGCWMSPanel; |
55 |
import org.gvsig.publish.gui.publish.IPublishPluginPanel; |
56 |
import org.gvsig.publish.gui.wizard.PublishWizardController; |
57 |
import org.gvsig.publish.mapserver.gui.MSAdvancedPanel; |
58 |
import org.gvsig.publish.mapserver.gui.MSBasicPanel; |
59 |
import org.gvsig.publish.mapserver.gui.wcs.MSWCSAdvancedPanel; |
60 |
import org.gvsig.publish.mapserver.gui.wcs.MSWCSLayerAdvancedPanel; |
61 |
import org.gvsig.publish.mapserver.gui.wfs.MSWFSAdvancedPanel; |
62 |
import org.gvsig.publish.mapserver.gui.wfs.MSWFSLayerAdvancedPanel; |
63 |
import org.gvsig.publish.mapserver.gui.wms.MSWMSAdvancedPanel; |
64 |
import org.gvsig.publish.mapserver.gui.wms.MSWMSLayerAdvancedPanel; |
65 |
import org.gvsig.publish.mapserver.model.Mapserver; |
66 |
import org.gvsig.publish.mapserver.model.wcs.MapserverWCS; |
67 |
import org.gvsig.publish.mapserver.model.wcs.MapserverWCSLayer; |
68 |
import org.gvsig.publish.mapserver.model.wfs.MapserverWFS; |
69 |
import org.gvsig.publish.mapserver.model.wfs.MapserverWFSLayer; |
70 |
import org.gvsig.publish.mapserver.model.wms.MapserverWMS; |
71 |
import org.gvsig.publish.mapserver.model.wms.MapserverWMSLayer; |
72 |
import org.gvsig.publish.serversmodel.RemoteResource; |
73 |
import org.gvsig.publish.serversmodel.Server; |
74 |
import org.gvsig.publish.serversmodel.Service; |
75 |
|
76 |
import com.iver.utiles.FileUtils; |
77 |
import com.iver.utiles.GenericFileFilter; |
78 |
/**
|
79 |
* Wizard GUI controller for Mapserver publication
|
80 |
*
|
81 |
* @author jvhigon
|
82 |
*
|
83 |
*/
|
84 |
public class MSWizardController extends PublishWizardController { |
85 |
//Associantions
|
86 |
private IPublishPluginPanel serverBasicPanel = null; |
87 |
private IPublishPluginPanel serverAdvancedPanel = null; |
88 |
//for wms
|
89 |
private IPublishPluginPanel wmsBasicPanel = null; |
90 |
private IPublishPluginPanel wmsAdvancedPanel = null; |
91 |
private IPublishPluginPanel wmslyrBasicPanel = null; |
92 |
private IPublishPluginPanel wmslyrAdvancedPanel = null; |
93 |
private IPublishPluginPanel wmslyrGroupPanel=null; |
94 |
//for wfs
|
95 |
private IPublishPluginPanel wfsBasicPanel = null; |
96 |
private IPublishPluginPanel wfsAdvancedPanel = null; |
97 |
private IPublishPluginPanel wfslyrBasicPanel = null; |
98 |
private IPublishPluginPanel wfslyrAdvancedPanel = null; |
99 |
//fow wcs
|
100 |
private IPublishPluginPanel wcsBasicPanel = null; |
101 |
private IPublishPluginPanel wcsAdvancedPanel = null; |
102 |
private IPublishPluginPanel wcslyrBasicPanel = null; |
103 |
private IPublishPluginPanel wcslyrAdvancedPanel = null; |
104 |
private Mapserver active_server;
|
105 |
|
106 |
//FileChooser
|
107 |
private PublishFileChooser mapfileChooser = null; |
108 |
private PublishFileChooser imagepathChooser = null; |
109 |
|
110 |
public MSWizardController() {
|
111 |
super();
|
112 |
mapfileChooser = new PublishFileChooser(new File(System.getProperty("user.home"))); |
113 |
GenericFileFilter filter = new GenericFileFilter("map", "Mapserver mapfiles"); |
114 |
mapfileChooser.setFileFilter(filter); |
115 |
imagepathChooser = new PublishFileChooser(new File(System.getProperty("user.home"))); |
116 |
imagepathChooser.setFileSelectionMode(PublishFileChooser.DIRECTORIES_ONLY); |
117 |
} |
118 |
/*
|
119 |
*
|
120 |
* (non-Javadoc)
|
121 |
* @see org.gvsig.publish.gui.wizard.PublishWizardController#getRemoteResourceAdvancedPanel(org.gvsig.publish.serversmodel.RemoteResource)
|
122 |
*/
|
123 |
public IPublishPluginPanel getRemoteResourceAdvancedPanel(
|
124 |
RemoteResource remoteResource) { |
125 |
if (remoteResource.getRegisterTag() == MapserverWMSLayer.REGISTER_TAG){
|
126 |
MapserverWMSLayer wmslyr = (MapserverWMSLayer)remoteResource; |
127 |
if (wmslyr.getChildsCount() == 0){ |
128 |
getWmslyrAdvancedPanel().setModel(remoteResource); |
129 |
return getWmslyrAdvancedPanel();
|
130 |
}else{
|
131 |
return getWmslyrGroupPanel();
|
132 |
} |
133 |
} |
134 |
if (remoteResource.getRegisterTag() == MapserverWFSLayer.REGISTER_TAG){
|
135 |
getWfslyrAdvancedPanel().setModel(remoteResource); |
136 |
return getWfslyrAdvancedPanel();
|
137 |
} |
138 |
if (remoteResource.getRegisterTag() == MapserverWCSLayer.REGISTER_TAG){
|
139 |
getWcslyrAdvancedPanel().setModel(remoteResource); |
140 |
return getWcslyrAdvancedPanel();
|
141 |
} |
142 |
return null; |
143 |
} |
144 |
|
145 |
/*
|
146 |
* (non-Javadoc)
|
147 |
* @see org.gvsig.publish.gui.wizard.PublishWizardController#getRemoteResourcePanel(org.gvsig.publish.serversmodel.RemoteResource)
|
148 |
*/
|
149 |
public IPublishPluginPanel getRemoteResourcePanel(
|
150 |
RemoteResource remoteResource) { |
151 |
if (remoteResource.getRegisterTag() == MapserverWMSLayer.REGISTER_TAG){
|
152 |
getWmslyrBasicPanel().setModel(remoteResource); |
153 |
return getWmslyrBasicPanel();
|
154 |
} |
155 |
if (remoteResource.getRegisterTag() == MapserverWFSLayer.REGISTER_TAG){
|
156 |
getWfslyrBasicPanel().setModel(remoteResource); |
157 |
return getWfslyrBasicPanel();
|
158 |
} |
159 |
if (remoteResource.getRegisterTag() == MapserverWCSLayer.REGISTER_TAG){
|
160 |
getWcslyrBasicPanel().setModel(remoteResource); |
161 |
return getWcslyrBasicPanel();
|
162 |
} |
163 |
return null; |
164 |
|
165 |
} |
166 |
|
167 |
/*
|
168 |
* (non-Javadoc)
|
169 |
* @see org.gvsig.publish.gui.wizard.PublishWizardController#getServerAdvancedPanel(org.gvsig.publish.serversmodel.Server)
|
170 |
*/
|
171 |
public IPublishPluginPanel getServerAdvancedPanel(Server server) {
|
172 |
getServerAdvancedPanel().setModel(server); |
173 |
return getServerAdvancedPanel();
|
174 |
} |
175 |
|
176 |
/*
|
177 |
* (non-Javadoc)
|
178 |
* @see org.gvsig.publish.gui.wizard.PublishWizardController#getServerPanel(org.gvsig.publish.serversmodel.Server)
|
179 |
*/
|
180 |
public IPublishPluginPanel getServerPanel(Server server) {
|
181 |
active_server = (Mapserver)server; |
182 |
getServerBasicPanel().setModel(server); |
183 |
return getServerBasicPanel();
|
184 |
} |
185 |
|
186 |
/*
|
187 |
* (non-Javadoc)
|
188 |
* @see org.gvsig.publish.gui.wizard.PublishWizardController#getServiceAdvancedPanel(org.gvsig.publish.serversmodel.Service)
|
189 |
*/
|
190 |
public IPublishPluginPanel getServiceAdvancedPanel(Service service) {
|
191 |
if (service.getRegisterTag() == MapserverWMS.REGISTER_TAG){
|
192 |
getWmsAdvancedPanel().setModel(service); |
193 |
return (IPublishPluginPanel) getWmsAdvancedPanel();
|
194 |
} |
195 |
if (service.getRegisterTag() == MapserverWFS.REGISTER_TAG){
|
196 |
getWfsAdvancedPanel().setModel(service); |
197 |
return (IPublishPluginPanel) getWfsAdvancedPanel();
|
198 |
} |
199 |
if (service.getRegisterTag() == MapserverWCS.REGISTER_TAG){
|
200 |
getWcsAdvancedPanel().setModel(service); |
201 |
return (IPublishPluginPanel) getWcsAdvancedPanel();
|
202 |
} |
203 |
return null; |
204 |
} |
205 |
|
206 |
/*
|
207 |
* (non-Javadoc)
|
208 |
* @see org.gvsig.publish.gui.wizard.PublishWizardController#getServicePanel(org.gvsig.publish.serversmodel.Service)
|
209 |
*/
|
210 |
public IPublishPluginPanel getServicePanel(Service service) {
|
211 |
if (service.getRegisterTag() == MapserverWMS.REGISTER_TAG){
|
212 |
getWmsBasicPanel().setModel(service); |
213 |
return (IPublishPluginPanel) getWmsBasicPanel();
|
214 |
} |
215 |
if (service.getRegisterTag() == MapserverWFS.REGISTER_TAG){
|
216 |
getWfsBasicPanel().setModel(service); |
217 |
return (IPublishPluginPanel) getWfsBasicPanel();
|
218 |
} |
219 |
if (service.getRegisterTag() == MapserverWCS.REGISTER_TAG){
|
220 |
getWcsBasicPanel().setModel(service); |
221 |
return (IPublishPluginPanel) getWcsBasicPanel();
|
222 |
} |
223 |
return null; |
224 |
} |
225 |
|
226 |
/**
|
227 |
* @return the wmslyrBasicPanel
|
228 |
*/
|
229 |
public IPublishPluginPanel getWmslyrBasicPanel() {
|
230 |
if (wmslyrBasicPanel == null){ |
231 |
wmslyrBasicPanel = new OGCCommonMetadataPanel();
|
232 |
} |
233 |
return wmslyrBasicPanel;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* @return the serverBasicPanel
|
238 |
*/
|
239 |
public IPublishPluginPanel getServerBasicPanel() {
|
240 |
if (serverBasicPanel == null){ |
241 |
serverBasicPanel = new MSBasicPanel();
|
242 |
serverBasicPanel.setListener(this);
|
243 |
} |
244 |
return serverBasicPanel;
|
245 |
} |
246 |
|
247 |
/**
|
248 |
* @return the serverAdvancedPanel
|
249 |
*/
|
250 |
public IPublishPluginPanel getServerAdvancedPanel() {
|
251 |
if (serverAdvancedPanel == null){ |
252 |
serverAdvancedPanel = new MSAdvancedPanel();
|
253 |
serverAdvancedPanel.setListener(this);
|
254 |
} |
255 |
return serverAdvancedPanel;
|
256 |
} |
257 |
/**
|
258 |
* @return the wmsBasicPanel
|
259 |
*/
|
260 |
public IPublishPluginPanel getWmsBasicPanel() {
|
261 |
if (wmsBasicPanel == null){ |
262 |
wmsBasicPanel = new OGCWMSPanel();
|
263 |
} |
264 |
return wmsBasicPanel;
|
265 |
} |
266 |
|
267 |
/**
|
268 |
* @return the wmsAdvancedPanel
|
269 |
*/
|
270 |
public IPublishPluginPanel getWmsAdvancedPanel() {
|
271 |
if (wmsAdvancedPanel == null){ |
272 |
wmsAdvancedPanel = new MSWMSAdvancedPanel();
|
273 |
} |
274 |
return wmsAdvancedPanel;
|
275 |
} |
276 |
|
277 |
/**
|
278 |
* @return the wmslyrAdvancedPanel
|
279 |
*/
|
280 |
public IPublishPluginPanel getWmslyrAdvancedPanel() {
|
281 |
if (wmslyrAdvancedPanel==null){ |
282 |
wmslyrAdvancedPanel = new MSWMSLayerAdvancedPanel();
|
283 |
} |
284 |
return wmslyrAdvancedPanel;
|
285 |
} |
286 |
/*
|
287 |
*
|
288 |
* @return the panel for grouped wms layers
|
289 |
*/
|
290 |
public IPublishPluginPanel getWmslyrGroupPanel(){
|
291 |
if (wmslyrGroupPanel == null){ |
292 |
wmslyrGroupPanel = new PublishPanelNull();
|
293 |
} |
294 |
return wmslyrGroupPanel;
|
295 |
} |
296 |
|
297 |
/**
|
298 |
* @return the wfsBasicPanel
|
299 |
*/
|
300 |
public IPublishPluginPanel getWfsBasicPanel() {
|
301 |
if (wfsBasicPanel==null){ |
302 |
wfsBasicPanel = new OGCWFSPanel();
|
303 |
} |
304 |
return wfsBasicPanel;
|
305 |
} |
306 |
|
307 |
/**
|
308 |
* @return the wfsAdvancedPanel
|
309 |
*/
|
310 |
public IPublishPluginPanel getWfsAdvancedPanel() {
|
311 |
if (wfsAdvancedPanel==null){ |
312 |
wfsAdvancedPanel = new MSWFSAdvancedPanel();
|
313 |
} |
314 |
return wfsAdvancedPanel;
|
315 |
} |
316 |
|
317 |
/**
|
318 |
* @return the wfslyrBasicPanel
|
319 |
*/
|
320 |
public IPublishPluginPanel getWfslyrBasicPanel() {
|
321 |
if (wfslyrBasicPanel == null){ |
322 |
wfslyrBasicPanel = new OGCCommonMetadataPanel();
|
323 |
} |
324 |
return wfslyrBasicPanel;
|
325 |
} |
326 |
|
327 |
/**
|
328 |
* @return the wfslyrAdvancedPanel
|
329 |
*/
|
330 |
public IPublishPluginPanel getWfslyrAdvancedPanel() {
|
331 |
if (wfslyrAdvancedPanel == null){ |
332 |
wfslyrAdvancedPanel = new MSWFSLayerAdvancedPanel();
|
333 |
} |
334 |
return wfslyrAdvancedPanel;
|
335 |
} |
336 |
|
337 |
|
338 |
/**
|
339 |
* @return the wcsBasicPanel
|
340 |
*/
|
341 |
public IPublishPluginPanel getWcsBasicPanel() {
|
342 |
if (wcsBasicPanel == null){ |
343 |
wcsBasicPanel = new OGCWCSPanel();
|
344 |
} |
345 |
return wcsBasicPanel;
|
346 |
} |
347 |
|
348 |
/**
|
349 |
* @return the wcsAdvancedPanel
|
350 |
*/
|
351 |
public IPublishPluginPanel getWcsAdvancedPanel() {
|
352 |
if (wcsAdvancedPanel == null){ |
353 |
wcsAdvancedPanel = new MSWCSAdvancedPanel();
|
354 |
} |
355 |
return wcsAdvancedPanel;
|
356 |
} |
357 |
|
358 |
/**
|
359 |
* @return the wcslyrBasicPanel
|
360 |
*/
|
361 |
public IPublishPluginPanel getWcslyrBasicPanel() {
|
362 |
if (wcslyrBasicPanel == null){ |
363 |
wcslyrBasicPanel = new OGCCommonMetadataPanel();
|
364 |
} |
365 |
return wcslyrBasicPanel;
|
366 |
} |
367 |
|
368 |
/**
|
369 |
* @return the wcslyrAdvancedPanel
|
370 |
*/
|
371 |
public IPublishPluginPanel getWcslyrAdvancedPanel() {
|
372 |
if (wcslyrAdvancedPanel == null){ |
373 |
wcslyrAdvancedPanel = new MSWCSLayerAdvancedPanel();
|
374 |
} |
375 |
return wcslyrAdvancedPanel;
|
376 |
} |
377 |
|
378 |
/**
|
379 |
* This method gets the action from the MapfileChooser and ImagepathChooser.
|
380 |
* I must call the super.actionCommand() in order to execute the WizardController actions
|
381 |
*/
|
382 |
public void actionPerformed(ActionEvent e) { |
383 |
//we update the model in the parent
|
384 |
super.actionPerformed(e);
|
385 |
if (e.getActionCommand().equals("mapfile_path_event")){ |
386 |
//first of all I must update the model
|
387 |
//getServerBasicPanel().getModel();
|
388 |
|
389 |
//check if the mapfile is defined
|
390 |
int returnVal = mapfileChooser.showSaveDialog((JPanel)getServerBasicPanel()); |
391 |
if (returnVal == JFileChooser.APPROVE_OPTION){ |
392 |
File mapfile = mapfileChooser.getSelectedFile();
|
393 |
String aux = FileUtils.getFileWithoutExtension(mapfile);
|
394 |
aux = aux + ".map";
|
395 |
active_server.setMapfileFile(new File(aux)); |
396 |
getServerBasicPanel().setModel(active_server); |
397 |
} |
398 |
return;
|
399 |
} |
400 |
if (e.getActionCommand().equals("imagepath_path_event")){ |
401 |
//first of all I must update the model
|
402 |
//getServerAdvancedPanel().getModel();
|
403 |
|
404 |
int returnVal = imagepathChooser.showSaveDialog((JPanel)getServerAdvancedPanel()); |
405 |
if (returnVal == JFileChooser.APPROVE_OPTION){ |
406 |
File imagepath = imagepathChooser.getSelectedFile();
|
407 |
active_server.setImagePath(imagepath); |
408 |
getServerAdvancedPanel().setModel(active_server); |
409 |
} |
410 |
return;
|
411 |
} |
412 |
} |
413 |
|
414 |
} |