Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / featuretype / FeatureTypeAttributePanelView.java @ 44164

History | View | Annotate | Download (14.5 KB)

1
package org.gvsig.fmap.dal.swing.impl.featuretype;
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.JTabbedPane;
19
import javax.swing.JTextField;
20
import javax.swing.border.EmptyBorder;
21

    
22

    
23
public class FeatureTypeAttributePanelView extends JPanel
24
{
25
   JLabel lblFieldName = new JLabel();
26
   JTextField txtFieldName = new JTextField();
27
   JLabel lblFieldType = new JLabel();
28
   JComboBox cboFieldType = new JComboBox();
29
   JTabbedPane tabAditionalFields = new JTabbedPane();
30
   JLabel lblSize = new JLabel();
31
   JTextField txtSize = new JTextField();
32
   JLabel lblPrecision = new JLabel();
33
   JLabel lblDefaultValue = new JLabel();
34
   JTextField txtPrecision = new JTextField();
35
   JTextField txtDefaultValue = new JTextField();
36
   JLabel lblDataProfile = new JLabel();
37
   JComboBox cboDataProfile = new JComboBox();
38
   JCheckBox chkVirtualField = new JCheckBox();
39
   JButton btnVirtualField = new JButton();
40
   JTextField txtVirtualField = new JTextField();
41
   JLabel lblGeometryType = new JLabel();
42
   JLabel lblGeometrySubtype = new JLabel();
43
   JLabel lblCRS = new JLabel();
44
   JComboBox cboGeometryType = new JComboBox();
45
   JComboBox cboGeometrySubtype = new JComboBox();
46
   JButton btnCRS = new JButton();
47
   JTextField txtCRS = new JTextField();
48
   JLabel lblDateFormat = new JLabel();
49
   JComboBox cboDateFormat = new JComboBox();
50
   JLabel lblInterval = new JLabel();
51
   JLabel lblIntervalStart = new JLabel();
52
   JLabel lblIntervalEnd = new JLabel();
53
   JTextField txtIntervalStart = new JTextField();
54
   JButton btnIntervalStart = new JButton();
55
   JButton btnIntervalEnd = new JButton();
56
   JTextField txtIntervalEnd = new JTextField();
57
   JLabel lblIsPrimaryKey = new JLabel();
58
   JCheckBox chkIsPrimaryKey = new JCheckBox();
59
   JLabel lblIsAutomatic = new JLabel();
60
   JCheckBox chkIsAutomatic = new JCheckBox();
61
   JLabel lblAllowNulls = new JLabel();
62
   JCheckBox chkAllowNulls = new JCheckBox();
63

    
64
   /**
65
    * Default constructor
66
    */
67
   public FeatureTypeAttributePanelView()
68
   {
69
      initializePanel();
70
   }
71

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

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

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

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

    
112
   }
113

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

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

    
151
   public JPanel createPanel()
152
   {
153
      JPanel jpanel1 = new JPanel();
154
      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,FILL:DEFAULT:NONE,CENTER:2DLU:NONE");
155
      CellConstraints cc = new CellConstraints();
156
      jpanel1.setLayout(formlayout1);
157

    
158
      lblFieldName.setName("lblFieldName");
159
      lblFieldName.setText("_Field_name");
160
      jpanel1.add(lblFieldName,cc.xy(2,2));
161

    
162
      txtFieldName.setName("txtFieldName");
163
      jpanel1.add(txtFieldName,cc.xy(4,2));
164

    
165
      lblFieldType.setName("lblFieldType");
166
      lblFieldType.setText("_Field_type");
167
      jpanel1.add(lblFieldType,cc.xy(2,4));
168

    
169
      cboFieldType.setName("cboFieldType");
170
      jpanel1.add(cboFieldType,cc.xy(4,4));
171

    
172
      tabAditionalFields.setName("tabAditionalFields");
173
      tabAditionalFields.addTab("_Basic_fields",null,createPanel1());
174
      tabAditionalFields.addTab("_Geometry",null,createPanel3());
175
      tabAditionalFields.addTab("_Time",null,createPanel5());
176
      jpanel1.add(tabAditionalFields,cc.xywh(2,8,3,1));
177

    
178
      jpanel1.add(createPanel7(),cc.xy(4,6));
179
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9 });
180
      return jpanel1;
