Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / AbstractWizardDBView.java @ 45650

History | View | Annotate | Download (14.4 KB)

1
package org.gvsig.geodb;
2

    
3
import com.jeta.forms.components.border.TitledBorderLabel;
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.JComboBox;
15
import javax.swing.JFrame;
16
import javax.swing.JLabel;
17
import javax.swing.JList;
18
import javax.swing.JPanel;
19
import javax.swing.JScrollPane;
20
import javax.swing.JTextField;
21
import javax.swing.border.EmptyBorder;
22

    
23

    
24
public class AbstractWizardDBView extends JPanel
25
{
26
   TitledBorderLabel lblConnection = new TitledBorderLabel();
27
   JComboBox cboConnection = new JComboBox();
28
   JButton btnConnection = new JButton();
29
   JList lstTables = new JList();
30
   JButton btnDeselectAllColumns = new JButton();
31
   JButton btnSelectAllColumns = new JButton();
32
   TitledBorderLabel lblTable = new TitledBorderLabel();
33
   TitledBorderLabel lblColumns = new TitledBorderLabel();
34
   JList lstColumns = new JList();
35
   JButton btnTablesFilter = new JButton();
36
   JTextField txtTablesFilter = new JTextField();
37
   JLabel lblName = new JLabel();
38
   JTextField txtName = new JTextField();
39
   JLabel lblIdField = new JLabel();
40
   JComboBox cboIdField = new JComboBox();
41
   JLabel lblGeometryField = new JLabel();
42
   JComboBox cboGeometryField = new JComboBox();
43
   JLabel lblProjection = new JLabel();
44
   JTextField txtProjection = new JTextField();
45
   JButton btnProjection = new JButton();
46
   JLabel lblFilter = new JLabel();
47
   JTextField txtFilter = new JTextField();
48
   JButton btnFilter = new JButton();
49
   JButton btnFilterBookmarks = new JButton();
50
   JButton btnFilterHistory = new JButton();
51
   JButton btnAdvancedProperties = new JButton();
52
   JLabel lblReadOnlyNotification = new JLabel();
53
   JLabel pnlCfgActions = new JLabel();
54

    
55
   /**
56
    * Default constructor
57
    */
58
   public AbstractWizardDBView()
59
   {
60
      initializePanel();
61
   }
62

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

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

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

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

    
103
   }
104

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

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

    
142
   public JPanel createPanel()
143
   {
144
      JPanel jpanel1 = new JPanel();
145
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
146
      CellConstraints cc = new CellConstraints();
147
      jpanel1.setLayout(formlayout1);
148

    
149
      lblConnection.setName("lblConnection");
150
      lblConnection.setText("_Connection");
151
      jpanel1.add(lblConnection,cc.xy(2,1));
152

    
153
      jpanel1.add(createPanel1(),cc.xy(2,3));
154
      jpanel1.add(createPanel2(),cc.xy(2,6));
155
      jpanel1.add(createPanel5(),cc.xy(2,9));
156
      jpanel1.add(createPanel8(),cc.xy(2,11));
157
      addFillComponents(jpanel1,new int[]{ 1,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12 });
158
      return jpanel1;
159
   }
160

    
161
   public JPanel createPanel1()
162
   {
163
      JPanel jpanel1 = new JPanel();
164
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
165
      CellConstraints cc = new CellConstraints();
166
      jpanel1.setLayout(formlayout1);
167

    
168
      cboConnection.setName("cboConnection");
169
      jpanel1.add(cboConnection,cc.xy(1,1));
170

    
171
      btnConnection.setActionCommand("...");
172
      btnConnection.setName("btnConnection");
173
      btnConnection.setOpaque(false);
174
      btnConnection.setText("...");
175
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
176
      btnConnection.setBorder(emptyborder1);
177
      jpanel1.add(btnConnection,cc.xy(3,1));
178

    
179
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
180
      return jpanel1;
181
   }
182

    
183
   public JPanel createPanel2()
184
   {
185
      JPanel jpanel1 = new JPanel();
186
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(0.5),FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.5)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
187
      CellConstraints cc = new CellConstraints();
188
      jpanel1.setLayout(formlayout1);
189

    
190
      lstTables.setName("lstTables");
191
      JScrollPane jscrollpane1 = new JScrollPane();
192
      jscrollpane1.setViewportView(lstTables);
193
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
194
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
195
      jpanel1.add(jscrollpane1,cc.xywh(1,5,1,3));
196

    
197
      jpanel1.add(createPanel3(),cc.xy(3,7));
198
      lblTable.setName("lblTable");
199
      lblTable.setText("choose_table");
200
      jpanel1.add(lblTable,cc.xy(1,1));
201

    
202
      lblColumns.setName("lblColumns");
203
      lblColumns.setText("table_fields");
204
      jpanel1.add(lblColumns,cc.xy(3,1));
205

    
206
      lstColumns.setName("lstColumns");
207
      JScrollPane jscrollpane2 = new JScrollPane();
208
      jscrollpane2.setViewportView(lstColumns);
209
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
210
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
211
      jpanel1.add(jscrollpane2,cc.xywh(3,3,1,3));
212

    
213
      jpanel1.add(createPanel4(),cc.xy(1,3));
214
      addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,3,4,6,7 });
215
      return jpanel1;
216
   }
217

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

    
225
      btnDeselectAllColumns.setActionCommand("Ninguno");
226
      btnDeselectAllColumns.setName("btnDeselectAllColumns");
227
      btnDeselectAllColumns.setOpaque(false);
228
      btnDeselectAllColumns.setText("_None");
229
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
230
      btnDeselectAllColumns.setBorder(emptyborder1);
231
      jpanel1.add(btnDeselectAllColumns,cc.xy(4,1));
