svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.downloader / org.gvsig.downloader.swing / org.gvsig.downloader.swing.scribejava / src / main / java / org / gvsig / downloader / swing / scribejava / keycloak / DownloaderAuthenticationKeycloakConfigPanelView.java @ 47828
History | View | Annotate | Download (7.14 KB)
1 |
package org.gvsig.downloader.swing.scribejava.keycloak; |
---|---|
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.JLabel; |
15 |
import javax.swing.JPanel; |
16 |
import javax.swing.JTextField; |
17 |
import javax.swing.border.EmptyBorder; |
18 |
|
19 |
|
20 |
public class DownloaderAuthenticationKeycloakConfigPanelView extends JPanel |
21 |
{ |
22 |
JLabel lblUrlKeycloak = new JLabel(); |
23 |
JLabel lblRealm = new JLabel(); |
24 |
JLabel lblLocalPort = new JLabel(); |
25 |
JTextField txtRealm = new JTextField(); |
26 |
JTextField txtLocalPort = new JTextField(); |
27 |
JButton btnConfigKeycloakHistory = new JButton(); |
28 |
JButton btnConfigKeycloakBookmarks = new JButton(); |
29 |
JTextField txtUrlKeycloak = new JTextField(); |
30 |
JLabel lblClientid = new JLabel(); |
31 |
JLabel lblScope = new JLabel(); |
32 |
JTextField txtClientid = new JTextField(); |
33 |
JTextField txtScope = new JTextField(); |
34 |
JLabel lblServiceUrl = new JLabel(); |
35 |
JTextField txtServiceUrl = new JTextField(); |
36 |
|
37 |
/**
|
38 |
* Default constructor
|
39 |
*/
|
40 |
public DownloaderAuthenticationKeycloakConfigPanelView()
|
41 |
{ |
42 |
initializePanel(); |
43 |
} |
44 |
|
45 |
/**
|
46 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
47 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
48 |
* @param cols an array of column indices in the first row where fill components should be added.
|
49 |
* @param rows an array of row indices in the first column where fill components should be added.
|
50 |
*/
|
51 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
52 |
{ |
53 |
Dimension filler = new Dimension(10,10); |
54 |
|
55 |
boolean filled_cell_11 = false; |
56 |
CellConstraints cc = new CellConstraints();
|
57 |
if ( cols.length > 0 && rows.length > 0 ) |
58 |
{ |
59 |
if ( cols[0] == 1 && rows[0] == 1 ) |
60 |
{ |
61 |
/** add a rigid area */
|
62 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
63 |
filled_cell_11 = true;
|
64 |
} |
65 |
} |
66 |
|
67 |
for( int index = 0; index < cols.length; index++ ) |
68 |
{ |
69 |
if ( cols[index] == 1 && filled_cell_11 ) |
70 |
{ |
71 |
continue;
|
72 |
} |
73 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
74 |
} |
75 |
|
76 |
for( int index = 0; index < rows.length; index++ ) |
77 |
{ |
78 |
if ( rows[index] == 1 && filled_cell_11 ) |
79 |
{ |
80 |
continue;
|
81 |
} |
82 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
83 |
} |
84 |
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* Helper method to load an image file from the CLASSPATH
|
89 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
90 |
* @return an ImageIcon instance with the specified image file
|
91 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
92 |
*/
|
93 |
public ImageIcon loadImage( String imageName ) |
94 |
{ |
95 |
try
|
96 |
{ |
97 |
ClassLoader classloader = getClass().getClassLoader();
|
98 |
java.net.URL url = classloader.getResource( imageName ); |
99 |
if ( url != null ) |
100 |
{ |
101 |
ImageIcon icon = new ImageIcon( url ); |
102 |
return icon;
|
103 |
} |
104 |
} |
105 |
catch( Exception e ) |
106 |
{ |
107 |
e.printStackTrace(); |
108 |
} |
109 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
110 |
} |
111 |
|
112 |
/**
|
113 |
* Method for recalculating the component orientation for
|
114 |
* right-to-left Locales.
|
115 |
* @param orientation the component orientation to be applied
|
116 |
*/
|
117 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
118 |
{ |
119 |
// Not yet implemented...
|
120 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
121 |
super.applyComponentOrientation(orientation);
|
122 |
} |
123 |
|
124 |
public JPanel createPanel() |
125 |
{ |
126 |
JPanel jpanel1 = new JPanel(); |
127 |
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: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"); |
128 |
CellConstraints cc = new CellConstraints();
|
129 |
jpanel1.setLayout(formlayout1); |
130 |
|
131 |
lblUrlKeycloak.setName("lblUrlKeycloak");
|
132 |
lblUrlKeycloak.setText("_URL_Keycloak");
|
133 |
jpanel1.add(lblUrlKeycloak,cc.xy(2,5)); |
134 |
|
135 |
lblRealm.setName("lblRealm");
|
136 |
lblRealm.setText("_Realm");
|
137 |
jpanel1.add(lblRealm,cc.xy(2,11)); |
138 |
|
139 |
lblLocalPort.setName("lblLocalPort");
|
140 |
lblLocalPort.setText("_Local_port");
|
141 |
jpanel1.add(lblLocalPort,cc.xy(2,13)); |
142 |
|
143 |
txtRealm.setName("txtRealm");
|
144 |
jpanel1.add(txtRealm,cc.xy(4,11)); |
145 |
|
146 |
txtLocalPort.setName("txtLocalPort");
|
147 |
jpanel1.add(txtLocalPort,cc.xy(4,13)); |
148 |
|
149 |
jpanel1.add(createPanel1(),new CellConstraints(4,2,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
150 |
txtUrlKeycloak.setName("txtUrlKeycloak");
|
151 |
jpanel1.add(txtUrlKeycloak,cc.xy(4,5)); |
152 |
|
153 |
lblClientid.setName("lblClientid");
|
154 |
lblClientid.setText("_Client_ID");
|
155 |
jpanel1.add(lblClientid,cc.xy(2,7)); |
156 |
|
157 |
lblScope.setName("lblScope");
|
158 |
lblScope.setText("_Scope");
|
159 |
jpanel1.add(lblScope,cc.xy(2,9)); |
160 |
|
161 |
txtClientid.setName("txtClientid");
|
162 |
jpanel1.add(txtClientid,cc.xy(4,7)); |
163 |
|
164 |
txtScope.setName("txtScope");
|
165 |
jpanel1.add(txtScope,cc.xy(4,9)); |
166 |
|
167 |
lblServiceUrl.setName("lblServiceUrl");
|
168 |
lblServiceUrl.setText("_URL_Service");
|
169 |
jpanel1.add(lblServiceUrl,cc.xy(2,3)); |
170 |
|
171 |
txtServiceUrl.setName("txtServiceUrl");
|
172 |
jpanel1.add(txtServiceUrl,cc.xy(4,3)); |
173 |
|
174 |
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 }); |
175 |
return jpanel1;
|
176 |
} |
177 |
|
178 |
public JPanel createPanel1() |
179 |
{ |
180 |
JPanel jpanel1 = new JPanel(); |
181 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
182 |
CellConstraints cc = new CellConstraints();
|
183 |
jpanel1.setLayout(formlayout1); |
184 |
|
185 |
btnConfigKeycloakHistory.setActionCommand("...");
|
186 |
btnConfigKeycloakHistory.setName("btnConfigKeycloakHistory");
|
187 |
btnConfigKeycloakHistory.setText("...");
|
188 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
189 |
btnConfigKeycloakHistory.setBorder(emptyborder1); |
190 |
jpanel1.add(btnConfigKeycloakHistory,cc.xy(3,1)); |
191 |
|
192 |
btnConfigKeycloakBookmarks.setActionCommand("...");
|
193 |
btnConfigKeycloakBookmarks.setName("btnConfigKeycloakBookmarks");
|
194 |
btnConfigKeycloakBookmarks.setText("...");
|
195 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
196 |
btnConfigKeycloakBookmarks.setBorder(emptyborder2); |
197 |
jpanel1.add(btnConfigKeycloakBookmarks,cc.xy(5,1)); |
198 |
|
199 |
addFillComponents(jpanel1,new int[]{ 1,2,4 },new int[]{ 1 }); |
200 |
return jpanel1;
|
201 |
} |
202 |
|
203 |
/**
|
204 |
* Initializer
|
205 |
*/
|
206 |
protected void initializePanel() |
207 |
{ |
208 |
setLayout(new BorderLayout()); |
209 |
add(createPanel(), BorderLayout.CENTER);
|
210 |
} |
211 |
|
212 |
|
213 |
} |