1 23 24 29 30 package com.sun.enterprise.tools.upgrade.gui; 31 32 36 import javax.swing.JFileChooser ; 37 import com.sun.enterprise.tools.upgrade.gui.util.*; 38 import java.util.logging.*; 39 import com.sun.enterprise.util.i18n.StringManager; 40 import com.sun.enterprise.tools.upgrade.common.*; 41 import com.sun.enterprise.tools.upgrade.logging.*; 42 43 public class DataCollectionPanel extends javax.swing.JPanel { 44 45 private FlowLabel flowContentLabel; 46 private javax.swing.JLabel sourceDirLabel; 47 private javax.swing.JTextField sourceDirTextField; 48 private javax.swing.JButton sourceDirectoryBrowseButton; 49 private javax.swing.JButton destDirBrowseButton; 50 private javax.swing.JLabel destDirLabel; 51 private javax.swing.JTextField destDirTextField; 52 private javax.swing.JPanel containerPanel; 53 private javax.swing.JCheckBox upgradeCertificates; 54 private javax.swing.JPasswordField adminPWTextField; 55 private javax.swing.JTextField adminUserTextField; 56 private javax.swing.JPasswordField masterPWTextField; 57 58 private CommonInfoModel commonInfoModel; 59 60 private JFileChooser fileChooser = null; 61 private java.util.Vector dialogListeners = new java.util.Vector (); 62 63 private StringManager stringManager = StringManager.getManager("com.sun.enterprise.tools.upgrade.gui"); 64 private Logger logger = com.sun.enterprise.tools.upgrade.common.CommonInfoModel.getDefaultLogger(); 65 66 67 public DataCollectionPanel(CommonInfoModel coInfoModel) { 68 this.commonInfoModel = coInfoModel; 69 initialize(); 70 } 71 private void initialize(){ 72 initComponents(); 73 this.setLayout(new java.awt.BorderLayout ()); 74 HeaderPanel headerPanel = new HeaderPanel(stringManager.getString("upgrade.gui.detailspanel.headerPanel")); 75 headerPanel.setInsets(new java.awt.Insets (12, 10, 5, 10)); 76 add(headerPanel, "North"); 77 add(containerPanel, "Center"); 78 sourceDirectoryBrowseButton.addActionListener(new java.awt.event.ActionListener () { 79 public void actionPerformed(java.awt.event.ActionEvent evt) { 80 sourceActionPerformed(evt); 81 } 82 }); 83 destDirBrowseButton.addActionListener(new java.awt.event.ActionListener () { 84 public void actionPerformed(java.awt.event.ActionEvent evt) { 85 destActionPerformed(evt); 86 } 87 }); 88 getfileChooser().setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY); 89 java.awt.event.KeyAdapter keyAdapter = new java.awt.event.KeyAdapter (){ 90 public void keyReleased(java.awt.event.KeyEvent ke){ 91 processDialogEvent(); 92 } 93 }; 94 sourceDirTextField.addKeyListener(keyAdapter); 95 destDirTextField.addKeyListener(keyAdapter); 96 String sourceDir=commonInfoModel.getSourceInstallDir(); 97 String targetDir=commonInfoModel.getTargetDomainRoot(); 98 if(sourceDir != null && !(sourceDir.equals(""))) 99 sourceDirTextField.setText(sourceDir); 100 if(targetDir != null && !(targetDir.equals(""))) 101 destDirTextField.setText(targetDir); 102 103 String adminUserName = commonInfoModel.getAdminUserName(); 104 String adminPassword = commonInfoModel.getAdminPassword(); 105 adminUserTextField.addKeyListener(keyAdapter); 106 adminPWTextField.addKeyListener(keyAdapter); 107 108 if(adminUserName != null && !(adminUserName.equals(""))) 109 adminUserTextField.setText(adminUserName); 110 if(adminPassword != null && !(adminPassword.equals(""))) 111 adminPWTextField.setText(adminPassword); 112 113 if(!this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){ 114 String masterPassword = commonInfoModel.getMasterPassword(); 115 masterPWTextField.addKeyListener(keyAdapter); 116 if(masterPassword != null && !(masterPassword.equals(""))) 117 masterPWTextField.setText(masterPassword); 118 } 119 120 } 121 125 private void initComponents() { 126 java.awt.GridBagConstraints gridBagConstraints; 127 flowContentLabel = new FlowLabel(); 128 sourceDirLabel = new javax.swing.JLabel (); 129 sourceDirTextField = new javax.swing.JTextField (); 130 sourceDirectoryBrowseButton = new javax.swing.JButton (); 131 destDirLabel = new javax.swing.JLabel (); 132 destDirTextField = new javax.swing.JTextField (); 133 destDirBrowseButton = new javax.swing.JButton (); 134 containerPanel = new javax.swing.JPanel (); 135 136 containerPanel.setLayout(new java.awt.GridBagLayout ()); 137 138 flowContentLabel.setText(stringManager.getString("upgrade.gui.detailspanel.flowContentLable")); 139 gridBagConstraints = new java.awt.GridBagConstraints (); 140 gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; 141 gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 1; 142 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 143 gridBagConstraints.insets = new java.awt.Insets (0, 10, 5, 0); 144 gridBagConstraints.weightx = 1.0; 145 containerPanel.add(flowContentLabel, gridBagConstraints); 146 147 sourceDirLabel.setText(stringManager.getString("upgrade.gui.detailspanel.sourceDirLabel")); 148 gridBagConstraints = new java.awt.GridBagConstraints (); 149 gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; 150 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 151 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 152 gridBagConstraints.insets = new java.awt.Insets (10, 10, 3, 10); 153 gridBagConstraints.weightx = 1.0; 154 containerPanel.add(sourceDirLabel, gridBagConstraints); 155 156 gridBagConstraints = new java.awt.GridBagConstraints (); 157 gridBagConstraints.gridx = 0; 158 gridBagConstraints.gridy = 2; 159 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 160 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 161 gridBagConstraints.insets = new java.awt.Insets (0, 10, 10, 5); 162 gridBagConstraints.weightx = 1.0; 163 containerPanel.add(sourceDirTextField, gridBagConstraints); 164 165 sourceDirectoryBrowseButton.setText(stringManager.getString("upgrade.gui.detailspanel.browseButtonText")); 166 gridBagConstraints = new java.awt.GridBagConstraints (); 167 gridBagConstraints.gridx = 1; 168 gridBagConstraints.gridy = 2; 169 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 170 gridBagConstraints.insets = new java.awt.Insets (0, 5, 10, 10); 171 containerPanel.add(sourceDirectoryBrowseButton, gridBagConstraints); 172 173 destDirLabel.setText(stringManager.getString("upgrade.gui.detailspanel.targetDirLabel")); 174 gridBagConstraints = new java.awt.GridBagConstraints (); 175 gridBagConstraints.gridx = 0; 176 gridBagConstraints.gridy = 3; 177 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.insets = new java.awt.Insets (0, 10, 3, 10); 180 gridBagConstraints.weightx = 1.0; 181 containerPanel.add(destDirLabel, gridBagConstraints); 182 183 gridBagConstraints = new java.awt.GridBagConstraints (); 184 gridBagConstraints.gridx = 0; 185 gridBagConstraints.gridy = 4; 186 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 187 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 188 gridBagConstraints.insets = new java.awt.Insets (0, 10, 10, 5); 189 gridBagConstraints.weightx = 1.0; 190 containerPanel.add(destDirTextField, gridBagConstraints); 191 192 destDirBrowseButton.setText(stringManager.getString("upgrade.gui.detailspanel.browseButtonText")); 193 gridBagConstraints = new java.awt.GridBagConstraints (); 194 gridBagConstraints.gridx = 1; 195 gridBagConstraints.gridy = 4; 196 gridBagConstraints.insets = new java.awt.Insets (0, 5, 10, 5); 197 containerPanel.add(destDirBrowseButton, gridBagConstraints); 198 199 upgradeCertificates = new javax.swing.JCheckBox (stringManager.getString("upgrade.gui.detailspanel.transferCertCheckBoxText"),false); 200 gridBagConstraints = new java.awt.GridBagConstraints (); 201 gridBagConstraints.gridx = 0; 202 gridBagConstraints.gridy = 5; 203 gridBagConstraints.gridwidth = 2; 204 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 205 gridBagConstraints.insets = new java.awt.Insets (10, 10, 10, 5); 206 gridBagConstraints.weightx = 1.0; 207 gridBagConstraints.weighty = 0; 208 containerPanel.add(upgradeCertificates, gridBagConstraints); 209 210 javax.swing.JPanel adminUserPwPanel = getAdminUserPasswordPanel(); 211 gridBagConstraints = new java.awt.GridBagConstraints (); 212 gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; 213 gridBagConstraints.gridheight = 1; gridBagConstraints.gridwidth = 2; 214 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 215 gridBagConstraints.insets = new java.awt.Insets (0, 0, 3, 10); 216 gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 0.0; 217 containerPanel.add(adminUserPwPanel, gridBagConstraints); 218 219 if(this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){ 220 javax.swing.JPanel dummyPanel = new javax.swing.JPanel (); 221 gridBagConstraints = new java.awt.GridBagConstraints (); 222 gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; 223 gridBagConstraints.gridheight = 1; gridBagConstraints.gridwidth = 2; 224 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 225 gridBagConstraints.insets = new java.awt.Insets (0, 10, 3, 10); 226 gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; 227 containerPanel.add(dummyPanel, gridBagConstraints); 228 } 229 } 230 private javax.swing.JPanel getAdminUserPasswordPanel(){ 231 javax.swing.JPanel panel = new javax.swing.JPanel (); 232 java.awt.GridBagConstraints gridBagConstraints; 233 javax.swing.JLabel admiUserLabel = new javax.swing.JLabel (); 234 javax.swing.JLabel admiPWLabel = new javax.swing.JLabel (); 235 adminUserTextField = new javax.swing.JTextField (); 236 adminPWTextField = new javax.swing.JPasswordField (); 237 238 panel.setLayout(new java.awt.GridBagLayout ()); 239 240 admiUserLabel.setText(stringManager.getString("upgrade.gui.detailspanel.adminUserLabel")); 241 gridBagConstraints = new java.awt.GridBagConstraints (); 242 gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; 243 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 244 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 245 gridBagConstraints.insets = new java.awt.Insets (10, 10, 3, 20); 246 gridBagConstraints.weightx = 1.0; 247 panel.add(admiUserLabel, gridBagConstraints); 248 249 admiPWLabel.setText(stringManager.getString("upgrade.gui.detailspanel.adminPWLabel")); 250 gridBagConstraints = new java.awt.GridBagConstraints (); 251 gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; 252 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 253 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 254 gridBagConstraints.insets = new java.awt.Insets (10, 20, 3, 10); 255 gridBagConstraints.weightx = 1.0; 256 panel.add(admiPWLabel, gridBagConstraints); 257 258 gridBagConstraints = new java.awt.GridBagConstraints (); 259 gridBagConstraints.gridx = 0; 260 gridBagConstraints.gridy = 1; 261 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 262 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 263 gridBagConstraints.insets = new java.awt.Insets (0, 10, 5, 20); 264 gridBagConstraints.weightx = 1.0; 265 panel.add(adminUserTextField, gridBagConstraints); 266 267 gridBagConstraints = new java.awt.GridBagConstraints (); 268 gridBagConstraints.gridx = 1; 269 gridBagConstraints.gridy = 1; 270 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 271 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 272 gridBagConstraints.insets = new java.awt.Insets (0, 20, 5, 10); 273 gridBagConstraints.weightx = 1.0; 274 panel.add(adminPWTextField, gridBagConstraints); 275 276 if(!this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){ 277 javax.swing.JLabel masterPWLabel = new javax.swing.JLabel (); 278 masterPWTextField = new javax.swing.JPasswordField (); 279 masterPWLabel.setText(stringManager.getString("upgrade.gui.detailspanel.masterPWLabel")); 280 gridBagConstraints = new java.awt.GridBagConstraints (); 281 gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; 282 gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 1; 283 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 284 gridBagConstraints.insets = new java.awt.Insets (10, 10, 3, 5); 285 gridBagConstraints.weightx = 1.0; 286 panel.add(masterPWLabel, gridBagConstraints); 287 288 gridBagConstraints = new java.awt.GridBagConstraints (); 289 gridBagConstraints.gridx = 0; 290 gridBagConstraints.gridy = 3; 291 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 292 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 293 gridBagConstraints.insets = new java.awt.Insets (0, 10, 10, 5); 294 gridBagConstraints.weightx = 1.0; 295 panel.add(masterPWTextField, gridBagConstraints); 296 297 javax.swing.JPanel dummyPanel = new javax.swing.JPanel (); 298 gridBagConstraints = new java.awt.GridBagConstraints (); 299 gridBagConstraints.gridx = 1; 300 gridBagConstraints.gridy = 3; 301 gridBagConstraints.gridwidth = 1; gridBagConstraints.gridheight = 1; 302 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 303 gridBagConstraints.insets = new java.awt.Insets (0, 20, 10, 5); 304 gridBagConstraints.weightx = 1.0; 305 panel.add(dummyPanel, gridBagConstraints); 306 } 307 308 return panel; 309 } 310 311 private void sourceActionPerformed(java.awt.event.ActionEvent evt){ 312 getfileChooser().setCurrentDirectory(new java.io.File (sourceDirTextField.getText())); 313 int returnedValue = getfileChooser().showOpenDialog(this); 314 if(returnedValue == javax.swing.JFileChooser.APPROVE_OPTION){ 315 sourceDirTextField.setText(String.valueOf(getfileChooser().getSelectedFile())); 316 this.processDialogEvent(); 317 } 318 } 319 private void destActionPerformed(java.awt.event.ActionEvent evt){ 320 getfileChooser().setCurrentDirectory(new java.io.File (destDirTextField.getText())); 321 int returnedValue = getfileChooser().showOpenDialog(this); 322 if(returnedValue == javax.swing.JFileChooser.APPROVE_OPTION){ 323 destDirTextField.setText(String.valueOf(getfileChooser().getSelectedFile())); 324 this.processDialogEvent(); 325 } 326 } 327 private javax.swing.JFileChooser getfileChooser() { 328 if (fileChooser == null) { 329 fileChooser = new javax.swing.JFileChooser (); 330 fileChooser.setName("fileChooser"); 331 fileChooser.setBounds(668, 49, 500, 300); 332 fileChooser.setDialogTitle(stringManager.getString("upgrade.gui.detailspanel.fileChooseTitle")); 333 334 } 335 return fileChooser; 336 } 337 public String getSourceDirectoryPath(){ 338 return this.sourceDirTextField.getText(); 339 } 340 public String getDestinationDirectoryPath(){ 341 return this.destDirTextField.getText(); 342 } 343 public String getAdminUserName(){ 344 return this.adminUserTextField.getText(); 345 } 346 public String getAdminPassword(){ 347 return this.adminPWTextField.getText(); 348 } 349 public String getMasterPassword(){ 350 return this.masterPWTextField.getText(); 351 } 352 public void addDialogListener(DialogListener listener){ 353 this.dialogListeners.addElement(listener); 354 } 355 public boolean isUpgradeCertificatesSelected(){ 356 return this.upgradeCertificates.isSelected(); 357 } 358 public void removeDialogListener(DialogListener listener){ 359 this.dialogListeners.removeElement(listener); 360 } 361 private void processDialogEvent(){ 362 DialogEvent de = new DialogEvent(this, DialogEvent.CHANGE_ACTION); 363 for(int i=0 ; i<this.dialogListeners.size(); i++){ 364 ((DialogListener)dialogListeners.elementAt(i)).dialogProcessed(de); 365 } 366 } 367 368 } 369 | Popular Tags |