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 / copyxml2db / CopyXml2dbPanelView.java @ 47336

History | View | Annotate | Download (10.3 KB)

1
package org.gvsig.xml2db.swing.impl.copyxml2db;
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.JTextField;
20
import javax.swing.border.EmptyBorder;
21

    
22

    
23
public class CopyXml2dbPanelView extends JPanel
24
{
25
   JLabel lblFileXML = new JLabel();
26
   JLabel lblDatabaseFile = new JLabel();
27
   JLabel lblRepositoryName = new JLabel();
28
   JTextField txtRepositoryName = new JTextField();
29
   JLabel lblProjection = new JLabel();
30
   JLabel lblCharset = new JLabel();
31
   JComboBox cboCharset = new JComboBox();
32
   JLabel lblRegisterConnection = new JLabel();
33
   JCheckBox chkRegisterConnection = new JCheckBox();
34
   JLabel lblConnectToRepository = new JLabel();
35
   JCheckBox chkConnectToRepository = new JCheckBox();
36
   JLabel lblOverwriteDatabase = new JLabel();
37
   JCheckBox chkOverwriteDatabase = new JCheckBox();
38
   JLabel lblLocale = new JLabel();
39
   JTextField txtXMLFile = new JTextField();
40
   JButton btnXMLFile = new JButton();
41
   JButton btnDataBaseFile = new JButton();
42
   JTextField txtDatabaseFile = new JTextField();
43
   JTextField txtProjection = new JTextField();
44
   JButton btnProjection = new JButton();
45
   JLabel lblStatusCaption = new JLabel();
46
   JLabel lblStatusMsg = new JLabel();
47
   JProgressBar pbStatus = new JProgressBar();
48
   JComboBox cboLocale = new JComboBox();
49

    
50
   /**
51
    * Default constructor
52
    */
53
   public CopyXml2dbPanelView()
54
   {
55
      initializePanel();
56
   }
57

    
58
   /**
59
    * Adds fill components to empty cells in the first row and first column of the grid.
60
    * This ensures that the grid spacing will be the same as shown in the designer.
61
    * @param cols an array of column indices in the first row where fill components should be added.
62
    * @param rows an array of row indices in the first column where fill components should be added.
63
    */
64
   void addFillComponents( Container panel, int[] cols, int[] rows )
65
   {
66
      Dimension filler = new Dimension(10,10);
67

    
68
      boolean filled_cell_11 = false;
69
      CellConstraints cc = new CellConstraints();
70
      if ( cols.length > 0 && rows.length > 0 )
71
      {
72
         if ( cols[0] == 1 && rows[0] == 1 )
73
         {
74
            /** add a rigid area  */
75
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
76
            filled_cell_11 = true;
77
         }
78
      }
79

    
80
      for( int index = 0; index < cols.length; index++ )
81
      {
82
         if ( cols[index] == 1 && filled_cell_11 )
83
         {
84
            continue;
85
         }
86
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
87
      }
88

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

    
98
   }
99

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

    
125
   /**
126
    * Method for recalculating the component orientation for 
127
    * right-to-left Locales.
128
    * @param orientation the component orientation to be applied
129
    */
130
   public void applyComponentOrientation( ComponentOrientation orientation )
131
   {
132
      // Not yet implemented...
133
      // I18NUtils.applyComponentOrientation(this, orientation);
134
      super.applyComponentOrientation(orientation);
135
   }
136

    
137
   public JPanel createPanel()
138
   {
139
      JPanel jpanel1 = new JPanel();
140
      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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
141
      CellConstraints cc = new CellConstraints();
142
      jpanel1.setLayout(formlayout1);
143

    
144
      lblFileXML.setName("lblFileXML");
145
      lblFileXML.setText("_XML_File");
146
      jpanel1.add(lblFileXML,cc.xy(2,2));
147

    
148
      lblDatabaseFile.setName("lblDatabaseFile");
149
      lblDatabaseFile.setText("_File_for_the_database");
150
      jpanel1.add(lblDatabaseFile,cc.xy(2,10));
151

    
152
      lblRepositoryName.setName("lblRepositoryName");
153
      lblRepositoryName.setText("_Name_for_the_repository");
154
      jpanel1.add(lblRepositoryName,cc.xy(2,12));
155

    
156
      txtRepositoryName.setName("txtRepositoryName");
157
      jpanel1.add(txtRepositoryName,cc.xy(4,12));
158

    
159
      lblProjection.setName("lblProjection");
160
      lblProjection.setText("_Projection");
161
      jpanel1.add(lblProjection,cc.xy(2,8));
162

    
163
      lblCharset.setName("lblCharset");
164
      lblCharset.setText("_Charset");
165
      jpanel1.add(lblCharset,cc.xy(2,4));
166

    
167
      cboCharset.setName("cboCharset");
168
      jpanel1.add(cboCharset,cc.xy(4,4));
169

    
170
      lblRegisterConnection.setName("lblRegisterConnection");
171
      lblRegisterConnection.setText("_Register_connection");
172
      jpanel1.add(lblRegisterConnection,cc.xy(2,14));
173

    
174
      chkRegisterConnection.setName("chkRegisterConnection");
175
      jpanel1.add(chkRegisterConnection,cc.xy(4,14));
176

    
177
      lblConnectToRepository.setName("lblConnectToRepository");
178
      lblConnectToRepository.setText("_Connect_to_repository");
179
      jpanel1.add(lblConnectToRepository,cc.xy(2,16));
180

    
181
      chkConnectToRepository.setName("chkConnectToRepository");
182
      jpanel1.add(chkConnectToRepository,cc.xy(4,16));
183

    
184
      lblOverwriteDatabase.setName("lblOverwriteDatabase");
185
      lblOverwriteDatabase.setText("_Overwrite_database");
186
      jpanel1.add(lblOverwriteDatabase,cc.xy(2,18));
187

    
188
      chkOverwriteDatabase.setName("chkOverwriteDatabase");
189
      jpanel1.add(chkOverwriteDatabase,cc.xy(4,18));
190

    
191
      lblLocale.setName("lblLocale");
192
      lblLocale.setText("_Language");
193
      jpanel1.add(lblLocale,cc.xy(2,6));
194

    
195
      jpanel1.add(createPanel1(),cc.xy(4,2));
196
      jpanel1.add(createPanel2(),cc.xy(4,10));
197
      jpanel1.add(createPanel3(),cc.xy(4,8));
198
      jpanel1.add(createPanel4(),cc.xywh(2,20,3,1));
199
      cboLocale.setName("cboLocale");
200
      jpanel1.add(cboLocale,cc.xy(4,6));
201

    
202
      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 });