181
   }
182

    
183
   public JPanel createPanel1()
184
   {
185
      JPanel jpanel1 = new JPanel();
186
      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");
187
      CellConstraints cc = new CellConstraints();
188
      jpanel1.setLayout(formlayout1);
189

    
190
      lblSize.setName("lblSize");
191
      lblSize.setText("_Size");
192
      jpanel1.add(lblSize,cc.xy(2,2));
193

    
194
      txtSize.setName("txtSize");
195
      jpanel1.add(txtSize,cc.xy(4,2));
196

    
197
      lblPrecision.setName("lblPrecision");
198
      lblPrecision.setText("_Precision");
199
      jpanel1.add(lblPrecision,cc.xy(2,4));
200

    
201
      lblDefaultValue.setName("lblDefaultValue");
202
      lblDefaultValue.setText("_Default_value");
203
      jpanel1.add(lblDefaultValue,cc.xy(2,6));
204

    
205
      txtPrecision.setName("txtPrecision");
206
      jpanel1.add(txtPrecision,cc.xy(4,4));
207

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

    
211
      lblDataProfile.setName("lblDataProfile");
212
      lblDataProfile.setText("_Data_profile");
213
      jpanel1.add(lblDataProfile,cc.xy(2,8));
214

    
215
      cboDataProfile.setName("cboDataProfile");
216
      jpanel1.add(cboDataProfile,cc.xy(4,8));
217

    
218
      chkVirtualField.setActionCommand("Campo virtual");
219
      chkVirtualField.setName("chkVirtualField");
220
      chkVirtualField.setText("_Virtual_field");
221
      jpanel1.add(chkVirtualField,cc.xy(2,10));
222

    
223
      jpanel1.add(createPanel2(),cc.xy(4,10));
224
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10 });
225
      return jpanel1;
226
   }
227

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

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

    
242
      txtVirtualField.setName("txtVirtualField");
243
      jpanel1.add(txtVirtualField,cc.xy(1,1));
244

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

    
249
   public JPanel createPanel3()
250
   {
251
      JPanel jpanel1 = new JPanel();
252
      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");
253
      CellConstraints cc = new CellConstraints();
254
      jpanel1.setLayout(formlayout1);
255

    
256
      lblGeometryType.setName("lblGeometryType");
257
      lblGeometryType.setText("_Geometry_type");
258
      jpanel1.add(lblGeometryType,cc.xy(2,2));
259

    
260
      lblGeometrySubtype.setName("lblGeometrySubtype");
261
      lblGeometrySubtype.setText("_Geometry_subtype");
262
      jpanel1.add(lblGeometrySubtype,cc.xy(2,4));
263

    
264
      lblCRS.setName("lblCRS");
265
      lblCRS.setText("_CRS");
266
      jpanel1.add(lblCRS,cc.xy(2,6));
267

    
268
      cboGeometryType.setName("cboGeometryType");
269
      jpanel1.add(cboGeometryType,cc.xy(4,2));
270

    
271
      cboGeometrySubtype.setName("cboGeometrySubtype");
272
      jpanel1.add(cboGeometrySubtype,cc.xy(4,4));
273

    
274
      jpanel1.add(createPanel4(),cc.xy(4,6));
275
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7 });
276
      return jpanel1;
277
   }
278

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

    
286
      btnCRS.setActionCommand("...");
287
      btnCRS.setName("btnCRS");
288
      btnCRS.setText("...");
289
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
290
      btnCRS.setBorder(emptyborder1);
291
      jpanel1.add(btnCRS,cc.xy(3,1));
292

    
293
      txtCRS.setName("txtCRS");
294
      jpanel1.add(txtCRS,cc.xy(1,1));
295

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

    
300
   public JPanel createPanel5()
