svn-gvsig-desktop / branches / v10 / extensions / extPublish / src / org / gvsig / publish / gui / wizard / PublishWizardController.java @ 19900
History | View | Annotate | Download (8.19 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.gui.wizard; |
42 |
|
43 |
import java.awt.event.ActionEvent; |
44 |
import java.awt.event.ActionListener; |
45 |
|
46 |
import javax.swing.event.ChangeEvent; |
47 |
import javax.swing.event.ChangeListener; |
48 |
import javax.swing.event.TreeSelectionEvent; |
49 |
import javax.swing.event.TreeSelectionListener; |
50 |
|
51 |
import org.gvsig.publish.gui.addResource.AddResourceController; |
52 |
import org.gvsig.publish.gui.publish.IPublishPluginController; |
53 |
import org.gvsig.publish.gui.publish.IPublishPluginPanel; |
54 |
import org.gvsig.publish.serversmodel.Publication; |
55 |
import org.gvsig.publish.serversmodel.RemoteResource; |
56 |
import org.gvsig.publish.serversmodel.Server; |
57 |
import org.gvsig.publish.serversmodel.Service; |
58 |
/**
|
59 |
* GUI controller for a publication wizard.
|
60 |
*
|
61 |
* @author jvhigon
|
62 |
*
|
63 |
*/
|
64 |
public abstract class PublishWizardController implements IPublishPluginController, ActionListener, TreeSelectionListener, ChangeListener { |
65 |
//Associations
|
66 |
private PublishWizardPanel panel;
|
67 |
private Publication publication;
|
68 |
private Server currentServer;
|
69 |
private Service currentService;
|
70 |
private RemoteResource currentRemoteResource;
|
71 |
private IPublishPluginPanel serverBasicPane;
|
72 |
private IPublishPluginPanel serverAdvancedPane;
|
73 |
private IPublishPluginPanel serviceBasicPane;
|
74 |
private IPublishPluginPanel serviceAdvancedPane;
|
75 |
private IPublishPluginPanel remoteBasicPane;
|
76 |
private IPublishPluginPanel remoteAdvancedPane;
|
77 |
//Events
|
78 |
public static final String ADD_RESOURCE_EVENT="add_resource_event"; |
79 |
|
80 |
//Constructor
|
81 |
/**
|
82 |
* Default constructor. It creates the panel and set its listener as "this".
|
83 |
*/
|
84 |
public PublishWizardController() {
|
85 |
this.panel = new PublishWizardPanel(); |
86 |
this.panel.setListener(this); |
87 |
} |
88 |
//Abstract methods
|
89 |
/**
|
90 |
* Any subclass must have a panel for server parameters
|
91 |
* @param server
|
92 |
* @return
|
93 |
*/
|
94 |
public abstract IPublishPluginPanel getServerPanel(Server server); |
95 |
/**
|
96 |
* Any subclass must have a panel for advanced server parameters
|
97 |
* @param server model I want to show
|
98 |
* @return
|
99 |
*/
|
100 |
public abstract IPublishPluginPanel getServerAdvancedPanel(Server server); |
101 |
/**
|
102 |
* Any subclass must have a panel for service parameters
|
103 |
* @param service model I want to show
|
104 |
* @return
|
105 |
*/
|
106 |
public abstract IPublishPluginPanel getServicePanel(Service service); |
107 |
/**
|
108 |
* Any subclass must have a panel for advanced service parameters
|
109 |
* @param service model I want to show
|
110 |
* @return
|
111 |
*/
|
112 |
public abstract IPublishPluginPanel getServiceAdvancedPanel(Service service); |
113 |
/**
|
114 |
* Any subclass must have a panel for remote resources panel
|
115 |
* @param remoteResource model I want to show
|
116 |
* @return
|
117 |
*/
|
118 |
public abstract IPublishPluginPanel getRemoteResourcePanel(RemoteResource remoteResource); |
119 |
/**
|
120 |
* Any subclass must have a panel for advanced remote resources panel
|
121 |
* @param remoteResource model I want to show
|
122 |
* @return
|
123 |
*/
|
124 |
public abstract IPublishPluginPanel getRemoteResourceAdvancedPanel(RemoteResource remoteResource); |
125 |
|
126 |
//Methods
|
127 |
/**
|
128 |
* Gets the publication from the GUI. The GUI will have to update the model first.
|
129 |
*/
|
130 |
public Object getModel() { |
131 |
serverBasicPane.getModel(); |
132 |
serverAdvancedPane.getModel(); |
133 |
serviceBasicPane.getModel(); |
134 |
serviceAdvancedPane.getModel(); |
135 |
if (remoteBasicPane != null) |
136 |
remoteBasicPane.getModel(); |
137 |
if (remoteAdvancedPane != null) |
138 |
remoteAdvancedPane.getModel(); |
139 |
return this.panel.getModel(); |
140 |
} |
141 |
/**
|
142 |
* Gets the GUI
|
143 |
*/
|
144 |
public IPublishPluginPanel getPanel() {
|
145 |
return this.panel; |
146 |
} |
147 |
/**
|
148 |
* Sets the publication which will be showed by the GUI. Then changes the current visible
|
149 |
* panel with the server panel
|
150 |
* @param entityModel must be a "publication" object
|
151 |
*/
|
152 |
public void setModel(Object entityModel) { |
153 |
// cast to publication
|
154 |
this.publication = (Publication) entityModel;
|
155 |
//puts the model into the panel
|
156 |
this.panel.setModel(entityModel);
|
157 |
|
158 |
//update the current server
|
159 |
currentServer = publication.getServer(); |
160 |
//update the current service --> if I have only one service for server
|
161 |
//If you want 2, you must pass an array of services and modify the services panel
|
162 |
currentService = currentServer.getService(0);
|
163 |
//update the current resource --> it depends changevalue event (at the begining I get the first rr)
|
164 |
//if the model contains a remote resource ...
|
165 |
if (currentService.getRemoteResourcesCount() > 0){ |
166 |
currentRemoteResource = currentService.getRemoteResource(0);
|
167 |
} |
168 |
//set the panels in the GUI
|
169 |
setPanels(); |
170 |
} |
171 |
/**
|
172 |
* gets the panel, after updates the model
|
173 |
*/
|
174 |
private void setPanels(){ |
175 |
|
176 |
//put server basic
|
177 |
serverBasicPane = getServerPanel(currentServer); |
178 |
//serverBasicPane.setModel(currentServer);
|
179 |
panel.setServerBasicPanel(serverBasicPane); |
180 |
|
181 |
//put server advanced
|
182 |
serverAdvancedPane = getServerAdvancedPanel(currentServer); |
183 |
//serverAdvancedPane.setModel(currentServer);
|
184 |
panel.setServerAdvancedPanel(serverAdvancedPane); |
185 |
|
186 |
//put service basic
|
187 |
serviceBasicPane = getServicePanel(currentService); |
188 |
//serviceBasicPane.setModel(serviceAdvancedPane);
|
189 |
panel.setServiceBasicPanel(serviceBasicPane); |
190 |
|
191 |
//put service advanced
|
192 |
serviceAdvancedPane = getServiceAdvancedPanel(currentService); |
193 |
panel.setServiceAdvancedPanel(serviceAdvancedPane); |
194 |
|
195 |
//put remote basic
|
196 |
if (currentRemoteResource !=null){ |
197 |
remoteBasicPane = getRemoteResourcePanel(currentRemoteResource); |
198 |
panel.setRemoteResourceBasicPanel(remoteBasicPane); |
199 |
} |
200 |
|
201 |
//put remote advanced
|
202 |
if (currentRemoteResource !=null){ |
203 |
remoteAdvancedPane = getRemoteResourceAdvancedPanel(currentRemoteResource); |
204 |
//remoteAdvancedPane.setModel(currentRemoteResource);
|
205 |
panel.setRemoteResourceAdvancedPanel(remoteAdvancedPane); |
206 |
} |
207 |
} |
208 |
/**
|
209 |
* Actions from buttons
|
210 |
*/
|
211 |
public void actionPerformed(ActionEvent e) { |
212 |
//first of all I update the model
|
213 |
getModel(); |
214 |
if (e.getActionCommand().equals(ADD_RESOURCE_EVENT)){
|
215 |
AddResourceController addResourceCtrl = new AddResourceController();
|
216 |
addResourceCtrl.setPublication(publication); |
217 |
addResourceCtrl.showWindow(); |
218 |
} |
219 |
} |
220 |
/**
|
221 |
* @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
|
222 |
*/
|
223 |
public void valueChanged(TreeSelectionEvent e) { |
224 |
Object source = null; |
225 |
if (e.getNewLeadSelectionPath() == null){ |
226 |
source = e.getOldLeadSelectionPath().getLastPathComponent(); |
227 |
}else{
|
228 |
source = e.getNewLeadSelectionPath().getLastPathComponent(); |
229 |
} |
230 |
//update the model
|
231 |
getModel(); |
232 |
currentRemoteResource = (RemoteResource)source; |
233 |
//update gui
|
234 |
setPanels(); |
235 |
} |
236 |
/**
|
237 |
* Change tab method
|
238 |
* @param e
|
239 |
*/
|
240 |
public void stateChanged(ChangeEvent e) { |
241 |
getModel(); |
242 |
int tab = panel.getSelectedTab();
|
243 |
if (tab==0){ |
244 |
panel.setEnabledPrevButton(false);
|
245 |
}else{
|
246 |
panel.setEnabledPrevButton(true);
|
247 |
} |
248 |
if (tab==2){ |
249 |
panel.setEnabledNextButton(false);
|
250 |
//if there isn't resource the addresource use case is called
|
251 |
if (publication.getServer().getService(0).getRemoteResourcesCount() == 0){ |
252 |
AddResourceController addResourceCtrl = new AddResourceController();
|
253 |
addResourceCtrl.setPublication(publication); |
254 |
addResourceCtrl.showWindow(); |
255 |
panel.setSelectedTab(2);
|
256 |
} |
257 |
}else{
|
258 |
panel.setEnabledNextButton(true);
|
259 |
} |
260 |
} |
261 |
|
262 |
} |