1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.j2ee.ui; 26 27 import javax.enterprise.deploy.spi.DeploymentManager ; 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 38 public class ConnectionTabVisualPanel extends javax.swing.JPanel { 39 40 44 45 private final DeploymentManagerProperties targetData; 46 private final SunDeploymentManagerInterface dm; 47 48 49 public ConnectionTabVisualPanel( DeploymentManager dm) { 50 51 this.dm = (SunDeploymentManagerInterface)dm; 52 targetData = new DeploymentManagerProperties(dm); 53 54 initComponents(); 55 InstanceProperties ips = targetData.getInstanceProperties(); 56 String url = (String ) ips.getProperty("url"); 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 setName(NbBundle.getMessage(ConnectionTabVisualPanel.class, "TITLE_AddUserDefinedLocalServerPanel")); 70 71 } 72 73 78 private void initComponents() { 80 81 socketField = new javax.swing.JTextField (); 82 userNameField = new javax.swing.JTextField (); 83 passwordField = new javax.swing.JPasswordField (); 84 domainField = new javax.swing.JTextField (); 85 domainLocField = new javax.swing.JTextField (); 86 portLabel = new javax.swing.JLabel (); 87 userNameLabel = new javax.swing.JLabel (); 88 userPasswordLabel = new javax.swing.JLabel (); 89 domainLabel = new javax.swing.JLabel (); 90 domainLocLabel = new javax.swing.JLabel (); 91 msgLabel = new javax.swing.JLabel (); 92 enableHttpMonitor = new javax.swing.JCheckBox (); 93 syncHttpProxies = new javax.swing.JCheckBox (); 94 95 socketField.setColumns(30); 96 socketField.setEditable(false); 97 98 userNameField.setColumns(30); 99 userNameField.addKeyListener(new java.awt.event.KeyAdapter () { 100 public void keyReleased(java.awt.event.KeyEvent evt) { 101 userNameFieldKeyReleased(evt); 102 } 103 }); 104 105 passwordField.setColumns(30); 106 passwordField.addKeyListener(new java.awt.event.KeyAdapter () { 107 public void keyReleased(java.awt.event.KeyEvent 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 bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/j2ee/ui/Bundle"); org.openide.awt.Mnemonics.setLocalizedText(portLabel, bundle.getString("LBL_AdminSocket")); 122 userNameLabel.setLabelFor(userNameField); 123 org.openide.awt.Mnemonics.setLocalizedText(userNameLabel, bundle.getString("LBL_Username")); 125 userPasswordLabel.setLabelFor(passwordField); 126 org.openide.awt.Mnemonics.setLocalizedText(userPasswordLabel, bundle.getString("LBL_Pw")); 128 domainLabel.setLabelFor(domainField); 129 org.openide.awt.Mnemonics.setLocalizedText(domainLabel, bundle.getString("LBL_Domain")); 131 domainLocLabel.setLabelFor(domainLocField); 132 org.openide.awt.Mnemonics.setLocalizedText(domainLocLabel, bundle.getString("LBL_DomainRoot")); 134 msgLabel.setForeground(new java.awt.Color (89, 79, 191)); 135 136 org.openide.awt.Mnemonics.setLocalizedText(enableHttpMonitor, org.openide.util.NbBundle.getBundle(ConnectionTabVisualPanel.class).getString("LBL_EnableHttpMonitor")); enableHttpMonitor.addActionListener(new java.awt.event.ActionListener () { 138 public void actionPerformed(java.awt.event.ActionEvent evt) { 139 enableHttpMonitorActionPerformed(evt); 140 } 141 }); 142 143 org.openide.awt.Mnemonics.setLocalizedText(syncHttpProxies, org.openide.util.NbBundle.getBundle(ConnectionTabVisualPanel.class).getString("LBL_SyncHttpProxy")); syncHttpProxies.addActionListener(new java.awt.event.ActionListener () { 145 public void actionPerformed(java.awt.event.ActionEvent 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 [] {passwordField, userNameField}, org.jdesktop.layout.GroupLayout.VERTICAL); 211 212 socketField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_AdminPort")); socketField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_AdminPort")); userNameField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Username")); userNameField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Username")); passwordField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Pw")); passwordField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Pw")); domainField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Domain")); domainField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Domain")); domainLocField.getAccessibleContext().setAccessibleName(bundle.getString("LBL_InstallRoot")); domainLocField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_InstallRoot")); portLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_AdminSocket")); portLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ASCD_AdminSocket")); userNameLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Username")); userNameLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Username")); userPasswordLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Pw")); userPasswordLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Pw")); domainLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_Domain")); domainLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Domain")); domainLocLabel.getAccessibleContext().setAccessibleName(bundle.getString("LBL_InstallRoot")); domainLocLabel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_InstallRoot")); enableHttpMonitor.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_EnableHttpMonitor")); syncHttpProxies.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ConnectionTabVisualPanel.class, "ACSD_SyncHttpProxy")); 235 getAccessibleContext().setAccessibleName(bundle.getString("Step_ChooseUserDefinedLocalServer")); getAccessibleContext().setAccessibleDescription(bundle.getString("AddUserDefinedLocalServerPanel_Desc")); } 239 private void syncHttpProxiesActionPerformed(java.awt.event.ActionEvent evt) { targetData.setSyncHttpProxyOn(syncHttpProxies.isSelected()); 241 if(syncHttpProxies.isSelected()) { 242 msgLabel.setText(NbBundle.getMessage(ConnectionTabVisualPanel.class, "Msg_httpProxyStatusChangedAtRestart")); 243 } 244 } 246 private void enableHttpMonitorActionPerformed(java.awt.event.ActionEvent evt) { targetData.setHttpMonitorOn(""+enableHttpMonitor.isSelected()); 248 msgLabel.setText(NbBundle.getMessage(ConnectionTabVisualPanel.class, "Msg_httpMonitorStatusChangedAtRestart")); 249 250 } 252 private void passwordFieldKeyReleased(java.awt.event.KeyEvent evt) { 258 } 260 private void userNameFieldKeyReleased(java.awt.event.KeyEvent evt) { 265 } 269 public void syncUpWithModel(){ 270 String userName = userNameField.getText(); 271 targetData.setUserName(userName); 272 dm.setUserName(userName); 273 char[] passWd = passwordField.getPassword(); 274 String adminPassword = new String (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(""))) { msgLabel.setText(NbBundle.getMessage(ConnectionTabVisualPanel.class, "Msg_ValidUser")); 283 retVal = false; 284 } 286 return retVal; 289 } 290 291 292 293 294 295 296 private javax.swing.JTextField domainField; 298 private javax.swing.JLabel domainLabel; 299 private javax.swing.JTextField domainLocField; 300 private javax.swing.JLabel domainLocLabel; 301 private javax.swing.JCheckBox enableHttpMonitor; 302 private javax.swing.JLabel msgLabel; 303 private javax.swing.JPasswordField passwordField; 304 private javax.swing.JLabel portLabel; 305 private javax.swing.JTextField socketField; 306 private javax.swing.JCheckBox syncHttpProxies; 307 private javax.swing.JTextField userNameField; 308 private javax.swing.JLabel userNameLabel; 309 private javax.swing.JLabel userPasswordLabel; 310 312 } 313 | Popular Tags |