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 / databaseworkspace / WorkspaceConfigurationPanelView.java @ 44304

History | View | Annotate | Download (12 KB)

1
package org.gvsig.geodb.databaseworkspace;
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.Color;
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.JPanel;
18
import javax.swing.JTextField;
19

    
20

    
21
public class WorkspaceConfigurationPanelView extends JPanel
22
{
23
   JButton btnCreateResourceTable = new JButton();
24
   JButton btnDropResourceTable = new JButton();
25
   JButton btnSearchResourceTable = new JButton();
26
   JButton btnShowResourceTable = new JButton();
27
   JComboBox cboConnections = new JComboBox();
28
   JButton btnAddConnection = new JButton();
29
   JButton btnShowRepositoryTable = new JButton();
30
   JButton btnSearchRepositoryTable = new JButton();
31
   JButton btnCreateRepositoryTable = new JButton();
32
   JButton btnDropRepositoryTable = new JButton();
33
   JButton btnRepositoryAddTable = new JButton();
34
   JButton btnConnectToRepository = new JButton();
35
   JButton btnCreateConfigurationTable = new JButton();
36
   JButton btnDropConfigurationTable = new JButton();
37
   JButton btnSearchConfigurationTable = new JButton();
38
   JButton btnShowConfigurationTable = new JButton();
39
   JTextField txtStoresRepositoryId = new JTextField();
40
   JTextField txtStoresRepositoryLabel = new JTextField();
41

    
42
   /**
43
    * Default constructor
44
    */
45
   public WorkspaceConfigurationPanelView()
46
   {
47
      initializePanel();
48
   }
49

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

    
60
      boolean filled_cell_11 = false;
61
      CellConstraints cc = new CellConstraints();
62
      if ( cols.length > 0 && rows.length > 0 )
63
      {
64
         if ( cols[0] == 1 && rows[0] == 1 )
65
         {
66
            /** add a rigid area  */
67
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
68
            filled_cell_11 = true;
69
         }
70
      }
71

    
72
      for( int index = 0; index < cols.length; index++ )
73
      {
74
         if ( cols[index] == 1 && filled_cell_11 )
75
         {
76
            continue;
77
         }
78
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
79
      }
80

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

    
90
   }
91

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

    
117
   /**
118
    * Method for recalculating the component orientation for 
119
    * right-to-left Locales.
120
    * @param orientation the component orientation to be applied
121
    */
122
   public void applyComponentOrientation( ComponentOrientation orientation )
123
   {
124
      // Not yet implemented...
125
      // I18NUtils.applyComponentOrientation(this, orientation);
126
      super.applyComponentOrientation(orientation);
127
   }
128

    
129
   public JPanel createPanel()
130
   {
131
      JPanel jpanel1 = new JPanel();
132
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
133
      CellConstraints cc = new CellConstraints();
134
      jpanel1.setLayout(formlayout1);
135

    
136
      JLabel jlabel1 = new JLabel();
137
      jlabel1.setText("Resources");
138
      jpanel1.add(jlabel1,cc.xy(2,5));
139

    
140
      JLabel jlabel2 = new JLabel();
141
      jlabel2.setText("Tables repository");
142
      jpanel1.add(jlabel2,cc.xy(2,9));
143

    
144
      JLabel jlabel3 = new JLabel();
145
      jlabel3.setText("Configuraction");
146
      jpanel1.add(jlabel3,cc.xy(2,15));
147

    
148
      JLabel jlabel4 = new JLabel();
149
      jlabel4.setText("Connection");
150
      jpanel1.add(jlabel4,cc.xy(2,1));
151

    
152
      jpanel1.add(createPanel1(),cc.xy(2,7));
153
      jpanel1.add(createPanel2(),cc.xy(2,3));
154
      jpanel1.add(createPanel3(),cc.xy(2,13));
155
      jpanel1.add(createPanel4(),cc.xy(2,17));
156
      jpanel1.add(createPanel5(),cc.xy(2,11));
157
      addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 });
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:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
165
      CellConstraints cc = new CellConstraints();
166
      jpanel1.setLayout(formlayout1);
167

    
168
      btnCreateResourceTable.setActionCommand("Create");
169
      btnCreateResourceTable.setName("btnCreateResourceTable");
170
      btnCreateResourceTable.setText("Create");
171
      jpanel1.add(btnCreateResourceTable,cc.xy(4,1));
172

    
173
      btnDropResourceTable.setActionCommand("Create");
174
      btnDropResourceTable.setName("btnDropResourceTable");
175
      btnDropResourceTable.setText("Drop");
176
      jpanel1.add(btnDropResourceTable,cc.xy(2,1));
177

    
178
      btnSearchResourceTable.setActionCommand("Edit");
179
      btnSearchResourceTable.setName("btnSearchResourceTable");
180
      btnSearchResourceTable.setText("Search");
181
      jpanel1.add(btnSearchResourceTable,cc.xy(6,1));
182

    
183
      btnShowResourceTable.setActionCommand("Edit");
184
      btnShowResourceTable.setName("btnShowResourceTable");
185
      btnShowResourceTable.setText("Show form");
186
      jpanel1.add(btnShowResourceTable,cc.xy(8,1));
187

    
188
      addFillComponents(jpanel1,new int[]{ 1,3,5,7 },new int[]{ 1 });
189
      return jpanel1;
190
   }
191

    
192
   public JPanel createPanel2()
