root / trunk / extensions / extPublish / src / com / iver / cit / gvsig / publish / gui / OptionsServerControlsPanel.java @ 6977
History | View | Annotate | Download (5.65 KB)
1 |
package com.iver.cit.gvsig.publish.gui; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.FlowLayout; |
5 |
import java.awt.event.ActionListener; |
6 |
import java.lang.reflect.InvocationTargetException; |
7 |
import java.util.Properties; |
8 |
|
9 |
import javax.swing.JButton; |
10 |
import javax.swing.JPanel; |
11 |
|
12 |
import com.iver.andami.PluginServices; |
13 |
import com.iver.cit.gvsig.publish.servers.ServicePanel; |
14 |
import com.iver.cit.gvsig.publish.servers.mapserver.ServiceWMSPanel; |
15 |
|
16 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
17 |
*
|
18 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
19 |
*
|
20 |
* This program is free software; you can redistribute it and/or
|
21 |
* modify it under the terms of the GNU General Public License
|
22 |
* as published by the Free Software Foundation; either version 2
|
23 |
* of the License, or (at your option) any later version.
|
24 |
*
|
25 |
* This program is distributed in the hope that it will be useful,
|
26 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
* GNU General Public License for more details.
|
29 |
*
|
30 |
* You should have received a copy of the GNU General Public License
|
31 |
* along with this program; if not, write to the Free Software
|
32 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
33 |
*
|
34 |
* For more information, contact:
|
35 |
*
|
36 |
* Generalitat Valenciana
|
37 |
* Conselleria d'Infraestructures i Transport
|
38 |
* Av. Blasco Ib??ez, 50
|
39 |
* 46010 VALENCIA
|
40 |
* SPAIN
|
41 |
*
|
42 |
* +34 963862235
|
43 |
* gvsig@gva.es
|
44 |
* www.gvsig.gva.es
|
45 |
*
|
46 |
* or
|
47 |
*
|
48 |
* IVER T.I. S.A
|
49 |
* Salamanca 50
|
50 |
* 46005 Valencia
|
51 |
* Spain
|
52 |
*
|
53 |
* +34 963163400
|
54 |
* dac@iver.es
|
55 |
*/
|
56 |
/* CVS MESSAGES:
|
57 |
*
|
58 |
* $Id: OptionsServerControlsPanel.java 6977 2006-09-01 13:40:59Z jorpiell $
|
59 |
* $Log$
|
60 |
* Revision 1.2 2006-09-01 13:40:59 jorpiell
|
61 |
* Primer gran commit de la extension
|
62 |
*
|
63 |
* Revision 1.1 2006/08/31 19:19:04 jorpiell
|
64 |
* *** empty log message ***
|
65 |
*
|
66 |
*
|
67 |
*/
|
68 |
/**
|
69 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
70 |
*/
|
71 |
public class OptionsServerControlsPanel extends JPanel{ |
72 |
private ServicePanel serverOptionsPanel = null; |
73 |
private JPanel buttonsPanel = null; |
74 |
private JButton lastButton = null; |
75 |
private JButton acceptButton = null; |
76 |
|
77 |
/**
|
78 |
* This method initializes
|
79 |
*
|
80 |
*/
|
81 |
public OptionsServerControlsPanel(Class controlsPanel) { |
82 |
super();
|
83 |
serverOptionsPanel = createControlsPanel(controlsPanel); |
84 |
initialize(); |
85 |
} |
86 |
|
87 |
private ServicePanel createControlsPanel(Class clazz){ |
88 |
Class [] args = {}; |
89 |
Object [] params = {}; |
90 |
try {
|
91 |
ServicePanel panel = (ServicePanel)clazz.getConstructor(args).newInstance(params); |
92 |
panel.setPreferredSize(panel.getPreferredSize()); |
93 |
panel.setSize(panel.getSize()); |
94 |
return panel;
|
95 |
} catch (IllegalArgumentException e) { |
96 |
// TODO Auto-generated catch block
|
97 |
e.printStackTrace(); |
98 |
} catch (SecurityException e) { |
99 |
// TODO Auto-generated catch block
|
100 |
e.printStackTrace(); |
101 |
} catch (InstantiationException e) { |
102 |
// TODO Auto-generated catch block
|
103 |
e.printStackTrace(); |
104 |
} catch (IllegalAccessException e) { |
105 |
// TODO Auto-generated catch block
|
106 |
e.printStackTrace(); |
107 |
} catch (InvocationTargetException e) { |
108 |
// TODO Auto-generated catch block
|
109 |
e.printStackTrace(); |
110 |
} catch (NoSuchMethodException e) { |
111 |
// TODO Auto-generated catch block
|
112 |
e.printStackTrace(); |
113 |
} |
114 |
return null; |
115 |
} |
116 |
|
117 |
/**
|
118 |
* This method initializes this
|
119 |
*
|
120 |
*/
|
121 |
private void initialize() { |
122 |
this.setLayout(new FlowLayout()); |
123 |
this.setPreferredSize(calculateDimension());
|
124 |
this.add(getServerOptionsPanel(), null); |
125 |
this.add(getButtonsPanel(), null); |
126 |
} |
127 |
|
128 |
private Dimension calculateDimension(){ |
129 |
Dimension dimension = new Dimension(); |
130 |
double width = getServerOptionsPanel().getPreferredSize().getWidth() + 20; |
131 |
double height = getServerOptionsPanel().getPreferredSize().getHeight() + 30; |
132 |
dimension.setSize(width,height); |
133 |
return dimension;
|
134 |
} |
135 |
|
136 |
/**
|
137 |
* This method initializes serverOptionsPanel
|
138 |
*
|
139 |
* @return javax.swing.JPanel
|
140 |
*/
|
141 |
private ServicePanel getServerOptionsPanel() {
|
142 |
if (serverOptionsPanel == null) { |
143 |
serverOptionsPanel = new ServiceWMSPanel();
|
144 |
serverOptionsPanel.setPreferredSize(new Dimension(500,20)); |
145 |
serverOptionsPanel.setName("serverOptionsPanel");
|
146 |
} |
147 |
return serverOptionsPanel;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* This method initializes buttonsPanel
|
152 |
*
|
153 |
* @return javax.swing.JPanel
|
154 |
*/
|
155 |
private JPanel getButtonsPanel() { |
156 |
if (buttonsPanel == null) { |
157 |
FlowLayout flowLayout = new FlowLayout(); |
158 |
flowLayout.setAlignment(java.awt.FlowLayout.RIGHT); |
159 |
buttonsPanel = new JPanel(); |
160 |
buttonsPanel.setPreferredSize(new java.awt.Dimension(500,30)); |
161 |
buttonsPanel.setName("buttonsPanel");
|
162 |
buttonsPanel.setLayout(flowLayout); |
163 |
buttonsPanel.add(getLastButton(), null);
|
164 |
buttonsPanel.add(getAcceptButton(), null);
|
165 |
} |
166 |
return buttonsPanel;
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* This method initializes lastButton
|
171 |
*
|
172 |
* @return javax.swing.JButton
|
173 |
*/
|
174 |
private JButton getLastButton() { |
175 |
if (lastButton == null) { |
176 |
lastButton = new JButton(); |
177 |
lastButton.setText(PluginServices.getText(this, "last")); |
178 |
lastButton.setPreferredSize(new Dimension(100,20)); |
179 |
lastButton.setActionCommand("last");
|
180 |
} |
181 |
return lastButton;
|
182 |
} |
183 |
|
184 |
/**
|
185 |
* This method initializes acceptButton
|
186 |
*
|
187 |
* @return javax.swing.JButton
|
188 |
*/
|
189 |
private JButton getAcceptButton() { |
190 |
if (acceptButton == null) { |
191 |
acceptButton = new JButton(); |
192 |
acceptButton.setText(PluginServices.getText(this, "accept")); |
193 |
acceptButton.setPreferredSize(new Dimension(100,20)); |
194 |
acceptButton.setActionCommand("accept");
|
195 |
} |
196 |
return acceptButton;
|
197 |
} |
198 |
|
199 |
public void addButtonsListener(ActionListener listener){ |
200 |
getLastButton().addActionListener(listener); |
201 |
getAcceptButton().addActionListener(listener); |
202 |
} |
203 |
|
204 |
public Properties getServerProperties(){ |
205 |
return serverOptionsPanel.getProperties();
|
206 |
} |
207 |
|
208 |
} |