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

History | View | Annotate | Download (13.9 KB)

1 44533 jjdelcerro
package org.gvsig.geodb;
2 41633 jjdelcerro
3 44533 jjdelcerro
import com.jeta.forms.components.border.TitledBorderLabel;
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 41633 jjdelcerro
import java.awt.Dimension;
10
import javax.swing.Box;
11 44533 jjdelcerro
import javax.swing.ImageIcon;
12 41633 jjdelcerro
import javax.swing.JButton;
13
import javax.swing.JComboBox;
14
import javax.swing.JLabel;
15
import javax.swing.JList;
16 44533 jjdelcerro
import javax.swing.JPanel;
17 41633 jjdelcerro
import javax.swing.JScrollPane;
18
import javax.swing.JTextField;
19 44533 jjdelcerro
import javax.swing.border.EmptyBorder;
20 41633 jjdelcerro
21
22 44533 jjdelcerro
public class AbstractWizardDBView extends JPanel
23
{
24
   TitledBorderLabel lblConnection = new TitledBorderLabel();
25
   JComboBox cboConnection = new JComboBox();
26
   JButton btnConnection = new JButton();
27
   JList lstTables = new JList();
28
   JButton btnDeselectAllColumns = new JButton();
29
   JButton btnSelectAllColumns = new JButton();
30
   TitledBorderLabel lblTable = new TitledBorderLabel();
31
   TitledBorderLabel lblColumns = new TitledBorderLabel();
32 45062 jjdelcerro
   JList lstColumns = new JList();
33
   JButton btnTablesFilter = new JButton();
34
   JTextField txtTablesFilter = new JTextField();
35 44533 jjdelcerro
   JLabel lblName = new JLabel();
36
   JTextField txtName = new JTextField();
37
   JLabel lblIdField = new JLabel();
38
   JComboBox cboIdField = new JComboBox();
39
   JLabel lblGeometryField = new JLabel();
40
   JComboBox cboGeometryField = new JComboBox();
41
   JLabel lblProjection = new JLabel();
42
   JTextField txtProjection = new JTextField();
43
   JButton btnProjection = new JButton();
44
   JLabel lblFilter = new JLabel();
45
   JTextField txtFilter = new JTextField();
46
   JButton btnFilter = new JButton();
47
   JButton btnFilterBookmarks = new JButton();
48
   JButton btnFilterHistory = new JButton();
49
   JButton btnAdvancedProperties = new JButton();
50 45627 fdiaz
   JLabel lblReadOnlyNotification = new JLabel();
51 41633 jjdelcerro
52 44533 jjdelcerro
   /**
53
    * Default constructor
54
    */
55
   public AbstractWizardDBView()
56
   {
57
      initializePanel();
58
   }
59 41633 jjdelcerro
60 44533 jjdelcerro
   /**
61
    * Adds fill components to empty cells in the first row and first column of the grid.
62
    * This ensures that the grid spacing will be the same as shown in the designer.
63
    * @param cols an array of column indices in the first row where fill components should be added.
64
    * @param rows an array of row indices in the first column where fill components should be added.
65
    */
66
   void addFillComponents( Container panel, int[] cols, int[] rows )
67
   {
68
      Dimension filler = new Dimension(10,10);
69 41633 jjdelcerro
70 44533 jjdelcerro
      boolean filled_cell_11 = false;
71
      CellConstraints cc = new CellConstraints();
72
      if ( cols.length > 0 && rows.length > 0 )
73
      {
74
         if ( cols[0] == 1 && rows[0] == 1 )
75
         {
76
            /** add a rigid area  */
77
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
78
            filled_cell_11 = true;
79
         }
80
      }
81 41633 jjdelcerro
82 44533 jjdelcerro
      for( int index = 0; index < cols.length; index++ )
83
      {
84
         if ( cols[index] == 1 && filled_cell_11 )
85
         {
86
            continue;
87
         }
88
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
89
      }
90 41633 jjdelcerro
91 44533 jjdelcerro
      for( int index = 0; index < rows.length; index++ )
92
      {
93
         if ( rows[index] == 1 && filled_cell_11 )
94
         {
95
            continue;
96
         }
97
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
98
      }
99 41633 jjdelcerro
100 44533 jjdelcerro
   }
101 41633 jjdelcerro
102 44533 jjdelcerro
   /**
103
    * Helper method to load an image file from the CLASSPATH
104
    * @param imageName the package and name of the file to load relative to the CLASSPATH
105
    * @return an ImageIcon instance with the specified image file
106
    * @throws IllegalArgumentException if the image resource cannot be loaded.
107
    */
108
   public ImageIcon loadImage( String imageName )
109
   {
110
      try
111
      {
112
         ClassLoader classloader = getClass().getClassLoader();
113
         java.net.URL url = classloader.getResource( imageName );
114
         if ( url != null )
115
         {
116
            ImageIcon icon = new ImageIcon( url );
117
            return icon;
118
         }
119
      }
120
      catch( Exception e )
121
      {
122
         e.printStackTrace();
123
      }
124
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
125
   }
126 41633 jjdelcerro
127 44533 jjdelcerro
   /**
128
    * Method for recalculating the component orientation for
129
    * right-to-left Locales.
130
    * @param orientation the component orientation to be applied
131
    */
132
   public void applyComponentOrientation( ComponentOrientation orientation )
133
   {
134
      // Not yet implemented...
135
      // I18NUtils.applyComponentOrientation(this, orientation);
136
      super.applyComponentOrientation(orientation);
137
   }
138 41633 jjdelcerro
139 44533 jjdelcerro
   public JPanel createPanel()
140
   {
141
      JPanel jpanel1 = new JPanel();
142
      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");
143
      CellConstraints cc = new CellConstraints();
144
      jpanel1.setLayout(formlayout1);
145 41633 jjdelcerro
146 44533 jjdelcerro
      lblConnection.setName("lblConnection");
147
      lblConnection.setText("_Connection");
148
      jpanel1.add(lblConnection,cc.xy(2,1));
149 41633 jjdelcerro
150 44533 jjdelcerro
      jpanel1.add(createPanel1(),cc.xy(2,3));
151
      jpanel1.add(createPanel2(),cc.xy(2,6));
152 45062 jjdelcerro
      jpanel1.add(createPanel5(),cc.xy(2,9));
153 45627 fdiaz
      jpanel1.add(createPanel8(),cc.xy(2,11));
154 44533 jjdelcerro
      addFillComponents(jpanel1,new int[]{ 1,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12 });
155
      return jpanel1;
156
   }
157 41633 jjdelcerro
158 44533 jjdelcerro
   public JPanel createPanel1()
159
   {
160
      JPanel jpanel1 = new JPanel();
161
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
162
      CellConstraints cc = new CellConstraints();
163
      jpanel1.setLayout(formlayout1);
164 41633 jjdelcerro
165 44533 jjdelcerro
      cboConnection.setName("cboConnection");
166
      jpanel1.add(cboConnection,cc.xy(1,1));
167 41633 jjdelcerro
168 44533 jjdelcerro
      btnConnection.setActionCommand("...");
169
      btnConnection.setName("btnConnection");
170
      btnConnection.setText("...");
171
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
172
      btnConnection.setBorder(emptyborder1);
173
      jpanel1.add(btnConnection,cc.xy(3,1));
174 41633 jjdelcerro
175 44533 jjdelcerro
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
176
      return jpanel1;
177
   }
178 41633 jjdelcerro
179 44533 jjdelcerro
   public JPanel createPanel2()
180
   {
181
      JPanel jpanel1 = new JPanel();
182 45062 jjdelcerro
      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");
183 44533 jjdelcerro
      CellConstraints cc = new CellConstraints();
184
      jpanel1.setLayout(formlayout1);
185 41633 jjdelcerro
186 44533 jjdelcerro
      lstTables.setName("lstTables");
187
      JScrollPane jscrollpane1 = new JScrollPane();
188
      jscrollpane1.setViewportView(lstTables);
189
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
190
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
191 45062 jjdelcerro
      jpanel1.add(jscrollpane1,cc.xywh(1,5,1,3));
192 41633 jjdelcerro
193 45062 jjdelcerro
      jpanel1.add(createPanel3(),cc.xy(3,7));
194 44533 jjdelcerro
      lblTable.setName("lblTable");
195
      lblTable.setText("choose_table");
196
      jpanel1.add(lblTable,cc.xy(1,1));
197 41633 jjdelcerro
198 44533 jjdelcerro
      lblColumns.setName("lblColumns");
199
      lblColumns.setText("table_fields");
200
      jpanel1.add(lblColumns,cc.xy(3,1));
201 41633 jjdelcerro
202 45062 jjdelcerro
      lstColumns.setName("lstColumns");
203
      JScrollPane jscrollpane2 = new JScrollPane();
204
      jscrollpane2.setViewportView(lstColumns);
205
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
206
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
207
      jpanel1.add(jscrollpane2,cc.xywh(3,3,1,3));
208
209
      jpanel1.add(createPanel4(),cc.xy(1,3));
210
      addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,3,4,6,7 });
