Statistics
| Revision:

gvsig-projects-pool / org.gvsig.online / trunk / org.gvsig.online / org.gvsig.online.swing / org.gvsig.online.swing.impl / src / main / java / org / gvsig / online / swing / impl / initworkspace / OnlineJInitWorkingcopyView.java @ 9515

History | View | Annotate | Download (14.8 KB)

1
package org.gvsig.online.swing.impl.initworkspace;
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.JProgressBar;
19
import javax.swing.JScrollPane;
20
import javax.swing.JTable;
21
import javax.swing.JTextField;
22
import javax.swing.border.EmptyBorder;
23

    
24

    
25
public class OnlineJInitWorkingcopyView extends JPanel
26
{
27
   JLabel lblSiteUrl = new JLabel();
28
   JLabel lblProjects = new JLabel();
29
   JLabel lblWorkspaceFile = new JLabel();
30
   JLabel lblWorkspaceName = new JLabel();
31
   JLabel lblLayers = new JLabel();
32
   JTable tblLayers = new JTable();
33
   JLabel lblWorkingArea = new JLabel();
34
   JComboBox cboProjects = new JComboBox();
35
   JTextField txtWorkspaceName = new JTextField();
36
   JCheckBox chkCreateConnectionToDatabase = new JCheckBox();
37
   JTextField txtWorkspaceFile = new JTextField();
38
   JButton btnWorkspaceFile = new JButton();
39
   JTextField txtWorkingAreaLabel = new JTextField();
40
   JTextField txtWorkingArea = new JTextField();
41
   JButton btnWorkingAreaFromView = new JButton();
42
   JButton btnWorkingAreaDialog = new JButton();
43
   JButton btnWorkingAreaHistory = new JButton();
44
   JButton btnWorkingAreaBookmarks = new JButton();
45
   JButton btnSiteURLHistory = new JButton();
46
   JButton btnSiteURLBookmarks = new JButton();
47
   JTextField txtSiteURL = new JTextField();
48
   JButton btnSiteURLRefresh = new JButton();
49
   JLabel lblStatusTitle = new JLabel();
50
   JProgressBar pbStatus = new JProgressBar();
51
   JLabel lblStatusMessages = new JLabel();
52
   JButton btnStatusCancel = new JButton();
53
   JComboBox cboAuthentication = new JComboBox();
54
   JButton btnAuthentication = new JButton();
55
   JButton btnAuthenticationTest = new JButton();
56

    
57
   /**
58
    * Default constructor
59
    */
60
   public OnlineJInitWorkingcopyView()
61
   {
62
      initializePanel();
63
   }
64

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

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

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

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

    
105
   }
106

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

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

    
144
   public JPanel createPanel()
145
   {
146
      JPanel jpanel1 = new JPanel();
147
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT: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,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
148
      CellConstraints cc = new CellConstraints();
149
      jpanel1.setLayout(formlayout1);
150

    
151
      lblSiteUrl.setName("lblSiteUrl");
152
      lblSiteUrl.setText("Url del servidor");
153
      jpanel1.add(lblSiteUrl,cc.xy(2,2));
154

    
155
      lblProjects.setName("lblProjects");
156
      lblProjects.setText("Proyecto");
157
      jpanel1.add(lblProjects,cc.xy(2,6));
158

    
159
      lblWorkspaceFile.setName("lblWorkspaceFile");
160
      lblWorkspaceFile.setText("Fichero local");
161
      jpanel1.add(lblWorkspaceFile,cc.xy(2,8));
162

    
163
      lblWorkspaceName.setName("lblWorkspaceName");
164
      lblWorkspaceName.setText("Nombre");
165
      jpanel1.add(lblWorkspaceName,cc.xy(2,12));
166

    
167
      lblLayers.setName("lblLayers");
168
      lblLayers.setText("Capas");
169
      jpanel1.add(lblLayers,cc.xy(2,14));
170

    
171
      tblLayers.setName("tblLayers");
172
      JScrollPane jscrollpane1 = new JScrollPane();
173
      jscrollpane1.setViewportView(tblLayers);
174
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
175
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
176
      jpanel1.add(jscrollpane1,cc.xywh(2,16,3,1));
177

    
178
      lblWorkingArea.setName("lblWorkingArea");
179
      lblWorkingArea.setText("_Working_area");
180
      jpanel1.add(lblWorkingArea,new CellConstraints(2,18,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
181

    
182
      cboProjects.setName("cboProjects");
183
      jpanel1.add(cboProjects,cc.xy(4,6));
184

    
185
      txtWorkspaceName.setName("txtWorkspaceName");
186
      txtWorkspaceName.setSelectionEnd(7);
187
      txtWorkspaceName.setSelectionStart(7);
188
      txtWorkspaceName.setText("Pruebas");
189
      jpanel1.add(txtWorkspaceName,cc.xy(4,12));
190

    
191
      chkCreateConnectionToDatabase.setActionCommand("_Create_conexion_to_database");
192
      chkCreateConnectionToDatabase.setName("chkCreateConnectionToDatabase");
193
      chkCreateConnectionToDatabase.setSelected(true);
194
      chkCreateConnectionToDatabase.setText("_Create_conexion_to_database");
195
      chkCreateConnectionToDatabase.setHorizontalAlignment(JCheckBox.LEFT);
196
      jpanel1.add(chkCreateConnectionToDatabase,cc.xy(4,10));
197

    
198
      JLabel jlabel1 = new JLabel();
199
      jlabel1.setText("Autenticacion");
200
      jpanel1.add(jlabel1,cc.xy(2,4));
201

    
202
      jpanel1.add(createPanel1(),cc.xy(4,8));
203
      jpanel1.add(createPanel2(),cc.xy(4,18));
204
      jpanel1.add(createPanel3(),cc.xy(4,2));
205
      jpanel1.add(createPanel4(),cc.xywh(2,20,3,1));
206
      jpanel1.add(createPanel5(),cc.xy(4,4));
207
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 });
208
      return jpanel1;
209
   }
