svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.downloader / org.gvsig.downloader.swing / org.gvsig.downloader.swing.impl / src / main / java / org / gvsig / downloader / swing / impl / config / DownloaderConfigPanelView.java @ 47821
History | View | Annotate | Download (11.5 KB)
1 |
package org.gvsig.downloader.swing.impl.config; |
---|---|
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.JFrame; |
14 |
import javax.swing.JList; |
15 |
import javax.swing.JPanel; |
16 |
import javax.swing.JScrollPane; |
17 |
import javax.swing.JTabbedPane; |
18 |
import javax.swing.JTable; |
19 |
import javax.swing.JTextArea; |
20 |
import javax.swing.border.EmptyBorder; |
21 |
|
22 |
|
23 |
public class DownloaderConfigPanelView extends JPanel |
24 |
{ |
25 |
JTabbedPane tabDownloaderConfig = new JTabbedPane(); |
26 |
JTable tblAuthenticatedServices = new JTable(); |
27 |
JButton btnAuthenticatedServicesEdit = new JButton(); |
28 |
JButton btnAuthenticatedServicesRemove = new JButton(); |
29 |
JButton btnAuthenticatedServicesAdd = new JButton(); |
30 |
JTable tblCredentials = new JTable(); |
31 |
JButton btnCredentialsEdit = new JButton(); |
32 |
JButton btnCredentialsRemove = new JButton(); |
33 |
JList lstAuthenticationTypes = new JList(); |
34 |
JTextArea txtAuthenticationTypesDescription = new JTextArea(); |
35 |
|
36 |
/**
|
37 |
* Default constructor
|
38 |
*/
|
39 |
public DownloaderConfigPanelView()
|
40 |
{ |
41 |
initializePanel(); |
42 |
} |
43 |
|
44 |
/**
|
45 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
46 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
47 |
* @param cols an array of column indices in the first row where fill components should be added.
|
48 |
* @param rows an array of row indices in the first column where fill components should be added.
|
49 |
*/
|
50 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
51 |
{ |
52 |
Dimension filler = new Dimension(10,10); |
53 |
|
54 |
boolean filled_cell_11 = false; |
55 |
CellConstraints cc = new CellConstraints();
|
56 |
if ( cols.length > 0 && rows.length > 0 ) |
57 |
{ |
58 |
if ( cols[0] == 1 && rows[0] == 1 ) |
59 |
{ |
60 |
/** add a rigid area */
|
61 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
62 |
filled_cell_11 = true;
|
63 |
} |
64 |
} |
65 |
|
66 |
for( int index = 0; index < cols.length; index++ ) |
67 |
{ |
68 |
if ( cols[index] == 1 && filled_cell_11 ) |
69 |
{ |
70 |
continue;
|
71 |
} |
72 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
73 |
} |
74 |
|
75 |
for( int index = 0; index < rows.length; index++ ) |
76 |
{ |
77 |
if ( rows[index] == 1 && filled_cell_11 ) |
78 |
{ |
79 |
continue;
|
80 |
} |
81 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
82 |
} |
83 |
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* Helper method to load an image file from the CLASSPATH
|
88 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
89 |
* @return an ImageIcon instance with the specified image file
|
90 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
91 |
*/
|
92 |
public ImageIcon loadImage( String imageName ) |
93 |
{ |
94 |
try
|
95 |
{ |
96 |
ClassLoader classloader = getClass().getClassLoader();
|
97 |
java.net.URL url = classloader.getResource( imageName ); |
98 |
if ( url != null ) |
99 |
{ |
100 |
ImageIcon icon = new ImageIcon( url ); |
101 |
return icon;
|
102 |
} |
103 |
} |
104 |
catch( Exception e ) |
105 |
{ |
106 |
e.printStackTrace(); |
107 |
} |
108 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
109 |
} |
110 |
|
111 |
/**
|
112 |
* Method for recalculating the component orientation for
|
113 |
* right-to-left Locales.
|
114 |
* @param orientation the component orientation to be applied
|
115 |
*/
|
116 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
117 |
{ |
118 |
// Not yet implemented...
|
119 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
120 |
super.applyComponentOrientation(orientation);
|
121 |
} |
122 |
|
123 |
public JPanel createPanel() |
124 |
{ |
125 |
JPanel jpanel1 = new JPanel(); |
126 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE"); |
127 |
CellConstraints cc = new CellConstraints();
|
128 |
jpanel1.setLayout(formlayout1); |
129 |
|
130 |
tabDownloaderConfig.setName("tabDownloaderConfig");
|
131 |
tabDownloaderConfig.addTab("_Authenticated_services",null,createPanel1()); |
132 |
tabDownloaderConfig.addTab("_Credentials",null,createPanel3()); |
133 |
tabDownloaderConfig.addTab("_Authentication_types",null,createPanel5()); |
134 |
jpanel1.add(tabDownloaderConfig,cc.xy(2,2)); |
135 |
|
136 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 }); |
137 |
return jpanel1;
|
138 |
} |
139 |
|
140 |
public JPanel createPanel1() |
141 |
{ |
142 |
JPanel jpanel1 = new JPanel(); |
143 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
144 |
CellConstraints cc = new CellConstraints();
|
145 |
jpanel1.setLayout(formlayout1); |
146 |
|
147 |
tblAuthenticatedServices.setName("tblAuthenticatedServices");
|
148 |
JScrollPane jscrollpane1 = new JScrollPane(); |
149 |
jscrollpane1.setViewportView(tblAuthenticatedServices); |
150 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
151 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
152 |
jpanel1.add(jscrollpane1,cc.xy(2,2)); |
153 |
|
154 |
jpanel1.add(createPanel2(),new CellConstraints(2,4,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
155 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5 }); |
156 |
return jpanel1;
|
157 |
} |
158 |
|
159 |
public JPanel createPanel2() |
160 |
{ |
161 |
JPanel jpanel1 = new JPanel(); |
162 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
163 |
CellConstraints cc = new CellConstraints();
|
164 |
jpanel1.setLayout(formlayout1); |
165 |
|
166 |
btnAuthenticatedServicesEdit.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.compat/org.gvsig.compat.se/src/main/resources/org/gvsig/compat/se/net/downloader/seauth/swing/images/common-edit.png"));
|
167 |
btnAuthenticatedServicesEdit.setName("btnAuthenticatedServicesEdit");
|
168 |
btnAuthenticatedServicesEdit.setToolTipText("_Edit_service");
|
169 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
170 |
btnAuthenticatedServicesEdit.setBorder(emptyborder1); |
171 |
jpanel1.add(btnAuthenticatedServicesEdit,cc.xy(6,1)); |
172 |
|
173 |
btnAuthenticatedServicesRemove.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.compat/org.gvsig.compat.se/src/main/resources/org/gvsig/compat/se/net/downloader/seauth/swing/images/common-remove.png"));
|
174 |
btnAuthenticatedServicesRemove.setName("btnAuthenticatedServicesRemove");
|
175 |
btnAuthenticatedServicesRemove.setToolTipText("_Remove_service");
|
176 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
177 |
btnAuthenticatedServicesRemove.setBorder(emptyborder2); |
178 |
jpanel1.add(btnAuthenticatedServicesRemove,cc.xy(4,1)); |
179 |
|
180 |
btnAuthenticatedServicesAdd.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.compat/org.gvsig.compat.se/src/main/resources/org/gvsig/compat/se/net/downloader/seauth/swing/images/common-add.png"));
|
181 |
btnAuthenticatedServicesAdd.setName("btnAuthenticatedServicesAdd");
|
182 |
btnAuthenticatedServicesAdd.setToolTipText("_Add_service");
|
183 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
184 |
btnAuthenticatedServicesAdd.setBorder(emptyborder3); |
185 |
jpanel1.add(btnAuthenticatedServicesAdd,cc.xy(2,1)); |
186 |
|
187 |
addFillComponents(jpanel1,new int[]{ 1,3,5 },new int[]{ 1 }); |
188 |
return jpanel1;
|
189 |
} |
190 |
|
191 |
public JPanel createPanel3() |
192 |
{ |
193 |
JPanel jpanel1 = new JPanel(); |
194 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
195 |
CellConstraints cc = new CellConstraints();
|
196 |
jpanel1.setLayout(formlayout1); |
197 |
|
198 |
tblCredentials.setName("tblCredentials");
|
199 |
JScrollPane jscrollpane1 = new JScrollPane(); |
200 |
jscrollpane1.setViewportView(tblCredentials); |
201 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
202 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
203 |
jpanel1.add(jscrollpane1,cc.xy(2,2)); |
204 |
|
205 |
jpanel1.add(createPanel4(),new CellConstraints(2,4,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
206 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5 }); |
207 |
return jpanel1;
|
208 |
} |
209 |
|
210 |
public JPanel createPanel4() |
211 |
{ |
212 |
JPanel jpanel1 = new JPanel(); |
213 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
214 |
CellConstraints cc = new CellConstraints();
|
215 |
jpanel1.setLayout(formlayout1); |
216 |
|
217 |
btnCredentialsEdit.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.compat/org.gvsig.compat.se/src/main/resources/org/gvsig/compat/se/net/downloader/seauth/swing/images/common-edit.png"));
|
218 |
btnCredentialsEdit.setName("btnCredentialsEdit");
|
219 |
btnCredentialsEdit.setToolTipText("_Edit_credentials");
|
220 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
221 |
btnCredentialsEdit.setBorder(emptyborder1); |
222 |
jpanel1.add(btnCredentialsEdit,cc.xy(6,1)); |
223 |
|
224 |
btnCredentialsRemove.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.compat/org.gvsig.compat.se/src/main/resources/org/gvsig/compat/se/net/downloader/seauth/swing/images/common-remove.png"));
|
225 |
btnCredentialsRemove.setName("btnCredentialsRemove");
|
226 |
btnCredentialsRemove.setToolTipText("_Remove_credentials");
|
227 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
228 |
btnCredentialsRemove.setBorder(emptyborder2); |
229 |
jpanel1.add(btnCredentialsRemove,cc.xy(4,1)); |
230 |
|
231 |
addFillComponents(jpanel1,new int[]{ 1,2,3,5 },new int[]{ 1 }); |
232 |
return jpanel1;
|
233 |
} |
234 |
|
235 |
public JPanel createPanel5() |
236 |
{ |
237 |
JPanel jpanel1 = new JPanel(); |
238 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
239 |
CellConstraints cc = new CellConstraints();
|
240 |
jpanel1.setLayout(formlayout1); |
241 |
|
242 |
lstAuthenticationTypes.setName("lstAuthenticationTypes");
|
243 |
JScrollPane jscrollpane1 = new JScrollPane(); |
244 |
jscrollpane1.setViewportView(lstAuthenticationTypes); |
245 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
246 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
247 |
jpanel1.add(jscrollpane1,cc.xy(2,2)); |
248 |
|
249 |
txtAuthenticationTypesDescription.setEditable(false);
|
250 |
txtAuthenticationTypesDescription.setName("txtAuthenticationTypesDescription");
|
251 |
JScrollPane jscrollpane2 = new JScrollPane(); |
252 |
jscrollpane2.setViewportView(txtAuthenticationTypesDescription); |
253 |
jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
254 |
jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
255 |
jpanel1.add(jscrollpane2,cc.xy(2,4)); |
256 |
|
257 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5 }); |
258 |
return jpanel1;
|
259 |
} |
260 |
|
261 |
/**
|
262 |
* Initializer
|
263 |
*/
|
264 |
protected void initializePanel() |
265 |
{ |
266 |
setLayout(new BorderLayout()); |
267 |
add(createPanel(), BorderLayout.CENTER);
|
268 |
} |
269 |
|
270 |
|
271 |
} |