gvsig-projects-pool / org.gvsig.online / trunk / org.gvsig.online / org.gvsig.online.swing / org.gvsig.online.swing.impl / src / main / java / org / gvsig / online / swing / impl / initworkspace / OnlineJInitWorkingcopyView.java @ 9512
History | View | Annotate | Download (13 KB)
1 |
package org.gvsig.online.swing.impl.initworkspace; |
---|---|
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.JCheckBox; |
14 |
import javax.swing.JComboBox; |
15 |
import javax.swing.JFrame; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JPanel; |
18 |
import javax.swing.JProgressBar; |
19 |
import javax.swing.JScrollPane; |
20 |
import javax.swing.JTable; |
21 |
import javax.swing.JTextField; |
22 |
import javax.swing.border.EmptyBorder; |
23 |
|
24 |
|
25 |
public class OnlineJInitWorkingcopyView extends JPanel |
26 |
{ |
27 |
JLabel lblSiteUrl = new JLabel(); |
28 |
JLabel lblProjects = new JLabel(); |
29 |
JLabel lblWorkspaceFile = new JLabel(); |
30 |
JLabel lblWorkspaceName = new JLabel(); |
31 |
JLabel lblLayers = new JLabel(); |
32 |
JTable tblLayers = new JTable(); |
33 |
JLabel lblWorkingArea = new JLabel(); |
34 |
JComboBox cboProjects = new JComboBox(); |
35 |
JTextField txtWorkspaceName = new JTextField(); |
36 |
JCheckBox chkCreateConnectionToDatabase = new JCheckBox(); |
37 |
JTextField txtWorkspaceFile = new JTextField(); |
38 |
JButton btnWorkspaceFile = new JButton(); |
39 |
JTextField txtWorkingAreaLabel = new JTextField(); |
40 |
JTextField txtWorkingArea = new JTextField(); |
41 |
JButton btnWorkingAreaFromView = new JButton(); |
42 |
JButton btnWorkingAreaDialog = new JButton(); |
43 |
JButton btnWorkingAreaHistory = new JButton(); |
44 |
JButton btnWorkingAreaBookmarks = new JButton(); |
45 |
JButton btnSiteURLHistory = new JButton(); |
46 |
JButton btnSiteURLBookmarks = new JButton(); |
47 |
JTextField txtSiteURL = new JTextField(); |
48 |
JButton btnSiteURLRefresh = new JButton(); |
49 |
JLabel lblStatusTitle = new JLabel(); |
50 |
JProgressBar pbStatus = new JProgressBar(); |
51 |
JLabel lblStatusMessages = new JLabel(); |
52 |
JButton btnStatusCancel = new JButton(); |
53 |
|
54 |
/**
|
55 |
* Default constructor
|
56 |
*/
|
57 |
public OnlineJInitWorkingcopyView()
|
58 |
{ |
59 |
initializePanel(); |
60 |
} |
61 |
|
62 |
/**
|
63 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
64 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
65 |
* @param cols an array of column indices in the first row where fill components should be added.
|
66 |
* @param rows an array of row indices in the first column where fill components should be added.
|
67 |
*/
|
68 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
69 |
{ |
70 |
Dimension filler = new Dimension(10,10); |
71 |
|
72 |
boolean filled_cell_11 = false; |
73 |
CellConstraints cc = new CellConstraints();
|
74 |
if ( cols.length > 0 && rows.length > 0 ) |
75 |
{ |
76 |
if ( cols[0] == 1 && rows[0] == 1 ) |
77 |
{ |
78 |
/** add a rigid area */
|
79 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
80 |
filled_cell_11 = true;
|
81 |
} |
82 |
} |
83 |
|
84 |
for( int index = 0; index < cols.length; index++ ) |
85 |
{ |
86 |
if ( cols[index] == 1 && filled_cell_11 ) |
87 |
{ |
88 |
continue;
|
89 |
} |
90 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
91 |
} |
92 |
|
93 |
for( int index = 0; index < rows.length; index++ ) |
94 |
{ |
95 |
if ( rows[index] == 1 && filled_cell_11 ) |
96 |
{ |
97 |
continue;
|
98 |
} |
99 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
100 |
} |
101 |
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* Helper method to load an image file from the CLASSPATH
|
106 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
107 |
* @return an ImageIcon instance with the specified image file
|
108 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
109 |
*/
|
110 |
public ImageIcon loadImage( String imageName ) |
111 |
{ |
112 |
try
|
113 |
{ |
114 |
ClassLoader classloader = getClass().getClassLoader();
|
115 |
java.net.URL url = classloader.getResource( imageName ); |
116 |
if ( url != null ) |
117 |
{ |
118 |
ImageIcon icon = new ImageIcon( url ); |
119 |
return icon;
|
120 |
} |
121 |
} |
122 |
catch( Exception e ) |
123 |
{ |
124 |
e.printStackTrace(); |
125 |
} |
126 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
127 |
} |
128 |
|
129 |
/**
|
130 |
* Method for recalculating the component orientation for
|
131 |
* right-to-left Locales.
|
132 |
* @param orientation the component orientation to be applied
|
133 |
*/
|
134 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
135 |
{ |
136 |
// Not yet implemented...
|
137 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
138 |
super.applyComponentOrientation(orientation);
|
139 |
} |
140 |
|
141 |
public JPanel createPanel() |
142 |
{ |
143 |
JPanel jpanel1 = new JPanel(); |
144 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER: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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
145 |
CellConstraints cc = new CellConstraints();
|
146 |
jpanel1.setLayout(formlayout1); |
147 |
|
148 |
lblSiteUrl.setName("lblSiteUrl");
|
149 |
lblSiteUrl.setText("Url del servidor");
|
150 |
jpanel1.add(lblSiteUrl,cc.xy(2,2)); |
151 |
|
152 |
lblProjects.setName("lblProjects");
|
153 |
lblProjects.setText("Proyecto");
|
154 |
jpanel1.add(lblProjects,cc.xy(2,4)); |
155 |
|
156 |
lblWorkspaceFile.setName("lblWorkspaceFile");
|
157 |
lblWorkspaceFile.setText("Fichero local");
|
158 |
jpanel1.add(lblWorkspaceFile,cc.xy(2,6)); |
159 |
|
160 |
lblWorkspaceName.setName("lblWorkspaceName");
|
161 |
lblWorkspaceName.setText("Nombre");
|
162 |
jpanel1.add(lblWorkspaceName,cc.xy(2,10)); |
163 |
|
164 |
lblLayers.setName("lblLayers");
|
165 |
lblLayers.setText("Capas");
|
166 |
jpanel1.add(lblLayers,cc.xy(2,12)); |
167 |
|
168 |
tblLayers.setName("tblLayers");
|
169 |
JScrollPane jscrollpane1 = new JScrollPane(); |
170 |
jscrollpane1.setViewportView(tblLayers); |
171 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
172 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
173 |
jpanel1.add(jscrollpane1,cc.xywh(2,14,3,1)); |
174 |
|
175 |
lblWorkingArea.setName("lblWorkingArea");
|
176 |
lblWorkingArea.setText("_Working_area");
|
177 |
jpanel1.add(lblWorkingArea,new CellConstraints(2,16,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); |
178 |
|
179 |
cboProjects.setName("cboProjects");
|
180 |
jpanel1.add(cboProjects,cc.xy(4,4)); |
181 |
|
182 |
txtWorkspaceName.setName("txtWorkspaceName");
|
183 |
txtWorkspaceName.setSelectionEnd(7);
|
184 |
txtWorkspaceName.setSelectionStart(7);
|
185 |
txtWorkspaceName.setText("Pruebas");
|
186 |
jpanel1.add(txtWorkspaceName,cc.xy(4,10)); |
187 |
|
188 |
chkCreateConnectionToDatabase.setActionCommand("_Create_conexion_to_database");
|
189 |
chkCreateConnectionToDatabase.setName("chkCreateConnectionToDatabase");
|
190 |
chkCreateConnectionToDatabase.setSelected(true);
|
191 |
chkCreateConnectionToDatabase.setText("_Create_conexion_to_database");
|
192 |
chkCreateConnectionToDatabase.setHorizontalAlignment(JCheckBox.LEFT);
|
193 |
jpanel1.add(chkCreateConnectionToDatabase,cc.xy(4,8)); |
194 |
|
195 |
jpanel1.add(createPanel1(),cc.xy(4,6)); |
196 |
jpanel1.add(createPanel2(),cc.xy(4,16)); |
197 |
jpanel1.add(createPanel3(),cc.xy(4,2)); |
198 |
jpanel1.add(createPanel4(),cc.xywh(2,18,3,1)); |
199 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 }); |
200 |
return jpanel1;
|
201 |
} |
202 |
|
203 |
public JPanel createPanel1() |
204 |
{ |
205 |
JPanel jpanel1 = new JPanel(); |
206 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
207 |
CellConstraints cc = new CellConstraints();
|
208 |
jpanel1.setLayout(formlayout1); |
209 |
|
210 |
txtWorkspaceFile.setName("txtWorkspaceFile");
|
211 |
jpanel1.add(txtWorkspaceFile,cc.xy(1,1)); |
212 |
|
213 |
btnWorkspaceFile.setActionCommand("...");
|
214 |
btnWorkspaceFile.setName("btnWorkspaceFile");
|
215 |
btnWorkspaceFile.setText("...");
|
216 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
217 |
btnWorkspaceFile.setBorder(emptyborder1); |
218 |
jpanel1.add(btnWorkspaceFile,cc.xy(3,1)); |
219 |
|
220 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
221 |
return jpanel1;
|
222 |
} |
223 |
|
224 |
public JPanel createPanel2() |
225 |
{ |
226 |
JPanel jpanel1 = new JPanel(); |
227 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
228 |
CellConstraints cc = new CellConstraints();
|
229 |
jpanel1.setLayout(formlayout1); |
230 |
|
231 |
txtWorkingAreaLabel.setName("txtWorkingAreaLabel");
|
232 |
jpanel1.add(txtWorkingAreaLabel,cc.xy(1,1)); |
233 |
|
234 |
txtWorkingArea.setName("txtWorkingArea");
|
235 |
jpanel1.add(txtWorkingArea,cc.xy(1,3)); |
236 |
|
237 |
btnWorkingAreaFromView.setActionCommand("...");
|
238 |
btnWorkingAreaFromView.setIcon(loadImage("org.gvsig.online/org.gvsig.online.swing/org.gvsig.online.swing.impl/src/main/resources/org/gvsig/online/swing/impl/images/picker-envelope-from-mapcontrol.png"));
|
239 |
btnWorkingAreaFromView.setName("btnWorkingAreaFromView");
|
240 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
241 |
btnWorkingAreaFromView.setBorder(emptyborder1); |
242 |
jpanel1.add(btnWorkingAreaFromView,cc.xy(3,3)); |
243 |
|
244 |
btnWorkingAreaDialog.setActionCommand("...");
|
245 |
btnWorkingAreaDialog.setIcon(loadImage("addons/onlinecaptures/images/picker-envelope-from-mapcontrol.png"));
|
246 |
btnWorkingAreaDialog.setName("btnWorkingAreaDialog");
|
247 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
248 |
btnWorkingAreaDialog.setBorder(emptyborder2); |
249 |
jpanel1.add(btnWorkingAreaDialog,cc.xy(5,3)); |
250 |
|
251 |
btnWorkingAreaHistory.setActionCommand("...");
|
252 |
btnWorkingAreaHistory.setName("btnWorkingAreaHistory");
|
253 |
btnWorkingAreaHistory.setText("...");
|
254 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
255 |
btnWorkingAreaHistory.setBorder(emptyborder3); |
256 |
jpanel1.add(btnWorkingAreaHistory,cc.xy(3,1)); |
257 |
|
258 |
btnWorkingAreaBookmarks.setActionCommand("...");
|
259 |
btnWorkingAreaBookmarks.setName("btnWorkingAreaBookmarks");
|
260 |
btnWorkingAreaBookmarks.setText("...");
|
261 |
EmptyBorder emptyborder4 = new EmptyBorder(2,2,2,2); |
262 |
btnWorkingAreaBookmarks.setBorder(emptyborder4); |
263 |
jpanel1.add(btnWorkingAreaBookmarks,cc.xy(5,1)); |
264 |
|
265 |
addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2 }); |
266 |
return jpanel1;
|
267 |
} |
268 |
|
269 |
public JPanel createPanel3() |
270 |
{ |
271 |
JPanel jpanel1 = new JPanel(); |
272 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
273 |
CellConstraints cc = new CellConstraints();
|
274 |
jpanel1.setLayout(formlayout1); |
275 |
|
276 |
btnSiteURLHistory.setActionCommand("...");
|
277 |
btnSiteURLHistory.setName("btnSiteURLHistory");
|
278 |
btnSiteURLHistory.setText("...");
|
279 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
280 |
btnSiteURLHistory.setBorder(emptyborder1); |
281 |
jpanel1.add(btnSiteURLHistory,cc.xy(5,1)); |
282 |
|
283 |
btnSiteURLBookmarks.setActionCommand("...");
|
284 |
btnSiteURLBookmarks.setName("btnSiteURLBookmarks");
|
285 |
btnSiteURLBookmarks.setText("...");
|
286 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
287 |
btnSiteURLBookmarks.setBorder(emptyborder2); |
288 |
jpanel1.add(btnSiteURLBookmarks,cc.xy(7,1)); |
289 |
|
290 |
txtSiteURL.setName("txtSiteURL");
|
291 |
jpanel1.add(txtSiteURL,cc.xy(1,1)); |
292 |
|
293 |
btnSiteURLRefresh.setActionCommand("...");
|
294 |
btnSiteURLRefresh.setIcon(loadImage("addons/onlinecaptures/capturas/common-refresh.png"));
|
295 |
btnSiteURLRefresh.setName("btnSiteURLRefresh");
|
296 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
297 |
btnSiteURLRefresh.setBorder(emptyborder3); |
298 |
jpanel1.add(btnSiteURLRefresh,cc.xy(3,1)); |
299 |
|
300 |
addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]); |
301 |
return jpanel1;
|
302 |
} |
303 |
|
304 |
public JPanel createPanel4() |
305 |
{ |
306 |
JPanel jpanel1 = new JPanel(); |
307 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:MAX(12DLU;DEFAULT):NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
308 |
CellConstraints cc = new CellConstraints();
|
309 |
jpanel1.setLayout(formlayout1); |
310 |
|
311 |
lblStatusTitle.setName("lblStatusTitle");
|
312 |
jpanel1.add(lblStatusTitle,cc.xy(1,1)); |
313 |
|
314 |
pbStatus.setName("pbStatus");
|
315 |
pbStatus.setValue(25);
|
316 |
jpanel1.add(pbStatus,cc.xy(1,2)); |
317 |
|
318 |
lblStatusMessages.setName("lblStatusMessages");
|
319 |
jpanel1.add(lblStatusMessages,cc.xy(1,3)); |
320 |
|
321 |
btnStatusCancel.setActionCommand("...");
|
322 |
btnStatusCancel.setName("btnStatusCancel");
|
323 |
btnStatusCancel.setOpaque(false);
|
324 |
btnStatusCancel.setText("...");
|
325 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
326 |
btnStatusCancel.setBorder(emptyborder1); |
327 |
jpanel1.add(btnStatusCancel,cc.xy(2,2)); |
328 |
|
329 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
330 |
return jpanel1;
|
331 |
} |
332 |
|
333 |
/**
|
334 |
* Initializer
|
335 |
*/
|
336 |
protected void initializePanel() |
337 |
{ |
338 |
setLayout(new BorderLayout()); |
339 |
add(createPanel(), BorderLayout.CENTER);
|
340 |
} |
341 |
|
342 |
|
343 |
} |