203
      return jpanel1;
204
   }
205

    
206
   public JPanel createPanel1()
207
   {
208
      JPanel jpanel1 = new JPanel();
209
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
210
      CellConstraints cc = new CellConstraints();
211
      jpanel1.setLayout(formlayout1);
212

    
213
      txtXMLFile.setName("txtXMLFile");
214
      jpanel1.add(txtXMLFile,cc.xy(1,1));
215

    
216
      btnXMLFile.setActionCommand("...");
217
      btnXMLFile.setName("btnXMLFile");
218
      btnXMLFile.setText("...");
219
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
220
      btnXMLFile.setBorder(emptyborder1);
221
      jpanel1.add(btnXMLFile,cc.xy(3,1));
222

    
223
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
224
      return jpanel1;
225
   }
226

    
227
   public JPanel createPanel2()
228
   {
229
      JPanel jpanel1 = new JPanel();
230
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
231
      CellConstraints cc = new CellConstraints();
232
      jpanel1.setLayout(formlayout1);
233

    
234
      btnDataBaseFile.setActionCommand("...");
235
      btnDataBaseFile.setName("btnDataBaseFile");
236
      btnDataBaseFile.setText("...");
237
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
238
      btnDataBaseFile.setBorder(emptyborder1);
239
      jpanel1.add(btnDataBaseFile,cc.xy(3,1));
240

    
241
      txtDatabaseFile.setName("txtDatabaseFile");
242
      jpanel1.add(txtDatabaseFile,cc.xy(1,1));
243

    
244
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
245
      return jpanel1;
246
   }
247

    
248
   public JPanel createPanel3()
249
   {
250
      JPanel jpanel1 = new JPanel();
251
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
252
      CellConstraints cc = new CellConstraints();
253
      jpanel1.setLayout(formlayout1);
254

    
255
      txtProjection.setName("txtProjection");
256
      jpanel1.add(txtProjection,cc.xy(1,1));
257

    
258
      btnProjection.setActionCommand("...");
259
      btnProjection.setName("btnProjection");
260
      btnProjection.setText("...");
261
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
262
      btnProjection.setBorder(emptyborder1);
263
      jpanel1.add(btnProjection,cc.xy(3,1));
264

    
265
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
266
      return jpanel1;
267
   }
268

    
269
   public JPanel createPanel4()
270
   {
271
      JPanel jpanel1 = new JPanel();
272
      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");
273
      CellConstraints cc = new CellConstraints();
274
      jpanel1.setLayout(formlayout1);
275

    
276
      lblStatusCaption.setName("lblStatusCaption");
277
      jpanel1.add(lblStatusCaption,cc.xy(1,1));
278

    
279
      lblStatusMsg.setName("lblStatusMsg");
280
      jpanel1.add(lblStatusMsg,cc.xy(1,3));
281

    
282
      pbStatus.setName("pbStatus");
283
      pbStatus.setValue(25);
284
      jpanel1.add(pbStatus,cc.xy(1,2));
285

    
286
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
287
      return jpanel1;
288
   }
289

    
290
   /**
291
    * Initializer
292
    */
293
   protected void initializePanel()
294
   {
295
      setLayout(new BorderLayout());
296
      add(createPanel(), BorderLayout.CENTER);
297
   }
298

    
299

    
300
}