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