211 44533 jjdelcerro
      return jpanel1;
212
   }
213 41633 jjdelcerro
214 44533 jjdelcerro
   public JPanel createPanel3()
215
   {
216
      JPanel jpanel1 = new JPanel();
217
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
218
      CellConstraints cc = new CellConstraints();
219
      jpanel1.setLayout(formlayout1);
220 41633 jjdelcerro
221 44533 jjdelcerro
      btnDeselectAllColumns.setActionCommand("Ninguno");
222
      btnDeselectAllColumns.setName("btnDeselectAllColumns");
223
      btnDeselectAllColumns.setText("_None");
224
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
225
      btnDeselectAllColumns.setBorder(emptyborder1);
226
      jpanel1.add(btnDeselectAllColumns,cc.xy(4,1));
227 41633 jjdelcerro
228 44533 jjdelcerro
      btnSelectAllColumns.setActionCommand("Todos");
229
      btnSelectAllColumns.setName("btnSelectAllColumns");
230
      btnSelectAllColumns.setText("_All");
231
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
232
      btnSelectAllColumns.setBorder(emptyborder2);
233
      jpanel1.add(btnSelectAllColumns,cc.xy(2,1));
234 41633 jjdelcerro
235 44533 jjdelcerro
      addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 });
236
      return jpanel1;
