1 23 24 package org.infoglue.cmsinstaller; 25 26 import javax.swing.*; 27 import java.awt.*; 28 import java.awt.event.ActionEvent ; 29 import java.awt.event.ActionListener ; 30 import java.io.File ; 31 32 35 36 public class ServerDialog extends JPanel implements ActionListener 37 { 38 private InfoGlueInstaller infoglueInstaller = null; 39 40 private final static String introductionHeader = "Server setup"; 41 private final static String introductionMessage = "For the system to work we also have to set up the properties below so they corresponds to your configuration. Tip: All fields have a help text if you put your mouse over the label.\n\nPlease supply the information needed below."; 42 43 private final static String applicationServerLabel = "Application server"; 44 private final static String hostNameLabel = "Host Name"; 45 private final static String portNumberLabel = "Port number"; 46 private final static String applicationSuffixLabel = "Application suffix"; 47 private final static String digitalAssetPathLabel = "Digital asset path"; 48 private final static String enablePortalLabel = "Enable JSR 168 support"; 49 private final static String applicationPathLabel = "InfoGlue HOME"; 50 private final static String smtpHostNameLabel = "SMTP Host"; 51 private final static String applicationServerHomePathLabel = "App Server HOME"; 52 53 private final static String superUserLabel = "Superuser"; 54 private final static String superUserPasswordLabel = "Password"; 55 56 private JComboBox applicationServer = null; 57 private JTextField hostName = null; 58 private JTextField digitalAssetPath = null; 59 private JTextField applicationPath = null; 60 private JTextField portNumber = null; 61 private JTextField applicationSuffix = null; 62 private JTextField smtpHostName = null; 63 private JTextField applicationServerHomePath = null; 64 private JCheckBox createCMS = null; 65 private JCheckBox createDeliverWorking = null; 66 private JCheckBox createDeliverPreview = null; 67 private JCheckBox createDeliverLive = null; 68 69 private JTextField superUserName = null; 70 private JTextField superUserPassword = null; 71 72 private JCheckBox enablePortal = null; 73 74 private JTextArea errorMessage = null; 75 76 82 private int xPosLabels = 0; 83 private int xPosLabelsWidth = 140; 84 private int xPosValues = 150; 85 private int xPosValuesWidth = 230; 86 87 88 private static String keylist = "abcdefghijklmnopqrstuvwxyz123456789"; 89 90 public static String generatePassword(int length) 91 { 92 String temp = ""; 93 for (int i=0; i < length; i++) 94 temp += keylist.charAt((int)Math.floor(Math.random() * keylist.length())); 95 96 return temp; 97 } 98 99 public ServerDialog(InfoGlueInstaller infoglueInstaller) 100 { 101 this.infoglueInstaller = infoglueInstaller; 102 103 this.setSize(450, 400); 104 this.setLayout(null); 105 this.setBackground(Color.white); 106 JLabel introductionLabel = new JLabel(introductionHeader); 107 introductionLabel.setBounds(xPosLabels, 0, 400, 30); 108 introductionLabel.setFont(new java.awt.Font ("Dialog", java.awt.Font.BOLD, 16)); 109 110 JTextArea textArea = new JTextArea(introductionMessage); 111 textArea.setEditable(false); 112 textArea.setBounds(xPosLabels, 30, 400, 80); 113 textArea.setWrapStyleWord(true); 114 textArea.setLineWrap(true); 115 116 JLabel appServerJLabel = new JLabel(applicationServerLabel); 118 appServerJLabel.setBounds(xPosLabels, 120, 130, 20); 119 appServerJLabel.setToolTipText("<html>The application server you wish to run InfoGlue on.</html>"); 120 this.applicationServer = new JComboBox(); 121 this.applicationServer.addActionListener(this); 122 this.applicationServer.addItem("Tomcat 5.x"); 123 this.applicationServer.addItem("Tomcat 4.x"); 124 this.applicationServer.addItem("JBoss 4.0"); 125 this.applicationServer.setBounds(xPosValues, 120, xPosValuesWidth, 20); 126 this.applicationServer.setBackground(new Color(230, 230, 245)); 127 HelpButton helpButton = new HelpButton(appServerJLabel); 128 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 120, 20, 20); 129 this.add(helpButton); 130 131 JLabel hostNameJLabel = new JLabel(hostNameLabel); 132 hostNameJLabel.setBounds(xPosLabels, 140, 130, 20); 133 hostNameJLabel.setToolTipText("<html>The hostname or IP-address of the application server you are installing InfoGlue on.<br>If you want people to access your site from other computers this is important to set correctly.</html>"); 134 this.hostName = new JTextField("localhost"); 135 this.hostName.setBounds(xPosValues, 140, xPosValuesWidth, 20); 136 this.hostName.setBackground(new Color(230, 230, 245)); 137 helpButton = new HelpButton(hostNameJLabel); 138 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 140, 20, 20); 139 this.add(helpButton); 140 141 JLabel portNumberJLabel = new JLabel(portNumberLabel); 142 portNumberJLabel.setBounds(xPosLabels, 160, 130, 20); 143 portNumberJLabel.setToolTipText("<html>The port number tomcat operates on.</html>"); 144 this.portNumber = new JTextField("8080"); 145 this.portNumber.setBounds(xPosValues, 160, xPosValuesWidth, 20); 146 this.portNumber.setBackground(new Color(230, 230, 245)); 147 helpButton = new HelpButton(portNumberJLabel); 148 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 160, 20, 20); 149 this.add(helpButton); 150 151 JLabel applicationSuffixJLabel = new JLabel(applicationSuffixLabel); 152 applicationSuffixJLabel.setBounds(xPosLabels, 180, 130, 20); 153 applicationSuffixJLabel.setToolTipText("<html>The suffix will be added to the name of the infoglue applications.<br>This feature is mostly used in shared environments like hosting services.<br>You can leave it out if this is a one-client installation.</html>"); 154 this.applicationSuffix = new JTextField(""); 156 this.applicationSuffix.setBounds(xPosValues, 180, xPosValuesWidth, 20); 157 this.applicationSuffix.setBackground(new Color(230, 230, 245)); 158 helpButton = new HelpButton(applicationSuffixJLabel); 159 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 180, 20, 20); 160 this.add(helpButton); 161 162 JLabel appServerHomePathJLabel = new JLabel(applicationServerHomePathLabel); 163 appServerHomePathJLabel.setBounds(xPosLabels, 200, 130, 20); 164 appServerHomePathJLabel.setToolTipText("<html>Point out the home directory of your application server.<br>Often something like c:\\Program Files\\Apache Software Foundation\\Tomcat 5.5</html>"); 165 this.applicationServerHomePath = new JTextField(InfoGlueCommandLineInstaller.getTomcatHomePath()); 166 this.applicationServerHomePath.setName("applicationServerHomePath"); 167 this.applicationServerHomePath.setBounds(xPosValues, 200, xPosValuesWidth - 40, 20); 168 this.applicationServerHomePath.setBackground(new Color(230, 230, 245)); 169 JButton browseButton = new BrowseButton("...", infoglueInstaller.installerSkeleton, applicationServerHomePath); 171 browseButton.setBounds(xPosValues + xPosValuesWidth - 40, 200, 40, 20); 172 helpButton = new HelpButton(appServerHomePathJLabel); 173 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 200, 20, 20); 174 this.add(helpButton); 175 176 189 190 JLabel applicationPathJLabel = new JLabel(applicationPathLabel); 191 applicationPathJLabel.setBounds(xPosLabels, 220, 130, 20); 192 applicationPathJLabel.setToolTipText("<html>Point out the home directory of your InfoGlue directory.<br>As InfoGlue will create a couple of applications/subdirectories you are wise<br>to create a common InfoGlue directory somewhere on the disc which you supply.</html>"); 193 this.applicationPath = new JTextField(InfoGlueCommandLineInstaller.getTomcatHomePath()); 194 this.applicationPath.setBounds(xPosValues, 220, xPosValuesWidth - 40, 20); 195 this.applicationPath.setBackground(new Color(230, 230, 245)); 196 JButton browseButton2 = new BrowseButton("...", infoglueInstaller.installerSkeleton, applicationPath); 198 browseButton2.setBounds(xPosValues + xPosValuesWidth - 40, 220, 40, 20); 199 helpButton = new HelpButton(applicationPathJLabel); 200 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 220, 20, 20); 201 this.add(helpButton); 202 203 this.applicationPath.setText(this.applicationServerHomePath.getText() + File.separator + "webapps"); 204 this.applicationPath.setEditable(false); 205 browseButton2.setEnabled(false); 206 browseButton2.setVisible(false); 207 208 JLabel enablePortalJLabel = new JLabel(enablePortalLabel); 209 enablePortalJLabel.setBounds(xPosLabels, 240, 150, 20); 210 enablePortalJLabel.setToolTipText("<html>Do you want to be able to use portlets in InfoGlue?<br>You can activate this later if you don't want it now.<html>"); 211 this.enablePortal = new JCheckBox("Yes (forces install under tomcat)"); 212 this.enablePortal.setBounds(xPosValues, 240, xPosValuesWidth, 20); 213 this.enablePortal.setSelected(true); 214 this.enablePortal.setEnabled(true); 215 this.enablePortal.setBackground(Color.white); 216 helpButton = new HelpButton(enablePortalJLabel); 217 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 240, 20, 20); 218 this.add(helpButton); 219 220 JLabel selectApplicationsLabel = new JLabel("Applications to install"); 221 selectApplicationsLabel.setBounds(xPosLabels, 280, 130, 20); 222 selectApplicationsLabel.setToolTipText("<html>InfoGlue consists of several applications and two are mandatory.<br>You are also able to select if you wish to install a preview-deliver and a live-deliver.<br>The preview-deliver is used for preview at publication and the live site shows only<br>published data and are aimed to be the deliver used for the public. Both options are recommended.<html>"); 223 this.createCMS = new JCheckBox("InfoGlue CMS"); 224 this.createCMS.setBounds(xPosValues, 280, xPosValuesWidth, 20); 225 this.createCMS.setSelected(true); 226 this.createCMS.setBackground(Color.white); 228 this.createDeliverWorking = new JCheckBox("InfoGlue Deliver Working"); 229 this.createDeliverWorking.setBounds(xPosValues, 300, xPosValuesWidth, 20); 230 this.createDeliverWorking.setSelected(true); 231 this.createDeliverWorking.setBackground(Color.white); 233 this.createDeliverPreview = new JCheckBox("InfoGlue Deliver Preview"); 234 this.createDeliverPreview.setBounds(xPosValues, 320, xPosValuesWidth, 20); 235 this.createDeliverPreview.setBackground(Color.white); 236 this.createDeliverLive = new JCheckBox("InfoGlue Deliver Live"); 237 this.createDeliverLive.setBounds(xPosValues, 340, xPosValuesWidth, 20); 238 this.createDeliverLive.setBackground(Color.white); 239 helpButton = new HelpButton(selectApplicationsLabel); 240 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 280, 20, 20); 241 this.add(helpButton); 242 243 JLabel smtpHostNameJLabel = new JLabel(smtpHostNameLabel); 244 smtpHostNameJLabel.setBounds(xPosLabels, 360, 130, 20); 245 smtpHostNameJLabel.setToolTipText("<html>Your email server used for outgoing mail.</html>"); 246 this.smtpHostName = new JTextField("your.emailserver.com"); 247 this.smtpHostName.setBounds(xPosValues, 360, xPosValuesWidth, 20); 248 this.smtpHostName.setBackground(new Color(230, 230, 245)); 249 helpButton = new HelpButton(smtpHostNameJLabel); 250 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 360, 20, 20); 251 this.add(helpButton); 252 253 259 260 JLabel superUserJLabel = new JLabel(superUserLabel); 261 superUserJLabel.setBounds(xPosLabels, 400, 130, 20); 262 superUserJLabel.setToolTipText("<html>State what user name should be used for super user access to the cms.</html>"); 263 this.superUserName = new JTextField("root"); 264 this.superUserName.setBounds(xPosValues, 400, xPosValuesWidth, 20); 265 this.superUserName.setBackground(new Color(230, 230, 245)); 266 helpButton = new HelpButton(superUserJLabel); 267 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 400, 20, 20); 268 this.add(helpButton); 269 270 JLabel superUserPasswordJLabel = new JLabel(superUserPasswordLabel); 271 superUserPasswordJLabel.setBounds(xPosLabels, 420, 130, 20); 272 superUserPasswordJLabel.setToolTipText("<html>State what password the super user should use to access the cms.</html>"); 273 this.superUserPassword = new JTextField(generatePassword(6)); 274 this.superUserPassword.setBounds(xPosValues, 420, xPosValuesWidth, 20); 275 this.superUserPassword.setBackground(new Color(230, 230, 245)); 276 helpButton = new HelpButton(superUserPasswordJLabel); 277 helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 420, 20, 20); 278 this.add(helpButton); 279 280 new PortletCheckboxListener(enablePortal, applicationPath, applicationServerHomePath, browseButton2); 281 282 this.errorMessage = new JTextArea(""); 283 this.errorMessage.setForeground(Color.red); 284 this.errorMessage.setEditable(false); 286 this.errorMessage.setBounds(xPosLabels, 440, 450, 60); 287 this.errorMessage.setWrapStyleWord(true); 288 this.errorMessage.setLineWrap(true); 289 290 this.add(introductionLabel); 291 this.add(textArea); 292 this.add(appServerJLabel); 293 this.add(applicationServer); 294 295 this.add(hostNameJLabel); 296 this.add(hostName); 297 this.add(portNumberJLabel); 298 this.add(portNumber); 299 this.add(applicationSuffixJLabel); 300 this.add(applicationSuffix); 301 this.add(selectApplicationsLabel); 302 this.add(createCMS); 303 this.add(createDeliverWorking); 304 this.add(createDeliverPreview); 305 this.add(createDeliverLive); 306 this.add(smtpHostNameJLabel); 309 this.add(smtpHostName); 310 this.add(appServerHomePathJLabel); 311 this.add(applicationServerHomePath); 312 this.add(enablePortalJLabel); 315 this.add(enablePortal); 316 this.add(applicationPathJLabel); 317 this.add(applicationPath); 318 this.add(browseButton); 319 this.add(browseButton2); 320 321 this.add(superUserJLabel); 322 this.add(superUserName); 323 this.add(superUserPasswordJLabel); 324 this.add(superUserPassword); 325 326 this.add(errorMessage); 327 328 infoglueInstaller.setBackButtonCommand("ShowDatabaseDialog"); 329 infoglueInstaller.setNextButtonCommand("ShowFinishDialog"); 330 infoglueInstaller.setNextButtonLabel("Next"); 331 } 332 333 public void actionPerformed(ActionEvent e) 334 { 335 if(e.getSource().equals(this.applicationServer)) 336 { 337 if(this.applicationPath != null) 338 { 339 if(this.getApplicationServer().startsWith("JBoss 4")) 340 { 341 this.applicationPath.setEditable(false); 342 } 343 else if(this.getApplicationServer().startsWith("Tomcat")) 344 { 345 if(this.getEnablePortal().equalsIgnoreCase("false")) 346 { 347 this.applicationPath.setEditable(true); 348 } 349 } 350 } 351 } 352 } 353 354 public void setErrorMessage(String errorMessage) 355 { 356 this.errorMessage.setText("An error made the installation stop: \n" + errorMessage); 357 } 358 359 public String getHostName() 360 { 361 return this.hostName.getText(); 362 } 363 364 public String getPortNumber() 365 { 366 return this.portNumber.getText(); 367 } 368 369 public String getApplicationSuffix() 370 { 371 return this.applicationSuffix.getText(); 372 } 373 374 public String getDigitalAssetPath() 375 { 376 return this.digitalAssetPath.getText(); 377 } 378 379 public String getSmtpHostName() 380 { 381 return this.smtpHostName.getText(); 382 } 383 384 public String getApplicationServerHomePath() 385 { 386 return this.applicationServerHomePath.getText(); 387 } 388 389 public void setApplicationServerHomePath(String applicationServerHomePath) 390 { 391 this.applicationServerHomePath.setText(applicationServerHomePath); 392 } 393 394 public void setApplicationPath(String applicationPath) 395 { 396 this.applicationPath.setText(applicationPath); 397 } 398 399 public String getApplicationServer() 400 { 401 return this.applicationServer.getSelectedItem().toString(); 402 } 403 404 410 411 public String getCreateCMS() 412 { 413 if(createCMS.isSelected()) 414 return "Yes"; 415 else 416 return "No"; 417 } 418 419 public String getCreateDeliverLive() 420 { 421 if(createDeliverLive.isSelected()) 422 return "Yes"; 423 else 424 return "No"; 425 } 426 427 public String getCreateDeliverPreview() 428 { 429 if(createDeliverPreview.isSelected()) 430 return "Yes"; 431 else 432 return "No"; 433 } 434 435 public String getCreateDeliverWorking() 436 { 437 if(createDeliverWorking.isSelected()) 438 return "Yes"; 439 else 440 return "No"; 441 } 442 443 public String getApplicationPath() 444 { 445 return applicationPath.getText(); 446 } 447 448 public void paint(Graphics g) 449 { 450 Graphics2D g2 = (Graphics2D)g; 451 g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); 452 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 453 454 super.paint(g); 455 } 456 457 public String getSuperUserName() 458 { 459 return superUserName.getText(); 460 } 461 462 public String getSuperUserPassword() 463 { 464 return superUserPassword.getText(); 465 } 466 467 public String getActionDispatcher() 468 { 469 if(this.enablePortal.isSelected()) 470 return "org.infoglue.deliver.portal.dispatcher.PortalServletDispatcher"; 471 else 472 return "webwork.dispatcher.ServletDispatcher"; 473 } 474 475 public String getEnablePortal() 476 { 477 if(this.enablePortal.isSelected()) 478 return "true"; 479 else 480 return "false"; 481 } 482 483 } | Popular Tags |