gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.app / org.gvsig.vcsgis.app.server / src / main / java / org / gvsig / vcsgis / app / server / VCSGisServerPanelView.java @ 8713
History | View | Annotate | Download (8.3 KB)
1 |
package org.gvsig.vcsgis.app.server; |
---|---|
2 |
|
3 |
import com.jeta.open.i18n.I18NUtils; |
4 |
import com.jgoodies.forms.layout.CellConstraints; |
5 |
import com.jgoodies.forms.layout.FormLayout; |
6 |
import java.awt.BorderLayout; |
7 |
import java.awt.ComponentOrientation; |
8 |
import java.awt.Container; |
9 |
import java.awt.Dimension; |
10 |
import javax.swing.Box; |
11 |
import javax.swing.ImageIcon; |
12 |
import javax.swing.JButton; |
13 |
import javax.swing.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.JScrollPane; |
18 |
import javax.swing.JTextArea; |
19 |
import javax.swing.JTextField; |
20 |
import javax.swing.border.EmptyBorder; |
21 |
|
22 |
|
23 |
public class VCSGisServerPanelView extends JPanel |
24 |
{ |
25 |
JLabel lblPort = new JLabel(); |
26 |
JTextField txtPort = new JTextField(); |
27 |
JLabel lblMessages = new JLabel(); |
28 |
JTextArea txtLog = new JTextArea(); |
29 |
JLabel lblDatabase = new JLabel(); |
30 |
JButton btnStop = new JButton(); |
31 |
JButton btnRestart = new JButton(); |
32 |
JButton btnAddConnection = new JButton(); |
33 |
JComboBox cboConnections = new JComboBox(); |
34 |
JLabel lblDebugFile = new JLabel(); |
35 |
JTextField txtDebugFile = new JTextField(); |
36 |
JButton btnDebugFile = new JButton(); |
37 |
|
38 |
/**
|
39 |
* Default constructor
|
40 |
*/
|
41 |
public VCSGisServerPanelView()
|
42 |
{ |
43 |
initializePanel(); |
44 |
} |
45 |
|
46 |
/**
|
47 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
48 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
49 |
* @param cols an array of column indices in the first row where fill components should be added.
|
50 |
* @param rows an array of row indices in the first column where fill components should be added.
|
51 |
*/
|
52 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
53 |
{ |
54 |
Dimension filler = new Dimension(10,10); |
55 |
|
56 |
boolean filled_cell_11 = false; |
57 |
CellConstraints cc = new CellConstraints();
|
58 |
if ( cols.length > 0 && rows.length > 0 ) |
59 |
{ |
60 |
if ( cols[0] == 1 && rows[0] == 1 ) |
61 |
{ |
62 |
/** add a rigid area */
|
63 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
64 |
filled_cell_11 = true;
|
65 |
} |
66 |
} |
67 |
|
68 |
for( int index = 0; index < cols.length; index++ ) |
69 |
{ |
70 |
if ( cols[index] == 1 && filled_cell_11 ) |
71 |
{ |
72 |
continue;
|
73 |
} |
74 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
75 |
} |
76 |
|
77 |
for( int index = 0; index < rows.length; index++ ) |
78 |
{ |
79 |
if ( rows[index] == 1 && filled_cell_11 ) |
80 |
{ |
81 |
continue;
|
82 |
} |
83 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
84 |
} |
85 |
|
86 |
} |
87 |
|
88 |
/**
|
89 |
* Helper method to load an image file from the CLASSPATH
|
90 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
91 |
* @return an ImageIcon instance with the specified image file
|
92 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
93 |
*/
|
94 |
public ImageIcon loadImage( String imageName ) |
95 |
{ |
96 |
try
|
97 |
{ |
98 |
ClassLoader classloader = getClass().getClassLoader();
|
99 |
java.net.URL url = classloader.getResource( imageName ); |
100 |
if ( url != null ) |
101 |
{ |
102 |
ImageIcon icon = new ImageIcon( url ); |
103 |
return icon;
|
104 |
} |
105 |
} |
106 |
catch( Exception e ) |
107 |
{ |
108 |
e.printStackTrace(); |
109 |
} |
110 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
111 |
} |
112 |
|
113 |
/**
|
114 |
* Method for recalculating the component orientation for
|
115 |
* right-to-left Locales.
|
116 |
* @param orientation the component orientation to be applied
|
117 |
*/
|
118 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
119 |
{ |
120 |
// Not yet implemented...
|
121 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
122 |
super.applyComponentOrientation(orientation);
|
123 |
} |
124 |
|
125 |
public JPanel createPanel() |
126 |
{ |
127 |
JPanel jpanel1 = new JPanel(); |
128 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE"); |
129 |
CellConstraints cc = new CellConstraints();
|
130 |
jpanel1.setLayout(formlayout1); |
131 |
|
132 |
jpanel1.add(createPanel1(),cc.xy(2,2)); |
133 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 }); |
134 |
return jpanel1;
|
135 |
} |
136 |
|
137 |
public JPanel createPanel1() |
138 |
{ |
139 |
JPanel jpanel1 = new JPanel(); |
140 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
141 |
CellConstraints cc = new CellConstraints();
|
142 |
jpanel1.setLayout(formlayout1); |
143 |
|
144 |
lblPort.setName("lblPort");
|
145 |
lblPort.setText("_Port");
|
146 |
jpanel1.add(lblPort,cc.xy(1,3)); |
147 |
|
148 |
txtPort.setName("txtPort");
|
149 |
txtPort.setHorizontalAlignment(JTextField.RIGHT);
|
150 |
jpanel1.add(txtPort,cc.xywh(3,3,3,1)); |
151 |
|
152 |
lblMessages.setName("lblMessages");
|
153 |
lblMessages.setText("_Messages");
|
154 |
jpanel1.add(lblMessages,cc.xy(1,7)); |
155 |
|
156 |
txtLog.setName("txtLog");
|
157 |
JScrollPane jscrollpane1 = new JScrollPane(); |
158 |
jscrollpane1.setViewportView(txtLog); |
159 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
160 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
161 |
jpanel1.add(jscrollpane1,cc.xywh(1,9,5,1)); |
162 |
|
163 |
lblDatabase.setName("lblDatabase");
|
164 |
lblDatabase.setText("_Database");
|
165 |
jpanel1.add(lblDatabase,cc.xy(1,1)); |
166 |
|
167 |
jpanel1.add(createPanel2(),cc.xywh(1,11,5,1)); |
168 |
btnAddConnection.setActionCommand("...");
|
169 |
btnAddConnection.setName("btnAddConnection");
|
170 |
btnAddConnection.setOpaque(false);
|
171 |
btnAddConnection.setText("...");
|
172 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
173 |
btnAddConnection.setBorder(emptyborder1); |
174 |
jpanel1.add(btnAddConnection,cc.xy(5,1)); |
175 |
|
176 |
cboConnections.setName("cboConnections");
|
177 |
cboConnections.setOpaque(false);
|
178 |
jpanel1.add(cboConnections,cc.xy(3,1)); |
179 |
|
180 |
lblDebugFile.setName("lblDebugFile");
|
181 |
lblDebugFile.setText("_Debug_file");
|
182 |
jpanel1.add(lblDebugFile,cc.xy(1,5)); |
183 |
|
184 |
jpanel1.add(createPanel3(),cc.xy(3,5)); |
185 |
addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2,4,6,8,10,11 }); |
186 |
return jpanel1;
|
187 |
} |
188 |
|
189 |
public JPanel createPanel2() |
190 |
{ |
191 |
JPanel jpanel1 = new JPanel(); |
192 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
193 |
CellConstraints cc = new CellConstraints();
|
194 |
jpanel1.setLayout(formlayout1); |
195 |
|
196 |
btnStop.setActionCommand("Stop");
|
197 |
btnStop.setIcon(loadImage("common-stop.png"));
|
198 |
btnStop.setName("btnStop");
|
199 |
btnStop.setOpaque(false);
|
200 |
btnStop.setText("_Stop");
|
201 |
btnStop.setToolTipText("_Stop_the_data_service");
|
202 |
jpanel1.add(btnStop,cc.xy(6,1)); |
203 |
|
204 |
btnRestart.setActionCommand("Restart");
|
205 |
btnRestart.setIcon(loadImage("common-start.png"));
|
206 |
btnRestart.setName("btnRestart");
|
207 |
btnRestart.setOpaque(false);
|
208 |
btnRestart.setText("_Restart");
|
209 |
btnRestart.setToolTipText("_Restart_the_data_service");
|
210 |
jpanel1.add(btnRestart,cc.xy(4,1)); |
211 |
|
212 |
addFillComponents(jpanel1,new int[]{ 1,2,3,5 },new int[]{ 1 }); |
213 |
return jpanel1;
|
214 |
} |
215 |
|
216 |
public JPanel createPanel3() |
217 |
{ |
218 |
JPanel jpanel1 = new JPanel(); |
219 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
220 |
CellConstraints cc = new CellConstraints();
|
221 |
jpanel1.setLayout(formlayout1); |
222 |
|
223 |
txtDebugFile.setName("txtDebugFile");
|
224 |
jpanel1.add(txtDebugFile,cc.xy(1,1)); |
225 |
|
226 |
btnDebugFile.setActionCommand("...");
|
227 |
btnDebugFile.setName("btnDebugFile");
|
228 |
btnDebugFile.setOpaque(false);
|
229 |
btnDebugFile.setText("...");
|
230 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
231 |
btnDebugFile.setBorder(emptyborder1); |
232 |
jpanel1.add(btnDebugFile,cc.xy(3,1)); |
233 |
|
234 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
235 |
return jpanel1;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* Initializer
|
240 |
*/
|
241 |
protected void initializePanel() |
242 |
{ |
243 |
setLayout(new BorderLayout()); |
244 |
add(createPanel(), BorderLayout.CENTER);
|
245 |
} |
246 |
|
247 |
|
248 |
} |