237
   }
238 41633 jjdelcerro
239 44533 jjdelcerro
   public JPanel createPanel4()
240
   {
241
      JPanel jpanel1 = new JPanel();
242 45062 jjdelcerro
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
243
      CellConstraints cc = new CellConstraints();
244
      jpanel1.setLayout(formlayout1);
245
246
      btnTablesFilter.setActionCommand("...");
247
      btnTablesFilter.setName("btnTablesFilter");
248
      btnTablesFilter.setText("...");
249
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
250
      btnTablesFilter.setBorder(emptyborder1);
251
      jpanel1.add(btnTablesFilter,cc.xy(3,1));
252
253
      txtTablesFilter.setName("txtTablesFilter");
254
      jpanel1.add(txtTablesFilter,cc.xy(1,1));
255
256
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
257
      return jpanel1;
258
   }
259
260
   public JPanel createPanel5()
261
   {
262
      JPanel jpanel1 = new JPanel();
263 44533 jjdelcerro
      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");
264
      CellConstraints cc = new CellConstraints();
265
      jpanel1.setLayout(formlayout1);
266
267
      lblName.setName("lblName");
268
      lblName.setText("_Name");
269
      jpanel1.add(lblName,cc.xy(1,2));
270
271
      txtName.setName("txtName");
272
      jpanel1.add(txtName,cc.xy(3,2));
273
274
      lblIdField.setName("lblIdField");
275
      lblIdField.setText("_Id_field");
276
      jpanel1.add(lblIdField,cc.xy(1,4));
277
278
      cboIdField.setName("cboIdField");
279
      jpanel1.add(cboIdField,cc.xy(3,4));
280
281
      lblGeometryField.setName("lblGeometryField");
282
      lblGeometryField.setText("_Geo_field");
283
      jpanel1.add(lblGeometryField,cc.xy(1,6));
284
285
      cboGeometryField.setName("cboGeometryField");
286
      jpanel1.add(cboGeometryField,cc.xy(3,6));
287
288
      lblProjection.setName("lblProjection");
289
      lblProjection.setText("_Projection");
290
      jpanel1.add(lblProjection,cc.xy(1,8));
291
292 45062 jjdelcerro
      jpanel1.add(createPanel6(),cc.xy(3,8));
293 44533 jjdelcerro
      lblFilter.setName("lblFilter");
294
      lblFilter.setText("_Filter");
295
      jpanel1.add(lblFilter,cc.xy(1,10));
296
297 45062 jjdelcerro
      jpanel1.add(createPanel7(),cc.xy(3,10));
298 44533 jjdelcerro
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,3,5,7,9 });
299
      return jpanel1;
