Statistics
| Revision:

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 @ 47607

History | View | Annotate | Download (12.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
   JLabel lblRegisterConnection = new JLabel();
41
   JCheckBox chkRegisterConnection = new JCheckBox();
42
   JLabel lblMode = new JLabel();
43
   JLabel lblLocale = new JLabel();
44
   JComboBox cboLocale = new JComboBox();
45
   JTextField txtXMLFile = new JTextField();
46
   JButton btnXMLFile = new JButton();
47
   JButton btnDataBaseFile = new JButton();
48
   JTextField txtDatabaseFile = new JTextField();
49
   JTextField txtProjection = new JTextField();
50
   JButton btnProjection = new JButton();
51
   JLabel lblStatusCaption = new JLabel();
52
   JLabel lblStatusMsg = new JLabel();
53
   JProgressBar pbStatus = new JProgressBar();
54
   JComboBox cboMode = new JComboBox();
55
   JLabel lblPrefixesForTables = new JLabel();
56
   JTextField txtPrefixesForTables = new JTextField();
57
   JLabel lblDatabaseType = new JLabel();
58
   JComboBox cboDatabaseType = new JComboBox();
59

    
60
   /**
61
    * Default constructor
62
    */
63
   public CreatedbFromXmlPanelView()
64
   {
65
      initializePanel();
66
   }
67

    
68
   /**
69
    * Adds fill components to empty cells in the first row and first column of the grid.
70
    * This ensures that the grid spacing will be the same as shown in the designer.
71
    * @param cols an array of column indices in the first row where fill components should be added.
72
    * @param rows an array of row indices in the first column where fill components should be added.
73
    */
74
   void addFillComponents( Container panel, int[] cols, int[] rows )
75
   {
76
      Dimension filler = new Dimension(10,10);
77

    
78
      boolean filled_cell_11 = false;
79
      CellConstraints cc = new CellConstraints();
80
      if ( cols.length > 0 && rows.length > 0 )
81
      {
82
         if ( cols[0] == 1 && rows[0] == 1 )
83
         {
84
            /** add a rigid area  */
85
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
86
            filled_cell_11 = true;
87
         }
88
      }
89

    
90
      for( int index = 0; index < cols.length; index++ )
91
      {
92
         if ( cols[index] == 1 && filled_cell_11 )
93
         {
94
            continue;
95
         }
96
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
97
      }
98

    
99
      for( int index = 0; index < rows.length; index++ )
100
      {
101
         if ( rows[index] == 1 && filled_cell_11 )
102
         {
103
            continue;
104
         }
105
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
106
      }
107

    
108
   }
109

    
110
   /**
111
    * Helper method to load an image file from the CLASSPATH
112
    * @param imageName the package and name of the file to load relative to the CLASSPATH
113
    * @return an ImageIcon instance with the specified image file
114
    * @throws IllegalArgumentException if the image resource cannot be loaded.
115
    */
116
   public ImageIcon loadImage( String imageName )
117
   {
118
      try
119
      {
120
         ClassLoader classloader = getClass().getClassLoader();
121
         java.net.URL url = classloader.getResource( imageName );
122
         if ( url != null )
123
         {
124
            ImageIcon icon = new ImageIcon( url );
125
            return icon;
126
         }
127
      }
128
      catch( Exception e )
129
      {
130
         e.printStackTrace();
131
      }
132
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
133
   }
134

    
135
   /**
136
    * Method for recalculating the component orientation for 
137
    * right-to-left Locales.
138
    * @param orientation the component orientation to be applied
139
    */
140
   public void applyComponentOrientation( ComponentOrientation orientation )
141
   {
142
      // Not yet implemented...
143
      // I18NUtils.applyComponentOrientation(this, orientation);
144
      super.applyComponentOrientation(orientation);
145
   }
146

    
147
   public JPanel createPanel()
148
   {
149
      JPanel jpanel1 = new JPanel();
150
      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,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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
151
      CellConstraints cc = new CellConstraints();
152
      jpanel1.setLayout(formlayout1);
153

    
154
      lblFileXML.setName("lblFileXML");
155
      lblFileXML.setText("_XML_File");
156
      jpanel1.add(lblFileXML,cc.xy(2,2));
157

    
158
      btnAnalizeXML.setActionCommand("...");
159
      btnAnalizeXML.setName("btnAnalizeXML");
160
      btnAnalizeXML.setRolloverEnabled(true);
161
      btnAnalizeXML.setText("_Analize_xml");
162
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
163
      btnAnalizeXML.setBorder(emptyborder1);
164
      jpanel1.add(btnAnalizeXML,new CellConstraints(4,12,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
165

    
166
      lblTables.setName("lblTables");
167
      lblTables.setText("_Tables");
168
      jpanel1.add(lblTables,cc.xywh(2,14,3,1));
169

    
170
      lstTables.setName("lstTables");
171
      JScrollPane jscrollpane1 = new JScrollPane();
172
      jscrollpane1.setViewportView(lstTables);
173
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
174
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
175
      jpanel1.add(jscrollpane1,cc.xywh(2,16,3,1));
176

    
177
      btnViewTableStructure.setActionCommand("...");
178
      btnViewTableStructure.setName("btnViewTableStructure");
179
      btnViewTableStructure.setRolloverEnabled(true);
180
      btnViewTableStructure.setText("_Show_table_structure");
181
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
182
      btnViewTableStructure.setBorder(emptyborder2);
183
      jpanel1.add(btnViewTableStructure,new CellConstraints(4,18,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
184

    
185
      lblCreatedb.setName("lblCreatedb");
186
      lblCreatedb.setText("_Create_database");
187
      jpanel1.add(lblCreatedb,cc.xywh(2,20,3,1));
188

    
189
      lblDatabaseFile.setName("lblDatabaseFile");
190
      lblDatabaseFile.setText("_File_for_the_database");
191
      jpanel1.add(lblDatabaseFile,cc.xy(2,24));
192

    
193
      lblRepositoryName.setName("lblRepositoryName");
194
      lblRepositoryName.setText("_Name_for_the_repository");
195
      jpanel1.add(lblRepositoryName,cc.xy(2,26));
196

    
197
      txtRepositoryName.setName("txtRepositoryName");
198
      jpanel1.add(txtRepositoryName,cc.xy(4,26));
199

    
200
      lblProjection.setName("lblProjection");
201
      lblProjection.setText("_Projection");
202
      jpanel1.add(lblProjection,cc.xy(2,8));
203

    
204
      lblCharset.setName("lblCharset");
205
      lblCharset.setText("_Charset");
206
      jpanel1.add(lblCharset,cc.xy(2,4));
207

    
208
      cboCharset.setName("cboCharset");
209
      jpanel1.add(cboCharset,cc.xy(4,4));
210

    
211
      lblRegisterConnection.setName("lblRegisterConnection");
212
      lblRegisterConnection.setText("_Register_connection");
213
      jpanel1.add(lblRegisterConnection,cc.xy(2,28));
214

    
215
      chkRegisterConnection.setName("chkRegisterConnection");
216
      chkRegisterConnection.setRolloverEnabled(true);
217
      jpanel1.add(chkRegisterConnection,cc.xy(4,28));
218

    
219
      lblMode.setName("lblMode");
220
      lblMode.setText("_Mode");
221
      jpanel1.add(lblMode,cc.xy(2,30));
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
      jpanel1.add(createPanel1(),cc.xy(4,2));
231
      jpanel1.add(createPanel2(),cc.xy(4,24));
232
      jpanel1.add(createPanel3(),cc.xy(4,8));
233
      jpanel1.add(createPanel4(),cc.xywh(2,32,3,1));
234
      cboMode.setName("cboMode");
235
      jpanel1.add(cboMode,cc.xy(4,30));
236

    
237
      lblPrefixesForTables.setName("lblPrefixesForTables");
238
      lblPrefixesForTables.setText("_Prefixes_for_tables");
239
      jpanel1.add(lblPrefixesForTables,cc.xy(2,10));
240

    
241
      txtPrefixesForTables.setName("txtPrefixesForTables");
242
      jpanel1.add(txtPrefixesForTables,cc.xy(4,10));
243

    
244
      lblDatabaseType.setName("lblDatabaseType");
245
      lblDatabaseType.setText("_Database_type");
246
      jpanel1.add(lblDatabaseType,cc.xy(2,22));
247

    
248
      cboDatabaseType.setName("cboDatabaseType");
249
      jpanel1.add(cboDatabaseType,cc.xy(4,22));
250

    
251
      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,30,31,32,33 });
252
      return jpanel1;
253
   }
254

    
255
   public JPanel createPanel1()
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
      txtXMLFile.setName("txtXMLFile");
263
      jpanel1.add(txtXMLFile,cc.xy(1,1));
264

    
265
      btnXMLFile.setActionCommand("...");
266
      btnXMLFile.setName("btnXMLFile");
267
      btnXMLFile.setRolloverEnabled(true);
268
      btnXMLFile.setText("...");
269
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
270
      btnXMLFile.setBorder(emptyborder1);
271
      jpanel1.add(btnXMLFile,cc.xy(3,1));
272

    
273
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
274
      return jpanel1;
275
   }
276

    
277
   public JPanel createPanel2()
278
   {
279
      JPanel jpanel1 = new JPanel();
280
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
281
      CellConstraints cc = new CellConstraints();
282
      jpanel1.setLayout(formlayout1);
283

    
284
      btnDataBaseFile.setActionCommand("...");
285
      btnDataBaseFile.setName("btnDataBaseFile");
286
      btnDataBaseFile.setRolloverEnabled(true);
287
      btnDataBaseFile.setText("...");
288
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
289
      btnDataBaseFile.setBorder(emptyborder1);
290
      jpanel1.add(btnDataBaseFile,cc.xy(3,1));
291

    
292
      txtDatabaseFile.setName("txtDatabaseFile");
293
      jpanel1.add(txtDatabaseFile,cc.xy(1,1));
294

    
295
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
296
      return jpanel1;
297
   }
298

    
299
   public JPanel createPanel3()
300
   {
301
      JPanel jpanel1 = new JPanel();
302
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
303
      CellConstraints cc = new CellConstraints();
304
      jpanel1.setLayout(formlayout1);
305

    
306
      txtProjection.setName("txtProjection");
307
      jpanel1.add(txtProjection,cc.xy(1,1));
308

    
309
      btnProjection.setActionCommand("...");
310
      btnProjection.setName("btnProjection");
311
      btnProjection.setRolloverEnabled(true);
312
      btnProjection.setText("...");
313
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
314
      btnProjection.setBorder(emptyborder1);
315
      jpanel1.add(btnProjection,cc.xy(3,1));
316

    
317
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
318
      return jpanel1;
319
   }
320

    
321
   public JPanel createPanel4()
322
   {
323
      JPanel jpanel1 = new JPanel();
324
      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");
325
      CellConstraints cc = new CellConstraints();
326
      jpanel1.setLayout(formlayout1);
327

    
328
      lblStatusCaption.setName("lblStatusCaption");
329
      jpanel1.add(lblStatusCaption,cc.xy(1,1));
330

    
331
      lblStatusMsg.setName("lblStatusMsg");
332
      jpanel1.add(lblStatusMsg,cc.xy(1,3));
333

    
334
      pbStatus.setName("pbStatus");
335
      pbStatus.setValue(25);
336
      jpanel1.add(pbStatus,cc.xy(1,2));
337

    
338
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
339
      return jpanel1;
340
   }
341

    
342
   /**
343
    * Initializer
344
    */
345
   protected void initializePanel()
346
   {
347
      setLayout(new BorderLayout());
348
      add(createPanel(), BorderLayout.CENTER);
349
   }
350

    
351

    
352
}