KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cmsinstaller > ServerDialog


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cmsinstaller;
25
26 import javax.swing.*;
27 import java.awt.*;
28 import java.awt.event.ActionEvent JavaDoc;
29 import java.awt.event.ActionListener JavaDoc;
30 import java.io.File JavaDoc;
31
32 /**
33  * This is the database dialog.
34  */

35
36 public class ServerDialog extends JPanel implements ActionListener JavaDoc
37 {
38     private InfoGlueInstaller infoglueInstaller = null;
39     
40     private final static String JavaDoc introductionHeader = "Server setup";
41     private final static String JavaDoc 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 JavaDoc applicationServerLabel = "Application server";
44     private final static String JavaDoc hostNameLabel = "Host Name";
45     private final static String JavaDoc portNumberLabel = "Port number";
46     private final static String JavaDoc applicationSuffixLabel = "Application suffix";
47     private final static String JavaDoc digitalAssetPathLabel = "Digital asset path";
48     private final static String JavaDoc enablePortalLabel = "Enable JSR 168 support";
49     private final static String JavaDoc applicationPathLabel = "InfoGlue HOME";
50     private final static String JavaDoc smtpHostNameLabel = "SMTP Host";
51     private final static String JavaDoc applicationServerHomePathLabel = "App Server HOME";
52
53     private final static String JavaDoc superUserLabel = "Superuser";
54     private final static String JavaDoc 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     /*
77     private int xPosLabels = 0;
78     private int xPosLabelsWidth = 120;
79     private int xPosValues = 130;
80     private int xPosValuesWidth = 190;
81     */

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 JavaDoc keylist = "abcdefghijklmnopqrstuvwxyz123456789";
89     
90     public static String JavaDoc generatePassword(int length)
91     {
92         String JavaDoc 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 JavaDoc("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         //here comes all input fields
117
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("");
155
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         //java.awt.FileDialog openFileDialog = new java.awt.FileDialog(this);
170
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         /*
177         JLabel tomcatVersionJLabel = new JLabel(tomcatVersionLabel);
178         tomcatVersionJLabel.setBounds(xPosLabels, 220, 130, 20);
179         tomcatVersionJLabel.setToolTipText("<html>Which version of tomcat do you run.</html>");
180         this.tomcatVersion = new JComboBox();
181         this.tomcatVersion.addItem("5");
182         this.tomcatVersion.addItem("4");
183         this.tomcatVersion.setBounds(xPosValues, 220, xPosValuesWidth - 40, 20);
184         this.tomcatVersion.setBackground(new Color(230, 230, 245));
185         helpButton = new HelpButton(tomcatVersionJLabel);
186         helpButton.setBounds(xPosValues + xPosValuesWidth + 2, 220, 20, 20);
187         this.add(helpButton);
188         */

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         //java.awt.FileDialog openFileDialog = new java.awt.FileDialog(this);
197
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.setEnabled(false);
227
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.setEnabled(false);
232
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         /*
254         JLabel digitalAssetPathJLabel = new JLabel(digitalAssetPathLabel);
255         digitalAssetPathJLabel.setBounds(xPosLabels, 380, 130, 20);
256         this.digitalAssetPath = new JTextField();
257         this.digitalAssetPath.setBounds(xPosValues, 380, xPosValuesWidth, 20);
258         */

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.setBackground(Color.yellow);
285
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(digitalAssetPathJLabel);
307
//this.add(digitalAssetPath);
308
this.add(smtpHostNameJLabel);
309         this.add(smtpHostName);
310         this.add(appServerHomePathJLabel);
311         this.add(applicationServerHomePath);
312         //this.add(tomcatVersionJLabel);
313
//this.add(tomcatVersion);
314
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 JavaDoc 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 JavaDoc errorMessage)
355     {
356         this.errorMessage.setText("An error made the installation stop: \n" + errorMessage);
357     }
358     
359     public String JavaDoc getHostName()
360     {
361         return this.hostName.getText();
362     }
363     
364     public String JavaDoc getPortNumber()
365     {
366         return this.portNumber.getText();
367     }
368
369     public String JavaDoc getApplicationSuffix()
370     {
371         return this.applicationSuffix.getText();
372     }
373
374     public String JavaDoc getDigitalAssetPath()
375     {
376         return this.digitalAssetPath.getText();
377     }
378     
379     public String JavaDoc getSmtpHostName()
380     {
381         return this.smtpHostName.getText();
382     }
383     
384     public String JavaDoc getApplicationServerHomePath()
385     {
386         return this.applicationServerHomePath.getText();
387     }
388     
389     public void setApplicationServerHomePath(String JavaDoc applicationServerHomePath)
390     {
391         this.applicationServerHomePath.setText(applicationServerHomePath);
392     }
393     
394     public void setApplicationPath(String JavaDoc applicationPath)
395     {
396         this.applicationPath.setText(applicationPath);
397     }
398
399     public String JavaDoc getApplicationServer()
400     {
401         return this.applicationServer.getSelectedItem().toString();
402     }
403
404     /*
405     public String getTomcatVersion()
406     {
407         return this.tomcatVersion.getSelectedItem().toString();
408     }
409     */

410     
411     public String JavaDoc getCreateCMS()
412     {
413         if(createCMS.isSelected())
414             return "Yes";
415         else
416             return "No";
417     }
418
419     public String JavaDoc getCreateDeliverLive()
420     {
421         if(createDeliverLive.isSelected())
422             return "Yes";
423         else
424             return "No";
425     }
426
427     public String JavaDoc getCreateDeliverPreview()
428     {
429         if(createDeliverPreview.isSelected())
430             return "Yes";
431         else
432             return "No";
433     }
434
435     public String JavaDoc getCreateDeliverWorking()
436     {
437         if(createDeliverWorking.isSelected())
438             return "Yes";
439         else
440             return "No";
441     }
442
443     public String JavaDoc 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 JavaDoc getSuperUserName()
458     {
459         return superUserName.getText();
460     }
461     
462     public String JavaDoc getSuperUserPassword()
463     {
464         return superUserPassword.getText();
465     }
466
467     public String JavaDoc 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 JavaDoc getEnablePortal()
476     {
477         if(this.enablePortal.isSelected())
478             return "true";
479         else
480             return "false";
481     }
482
483 }
Popular Tags