300
   }
301
302 45062 jjdelcerro
   public JPanel createPanel6()
303 44533 jjdelcerro
   {
304
      JPanel jpanel1 = new JPanel();
305
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","FILL:DEFAULT:NONE");
306
      CellConstraints cc = new CellConstraints();
307
      jpanel1.setLayout(formlayout1);
308
309
      txtProjection.setName("txtProjection");
310
      jpanel1.add(txtProjection,cc.xy(1,1));
311
312
      btnProjection.setActionCommand("...");
313
      btnProjection.setName("btnProjection");
314
      btnProjection.setText("...");
315
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
316
      btnProjection.setBorder(emptyborder1);
317
      jpanel1.add(btnProjection,cc.xy(3,1));
318
319
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
320
      return jpanel1;
321
   }
322
323 45062 jjdelcerro
   public JPanel createPanel7()
324 44533 jjdelcerro
   {
325
      JPanel jpanel1 = new JPanel();
326
      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");
327
      CellConstraints cc = new CellConstraints();
328
      jpanel1.setLayout(formlayout1);
329
330
      txtFilter.setName("txtFilter");
331
      jpanel1.add(txtFilter,cc.xy(1,1));
332
333
      btnFilter.setActionCommand("...");
334
      btnFilter.setName("btnFilter");
335
      btnFilter.setText("...");
336
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
337
      btnFilter.setBorder(emptyborder1);
338
      jpanel1.add(btnFilter,cc.xy(3,1));
339
340
      btnFilterBookmarks.setActionCommand("...");
341
      btnFilterBookmarks.setName("btnFilterBookmarks");
342
      btnFilterBookmarks.setText("...");
343
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
344
      btnFilterBookmarks.setBorder(emptyborder2);
345
      jpanel1.add(btnFilterBookmarks,cc.xy(7,1));
346
347
      btnFilterHistory.setActionCommand("...");
348
      btnFilterHistory.setName("btnFilterHistory");
349
      btnFilterHistory.setText("...");
350
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
351
      btnFilterHistory.setBorder(emptyborder3);
352
      jpanel1.add(btnFilterHistory,cc.xy(5,1));
353
354
      addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]);
355
      return jpanel1;
356
   }
357
358 45627 fdiaz
   public JPanel createPanel8()
359
   {
360
      JPanel jpanel1 = new JPanel();
361
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
362
      CellConstraints cc = new CellConstraints();
363
      jpanel1.setLayout(formlayout1);
364
365
      btnAdvancedProperties.setActionCommand("_Advanced_properties");
366
      btnAdvancedProperties.setName("btnAdvancedProperties");
367
      btnAdvancedProperties.setText("_Advanced_properties");
368
      jpanel1.add(btnAdvancedProperties,cc.xy(2,1));
369
370
      lblReadOnlyNotification.setName("lblReadOnlyNotification");
371
      lblReadOnlyNotification.setToolTipText("");
372
      jpanel1.add(lblReadOnlyNotification,cc.xy(1,1));
373
374
      addFillComponents(jpanel1,new int[0],new int[0]);
375
      return jpanel1;
376
   }
377
378 44533 jjdelcerro
   /**
379
    * Initializer
380
    */
381
   protected void initializePanel()
382
   {
383
      setLayout(new BorderLayout());
384
      add(createPanel(), BorderLayout.CENTER);
385
   }
386
387
388 41633 jjdelcerro
}