KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > j2ee > ui > ConnectionTabVisualPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * ConnectionTabVisualPanel.java
21  *
22  * Created on January 7, 2004
23  */

24
25 package org.netbeans.modules.j2ee.sun.ide.j2ee.ui;
26
27 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
28 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface;
29 import org.openide.util.NbBundle;
30
31 import org.netbeans.modules.j2ee.sun.ide.j2ee.DeploymentManagerProperties;
32 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
33
34 /** A single panel for a wizard - the GUI portion.
35  *
36  * @author nityad
37  */

38 public class ConnectionTabVisualPanel extends javax.swing.JPanel JavaDoc {
39     
40     /** The wizard panel descriptor associated with this GUI panel.
41      * If you need to fire state changes or something similar, you can
42      * use this handle to do so.
43      */

44     
45     private final DeploymentManagerProperties targetData;
46     private final SunDeploymentManagerInterface dm;
47     
48     /** Create the wizard panel and set up some basic properties. */
49     public ConnectionTabVisualPanel( DeploymentManager JavaDoc dm) {
50         
51         this.dm = (SunDeploymentManagerInterface)dm;
52         targetData = new DeploymentManagerProperties(dm);
53
54         initComponents();
55         InstanceProperties ips = targetData.getInstanceProperties();
56         String JavaDoc url = (String JavaDoc) ips.getProperty("url"); // NOI18N
57
int dex = url.indexOf("::");
58         if (dex > -1){
59             url = url.substring(dex+2);
60         }
61         socketField.setText(url);
62         userNameField.setText(targetData.getUserName());
63         passwordField.setText(targetData.getPassword());
64         domainField.setText(targetData.getDomainName());
65         domainLocField.setText(targetData.getLocation());
66         enableHttpMonitor.setSelected(Boolean.valueOf(targetData.getHttpMonitorOn()).booleanValue());
67         syncHttpProxies.setSelected(targetData.isSyncHttpProxyOn());
68         // Provide a name in the title bar.
69
setName(NbBundle.getMessage(ConnectionTabVisualPanel.class, "TITLE_AddUserDefinedLocalServerPanel"));
70         
71     }
72     
73     /** This method is called from within the constructor to
74      * initialize the form.
75      * WARNING: Do NOT modify this code. The content of this method is
76      * always regenerated by the Form Editor.
77      */

78     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
79
private void initComponents() {
80
81         socketField = new javax.swing.JTextField JavaDoc();
82         userNameField = new javax.swing.JTextField JavaDoc();
83         passwordField = new javax.swing.JPasswordField JavaDoc();
84         domainField = new javax.swing.JTextField JavaDoc();
85         domainLocField = new javax.swing.JTextField JavaDoc();
86         portLabel = new javax.swing.JLabel JavaDoc();
87         userNameLabel = new javax.swing.JLabel JavaDoc();
88         userPasswordLabel = new javax.swing.JLabel JavaDoc();
89         domainLabel = new javax.swing.JLabel JavaDoc();
90         domainLocLabel = new javax.swing.JLabel JavaDoc();
91         msgLabel = new javax.swing.JLabel JavaDoc();
92         enableHttpMonitor = new javax.swing.JCheckBox JavaDoc();
93         syncHttpProxies = new javax.swing.JCheckBox JavaDoc();
94
95         socketField.setColumns(30);
96         socketField.setEditable(false);
97
98         userNameField.setColumns(30);
99         userNameField.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
100             public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
101                 userNameFieldKeyReleased(evt);
102             }
103         });
104
105         passwordField.setColumns(30);
106         passwordField.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
107             public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
108                 passwordFieldKeyReleased(evt);
109             }
110         });
111
112         domainField.setColumns(30);
113         domainField.setEditable(false);
114
115         domainLocField.setColumns(30);
116         domainLocField.setEditable(false);
117
118         portLabel.setLabelFor(socketField);
119         java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/j2ee/ui/Bundle"); // NOI18N
120
org.openide.awt.Mnemonics.setLocalizedText(portLabel, bundle.getString("LBL_AdminSocket")); // NOI18N
121

122         userNameLabel.setLabelFor(userNameField);
123         org.openide.awt.Mnemonics.setLocalizedText(userNameLabel, bundle.getString("LBL_Username")); // NOI18N
124

