svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / AbstractWizardDBView.java @ 44533
History | View | Annotate | Download (12.5 KB)
1 |
package org.gvsig.geodb; |
---|---|
2 |
|
3 |
import com.jeta.forms.components.border.TitledBorderLabel; |
4 |
import com.jeta.open.i18n.I18NUtils; |
5 |
import com.jgoodies.forms.layout.CellConstraints; |
6 |
import com.jgoodies.forms.layout.FormLayout; |
7 |
import java.awt.BorderLayout; |
8 |
import java.awt.ComponentOrientation; |
9 |
import java.awt.Container; |
10 |
import java.awt.Dimension; |
11 |
import javax.swing.Box; |
12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JComboBox; |
15 |
import javax.swing.JFrame; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JList; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JScrollPane; |
20 |
import javax.swing.JTextField; |
21 |
import javax.swing.border.EmptyBorder; |
22 |
|
23 |
|
24 |
public class AbstractWizardDBView extends JPanel |
25 |
{ |
26 |
TitledBorderLabel lblConnection = new TitledBorderLabel();
|
27 |
JComboBox cboConnection = new JComboBox(); |
28 |
JButton btnConnection = new JButton(); |
29 |
JList lstTables = new JList(); |
30 |
JList lstColumns = new JList(); |
31 |
JButton btnDeselectAllColumns = new JButton(); |
32 |
JButton btnSelectAllColumns = new JButton(); |
33 |
TitledBorderLabel lblTable = new TitledBorderLabel();
|
34 |
TitledBorderLabel lblColumns = new TitledBorderLabel();
|
35 |
JLabel lblName = new JLabel(); |
36 |
JTextField txtName = new JTextField(); |
37 |
JLabel lblIdField = new JLabel(); |
38 |
JComboBox cboIdField = new JComboBox(); |
39 |
JLabel lblGeometryField = new JLabel(); |
40 |
JComboBox cboGeometryField = new JComboBox(); |
41 |
JLabel lblProjection = new JLabel(); |
42 |
JTextField txtProjection = new JTextField(); |
43 |
JButton btnProjection = new JButton(); |
44 |
JLabel lblFilter = new JLabel(); |
45 |
JTextField txtFilter = new JTextField(); |
46 |
JButton btnFilter = new JButton(); |
47 |
JButton btnFilterBookmarks = new JButton(); |
48 |
JButton btnFilterHistory = new JButton(); |
49 |
JButton btnAdvancedProperties = new JButton(); |
50 |
|
51 |
/**
|
52 |
* Default constructor
|
53 |
*/
|
54 |
public AbstractWizardDBView()
|
55 |
{ |
56 |
initializePanel(); |
57 |
} |
58 |
|
59 |
/**
|
60 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
61 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
62 |
* @param cols an array of column indices in the first row where fill components should be added.
|
63 |
* @param rows an array of row indices in the first column where fill components should be added.
|
64 |
*/
|
65 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
66 |
{ |
67 |
Dimension filler = new Dimension(10,10); |
68 |
|
69 |
boolean filled_cell_11 = false; |
70 |
CellConstraints cc = new CellConstraints();
|
71 |
if ( cols.length > 0 && rows.length > 0 ) |
72 |
{ |
73 |
if ( cols[0] == 1 && rows[0] == 1 ) |
74 |
{ |
75 |
/** add a rigid area */
|
76 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
77 |
filled_cell_11 = true;
|
78 |
} |
79 |
} |
80 |
|
81 |
for( int index = 0; index < cols.length; index++ ) |
82 |
{ |
83 |
if ( cols[index] == 1 && filled_cell_11 ) |
84 |
{ |
85 |
continue;
|
86 |
} |
87 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
88 |
} |
89 |
|
90 |
for( int index = 0; index < rows.length; index++ ) |
91 |
{ |
92 |
if ( rows[index] == 1 && filled_cell_11 ) |
93 |
{ |
94 |
continue;
|
95 |
} |
96 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
97 |
} |
98 |
|
99 |
} |
100 |
|
101 |
/**
|
102 |
* Helper method to load an image file from the CLASSPATH
|
103 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
104 |
* @return an ImageIcon instance with the specified image file
|
105 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
106 |
*/
|
107 |
public ImageIcon loadImage( String imageName ) |
108 |
{ |
109 |
try
|
110 |
{ |
111 |
ClassLoader classloader = getClass().getClassLoader();
|
112 |
java.net.URL url = classloader.getResource( imageName ); |
113 |
if ( url != null ) |
114 |
{ |
115 |
ImageIcon icon = new ImageIcon( url ); |
116 |
return icon;
|
117 |
} |
118 |
} |
119 |
catch( Exception e ) |
120 |
{ |
121 |
e.printStackTrace(); |
122 |
} |
123 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
124 |
} |
125 |
|
126 |
/**
|
127 |
* Method for recalculating the component orientation for
|
128 |
* right-to-left Locales.
|
129 |
* @param orientation the component orientation to be applied
|
130 |
*/
|
131 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
132 |
{ |
133 |
// Not yet implemented...
|
134 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
135 |
super.applyComponentOrientation(orientation);
|
136 |
} |
137 |
|
138 |
public JPanel createPanel() |
139 |
{ |
140 |
JPanel jpanel1 = new JPanel(); |
141 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
142 |
CellConstraints cc = new CellConstraints();
|
143 |
jpanel1.setLayout(formlayout1); |
144 |
|
145 |
lblConnection.setName("lblConnection");
|
146 |
lblConnection.setText("_Connection");
|
147 |
jpanel1.add(lblConnection,cc.xy(2,1)); |
148 |
|
149 |
jpanel1.add(createPanel1(),cc.xy(2,3)); |
150 |
jpanel1.add(createPanel2(),cc.xy(2,6)); |
151 |
jpanel1.add(createPanel4(),cc.xy(2,9)); |
152 |
btnAdvancedProperties.setActionCommand("_Advanced_properties");
|
153 |
btnAdvancedProperties.setName("btnAdvancedProperties");
|
154 |
btnAdvancedProperties.setText("_Advanced_properties");
|
155 |
jpanel1.add(btnAdvancedProperties,new CellConstraints(2,11,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
156 |
|
157 |
addFillComponents(jpanel1,new int[]{ 1,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12 }); |
158 |
return jpanel1;
|
159 |
} |
160 |
|
161 |
public JPanel createPanel1() |
162 |
{ |
163 |
JPanel jpanel1 = new JPanel(); |
164 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
165 |
CellConstraints cc = new CellConstraints();
|
166 |
jpanel1.setLayout(formlayout1); |
167 |
|
168 |
cboConnection.setName("cboConnection");
|
169 |
jpanel1.add(cboConnection,cc.xy(1,1)); |
170 |
|
171 |
btnConnection.setActionCommand("...");
|
172 |
btnConnection.setName("btnConnection");
|
173 |
btnConnection.setText("...");
|
174 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
175 |
btnConnection.setBorder(emptyborder1); |
176 |
jpanel1.add(btnConnection,cc.xy(3,1)); |
177 |
|
178 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
179 |
return jpanel1;
|
180 |
} |
181 |
|
182 |
public JPanel createPanel2() |
183 |
{ |
184 |
JPanel jpanel1 = new JPanel(); |
185 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(0.5),FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.5)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
186 |
CellConstraints cc = new CellConstraints();
|
187 |
jpanel1.setLayout(formlayout1); |
188 |
|
189 |
lstTables.setName("lstTables");
|
190 |
JScrollPane jscrollpane1 = new JScrollPane(); |
191 |
jscrollpane1.setViewportView(lstTables); |
192 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
193 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
194 |
jpanel1.add(jscrollpane1,cc.xywh(1,3,1,3)); |
195 |
|
196 |
lstColumns.setName("lstColumns");
|
197 |
JScrollPane jscrollpane2 = new JScrollPane(); |
198 |
jscrollpane2.setViewportView(lstColumns); |
199 |
jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
200 |
jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
201 |
jpanel1.add(jscrollpane2,cc.xy(3,3)); |
202 |
|
203 |
jpanel1.add(createPanel3(),cc.xy(3,5)); |
204 |
lblTable.setName("lblTable");
|
205 |
lblTable.setText("choose_table");
|
206 |
jpanel1.add(lblTable,cc.xy(1,1)); |
207 |
|
208 |
lblColumns.setName("lblColumns");
|
209 |
lblColumns.setText("table_fields");
|
210 |
jpanel1.add(lblColumns,cc.xy(3,1)); |
211 |
|
212 |
addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,4,5 }); |
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:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
220 |
CellConstraints cc = new CellConstraints();
|
221 |
jpanel1.setLayout(formlayout1); |
222 |
|
223 |
btnDeselectAllColumns.setActionCommand("Ninguno");
|
224 |
btnDeselectAllColumns.setName("btnDeselectAllColumns");
|
225 |
btnDeselectAllColumns.setText("_None");
|
226 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
227 |
btnDeselectAllColumns.setBorder(emptyborder1); |
228 |
jpanel1.add(btnDeselectAllColumns,cc.xy(4,1)); |
229 |
|
230 |
btnSelectAllColumns.setActionCommand("Todos");
|
231 |
btnSelectAllColumns.setName("btnSelectAllColumns");
|
232 |
btnSelectAllColumns.setText("_All");
|
233 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
234 |
btnSelectAllColumns.setBorder(emptyborder2); |
235 |
jpanel1.add(btnSelectAllColumns,cc.xy(2,1)); |
236 |
|
237 |
addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 }); |
238 |
return jpanel1;
|
239 |
} |
240 |
|
241 |
public JPanel createPanel4() |
242 |
{ |
243 |
JPanel jpanel1 = new JPanel(); |
244 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","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"); |
245 |
CellConstraints cc = new CellConstraints();
|
246 |
jpanel1.setLayout(formlayout1); |
247 |
|
248 |
lblName.setName("lblName");
|
249 |
lblName.setText("_Name");
|
250 |
jpanel1.add(lblName,cc.xy(1,2)); |
251 |
|
252 |
txtName.setName("txtName");
|
253 |
jpanel1.add(txtName,cc.xy(3,2)); |
254 |
|
255 |
lblIdField.setName("lblIdField");
|
256 |
lblIdField.setText("_Id_field");
|
257 |
jpanel1.add(lblIdField,cc.xy(1,4)); |
258 |
|
259 |
cboIdField.setName("cboIdField");
|
260 |
jpanel1.add(cboIdField,cc.xy(3,4)); |
261 |
|
262 |
lblGeometryField.setName("lblGeometryField");
|
263 |
lblGeometryField.setText("_Geo_field");
|
264 |
jpanel1.add(lblGeometryField,cc.xy(1,6)); |
265 |
|
266 |
cboGeometryField.setName("cboGeometryField");
|
267 |
jpanel1.add(cboGeometryField,cc.xy(3,6)); |
268 |
|
269 |
lblProjection.setName("lblProjection");
|
270 |
lblProjection.setText("_Projection");
|
271 |
jpanel1.add(lblProjection,cc.xy(1,8)); |
272 |
|
273 |
jpanel1.add(createPanel5(),cc.xy(3,8)); |
274 |
lblFilter.setName("lblFilter");
|
275 |
lblFilter.setText("_Filter");
|
276 |
jpanel1.add(lblFilter,cc.xy(1,10)); |
277 |
|
278 |
jpanel1.add(createPanel6(),cc.xy(3,10)); |
279 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,3,5,7,9 }); |
280 |
return jpanel1;
|
281 |
} |
282 |
|
283 |
public JPanel createPanel5() |
284 |
{ |
285 |
JPanel jpanel1 = new JPanel(); |
286 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","FILL:DEFAULT:NONE"); |
287 |
CellConstraints cc = new CellConstraints();
|
288 |
jpanel1.setLayout(formlayout1); |
289 |
|
290 |
txtProjection.setName("txtProjection");
|
291 |
jpanel1.add(txtProjection,cc.xy(1,1)); |
292 |
|
293 |
btnProjection.setActionCommand("...");
|
294 |
btnProjection.setName("btnProjection");
|
295 |
btnProjection.setText("...");
|
296 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
297 |
btnProjection.setBorder(emptyborder1); |
298 |
jpanel1.add(btnProjection,cc.xy(3,1)); |
299 |
|
300 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
301 |
return jpanel1;
|
302 |
} |
303 |
|
304 |
public JPanel createPanel6() |
305 |
{ |
306 |
JPanel jpanel1 = new JPanel(); |
307 |
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"); |
308 |
CellConstraints cc = new CellConstraints();
|
309 |
jpanel1.setLayout(formlayout1); |
310 |
|
311 |
txtFilter.setName("txtFilter");
|
312 |
jpanel1.add(txtFilter,cc.xy(1,1)); |
313 |
|
314 |
btnFilter.setActionCommand("...");
|
315 |
btnFilter.setName("btnFilter");
|
316 |
btnFilter.setText("...");
|
317 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
318 |
btnFilter.setBorder(emptyborder1); |
319 |
jpanel1.add(btnFilter,cc.xy(3,1)); |
320 |
|
321 |
btnFilterBookmarks.setActionCommand("...");
|
322 |
btnFilterBookmarks.setName("btnFilterBookmarks");
|
323 |
btnFilterBookmarks.setText("...");
|
324 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
325 |
btnFilterBookmarks.setBorder(emptyborder2); |
326 |
jpanel1.add(btnFilterBookmarks,cc.xy(7,1)); |
327 |
|
328 |
btnFilterHistory.setActionCommand("...");
|
329 |
btnFilterHistory.setName("btnFilterHistory");
|
330 |
btnFilterHistory.setText("...");
|
331 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
332 |
btnFilterHistory.setBorder(emptyborder3); |
333 |
jpanel1.add(btnFilterHistory,cc.xy(5,1)); |
334 |
|
335 |
addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]); |
336 |
return jpanel1;
|
337 |
} |
338 |
|
339 |
/**
|
340 |
* Initializer
|
341 |
*/
|
342 |
protected void initializePanel() |
343 |
{ |
344 |
setLayout(new BorderLayout()); |
345 |
add(createPanel(), BorderLayout.CENTER);
|
346 |
} |
347 |
|
348 |
|
349 |
} |