232

    
233
      btnSelectAllColumns.setActionCommand("Todos");
234
      btnSelectAllColumns.setName("btnSelectAllColumns");
235
      btnSelectAllColumns.setOpaque(false);
236
      btnSelectAllColumns.setText("_All");
237
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
238
      btnSelectAllColumns.setBorder(emptyborder2);
239
      jpanel1.add(btnSelectAllColumns,cc.xy(2,1));
240

    
241
      addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 });
242
      return jpanel1;
243
   }
244

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

    
252
      btnTablesFilter.setActionCommand("...");
253
      btnTablesFilter.setName("btnTablesFilter");
254
      btnTablesFilter.setText("...");
255
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
256
      btnTablesFilter.setBorder(emptyborder1);
257
      jpanel1.add(btnTablesFilter,cc.xy(3,1));
258

    
259
      txtTablesFilter.setName("txtTablesFilter");
260
      jpanel1.add(txtTablesFilter,cc.xy(1,1));
261

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

    
266
   public JPanel createPanel5()
267
   {
268
      JPanel jpanel1 = new JPanel();
269
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU: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");
270
      CellConstraints cc = new CellConstraints();
271
      jpanel1.setLayout(formlayout1);
272

    
273
      lblName.setName("lblName");
274
      lblName.setText("_Name");
275
      jpanel1.add(lblName,cc.xy(1,2));
276

    
277
      txtName.setName("txtName");
278
      jpanel1.add(txtName,cc.xy(3,2));
279

    
280
      lblIdField.setName("lblIdField");
281
      lblIdField.setText("_Id_field");
282
      jpanel1.add(lblIdField,cc.xy(1,4));
283

    
284
      cboIdField.setName("cboIdField");
285
      jpanel1.add(cboIdField,cc.xy(3,4));
286

    
287
      lblGeometryField.setName("lblGeometryField");
288
      lblGeometryField.setText("_Geo_field");
289
      jpanel1.add(lblGeometryField,cc.xy(1,6));
290

    
291
      cboGeometryField.setName("cboGeometryField");
292
      jpanel1.add(cboGeometryField,cc.xy(3,6));
293

    
294
      lblProjection.setName("lblProjection");
295
      lblProjection.setText("_Projection");
296
      jpanel1.add(lblProjection,cc.xy(1,8));
297

    
298
      jpanel1.add(createPanel6(),cc.xy(3,8));
299
      lblFilter.setName("lblFilter");
300
      lblFilter.setText("_Filter");
301
      jpanel1.add(lblFilter,cc.xy(1,10));
302

    
303
      jpanel1.add(createPanel7(),cc.xy(3,10));
304
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,3,5,7,9 });
305
      return jpanel1;
306
   }
307

    
308
   public JPanel createPanel6()
309
   {
310
      JPanel jpanel1 = new JPanel();
311
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","FILL:DEFAULT:NONE");
312
      CellConstraints cc = new CellConstraints();
313
      jpanel1.setLayout(formlayout1);
314

    
315
      txtProjection.setName("txtProjection");
316
      jpanel1.add(txtProjection,cc.xy(1,1));
317

    
318
      btnProjection.setActionCommand("...");
319
      btnProjection.setName("btnProjection");
320
      btnProjection.setOpaque(false);
321
      btnProjection.setText("...");
322
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
323
      btnProjection.setBorder(emptyborder1);
324
      jpanel1.add(btnProjection,cc.xy(3,1));
325

    
326
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
327
      return jpanel1;
328
   }
329

    
330
   public JPanel createPanel7()
331
   {
332
      JPanel jpanel1 = new JPanel();
333
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
334
      CellConstraints cc = new CellConstraints();
335
      jpanel1.setLayout(formlayout1);
336

    
337
      txtFilter.setName("txtFilter");
338
      jpanel1.add(txtFilter,cc.xy(1,1));
339

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

    
348
      btnFilterBookmarks.setActionCommand("...");
349
      btnFilterBookmarks.setName("btnFilterBookmarks");
350
      btnFilterBookmarks.setOpaque(false);
351
      btnFilterBookmarks.setText("...");
352
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
353
      btnFilterBookmarks.setBorder(emptyborder2);
354
      jpanel1.add(btnFilterBookmarks,cc.xy(7,1));
355

    
356
      btnFilterHistory.setActionCommand("...");
357
      btnFilterHistory.setName("btnFilterHistory");
358
      btnFilterHistory.setOpaque(false);
359
      btnFilterHistory.setText("...");
360
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
361
      btnFilterHistory.setBorder(emptyborder3);
362
      jpanel1.add(btnFilterHistory,cc.xy(5,1));
363

    
364
      addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]);
365
      return jpanel1;
366
   }
367

    
368
   public JPanel createPanel8()
369
   {
370
      JPanel jpanel1 = new JPanel();
371
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
372
      CellConstraints cc = new CellConstraints();
373
      jpanel1.setLayout(formlayout1);
374

    
375
      btnAdvancedProperties.setActionCommand("_Advanced_properties");
376
      btnAdvancedProperties.setName("btnAdvancedProperties");
377
      btnAdvancedProperties.setText("_Advanced_properties");
378
      jpanel1.add(btnAdvancedProperties,cc.xy(2,1));
379

    
380
      lblReadOnlyNotification.setName("lblReadOnlyNotification");
381
      jpanel1.add(lblReadOnlyNotification,new CellConstraints(1,1,1,1,CellConstraints.LEFT,CellConstraints.TOP));
382

    
383
      pnlCfgActions.setName("pnlCfgActions");
384
      jpanel1.add(pnlCfgActions,cc.xy(3,1));
385

    
386
      addFillComponents(jpanel1,new int[0],new int[0]);
387
      return jpanel1;
388
   }
389

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

    
399

    
400
}