125         userPasswordLabel.setLabelFor(passwordField);
126         org.openide.awt.Mnemonics.setLocalizedText(userPasswordLabel, bundle.getString("LBL_Pw")); // NOI18N
127

128         domainLabel.setLabelFor(domainField);
129         org.openide.awt.Mnemonics.setLocalizedText(domainLabel, bundle.getString("LBL_Domain")); // NOI18N
130

131         domainLocLabel.setLabelFor(domainLocField);
132         org.openide.awt.Mnemonics.setLocalizedText(domainLocLabel, bundle.getString("LBL_DomainRoot")); // NOI18N
133

134         msgLabel.setForeground(new java.awt.Color JavaDoc(89, 79, 191));
135
136         org.openide.awt.Mnemonics.setLocalizedText(enableHttpMonitor, org.openide.util.NbBundle.getBundle(ConnectionTabVisualPanel.class).getString("LBL_EnableHttpMonitor")); // NOI18N
137
enableHttpMonitor.addActionListener(new java.awt.event.ActionListener JavaDoc() {
138             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
139                 enableHttpMonitorActionPerformed(evt);
140             }
141         });
142
143         org.openide.awt.Mnemonics.setLocalizedText(syncHttpProxies, org.openide.util.NbBundle.getBundle(ConnectionTabVisualPanel.class).getString("LBL_SyncHttpProxy")); // NOI18N
144
syncHttpProxies.addActionListener(new java.awt.event.ActionListener JavaDoc() {
145             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
146                 syncHttpProxiesActionPerformed(evt);
147             }
148         });
149
150         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
151         this.setLayout(layout);
152         layout.setHorizontalGroup(
153             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
154             .add(layout.createSequentialGroup()
155                 .addContainerGap()
156                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
157                     .add(org.jdesktop.layout.GroupLayout.TRAILING, msgLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE)
158                     .add(enableHttpMonitor)
159                     .add(syncHttpProxies)
160                     .add(layout.createSequentialGroup()
161                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
162                             .add(userNameLabel)
163                             .add(portLabel)
164                             .add(userPasswordLabel)
165                             .add(domainLocLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
166                             .add(domainLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
167                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
168                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
169                             .add(domainField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
170                             .add(org.jdesktop.layout.GroupLayout.TRAILING, domainLocField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
171                             .add(layout.createSequentialGroup()
172                                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
173                                 .add(socketField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE))
174                             .add(passwordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE)
175                             .add(userNameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 358, Short.MAX_VALUE))))
176                 .addContainerGap())
177         );
178         layout.setVerticalGroup(
179             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
180             .add(layout.createSequentialGroup()
181                 .addContainerGap()
182                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
183                     .add(socketField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
184                     .add(portLabel))
185                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
186                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
187                     .add(userNameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
188                     .add(userNameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
189                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
190                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
191                     .add(passwordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
192                     .add(userPasswordLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
193                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
194                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
195                     .add(domainLocLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
196                     .add(domainLocField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
197                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
198                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
199                     .add(domainField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
200                     .add(domainLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
201                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
202                 .add(enableHttpMonitor)
203                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
204                 .add(syncHttpProxies)
205                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
206                 .add(msgLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)
207                 .addContainerGap())
208         );
209
210         layout.linkSize(new java.awt.Component JavaDoc[] {passwordField, userNameField}, org.jdesktop.layout.GroupLayout.VERTICAL);
211
212         socketField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_AdminPort")); // NOI18N
213
socketField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_AdminPort")); // NOI18N
214
userNameField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Username")); // NOI18N
215
userNameField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Username")); // NOI18N
216
passwordField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Pw")); // NOI18N
217
passwordField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Pw")); // NOI18N
218
domainField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Domain")); // NOI18N
219
domainField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Domain")); // NOI18N
220
domainLocField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_InstallRoot")); // NOI18N
221
domainLocField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_InstallRoot")); // NOI18N
222
portLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_AdminSocket")); // NOI18N
223
portLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ASCD_AdminSocket")); // NOI18N
224
userNameLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Username")); // NOI18N
225
userNameLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Username")); // NOI18N
226
userPasswordLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Pw")); // NOI18N
227
userPasswordLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Pw")); // NOI18N
228
domainLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Domain")); // NOI18N
229
domainLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Domain")); // NOI18N
230
domainLocLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_InstallRoot")); // NOI18N
231
domainLocLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_InstallRoot")); // NOI18N
232
enableHttpMonitor.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_EnableHttpMonitor")); // NOI18N
233
syncHttpProxies.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ConnectionTabVisualPanel.class, "ACSD_SyncHttpProxy")); // NOI18N
234

235         getAccessibleContext().setAccessibleName(bundle.getString("Step_ChooseUserDefinedLocalServer")); // NOI18N
236
getAccessibleContext().setAccessibleDescription(bundle.getString("AddUserDefinedLocalServerPanel_Desc")); // NOI18N
237
}// </editor-fold>//GEN-END:initComponents
238

239     private void syncHttpProxiesActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_syncHttpProxiesActionPerformed
240
targetData.setSyncHttpProxyOn(syncHttpProxies.isSelected());
241         if(syncHttpProxies.isSelected()) {
242             msgLabel.setText(NbBundle.getMessage(ConnectionTabVisualPanel.class, "Msg_httpProxyStatusChangedAtRestart"));
243         }
244     }//GEN-LAST:event_syncHttpProxiesActionPerformed
245

246     private void enableHttpMonitorActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_enableHttpMonitorActionPerformed
247
targetData.setHttpMonitorOn(""+enableHttpMonitor.isSelected());
248         msgLabel.setText(NbBundle.getMessage(ConnectionTabVisualPanel.class, "Msg_httpMonitorStatusChangedAtRestart"));
249         
250     }//GEN-LAST:event_enableHttpMonitorActionPerformed
251

252     private void passwordFieldKeyReleased(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_passwordFieldKeyReleased
253
// char[] passWd = passwordField.getPassword();
254
// String adminPassword = new String(passWd);
255
// targetData.setPassword(adminPassword);
256
// dm.setPassword(adminPassword);
257

258     }//GEN-LAST:event_passwordFieldKeyReleased
259

260     private void userNameFieldKeyReleased(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_userNameFieldKeyReleased
261
// String userName = userNameField.getText();
262
// targetData.setUserName(userName);
263
// dm.setUserName(userName);
264

265     }//GEN-LAST:event_userNameFieldKeyReleased
266
/* store username and passord in the model
267      * called when the tab is gone
268      **/

269     public void syncUpWithModel(){
270         String JavaDoc userName = userNameField.getText();
271         targetData.setUserName(userName);
272         dm.setUserName(userName);
273         char[] passWd = passwordField.getPassword();
274         String JavaDoc adminPassword = new String JavaDoc(passWd);
275         targetData.setPassword(adminPassword);
276         dm.setPassword(adminPassword);
277     }
278     
279     public boolean isValid(){
280         boolean retVal = true;
281         if((userNameField.getText() == null) || (userNameField.getText().trim().equals(""))) {//NOI18N
282
msgLabel.setText(NbBundle.getMessage(ConnectionTabVisualPanel.class, "Msg_ValidUser"));
283             retVal = false;
284         } //else {
285

286 // char[] passWd = passwordField.getPassword();
287
// String userPassword = new String(passWd);
288
return retVal;
289     }
290     
291     
292     
293     
294     
295     
296     // Variables declaration - do not modify//GEN-BEGIN:variables
297
private javax.swing.JTextField JavaDoc domainField;
298     private javax.swing.JLabel JavaDoc domainLabel;
299     private javax.swing.JTextField JavaDoc domainLocField;
300     private javax.swing.JLabel JavaDoc domainLocLabel;
301     private javax.swing.JCheckBox JavaDoc enableHttpMonitor;
302     private javax.swing.JLabel JavaDoc msgLabel;
303     private javax.swing.JPasswordField JavaDoc passwordField;
304     private javax.swing.JLabel JavaDoc portLabel;
305     private javax.swing.JTextField JavaDoc socketField;
306     private javax.swing.JCheckBox JavaDoc syncHttpProxies;
307     private javax.swing.JTextField JavaDoc userNameField;
308     private javax.swing.JLabel JavaDoc userNameLabel;
309     private javax.swing.JLabel JavaDoc userPasswordLabel;
310     // End of variables declaration//GEN-END:variables
311

312 }
313
Popular Tags