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

History | View | Annotate | Download (14.1 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 lblGeometryType = new JLabel();
37
   JLabel lblGeometrySubtype = new JLabel();
38
   JLabel lblCRS = new JLabel();
39
   JComboBox cboGeometryType = new JComboBox();
40
   JComboBox cboGeometrySubtype = new JComboBox();
41
   JButton btnCRS = new JButton();
42
   JTextField txtCRS = new JTextField();
43
   JLabel lblDateFormat = new JLabel();
44
   JComboBox cboDateFormat = new JComboBox();
45
   JLabel lblInterval = new JLabel();
46
   JLabel lblIntervalStart = new JLabel();
47
   JLabel lblIntervalEnd = new JLabel();
48
   JTextField txtIntervalStart = new JTextField();
49
   JButton btnIntervalStart = new JButton();
50
   JButton btnIntervalEnd = new JButton();
51
   JTextField txtIntervalEnd = new JTextField();
52
   JCheckBox chkVirtualField = new JCheckBox();
53
   JButton btnVirtualField = new JButton();
54
   JTextField txtVirtualField = new JTextField();
55
   JLabel lblIsPrimaryKey = new JLabel();
56
   JCheckBox chkIsPrimaryKey = new JCheckBox();
57
   JLabel lblIsAutomatic = new JLabel();
58
   JCheckBox chkIsAutomatic = new JCheckBox();
59
   JLabel lblAllowNulls = new JLabel();
60
   JCheckBox chkAllowNulls = new JCheckBox();
61

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

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

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

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

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

    
110
   }
111

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

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

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

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

    
160
      txtFieldName.setName("txtFieldName");
161
      jpanel1.add(txtFieldName,cc.xy(4,2));
162

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

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

    
170
      tabAditionalFields.setName("tabAditionalFields");
171
      tabAditionalFields.addTab("_Basic_types",null,createPanel1());
172
      tabAditionalFields.addTab("_Geometry",null,createPanel2());
173
      tabAditionalFields.addTab("_Time",null,createPanel4());
174
      jpanel1.add(tabAditionalFields,cc.xywh(2,8,3,1));
175

    
176
      chkVirtualField.setActionCommand("Campo virtual");
177
      chkVirtualField.setName("chkVirtualField");
178
      chkVirtualField.setText("_Virtual_field");
179
      jpanel1.add(chkVirtualField,cc.xy(2,10));
180

    
181
      jpanel1.add(createPanel6(),cc.xy(4,10));
182
      jpanel1.add(createPanel7(),cc.xy(4,6));
183
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11 });
184
      return jpanel1;
185
   }
186

    
187
   public JPanel createPanel1()
188
   {
189
      JPanel jpanel1 = new JPanel();
190
      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");
191
      CellConstraints cc = new CellConstraints();
192
      jpanel1.setLayout(formlayout1);
193

    
194
      lblSize.setName("lblSize");
195
      lblSize.setText("_Size");
196
      jpanel1.add(lblSize,cc.xy(2,2));
197

    
198
      txtSize.setName("txtSize");
199
      jpanel1.add(txtSize,cc.xy(4,2));
200

    
201
      lblPrecision.setName("lblPrecision");
202
      lblPrecision.setText("_Precision");
203
      jpanel1.add(lblPrecision,cc.xy(2,4));
204

    
205
      lblDefaultValue.setName("lblDefaultValue");
206
      lblDefaultValue.setText("_Default_value");
207
      jpanel1.add(lblDefaultValue,cc.xy(2,6));
208

    
209
      txtPrecision.setName("txtPrecision");
210
      jpanel1.add(txtPrecision,cc.xy(4,4));
211

    
212
      txtDefaultValue.setName("txtDefaultValue");
213
      jpanel1.add(txtDefaultValue,cc.xy(4,6));
214

    
215
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7 });
216
      return jpanel1;
217
   }
218

    
219
   public JPanel createPanel2()
220
   {
221
      JPanel jpanel1 = new JPanel();
222
      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");
223
      CellConstraints cc = new CellConstraints();
224
      jpanel1.setLayout(formlayout1);
225

    
226
      lblGeometryType.setName("lblGeometryType");
227
      lblGeometryType.setText("_Geometry_type");
228
      jpanel1.add(lblGeometryType,cc.xy(2,2));
229

    
230
      lblGeometrySubtype.setName("lblGeometrySubtype");
231
      lblGeometrySubtype.setText("_Geometry_subtype");
232
      jpanel1.add(lblGeometrySubtype,cc.xy(2,4));
233

    
234
      lblCRS.setName("lblCRS");
235
      lblCRS.setText("_CRS");
236
      jpanel1.add(lblCRS,cc.xy(2,6));
237

    
238
      cboGeometryType.setName("cboGeometryType");
239
      jpanel1.add(cboGeometryType,cc.xy(4,2));
240

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

    
244
      jpanel1.add(createPanel3(),cc.xy(4,6));
245
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7 });
246
      return jpanel1;
247
   }
248

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

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

    
263
      txtCRS.setName("txtCRS");