210

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

    
218
      txtWorkspaceFile.setName("txtWorkspaceFile");
219
      jpanel1.add(txtWorkspaceFile,cc.xy(1,1));
220

    
221
      btnWorkspaceFile.setActionCommand("...");
222
      btnWorkspaceFile.setName("btnWorkspaceFile");
223
      btnWorkspaceFile.setText("...");
224
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
225
      btnWorkspaceFile.setBorder(emptyborder1);
226
      jpanel1.add(btnWorkspaceFile,cc.xy(3,1));
227

    
228
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
229
      return jpanel1;
230
   }
231

    
232
   public JPanel createPanel2()
233
   {
234
      JPanel jpanel1 = new JPanel();
235
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
236
      CellConstraints cc = new CellConstraints();
237
      jpanel1.setLayout(formlayout1);
238

    
239
      txtWorkingAreaLabel.setName("txtWorkingAreaLabel");
240
      jpanel1.add(txtWorkingAreaLabel,cc.xy(1,1));
241

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

    
245
      btnWorkingAreaFromView.setActionCommand("...");
246
      btnWorkingAreaFromView.setIcon(loadImage("org.gvsig.online/org.gvsig.online.swing/org.gvsig.online.swing.impl/src/main/resources/org/gvsig/online/swing/impl/images/picker-envelope-from-mapcontrol.png"));
247
      btnWorkingAreaFromView.setName("btnWorkingAreaFromView");
248
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
249
      btnWorkingAreaFromView.setBorder(emptyborder1);
250
      jpanel1.add(btnWorkingAreaFromView,cc.xy(3,3));
251

    
252
      btnWorkingAreaDialog.setActionCommand("...");
253
      btnWorkingAreaDialog.setIcon(loadImage("addons/onlinecaptures/images/picker-envelope-from-mapcontrol.png"));
254
      btnWorkingAreaDialog.setName("btnWorkingAreaDialog");
255
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
256
      btnWorkingAreaDialog.setBorder(emptyborder2);
257
      jpanel1.add(btnWorkingAreaDialog,cc.xy(5,3));
258

    
259
      btnWorkingAreaHistory.setActionCommand("...");
260
      btnWorkingAreaHistory.setName("btnWorkingAreaHistory");
261
      btnWorkingAreaHistory.setText("...");
262
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
263
      btnWorkingAreaHistory.setBorder(emptyborder3);
264
      jpanel1.add(btnWorkingAreaHistory,cc.xy(3,1));
265

    
266
      btnWorkingAreaBookmarks.setActionCommand("...");
267
      btnWorkingAreaBookmarks.setName("btnWorkingAreaBookmarks");
268
      btnWorkingAreaBookmarks.setText("...");
269
      EmptyBorder emptyborder4 = new EmptyBorder(2,2,2,2);
270
      btnWorkingAreaBookmarks.setBorder(emptyborder4);
271
      jpanel1.add(btnWorkingAreaBookmarks,cc.xy(5,1));
272

    
273
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2 });
274
      return jpanel1;