193
   {
194
      JPanel jpanel1 = new JPanel();
195
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
196
      CellConstraints cc = new CellConstraints();
197
      jpanel1.setLayout(formlayout1);
198

    
199
      cboConnections.setName("cboConnections");
200
      jpanel1.add(cboConnections,cc.xy(1,1));
201

    
202
      btnAddConnection.setActionCommand("...");
203
      btnAddConnection.setName("btnAddConnection");
204
      btnAddConnection.setText("...");
205
      jpanel1.add(btnAddConnection,cc.xy(3,1));
206

    
207
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
208
      return jpanel1;
209
   }
210

    
211
   public JPanel createPanel3()
212
   {
213
      JPanel jpanel1 = new JPanel();
214
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
215
      CellConstraints cc = new CellConstraints();
216
      jpanel1.setLayout(formlayout1);
217

    
218
      btnShowRepositoryTable.setActionCommand("Edit");
219
      btnShowRepositoryTable.setName("btnShowRepositoryTable");
220
      btnShowRepositoryTable.setText("Show form");
221
      jpanel1.add(btnShowRepositoryTable,cc.xy(10,1));
222

    
223
      btnSearchRepositoryTable.setActionCommand("Edit");
224
      btnSearchRepositoryTable.setName("btnSearchRepositoryTable");
225
      btnSearchRepositoryTable.setText("Search");
226
      jpanel1.add(btnSearchRepositoryTable,cc.xy(8,1));
227

    
228
      btnCreateRepositoryTable.setActionCommand("Create");
229
      btnCreateRepositoryTable.setName("btnCreateRepositoryTable");
230
      btnCreateRepositoryTable.setText("Create");
231
      jpanel1.add(btnCreateRepositoryTable,cc.xy(6,1));
232

    
233
      btnDropRepositoryTable.setActionCommand("Create");
234
      btnDropRepositoryTable.setName("btnDropRepositoryTable");
235
      btnDropRepositoryTable.setText("Drop");
236
      jpanel1.add(btnDropRepositoryTable,cc.xy(4,1));
237

    
238
      btnRepositoryAddTable.setActionCommand("Edit");
239
      btnRepositoryAddTable.setName("btnRepositoryAddTable");
240
      btnRepositoryAddTable.setText("Add table");
241
      jpanel1.add(btnRepositoryAddTable,cc.xy(8,3));
242

    
243
      btnConnectToRepository.setActionCommand("Connect");
244
      btnConnectToRepository.setName("btnConnectToRepository");
245
      btnConnectToRepository.setText("Connect");
246
      jpanel1.add(btnConnectToRepository,cc.xy(10,3));
247

    
248
      addFillComponents(jpanel1,new int[]{ 1,2,3,5,7,9 },new int[]{ 1,2,3 });
249
      return jpanel1;
250
   }
251

    
252
   public JPanel createPanel4()
253
   {
254
      JPanel jpanel1 = new JPanel();
255
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
256
      CellConstraints cc = new CellConstraints();
257
      jpanel1.setLayout(formlayout1);
258

    
259
      btnCreateConfigurationTable.setActionCommand("Create");
260
      btnCreateConfigurationTable.setName("btnCreateConfigurationTable");
261
      btnCreateConfigurationTable.setText("Create");
262
      jpanel1.add(btnCreateConfigurationTable,cc.xy(4,1));
263

    
264
      btnDropConfigurationTable.setActionCommand("Create");
265
      btnDropConfigurationTable.setName("btnDropConfigurationTable");
266
      btnDropConfigurationTable.setText("Drop");
267
      jpanel1.add(btnDropConfigurationTable,cc.xy(2,1));
268

    
269
      btnSearchConfigurationTable.setActionCommand("Edit");
270
      btnSearchConfigurationTable.setName("btnSearchConfigurationTable");
271
      btnSearchConfigurationTable.setText("Search");
272
      jpanel1.add(btnSearchConfigurationTable,cc.xy(6,1));
273

    
274
      btnShowConfigurationTable.setActionCommand("Edit");
275
      btnShowConfigurationTable.setName("btnShowConfigurationTable");
276
      btnShowConfigurationTable.setText("Show form");
277
      jpanel1.add(btnShowConfigurationTable,cc.xy(8,1));
278

    
279
      addFillComponents(jpanel1,new int[]{ 1,3,5,7 },new int[]{ 1 });
280
      return jpanel1;
281
   }
282

    
283
   public JPanel createPanel5()
284
   {
285
      JPanel jpanel1 = new JPanel();
286
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
287
      CellConstraints cc = new CellConstraints();
288
      jpanel1.setLayout(formlayout1);
289

    
290
      JLabel jlabel1 = new JLabel();
291
      jlabel1.setText("Id");
292
      jpanel1.add(jlabel1,cc.xy(1,1));
293

    
294
      JLabel jlabel2 = new JLabel();
295
      jlabel2.setText("Label");
296
      jpanel1.add(jlabel2,cc.xy(1,3));
297

    
298
      txtStoresRepositoryId.setBackground(new Color(236,233,216));
299
      txtStoresRepositoryId.setEditable(false);
300
      txtStoresRepositoryId.setName("txtStoresRepositoryId");
301
      jpanel1.add(txtStoresRepositoryId,cc.xy(3,1));
302

    
303
      txtStoresRepositoryLabel.setBackground(new Color(236,233,216));
304
      txtStoresRepositoryLabel.setEditable(false);
305
      txtStoresRepositoryLabel.setName("txtStoresRepositoryLabel");
306
      jpanel1.add(txtStoresRepositoryLabel,cc.xy(3,3));
307

    
308
      addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2 });
309
      return jpanel1;
310
   }
311

    
312
   /**
313
    * Initializer
314
    */
315
   protected void initializePanel()
316
   {
317
      setLayout(new BorderLayout());
318
      add(createPanel(), BorderLayout.CENTER);
319
   }
320

    
321

    
322
}