Statistics
| Revision:

gvsig-projects-pool / org.gvsig.online / trunk / org.gvsig.online / org.gvsig.online.swing / org.gvsig.online.swing.scribejava / src / main / java / org / gvsig / online / swing / scribejava / keycloak / UserIdentificationKeycloakConfigPanelView.java @ 9514

History | View | Annotate | Download (6.5 KB)

1
package org.gvsig.online.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 UserIdentificationKeycloakConfigPanelView 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
   JLabel lblUrlOnline = new JLabel();
28
   JTextField txtUrlOnline = new JTextField();
29
   JButton btnConfigKeycloakHistory = new JButton();
30
   JButton btnConfigKeycloakBookmarks = new JButton();
31
   JTextField txtUrlKeycloak = new JTextField();
32

    
33
   /**
34
    * Default constructor
35
    */
36
   public UserIdentificationKeycloakConfigPanelView()
37
   {
38
      initializePanel();
39
   }
40

    
41
   /**
42
    * Adds fill components to empty cells in the first row and first column of the grid.
43
    * This ensures that the grid spacing will be the same as shown in the designer.
44
    * @param cols an array of column indices in the first row where fill components should be added.
45
    * @param rows an array of row indices in the first column where fill components should be added.
46
    */
47
   void addFillComponents( Container panel, int[] cols, int[] rows )
48
   {
49
      Dimension filler = new Dimension(10,10);
50

    
51
      boolean filled_cell_11 = false;
52
      CellConstraints cc = new CellConstraints();
53
      if ( cols.length > 0 && rows.length > 0 )
54
      {
55
         if ( cols[0] == 1 && rows[0] == 1 )
56
         {
57
            /** add a rigid area  */
58
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
59
            filled_cell_11 = true;
60
         }
61
      }
62

    
63
      for( int index = 0; index < cols.length; index++ )
64
      {
65
         if ( cols[index] == 1 && filled_cell_11 )
66
         {
67
            continue;
68
         }
69
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
70
      }
71

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

    
81
   }
82

    
83
   /**
84
    * Helper method to load an image file from the CLASSPATH
85
    * @param imageName the package and name of the file to load relative to the CLASSPATH
86
    * @return an ImageIcon instance with the specified image file
87
    * @throws IllegalArgumentException if the image resource cannot be loaded.
88
    */
89
   public ImageIcon loadImage( String imageName )
90
   {
91
      try
92
      {
93
         ClassLoader classloader = getClass().getClassLoader();
94
         java.net.URL url = classloader.getResource( imageName );
95
         if ( url != null )
96
         {
97
            ImageIcon icon = new ImageIcon( url );
98
            return icon;
99
         }
100
      }
101
      catch( Exception e )
102
      {
103
         e.printStackTrace();
104
      }
105
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
106
   }
107

    
108
   /**
109
    * Method for recalculating the component orientation for 
110
    * right-to-left Locales.
111
    * @param orientation the component orientation to be applied
112
    */
113
   public void applyComponentOrientation( ComponentOrientation orientation )
114
   {
115
      // Not yet implemented...
116
      // I18NUtils.applyComponentOrientation(this, orientation);
117
      super.applyComponentOrientation(orientation);
118
   }
119

    
120
   public JPanel createPanel()
121
   {
122
      JPanel jpanel1 = new JPanel();
123
      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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
124
      CellConstraints cc = new CellConstraints();
125
      jpanel1.setLayout(formlayout1);
126

    
127
      lblUrlKeycloak.setName("lblUrlKeycloak");
128
      lblUrlKeycloak.setText("_URL_Keycloak");
129
      jpanel1.add(lblUrlKeycloak,cc.xy(2,6));
130

    
131
      lblRealm.setName("lblRealm");
132
      lblRealm.setText("_Realm");
133
      jpanel1.add(lblRealm,cc.xy(2,8));
134

    
135
      lblLocalPort.setName("lblLocalPort");
136
      lblLocalPort.setText("_Local_port");
137
      jpanel1.add(lblLocalPort,cc.xy(2,10));
138

    
139
      txtRealm.setName("txtRealm");
140
      jpanel1.add(txtRealm,cc.xy(4,8));
141

    
142
      txtLocalPort.setName("txtLocalPort");
143
      jpanel1.add(txtLocalPort,cc.xy(4,10));
144

    
145
      lblUrlOnline.setName("lblUrlOnline");
146
      lblUrlOnline.setText("_URL_gvSIG_Online");
147
      jpanel1.add(lblUrlOnline,cc.xy(2,4));
148

    
149
      txtUrlOnline.setName("txtUrlOnline");
150
      jpanel1.add(txtUrlOnline,cc.xy(4,4));
151

    
152
      jpanel1.add(createPanel1(),new CellConstraints(4,2,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
153
      txtUrlKeycloak.setName("txtUrlKeycloak");
154
      jpanel1.add(txtUrlKeycloak,cc.xy(4,6));
155

    
156
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11 });
157
      return jpanel1;
158
   }
159

    
160
   public JPanel createPanel1()
161
   {
162
      JPanel jpanel1 = new JPanel();
163
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
164
      CellConstraints cc = new CellConstraints();
165
      jpanel1.setLayout(formlayout1);
166

    
167
      btnConfigKeycloakHistory.setActionCommand("...");
168
      btnConfigKeycloakHistory.setName("btnConfigKeycloakHistory");
169
      btnConfigKeycloakHistory.setText("...");
170
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
171
      btnConfigKeycloakHistory.setBorder(emptyborder1);
172
      jpanel1.add(btnConfigKeycloakHistory,cc.xy(3,1));
173

    
174
      btnConfigKeycloakBookmarks.setActionCommand("...");
175
      btnConfigKeycloakBookmarks.setName("btnConfigKeycloakBookmarks");
176
      btnConfigKeycloakBookmarks.setText("...");
177
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
178
      btnConfigKeycloakBookmarks.setBorder(emptyborder2);
179
      jpanel1.add(btnConfigKeycloakBookmarks,cc.xy(5,1));
180

    
181
      addFillComponents(jpanel1,new int[]{ 1,2,4 },new int[]{ 1 });
182
      return jpanel1;
183
   }
184

    
185
   /**
186
    * Initializer
187
    */
188
   protected void initializePanel()
189
   {
190
      setLayout(new BorderLayout());
191
      add(createPanel(), BorderLayout.CENTER);
192
   }
193

    
194

    
195
}