275
   }
276

    
277
   public JPanel createPanel3()
278
   {
279
      JPanel jpanel1 = new JPanel();
280
      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");
281
      CellConstraints cc = new CellConstraints();
282
      jpanel1.setLayout(formlayout1);
283

    
284
      btnSiteURLHistory.setActionCommand("...");
285
      btnSiteURLHistory.setName("btnSiteURLHistory");
286
      btnSiteURLHistory.setText("...");
287
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
288
      btnSiteURLHistory.setBorder(emptyborder1);
289
      jpanel1.add(btnSiteURLHistory,cc.xy(5,1));
290

    
291
      btnSiteURLBookmarks.setActionCommand("...");
292
      btnSiteURLBookmarks.setName("btnSiteURLBookmarks");
293
      btnSiteURLBookmarks.setText("...");
294
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
295
      btnSiteURLBookmarks.setBorder(emptyborder2);
296
      jpanel1.add(btnSiteURLBookmarks,cc.xy(7,1));
297

    
298
      txtSiteURL.setName("txtSiteURL");
299
      jpanel1.add(txtSiteURL,cc.xy(1,1));
300

    
301
      btnSiteURLRefresh.setActionCommand("...");
302
      btnSiteURLRefresh.setIcon(loadImage("addons/onlinecaptures/capturas/common-refresh.png"));
303
      btnSiteURLRefresh.setName("btnSiteURLRefresh");
304
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
305
      btnSiteURLRefresh.setBorder(emptyborder3);
306
      jpanel1.add(btnSiteURLRefresh,cc.xy(3,1));
307

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

    
312
   public JPanel createPanel4()
313
   {
314
      JPanel jpanel1 = new JPanel();
315
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:MAX(12DLU;DEFAULT):NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
316
      CellConstraints cc = new CellConstraints();
317
      jpanel1.setLayout(formlayout1);
318

    
319
      lblStatusTitle.setName("lblStatusTitle");
320
      jpanel1.add(lblStatusTitle,cc.xy(1,1));
321

    
322
      pbStatus.setName("pbStatus");
323
      pbStatus.setValue(25);
324
      jpanel1.add(pbStatus,cc.xy(1,2));
325

    
326
      lblStatusMessages.setName("lblStatusMessages");
327
      jpanel1.add(lblStatusMessages,cc.xy(1,3));
328

    
329
      btnStatusCancel.setActionCommand("...");
330
      btnStatusCancel.setName("btnStatusCancel");
331
      btnStatusCancel.setOpaque(false);
332
      btnStatusCancel.setText("...");
333
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
334
      btnStatusCancel.setBorder(emptyborder1);
335
      jpanel1.add(btnStatusCancel,cc.xy(2,2));
336

    
337
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
338
      return jpanel1;
339
   }
340

    
341
   public JPanel createPanel5()
342
   {
343
      JPanel jpanel1 = new JPanel();
344
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
345
      CellConstraints cc = new CellConstraints();
346
      jpanel1.setLayout(formlayout1);
347

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

    
351
      btnAuthentication.setActionCommand("...");
352
      btnAuthentication.setIcon(loadImage("datos/devel/org.gvsig.online/org.gvsig.online.swing/org.gvsig.online.swing.impl/src/main/resources/org/gvsig/online/swing/impl/images/online-auth-config.png"));
353
      btnAuthentication.setName("btnAuthentication");
354
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
355
      btnAuthentication.setBorder(emptyborder1);
356
      jpanel1.add(btnAuthentication,cc.xy(3,1));
357

    
358
      btnAuthenticationTest.setActionCommand("...");
359
      btnAuthenticationTest.setIcon(loadImage("datos/devel/org.gvsig.online/org.gvsig.online.swing/org.gvsig.online.swing.impl/src/main/resources/org/gvsig/online/swing/impl/images/online-auth-test.png"));
360
      btnAuthenticationTest.setName("btnAuthenticationTest");
361
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
362
      btnAuthenticationTest.setBorder(emptyborder2);
363
      jpanel1.add(btnAuthenticationTest,cc.xy(5,1));
364

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

    
369
   /**
370
    * Initializer
371
    */
372
   protected void initializePanel()
373
   {
374
      setLayout(new BorderLayout());
375
      add(createPanel(), BorderLayout.CENTER);
376
   }
377

    
378

    
379
}