301
   {
302
      JPanel jpanel1 = new JPanel();
303
      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:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
304
      CellConstraints cc = new CellConstraints();
305
      jpanel1.setLayout(formlayout1);
306

    
307
      lblDateFormat.setName("lblDateFormat");
308
      lblDateFormat.setText("_Date_format");
309
      jpanel1.add(lblDateFormat,cc.xy(2,2));
310

    
311
      cboDateFormat.setEditable(true);
312
      cboDateFormat.setName("cboDateFormat");
313
      cboDateFormat.setRequestFocusEnabled(false);
314
      jpanel1.add(cboDateFormat,cc.xy(4,2));
315

    
316
      lblInterval.setName("lblInterval");
317
      lblInterval.setText("_Interval");
318
      jpanel1.add(lblInterval,new CellConstraints(2,5,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
319

    
320
      jpanel1.add(createPanel6(),cc.xy(4,5));
321
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6 });
322
      return jpanel1;
323
   }
324

    
325
   public JPanel createPanel6()
326
   {
327
      JPanel jpanel1 = new JPanel();
328
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
329
      CellConstraints cc = new CellConstraints();
330
      jpanel1.setLayout(formlayout1);
331

    
332
      lblIntervalStart.setName("lblIntervalStart");
333
      lblIntervalStart.setText("_Start");
334
      jpanel1.add(lblIntervalStart,cc.xy(1,1));
335

    
336
      lblIntervalEnd.setName("lblIntervalEnd");
337
      lblIntervalEnd.setText("_End");
338
      jpanel1.add(lblIntervalEnd,cc.xy(1,3));
339

    
340
      txtIntervalStart.setName("txtIntervalStart");
341
      jpanel1.add(txtIntervalStart,cc.xy(3,1));
342

    
343
      btnIntervalStart.setActionCommand("...");
344
      btnIntervalStart.setName("btnIntervalStart");
345
      btnIntervalStart.setText("...");
346
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
347
      btnIntervalStart.setBorder(emptyborder1);
348
      jpanel1.add(btnIntervalStart,cc.xy(5,1));
349

    
350
      btnIntervalEnd.setActionCommand("...");
351
      btnIntervalEnd.setName("btnIntervalEnd");
352
      btnIntervalEnd.setText("...");
353
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
354
      btnIntervalEnd.setBorder(emptyborder2);
355
      jpanel1.add(btnIntervalEnd,cc.xy(5,3));
356

    
357
      txtIntervalEnd.setName("txtIntervalEnd");
358
      jpanel1.add(txtIntervalEnd,cc.xy(3,3));
359

    
360
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2 });
361
      return jpanel1;
362
   }
363

    
364
   public JPanel createPanel7()
365
   {
366
      JPanel jpanel1 = new JPanel();
367
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
368
      CellConstraints cc = new CellConstraints();
369
      jpanel1.setLayout(formlayout1);
370

    
371
      lblIsPrimaryKey.setName("lblIsPrimaryKey");
372
      lblIsPrimaryKey.setText("_Primary_key");
373
      jpanel1.add(lblIsPrimaryKey,cc.xy(1,1));
374

    
375
      chkIsPrimaryKey.setName("chkIsPrimaryKey");
376
      jpanel1.add(chkIsPrimaryKey,cc.xy(3,1));
377

    
378
      lblIsAutomatic.setName("lblIsAutomatic");
379
      lblIsAutomatic.setText("_Value_automatic");
380
      jpanel1.add(lblIsAutomatic,cc.xy(5,1));
381

    
382
      chkIsAutomatic.setName("chkIsAutomatic");
383
      jpanel1.add(chkIsAutomatic,cc.xy(7,1));
384

    
385
      lblAllowNulls.setName("lblAllowNulls");
386
      lblAllowNulls.setText("_Allow_nulls");
387
      jpanel1.add(lblAllowNulls,cc.xy(9,1));
388

    
389
      chkAllowNulls.setName("chkAllowNulls");
390
      jpanel1.add(chkAllowNulls,cc.xy(11,1));
391

    
392
      addFillComponents(jpanel1,new int[]{ 2,4,6,8,10,12 },new int[0]);
393
      return jpanel1;
394
   }
395

    
396
   /**
397
    * Initializer
398
    */
399
   protected void initializePanel()
400
   {
401
      setLayout(new BorderLayout());
402
      add(createPanel(), BorderLayout.CENTER);
403
   }
404

    
405

    
406
}