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 / DownloaderConfigServicePanelView.java @ 47823
History | View | Annotate | Download (6.24 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.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.JTextField; |
18 |
import javax.swing.border.EmptyBorder; |
19 |
|
20 |
|
21 |
public class DownloaderConfigServicePanelView extends JPanel |
22 |
{ |
23 |
JTextField txtServiceURL = new JTextField(); |
24 |
JComboBox cboAuthenticationType = new JComboBox(); |
25 |
JButton btnAuthenticationConfig = new JButton(); |
26 |
JButton btnAuthenticationTest = new JButton(); |
27 |
JLabel lblServiceURL = new JLabel(); |
28 |
JLabel lblAuthenmticationType = new JLabel(); |
29 |
|
30 |
/**
|
31 |
* Default constructor
|
32 |
*/
|
33 |
public DownloaderConfigServicePanelView()
|
34 |
{ |
35 |
initializePanel(); |
36 |
} |
37 |
|
38 |
/**
|
39 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
40 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
41 |
* @param cols an array of column indices in the first row where fill components should be added.
|
42 |
* @param rows an array of row indices in the first column where fill components should be added.
|
43 |
*/
|
44 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
45 |
{ |
46 |
Dimension filler = new Dimension(10,10); |
47 |
|
48 |
boolean filled_cell_11 = false; |
49 |
CellConstraints cc = new CellConstraints();
|
50 |
if ( cols.length > 0 && rows.length > 0 ) |
51 |
{ |
52 |
if ( cols[0] == 1 && rows[0] == 1 ) |
53 |
{ |
54 |
/** add a rigid area */
|
55 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
56 |
filled_cell_11 = true;
|
57 |
} |
58 |
} |
59 |
|
60 |
for( int index = 0; index < cols.length; index++ ) |
61 |
{ |
62 |
if ( cols[index] == 1 && filled_cell_11 ) |
63 |
{ |
64 |
continue;
|
65 |
} |
66 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
67 |
} |
68 |
|
69 |
for( int index = 0; index < rows.length; index++ ) |
70 |
{ |
71 |
if ( rows[index] == 1 && filled_cell_11 ) |
72 |
{ |
73 |
continue;
|
74 |
} |
75 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
76 |
} |
77 |
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* Helper method to load an image file from the CLASSPATH
|
82 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
83 |
* @return an ImageIcon instance with the specified image file
|
84 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
85 |
*/
|
86 |
public ImageIcon loadImage( String imageName ) |
87 |
{ |
88 |
try
|
89 |
{ |
90 |
ClassLoader classloader = getClass().getClassLoader();
|
91 |
java.net.URL url = classloader.getResource( imageName ); |
92 |
if ( url != null ) |
93 |
{ |
94 |
ImageIcon icon = new ImageIcon( url ); |
95 |
return icon;
|
96 |
} |
97 |
} |
98 |
catch( Exception e ) |
99 |
{ |
100 |
e.printStackTrace(); |
101 |
} |
102 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
103 |
} |
104 |
|
105 |
/**
|
106 |
* Method for recalculating the component orientation for
|
107 |
* right-to-left Locales.
|
108 |
* @param orientation the component orientation to be applied
|
109 |
*/
|
110 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
111 |
{ |
112 |
// Not yet implemented...
|
113 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
114 |
super.applyComponentOrientation(orientation);
|
115 |
} |
116 |
|
117 |
public JPanel createPanel() |
118 |
{ |
119 |
JPanel jpanel1 = new JPanel(); |
120 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
121 |
CellConstraints cc = new CellConstraints();
|
122 |
jpanel1.setLayout(formlayout1); |
123 |
|
124 |
txtServiceURL.setName("txtServiceURL");
|
125 |
jpanel1.add(txtServiceURL,cc.xy(4,2)); |
126 |
|
127 |
jpanel1.add(createPanel1(),cc.xy(4,4)); |
128 |
lblServiceURL.setName("lblServiceURL");
|
129 |
lblServiceURL.setText("_Service_URL");
|
130 |
jpanel1.add(lblServiceURL,cc.xy(2,2)); |
131 |
|
132 |
lblAuthenmticationType.setName("lblAuthenmticationType");
|
133 |
lblAuthenmticationType.setText("_Authentication_type");
|
134 |
jpanel1.add(lblAuthenmticationType,cc.xy(2,4)); |
135 |
|
136 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5 }); |
137 |
return jpanel1;
|
138 |
} |
139 |
|
140 |
public JPanel createPanel1() |
141 |
{ |
142 |
JPanel jpanel1 = new JPanel(); |
143 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
144 |
CellConstraints cc = new CellConstraints();
|
145 |
jpanel1.setLayout(formlayout1); |
146 |
|
147 |
cboAuthenticationType.setName("cboAuthenticationType");
|
148 |
jpanel1.add(cboAuthenticationType,cc.xy(1,1)); |
149 |
|
150 |
btnAuthenticationConfig.setActionCommand("...");
|
151 |
btnAuthenticationConfig.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.downloader/org.gvsig.downloader.swing/org.gvsig.downloader.swing.impl/src/main/resources/org/gvsig/downloader/swing/impl/images/downloader-auth-config.png"));
|
152 |
btnAuthenticationConfig.setName("btnAuthenticationConfig");
|
153 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
154 |
btnAuthenticationConfig.setBorder(emptyborder1); |
155 |
jpanel1.add(btnAuthenticationConfig,cc.xy(3,1)); |
156 |
|
157 |
btnAuthenticationTest.setActionCommand("...");
|
158 |
btnAuthenticationTest.setIcon(loadImage("datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.downloader/org.gvsig.downloader.swing/org.gvsig.downloader.swing.impl/src/main/resources/org/gvsig/downloader/swing/impl/images/downloader-auth-test.png"));
|
159 |
btnAuthenticationTest.setName("btnAuthenticationTest");
|
160 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
161 |
btnAuthenticationTest.setBorder(emptyborder2); |
162 |
jpanel1.add(btnAuthenticationTest,cc.xy(5,1)); |
163 |
|
164 |
addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]); |
165 |
return jpanel1;
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* Initializer
|
170 |
*/
|
171 |
protected void initializePanel() |
172 |
{ |
173 |
setLayout(new BorderLayout()); |
174 |
add(createPanel(), BorderLayout.CENTER);
|
175 |
} |
176 |
|
177 |
|
178 |
} |