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

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
   JTextField txtXMLFile = new JTextField();
35
   JButton btnXMLFile = new JButton();
36
   JButton btnDataBaseFile = new JButton();
37
   JTextField txtDatabaseFile = new JTextField();
38
   JTextField txtProjection = new JTextField();
39
   JButton btnProjection = new JButton();
40
   JLabel lblStatusCaption = new JLabel();
41
   JLabel lblStatusMsg = new JLabel();
42
   JProgressBar pbStatus = new JProgressBar();
43
   JLabel lblConnectToRepository = new JLabel();
44
   JCheckBox chkConnectToRepository = new JCheckBox();
45
   JLabel lblOverwriteDatabase = new JLabel();
46
   JCheckBox chkOverwriteDatabase = new JCheckBox();
47

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

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

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

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

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

    
96
   }
97

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

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

    
135
   public JPanel createPanel()
136
   {
137
      JPanel jpanel1 = new JPanel();
138
      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");
139
      CellConstraints cc = new CellConstraints();
140
      jpanel1.setLayout(formlayout1);
141

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

    
146
      lblDatabaseFile.setName("lblDatabaseFile");
147
      lblDatabaseFile.setText("_File_for_the_database");
148
      jpanel1.add(lblDatabaseFile,cc.xy(2,8));
149

    
150
      lblRepositoryName.setName("lblRepositoryName");
151
      lblRepositoryName.setText("_Name_for_the_repository");
152
      jpanel1.add(lblRepositoryName,cc.xy(2,10));
153

    
154
      txtRepositoryName.setName("txtRepositoryName");
155
      jpanel1.add(txtRepositoryName,cc.xy(4,10));
156

    
157
      lblProjection.setName("lblProjection");
158
      lblProjection.setText("_Projection");
159
      jpanel1.add(lblProjection,cc.xy(2,6));
160

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

    
165
      cboCharset.setName("cboCharset");
166
      jpanel1.add(cboCharset,cc.xy(4,4));
167

    
168
      lblRegisterConnection.setName("lblRegisterConnection");
169
      lblRegisterConnection.setText("_Register_connection");
170
      jpanel1.add(lblRegisterConnection,cc.xy(2,12));
171

    
172
      chkRegisterConnection.setName("chkRegisterConnection");
173
      jpanel1.add(chkRegisterConnection,cc.xy(4,12));
174

    
175
      jpanel1.add(createPanel1(),cc.xy(4,2));
176
      jpanel1.add(createPanel2(),cc.xy(4,8));
177
      jpanel1.add(createPanel3(),cc.xy(4,6));
178
      jpanel1.add(createPanel4(),cc.xywh(2,18,3,1));
179
      lblConnectToRepository.setName("lblConnectToRepository");
180
      lblConnectToRepository.setText("_Connect_to_repository");
181
      jpanel1.add(lblConnectToRepository,cc.xy(2,14));
182

    
183
      chkConnectToRepository.setName("chkConnectToRepository");
184
      jpanel1.add(chkConnectToRepository,cc.xy(4,14));
185

    
186
      lblOverwriteDatabase.setName("lblOverwriteDatabase");
187
      lblOverwriteDatabase.setText("_Overwrite_database");
188
      jpanel1.add(lblOverwriteDatabase,cc.xy(2,16));
189

    
190
      chkOverwriteDatabase.setName("chkOverwriteDatabase");
191
      jpanel1.add(chkOverwriteDatabase,cc.xy(4,16));
192

    
193
      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 });
194
      return jpanel1;
195
   }
196

    
197
   public JPanel createPanel1()
198
   {
199
      JPanel jpanel1 = new JPanel();
200
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
201
      CellConstraints cc = new CellConstraints();
202
      jpanel1.setLayout(formlayout1);
203

    
204
      txtXMLFile.setName("txtXMLFile");
205
      jpanel1.add(txtXMLFile,cc.xy(1,1));
206

    
207
      btnXMLFile.setActionCommand("...");
208
      btnXMLFile.setName("btnXMLFile");
209
      btnXMLFile.setOpaque(false);
210
      btnXMLFile.setRolloverEnabled(true);
211
      btnXMLFile.setText("...");
212
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
213
      btnXMLFile.setBorder(emptyborder1);
214
      jpanel1.add(btnXMLFile,cc.xy(3,1));
215

    
216
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
217
      return jpanel1;
218
   }
219

    
220
   public JPanel createPanel2()
221
   {
222
      JPanel jpanel1 = new JPanel();
223
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
224
      CellConstraints cc = new CellConstraints();
225
      jpanel1.setLayout(formlayout1);
226

    
227
      btnDataBaseFile.setActionCommand("...");
228
      btnDataBaseFile.setName("btnDataBaseFile");
229
      btnDataBaseFile.setOpaque(false);
230
      btnDataBaseFile.setRolloverEnabled(true);
231
      btnDataBaseFile.setText("...");
232
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
233
      btnDataBaseFile.setBorder(emptyborder1);
234
      jpanel1.add(btnDataBaseFile,cc.xy(3,1));
235

    
236
      txtDatabaseFile.setName("txtDatabaseFile");
237
      jpanel1.add(txtDatabaseFile,cc.xy(1,1));
238

    
239
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
240
      return jpanel1;
241
   }
242

    
243
   public JPanel createPanel3()
244
   {
245
      JPanel jpanel1 = new JPanel();
246
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
247
      CellConstraints cc = new CellConstraints();
248
      jpanel1.setLayout(formlayout1);
249

    
250
      txtProjection.setName("txtProjection");
251
      jpanel1.add(txtProjection,cc.xy(1,1));
252

    
253
      btnProjection.setActionCommand("...");
254
      btnProjection.setName("btnProjection");
255
      btnProjection.setOpaque(false);
256
      btnProjection.setRolloverEnabled(true);
257
      btnProjection.setText("...");
258
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
259
      btnProjection.setBorder(emptyborder1);
260
      jpanel1.add(btnProjection,cc.xy(3,1));
261

    
262
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
263
      return jpanel1;
264
   }
265

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

    
273
      lblStatusCaption.setName("lblStatusCaption");
274
      jpanel1.add(lblStatusCaption,cc.xy(1,1));
275

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

    
279
      pbStatus.setName("pbStatus");
280
      pbStatus.setValue(25);
281
      jpanel1.add(pbStatus,cc.xy(1,2));
282

    
283
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
284
      return jpanel1;
285
   }
286

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

    
296

    
297
}