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 / download / OnlineJDownloadView.java @ 9512

History | View | Annotate | Download (9.44 KB)

1
package org.gvsig.online.swing.impl.download;
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.JComboBox;
14
import javax.swing.JFrame;
15
import javax.swing.JLabel;
16
import javax.swing.JPanel;
17
import javax.swing.JProgressBar;
18
import javax.swing.JScrollPane;
19
import javax.swing.JTable;
20
import javax.swing.JTextField;
21
import javax.swing.border.EmptyBorder;
22

    
23

    
24
public class OnlineJDownloadView extends JPanel
25
{
26
   JLabel lblProjects = new JLabel();
27
   JLabel lblWorkspaceName = new JLabel();
28
   JLabel lblLayers = new JLabel();
29
   JTable tblLayers = new JTable();
30
   JLabel lblWorkingArea = new JLabel();
31
   JComboBox cboWorkingcopy = new JComboBox();
32
   JTextField txtWorkspaceName = new JTextField();
33
   JTextField txtWorkingAreaLabel = new JTextField();
34
   JTextField txtWorkingArea = new JTextField();
35
   JButton btnWorkingAreaFromView = new JButton();
36
   JButton btnWorkingAreaDialog = new JButton();
37
   JButton btnWorkingAreaBookmarks = new JButton();
38
   JButton btnWorkingAreaHistory = new JButton();
39
   JLabel lblStatusTitle = new JLabel();
40
   JProgressBar pbStatus = new JProgressBar();
41
   JLabel lblStatusMessages = new JLabel();
42
   JButton btnStatusCancel = new JButton();
43

    
44
   /**
45
    * Default constructor
46
    */
47
   public OnlineJDownloadView()
48
   {
49
      initializePanel();
50
   }
51

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

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

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

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

    
92
   }
93

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

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

    
131
   public JPanel createPanel()
132
   {
133
      JPanel jpanel1 = new JPanel();
134
      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,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
135
      CellConstraints cc = new CellConstraints();
136
      jpanel1.setLayout(formlayout1);
137

    
138
      lblProjects.setName("lblProjects");
139
      lblProjects.setText("_Workingcopy");
140
      jpanel1.add(lblProjects,cc.xy(2,2));
141

    
142
      lblWorkspaceName.setName("lblWorkspaceName");
143
      lblWorkspaceName.setText("Nombre");
144
      jpanel1.add(lblWorkspaceName,cc.xy(2,4));
145

    
146
      lblLayers.setName("lblLayers");
147
      lblLayers.setText("Capas");
148
      jpanel1.add(lblLayers,cc.xy(2,6));
149

    
150
      tblLayers.setName("tblLayers");
151
      JScrollPane jscrollpane1 = new JScrollPane();
152
      jscrollpane1.setViewportView(tblLayers);
153
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
154
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
155
      jpanel1.add(jscrollpane1,cc.xywh(2,8,3,1));
156

    
157
      lblWorkingArea.setName("lblWorkingArea");
158
      lblWorkingArea.setText("_Working_area");
159
      jpanel1.add(lblWorkingArea,new CellConstraints(2,10,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
160

    
161
      cboWorkingcopy.setName("cboWorkingcopy");
162
      jpanel1.add(cboWorkingcopy,cc.xy(4,2));
163

    
164
      txtWorkspaceName.setName("txtWorkspaceName");
165
      txtWorkspaceName.setSelectionEnd(7);
166
      txtWorkspaceName.setSelectionStart(7);
167
      txtWorkspaceName.setText("Pruebas");
168
      jpanel1.add(txtWorkspaceName,cc.xy(4,4));
169

    
170
      jpanel1.add(createPanel1(),cc.xy(4,10));
171
      jpanel1.add(createPanel2(),cc.xywh(2,12,3,1));
172
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 });
173
      return jpanel1;
174
   }
175

    
176
   public JPanel createPanel1()
177
   {
178
      JPanel jpanel1 = new JPanel();
179
      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");
180
      CellConstraints cc = new CellConstraints();
181
      jpanel1.setLayout(formlayout1);
182

    
183
      txtWorkingAreaLabel.setName("txtWorkingAreaLabel");
184
      jpanel1.add(txtWorkingAreaLabel,cc.xy(1,1));
185

    
186
      txtWorkingArea.setName("txtWorkingArea");
187
      jpanel1.add(txtWorkingArea,cc.xy(1,3));
188

    
189
      btnWorkingAreaFromView.setActionCommand("...");
190
      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"));
191
      btnWorkingAreaFromView.setName("btnWorkingAreaFromView");
192
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
193
      btnWorkingAreaFromView.setBorder(emptyborder1);
194
      jpanel1.add(btnWorkingAreaFromView,cc.xy(3,3));
195

    
196
      btnWorkingAreaDialog.setActionCommand("...");
197
      btnWorkingAreaDialog.setIcon(loadImage("addons/onlinecaptures/images/picker-envelope-from-mapcontrol.png"));
198
      btnWorkingAreaDialog.setName("btnWorkingAreaDialog");
199
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
200
      btnWorkingAreaDialog.setBorder(emptyborder2);
201
      jpanel1.add(btnWorkingAreaDialog,cc.xy(5,3));
202

    
203
      btnWorkingAreaBookmarks.setActionCommand("...");
204
      btnWorkingAreaBookmarks.setName("btnWorkingAreaBookmarks");
205
      btnWorkingAreaBookmarks.setText("...");
206
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
207
      btnWorkingAreaBookmarks.setBorder(emptyborder3);
208
      jpanel1.add(btnWorkingAreaBookmarks,cc.xy(5,1));
209

    
210
      btnWorkingAreaHistory.setActionCommand("...");
211
      btnWorkingAreaHistory.setName("btnWorkingAreaHistory");
212
      btnWorkingAreaHistory.setText("...");
213
      EmptyBorder emptyborder4 = new EmptyBorder(2,2,2,2);
214
      btnWorkingAreaHistory.setBorder(emptyborder4);
215
      jpanel1.add(btnWorkingAreaHistory,cc.xy(3,1));
216

    
217
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2 });
218
      return jpanel1;
219
   }
220

    
221
   public JPanel createPanel2()
222
   {
223
      JPanel jpanel1 = new JPanel();
224
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:MAX(12DLU;DEFAULT):NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
225
      CellConstraints cc = new CellConstraints();
226
      jpanel1.setLayout(formlayout1);
227

    
228
      lblStatusTitle.setName("lblStatusTitle");
229
      jpanel1.add(lblStatusTitle,cc.xy(1,1));
230

    
231
      pbStatus.setName("pbStatus");
232
      pbStatus.setValue(25);
233
      jpanel1.add(pbStatus,cc.xy(1,2));
234

    
235
      lblStatusMessages.setName("lblStatusMessages");
236
      jpanel1.add(lblStatusMessages,cc.xy(1,3));
237

    
238
      btnStatusCancel.setActionCommand("...");
239
      btnStatusCancel.setName("btnStatusCancel");
240
      btnStatusCancel.setOpaque(false);
241
      btnStatusCancel.setText("...");
242
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
243
      btnStatusCancel.setBorder(emptyborder1);
244
      jpanel1.add(btnStatusCancel,cc.xy(2,2));
245

    
246
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
247
      return jpanel1;
248
   }
249

    
250
   /**
251
    * Initializer
252
    */
253
   protected void initializePanel()
254
   {
255
      setLayout(new BorderLayout());
256
      add(createPanel(), BorderLayout.CENTER);
257
   }
258

    
259

    
260
}