svn-gvsig-desktop / branches / v10 / extensions / extPublishMapserver / src / org / gvsig / publish / mapserver / gui / MapserverController.java @ 14511
History | View | Annotate | Download (4.67 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; |
42 |
|
43 |
|
44 |
import java.awt.event.ActionEvent; |
45 |
import java.awt.event.ActionListener; |
46 |
import java.io.File; |
47 |
|
48 |
import javax.swing.JFileChooser; |
49 |
|
50 |
import org.gvsig.publish.gui.browser.BrowserController; |
51 |
import org.gvsig.publish.gui.publish.IPublishPluginPanel; |
52 |
import org.gvsig.publish.mapserver.gui.wms.MapserverLayerWMSPanel; |
53 |
import org.gvsig.publish.mapserver.gui.wms.MapserverServiceWMSPanel; |
54 |
import org.gvsig.publish.mapserver.model.Mapserver; |
55 |
import org.gvsig.publish.mapserver.model.wms.MapserverWMS; |
56 |
import org.gvsig.publish.mapserver.model.wms.MapserverWMSLayer; |
57 |
import org.gvsig.publish.serversModel.RemoteResource; |
58 |
import org.gvsig.publish.serversModel.Server; |
59 |
import org.gvsig.publish.serversModel.Service; |
60 |
|
61 |
import com.sun.media.jai.util.RWLock.UpgradeNotAllowed; |
62 |
|
63 |
/**
|
64 |
* This class represents the controller which shows the user the publication in Mapserver.
|
65 |
*
|
66 |
* At first, the publish extension call the method setModel(Mapserver) in order to fill all the panels
|
67 |
* When the user has finished to modify the model (Mapserver, its services a remote resources), the
|
68 |
* publish extension call the method getModel():Mapserver in order to publish (calling the publish() method
|
69 |
* of Mapserver)
|
70 |
*
|
71 |
*
|
72 |
* @author jvhigon
|
73 |
*
|
74 |
*/
|
75 |
|
76 |
public class MapserverController extends BrowserController implements ActionListener{ |
77 |
|
78 |
/*
|
79 |
* Event from the JFileChooser
|
80 |
*/
|
81 |
public final static String MAPFILE_CHOOSE_PATH_EVENT="mapfile_path_event"; |
82 |
|
83 |
Mapserver active_server = null;
|
84 |
/*
|
85 |
* Panels
|
86 |
*/
|
87 |
private MapserverPanel serverPanel= null; |
88 |
private MapserverServiceWMSPanel wmsPanel = null; |
89 |
private MapserverLayerWMSPanel wmsLayerPanel = null; |
90 |
private MapFileChooser mapfileChooser = null; |
91 |
/**
|
92 |
* Constructor
|
93 |
*
|
94 |
*/
|
95 |
public MapserverController(){
|
96 |
super();
|
97 |
//creates the panels and set itself like a listener from user events
|
98 |
serverPanel = new MapserverPanel();
|
99 |
serverPanel.setListener(this);
|
100 |
wmsPanel = new MapserverServiceWMSPanel();
|
101 |
wmsLayerPanel = new MapserverLayerWMSPanel();
|
102 |
//creates the filechooser
|
103 |
mapfileChooser = new MapFileChooser(new File(System.getProperty("user.home"))); |
104 |
} |
105 |
|
106 |
|
107 |
|
108 |
/**
|
109 |
* @see BrowserController#getServerPanel(Server)
|
110 |
*/
|
111 |
public IPublishPluginPanel getServerPanel(Server server) {
|
112 |
if (server.getType() == Mapserver.SERVER_MAPSERVER){
|
113 |
serverPanel.setModel(server); |
114 |
//set the server as active
|
115 |
active_server =(Mapserver) server; |
116 |
return (IPublishPluginPanel) serverPanel;
|
117 |
} |
118 |
return null; |
119 |
} |
120 |
|
121 |
/**
|
122 |
* @see BrowserController#getServicePanel(Service)
|
123 |
*/
|
124 |
public IPublishPluginPanel getServicePanel(Service service) {
|
125 |
if (service.getType() == MapserverWMS.MAPSERVER_WMS){
|
126 |
wmsPanel.setModel(service); |
127 |
return (IPublishPluginPanel) wmsPanel;
|
128 |
} |
129 |
return null; |
130 |
} |
131 |
/**
|
132 |
* @see BrowserController#getRemoteResourcePanel(RemoteResource)
|
133 |
*/
|
134 |
public IPublishPluginPanel getRemoteResourcePanel(RemoteResource remoteResource) {
|
135 |
if (remoteResource.getType() == MapserverWMSLayer.MAPSERVER_WMS_LAYER){
|
136 |
wmsLayerPanel.setModel(remoteResource); |
137 |
return wmsLayerPanel;
|
138 |
} |
139 |
return null; |
140 |
} |
141 |
/**
|
142 |
* This method gets the action from the JFileChooser
|
143 |
*/
|
144 |
public void actionPerformed(ActionEvent e) { |
145 |
if (e.getActionCommand().equals(MapserverController.MAPFILE_CHOOSE_PATH_EVENT)){
|
146 |
int returnVal = mapfileChooser.showSaveDialog(serverPanel);
|
147 |
if (returnVal == JFileChooser.APPROVE_OPTION){ |
148 |
File mapfile = mapfileChooser.getSelectedFile();
|
149 |
active_server.setMapfileFile(mapfile); |
150 |
serverPanel.setModel(active_server); |
151 |
} |
152 |
} |
153 |
} |
154 |
} |