svn-gvsig-desktop / trunk / extensions / extPublish / src / com / iver / cit / gvsig / publish / gui / SelectServerPanel.java @ 10626
History | View | Annotate | Download (12.1 KB)
1 |
package com.iver.cit.gvsig.publish.gui; |
---|---|
2 |
|
3 |
import java.awt.FlowLayout; |
4 |
import java.awt.GridBagConstraints; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.Insets; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.util.Iterator; |
10 |
import java.util.Set; |
11 |
|
12 |
import javax.swing.DefaultComboBoxModel; |
13 |
import javax.swing.JComboBox; |
14 |
import javax.swing.JLabel; |
15 |
import javax.swing.JPanel; |
16 |
import javax.swing.JTextField; |
17 |
|
18 |
import com.iver.andami.PluginServices; |
19 |
import com.iver.cit.gvsig.publish.Servers; |
20 |
import com.iver.cit.gvsig.publish.servers.GenericServer; |
21 |
import com.iver.utiles.swing.jcomboServer.JComboServer; |
22 |
import com.iver.utiles.swing.jcomboServer.ServerData; |
23 |
|
24 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
25 |
*
|
26 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
27 |
*
|
28 |
* This program is free software; you can redistribute it and/or
|
29 |
* modify it under the terms of the GNU General Public License
|
30 |
* as published by the Free Software Foundation; either version 2
|
31 |
* of the License, or (at your option) any later version.
|
32 |
*
|
33 |
* This program is distributed in the hope that it will be useful,
|
34 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
35 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
36 |
* GNU General Public License for more details.
|
37 |
*
|
38 |
* You should have received a copy of the GNU General Public License
|
39 |
* along with this program; if not, write to the Free Software
|
40 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
41 |
*
|
42 |
* For more information, contact:
|
43 |
*
|
44 |
* Generalitat Valenciana
|
45 |
* Conselleria d'Infraestructures i Transport
|
46 |
* Av. Blasco Ib??ez, 50
|
47 |
* 46010 VALENCIA
|
48 |
* SPAIN
|
49 |
*
|
50 |
* +34 963862235
|
51 |
* gvsig@gva.es
|
52 |
* www.gvsig.gva.es
|
53 |
*
|
54 |
* or
|
55 |
*
|
56 |
* IVER T.I. S.A
|
57 |
* Salamanca 50
|
58 |
* 46005 Valencia
|
59 |
* Spain
|
60 |
*
|
61 |
* +34 963163400
|
62 |
* dac@iver.es
|
63 |
*/
|
64 |
/* CVS MESSAGES:
|
65 |
*
|
66 |
* $Id: SelectServerPanel.java 10626 2007-03-06 16:55:54Z caballero $
|
67 |
* $Log$
|
68 |
* Revision 1.6 2007-03-06 16:50:30 caballero
|
69 |
* Exceptions
|
70 |
*
|
71 |
* Revision 1.5 2006/11/22 15:57:03 jorpiell
|
72 |
* Se ha ajustado el interfaz de usuario
|
73 |
*
|
74 |
* Revision 1.4 2006/11/13 08:25:04 dagilgon
|
75 |
* a?adidas "etiquetas" CLASS (completada) y JOIN
|
76 |
*
|
77 |
* Revision 1.3 2006/09/03 14:31:00 jorpiell
|
78 |
* Ahora se cargan todos los datos desde el fichero de configuraci?n. Se han a?adido algunos comentarios
|
79 |
*
|
80 |
* Revision 1.2 2006/09/01 13:40:59 jorpiell
|
81 |
* Primer gran commit de la extension
|
82 |
*
|
83 |
* Revision 1.1 2006/08/31 19:19:04 jorpiell
|
84 |
* *** empty log message ***
|
85 |
*
|
86 |
*
|
87 |
*/
|
88 |
/**
|
89 |
* Select server panel. It implements the first panel for
|
90 |
* the publish service wizard
|
91 |
*
|
92 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
93 |
*/
|
94 |
public class SelectServerPanel extends JPanel{ |
95 |
|
96 |
private JPanel serverNamePanel = null; |
97 |
private JPanel serverOptionsPanel = null; |
98 |
private JComboServer cmbServer = null; |
99 |
private JComboBox cmbServerBrand = null; |
100 |
private JComboBox cmbServerType = null; |
101 |
private JLabel lbUrl = null; |
102 |
private JLabel lbServerBrand = null; |
103 |
private JLabel lbServerType = null; |
104 |
private JPanel serverPathPanel = null; |
105 |
private JLabel lbPath = null; |
106 |
private JTextField tbPath = null; |
107 |
private Servers servers = null; |
108 |
private ServerData currentServer = null; |
109 |
|
110 |
/**
|
111 |
* This method initializes
|
112 |
*
|
113 |
*/
|
114 |
public SelectServerPanel() {
|
115 |
super();
|
116 |
initialize(); |
117 |
} |
118 |
|
119 |
/**
|
120 |
* This method initializes this
|
121 |
*
|
122 |
*/
|
123 |
private void initialize() { |
124 |
this.setLayout(new FlowLayout()); |
125 |
this.setPreferredSize(new java.awt.Dimension(600,150)); |
126 |
this.setSize(new java.awt.Dimension(600,150)); |
127 |
this.add(getServerNamePanel(), null); |
128 |
this.add(getServerOptionsPanel(), null); |
129 |
this.add(getServerPathPanel(), null); |
130 |
|
131 |
} |
132 |
|
133 |
/**
|
134 |
* This method initializes serverNamePanel
|
135 |
*
|
136 |
* @return javax.swing.JPanel
|
137 |
*/
|
138 |
private JPanel getServerNamePanel() { |
139 |
if (serverNamePanel == null) { |
140 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
141 |
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL; |
142 |
gridBagConstraints3.gridx = 1;
|
143 |
gridBagConstraints3.gridy = 0;
|
144 |
gridBagConstraints3.insets = new Insets(0,5,0,5); |
145 |
gridBagConstraints3.weightx = 1.0;
|
146 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
147 |
gridBagConstraints2.gridy = 0;
|
148 |
gridBagConstraints2.gridx = 0;
|
149 |
gridBagConstraints2.insets = new Insets(0,5,0,5); |
150 |
lbUrl = new JLabel(); |
151 |
lbUrl.setText(PluginServices.getText(this, "url")); |
152 |
serverNamePanel = new JPanel(); |
153 |
serverNamePanel.setLayout(new GridBagLayout()); |
154 |
serverNamePanel.setPreferredSize(new java.awt.Dimension(630,22)); |
155 |
serverNamePanel.setSize(new java.awt.Dimension(630,22)); |
156 |
serverNamePanel.add(lbUrl, gridBagConstraints2); |
157 |
serverNamePanel.add(getServerCombo(), gridBagConstraints3); |
158 |
} |
159 |
return serverNamePanel;
|
160 |
} |
161 |
|
162 |
/**
|
163 |
* This method initializes rerverOptionsPanel
|
164 |
*
|
165 |
* @return javax.swing.JPanel
|
166 |
*/
|
167 |
private JPanel getServerOptionsPanel() { |
168 |
if (serverOptionsPanel == null) { |
169 |
lbServerType = new JLabel(); |
170 |
lbServerType.setText(PluginServices.getText(this, "serverType")); |
171 |
lbServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
172 |
lbServerBrand = new JLabel(); |
173 |
lbServerBrand.setText(PluginServices.getText(this, "serverBrand")); |
174 |
lbServerBrand.setPreferredSize(new java.awt.Dimension(45,16)); |
175 |
GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); |
176 |
gridBagConstraints7.fill = java.awt.GridBagConstraints.HORIZONTAL; |
177 |
gridBagConstraints7.gridx = 3;
|
178 |
gridBagConstraints7.gridy = 0;
|
179 |
gridBagConstraints7.weightx = 1.0;
|
180 |
gridBagConstraints7.insets = new java.awt.Insets(5,5,5,5); |
181 |
GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); |
182 |
gridBagConstraints6.fill = java.awt.GridBagConstraints.HORIZONTAL; |
183 |
gridBagConstraints6.gridx = 2;
|
184 |
gridBagConstraints6.gridy = 0;
|
185 |
gridBagConstraints6.weightx = 0.5;
|
186 |
gridBagConstraints6.insets = new java.awt.Insets(5,5,5,5); |
187 |
GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
188 |
gridBagConstraints5.fill = java.awt.GridBagConstraints.HORIZONTAL; |
189 |
gridBagConstraints5.gridx = 1;
|
190 |
gridBagConstraints5.gridy = 0;
|
191 |
gridBagConstraints5.insets = new java.awt.Insets(5,5,5,5); |
192 |
gridBagConstraints5.weightx = 3;
|
193 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
194 |
gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL; |
195 |
gridBagConstraints4.gridx = 0;
|
196 |
gridBagConstraints4.gridy = 0;
|
197 |
gridBagConstraints4.insets = new java.awt.Insets(5,5,5,5); |
198 |
gridBagConstraints4.weightx = 0.5;
|
199 |
serverOptionsPanel = new JPanel(); |
200 |
serverOptionsPanel.setLayout(new GridBagLayout()); |
201 |
serverOptionsPanel.setPreferredSize(new java.awt.Dimension(630,22)); |
202 |
serverOptionsPanel.setSize(new java.awt.Dimension(630,22)); |
203 |
serverOptionsPanel.add(lbServerBrand, gridBagConstraints4); |
204 |
serverOptionsPanel.add(getCmbServerName(), gridBagConstraints5); |
205 |
serverOptionsPanel.add(lbServerType, gridBagConstraints6); |
206 |
serverOptionsPanel.add(getCmbServerType(), gridBagConstraints7); |
207 |
} |
208 |
return serverOptionsPanel;
|
209 |
} |
210 |
|
211 |
/**
|
212 |
* This method initializes serverCombo
|
213 |
*
|
214 |
* @return javax.swing.JComboBox
|
215 |
*/
|
216 |
private JComboServer getServerCombo() {
|
217 |
if (cmbServer == null) { |
218 |
cmbServer = new JComboServer();
|
219 |
cmbServer.setModel(new DefaultComboBoxModel()); |
220 |
cmbServer.setPreferredSize(new java.awt.Dimension(550, 20)); |
221 |
cmbServer.setEditable(true);
|
222 |
} |
223 |
return cmbServer;
|
224 |
} |
225 |
|
226 |
/**
|
227 |
* This method initializes serverNameCombo
|
228 |
*
|
229 |
* @return javax.swing.JComboBox
|
230 |
*/
|
231 |
private JComboBox getCmbServerName() { |
232 |
if (cmbServerBrand == null) { |
233 |
cmbServerBrand = new JComboBox(); |
234 |
cmbServerBrand.setModel(new DefaultComboBoxModel()); |
235 |
cmbServerBrand.setPreferredSize(new java.awt.Dimension(295, 20)); |
236 |
cmbServerBrand.addActionListener(new serverBrandChangeListener());
|
237 |
} |
238 |
return cmbServerBrand;
|
239 |
} |
240 |
|
241 |
/**
|
242 |
* This method initializes serverTypeCombo
|
243 |
*
|
244 |
* @return javax.swing.JComboBox
|
245 |
*/
|
246 |
private JComboBox getCmbServerType() { |
247 |
if (cmbServerType == null) { |
248 |
cmbServerType = new JComboBox(); |
249 |
cmbServerType.setModel(new DefaultComboBoxModel()); |
250 |
cmbServerType.setPreferredSize(new java.awt.Dimension(50, 20)); |
251 |
} |
252 |
return cmbServerType;
|
253 |
} |
254 |
|
255 |
/**
|
256 |
* This method initializes serverPathPanel
|
257 |
*
|
258 |
* @return javax.swing.JPanel
|
259 |
*/
|
260 |
private JPanel getServerPathPanel() { |
261 |
if (serverPathPanel == null) { |
262 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
263 |
gridBagConstraints10.fill = java.awt.GridBagConstraints.HORIZONTAL; |
264 |
gridBagConstraints10.gridx = 1;
|
265 |
gridBagConstraints10.gridy = 0;
|
266 |
gridBagConstraints10.weightx = 1.0;
|
267 |
gridBagConstraints10.insets = new java.awt.Insets(5,5,5,5); |
268 |
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
269 |
gridBagConstraints9.insets = new java.awt.Insets(5,5,5,5); |
270 |
gridBagConstraints9.gridy = 0;
|
271 |
gridBagConstraints9.gridx = 0;
|
272 |
lbPath = new JLabel(); |
273 |
lbPath.setText(PluginServices.getText(this, "server_path")); |
274 |
serverPathPanel = new JPanel(); |
275 |
serverPathPanel.setLayout(new GridBagLayout()); |
276 |
serverPathPanel.setPreferredSize(new java.awt.Dimension(630,22)); |
277 |
serverPathPanel.add(lbPath, gridBagConstraints9); |
278 |
serverPathPanel.add(getTbPath(), gridBagConstraints10); |
279 |
} |
280 |
return serverPathPanel;
|
281 |
} |
282 |
|
283 |
/**
|
284 |
* This method initializes tbPath
|
285 |
*
|
286 |
* @return javax.swing.JTextField
|
287 |
*/
|
288 |
private JTextField getTbPath() { |
289 |
if (tbPath == null) { |
290 |
tbPath = new JTextField(); |
291 |
} |
292 |
return tbPath;
|
293 |
} |
294 |
|
295 |
/**
|
296 |
* Fills the combos
|
297 |
* @param servers
|
298 |
*/
|
299 |
public void setServers(Servers servers){ |
300 |
this.servers = servers;
|
301 |
Set brands = servers.getBrands();
|
302 |
Iterator it = brands.iterator();
|
303 |
while (it.hasNext()) {
|
304 |
getCmbServerName().addItem(it.next()); |
305 |
} |
306 |
} |
307 |
|
308 |
/**
|
309 |
* Gest the server brand
|
310 |
*/
|
311 |
public String getServerBrand(){ |
312 |
return (String)getCmbServerName().getSelectedItem(); |
313 |
} |
314 |
|
315 |
/**
|
316 |
* Gest the server type
|
317 |
*/
|
318 |
public String getServerType(){ |
319 |
return (String)getCmbServerType().getSelectedItem(); |
320 |
} |
321 |
|
322 |
/**
|
323 |
* Gest the server URL
|
324 |
*/
|
325 |
public String getServerURL(){ |
326 |
return getServerCombo().getSelectedItem().toString();
|
327 |
} |
328 |
|
329 |
/**
|
330 |
* Gest the server path
|
331 |
*/
|
332 |
public String getServerPath(){ |
333 |
return getTbPath().getText();
|
334 |
} |
335 |
|
336 |
/**
|
337 |
* Sert a list of servers retrieved from the plugins-persistence
|
338 |
* file.
|
339 |
*/
|
340 |
public void setServersList(ServerData[] servers){ |
341 |
getServerCombo().setServerList(servers); |
342 |
cmbServer.addActionListener(new serverUrlChangeListener());
|
343 |
currentServerChanged(); |
344 |
} |
345 |
|
346 |
/**
|
347 |
* @return Returns the currentServer.
|
348 |
*/
|
349 |
public ServerData getCurrentServer() {
|
350 |
return currentServer;
|
351 |
} |
352 |
|
353 |
/**
|
354 |
* This method actualizes the current server information
|
355 |
* when the url combo changes.
|
356 |
*/
|
357 |
private void currentServerChanged(){ |
358 |
currentServer = getServerCombo().getSelectedServer(); |
359 |
if (currentServer != null){ |
360 |
if (servers.getGenericServer(currentServer.getProperty(GenericServer.GENERIC_SERVER_BRAND)) != null){ |
361 |
getCmbServerName().setSelectedItem(currentServer.getProperty(GenericServer.GENERIC_SERVER_BRAND)); |
362 |
if (servers.getGenericServer(currentServer.getProperty(GenericServer.GENERIC_SERVER_BRAND))
|
363 |
.getJPanel(currentServer.getServiceType()) != null){
|
364 |
getCmbServerType().setSelectedItem(currentServer.getServiceType()); |
365 |
} |
366 |
} |
367 |
getTbPath().setText(currentServer.getProperty(GenericServer.GENERIC_SERVER_PATH)); |
368 |
} |
369 |
} |
370 |
|
371 |
/**
|
372 |
* Listener for the server brand combo
|
373 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
374 |
*
|
375 |
*/
|
376 |
private class serverBrandChangeListener implements ActionListener{ |
377 |
public void actionPerformed(ActionEvent e) { |
378 |
getCmbServerType().removeAllItems(); |
379 |
if (getCmbServerName().getModel().getSize() > 0){ |
380 |
String genericServer = (String)getCmbServerName(). |
381 |
getModel().getSelectedItem(); |
382 |
Set services = servers.getGenericServer(genericServer).getServices();
|
383 |
Iterator it = services.iterator();
|
384 |
while (it.hasNext()) {
|
385 |
getCmbServerType().addItem(it.next()); |
386 |
} |
387 |
} |
388 |
|
389 |
} |
390 |
} |
391 |
|
392 |
/**
|
393 |
* Listener for the url combo
|
394 |
*
|
395 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
396 |
*/
|
397 |
private class serverUrlChangeListener implements ActionListener{ |
398 |
public void actionPerformed(ActionEvent e) { |
399 |
currentServerChanged(); |
400 |
} |
401 |
} |
402 |
|
403 |
|
404 |
|
405 |
} // @jve:decl-index=0:visual-constraint="10,10"
|