264
      jpanel1.add(txtCRS,cc.xy(1,1));
265

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

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

    
277
      lblDateFormat.setName("lblDateFormat");
278
      lblDateFormat.setText("_Date_format");
279
      jpanel1.add(lblDateFormat,cc.xy(2,2));
280

    
281
      cboDateFormat.setEditable(true);
282
      cboDateFormat.setName("cboDateFormat");
283
      cboDateFormat.setRequestFocusEnabled(false);
284
      jpanel1.add(cboDateFormat,cc.xy(4,2));
285

    
286
      lblInterval.setName("lblInterval");
287
      lblInterval.setText("_Interval");
288
      jpanel1.add(lblInterval,new CellConstraints(2,5,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
289

    
290
      jpanel1.add(createPanel5(),cc.xy(4,5));
291
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6 });
292
      return jpanel1;
293
   }
294

    
295
   public JPanel createPanel5()
296
   {
297
      JPanel jpanel1 = new JPanel();
298
      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");
299
      CellConstraints cc = new CellConstraints();
300
      jpanel1.setLayout(formlayout1);
301

    
302
      lblIntervalStart.setName("lblIntervalStart");
303
      lblIntervalStart.setText("_Start");
304
      jpanel1.add(lblIntervalStart,cc.xy(1,1));
305

    
306
      lblIntervalEnd.setName("lblIntervalEnd");
307
      lblIntervalEnd.setText("_End");
308
      jpanel1.add(lblIntervalEnd,cc.xy(1,3));
309

    
310
      txtIntervalStart.setName("txtIntervalStart");
311
      jpanel1.add(txtIntervalStart,cc.xy(3,1));
312

    
313
      btnIntervalStart.setActionCommand("...");
314
      btnIntervalStart.setName("btnIntervalStart");
315
      btnIntervalStart.setText("...");
316
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
317
      btnIntervalStart.setBorder(emptyborder1);
318
      jpanel1.add(btnIntervalStart,cc.xy(5,1));
319

    
320
      btnIntervalEnd.setActionCommand("...");
321
      btnIntervalEnd.setName("btnIntervalEnd");
322
      btnIntervalEnd.setText("...");
323
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
324
      btnIntervalEnd.setBorder(emptyborder2);
325
      jpanel1.add(btnIntervalEnd,cc.xy(5,3));
326

    
327
      txtIntervalEnd.setName("txtIntervalEnd");
328
      jpanel1.add(txtIntervalEnd,cc.xy(3,3));
329

    
330
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2 });
331
      return jpanel1;
332
   }
333

    
334
   public JPanel createPanel6()
335
   {
336
      JPanel jpanel1 = new JPanel();
337
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
338
      CellConstraints cc = new CellConstraints();
339
      jpanel1.setLayout(formlayout1);
340

    
341
      btnVirtualField.setActionCommand("...");
342
      btnVirtualField.setName("btnVirtualField");
343
      btnVirtualField.setText("...");
344
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
345
      btnVirtualField.setBorder(emptyborder1);
346
      jpanel1.add(btnVirtualField,cc.xy(3,1));
347

    
348
      txtVirtualField.setName("txtVirtualField");
349
      jpanel1.add(txtVirtualField,cc.xy(1,1));
350

    
351
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
352
      return jpanel1;
353
   }
354

    
355
   public JPanel createPanel7()
356
   {
357
      JPanel jpanel1 = new JPanel();
358
      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");
359
      CellConstraints cc = new CellConstraints();
360
      jpanel1.setLayout(formlayout1);
361

    
362
      lblIsPrimaryKey.setName("lblIsPrimaryKey");
363
      lblIsPrimaryKey.setText("_Primary_key");
364
      jpanel1.add(lblIsPrimaryKey,cc.xy(1,1));
365

    
366
      chkIsPrimaryKey.setName("chkIsPrimaryKey");
367
      jpanel1.add(chkIsPrimaryKey,cc.xy(3,1));
368

    
369
      lblIsAutomatic.setName("lblIsAutomatic");
370
      lblIsAutomatic.setText("_Value_automatic");
371
      jpanel1.add(lblIsAutomatic,cc.xy(5,1));
372

    
373
      chkIsAutomatic.setName("chkIsAutomatic");
374
      jpanel1.add(chkIsAutomatic,cc.xy(7,1));
375

    
376
      lblAllowNulls.setName("lblAllowNulls");
377
      lblAllowNulls.setText("_Allow_nulls");
378
      jpanel1.add(lblAllowNulls,cc.xy(9,1));
379

    
380
      chkAllowNulls.setName("chkAllowNulls");
381
      jpanel1.add(chkAllowNulls,cc.xy(11,1));
382

    
383
      addFillComponents(jpanel1,new int[]{ 2,4,6,8,10,12 },new int[0]);
384
      return jpanel1;
385
   }
386

    
387
   /**
388
    * Initializer
389
    */
390
   protected void initializePanel()
391
   {
392
      setLayout(new BorderLayout());
393
      add(createPanel(), BorderLayout.CENTER);
394
   }
395

    
396

    
397
}