KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.awt.event.*;
27 import java.io.*;
28
29 public class InstallerMouseAdapter implements ActionListener //MouseAdapter
30
{
31     private InfoGlueInstaller infoglueInstaller = null;
32     
33     public InstallerMouseAdapter(InfoGlueInstaller infoglueInstaller)
34     {
35         this.infoglueInstaller = infoglueInstaller;
36     }
37
38     //public void mouseClicked(MouseEvent e)
39
public void actionPerformed(ActionEvent e)
40     {
41         //String actionCommand = ((JButton)e.getComponent()).getActionCommand();
42
String JavaDoc actionCommand = e.getActionCommand();
43         
44         if(actionCommand.equalsIgnoreCase("ShowIntroductionDialog"))
45         {
46             this.infoglueInstaller.installerSkeleton.showIntroductionDialog();
47         }
48         else if(actionCommand.equalsIgnoreCase("ShowDatabaseDialog"))
49         {
50             this.infoglueInstaller.installerSkeleton.showDatabaseServerDialog();
51         }
52         else if(actionCommand.equalsIgnoreCase("ShowServerDialog"))
53         {
54             try
55             {
56                 //this.infoglueInstaller.setupDatabaseEnvironment();
57
this.infoglueInstaller.checkDatabase();
58                 
59                 this.infoglueInstaller.installerSkeleton.showServerDialog();
60             }
61             catch(Exception JavaDoc exception)
62             {
63                 this.infoglueInstaller.installerSkeleton.databaseDialog.setErrorMessage(exception.getMessage());
64                 this.infoglueInstaller.logProgress("An error occurred:" + exception.getMessage());
65                 exception.printStackTrace();
66             }
67         }
68         else if(actionCommand.equalsIgnoreCase("ShowFinishDialog"))
69         {
70             try
71             {
72                 if(this.infoglueInstaller.installerSkeleton.serverDialog.getApplicationServer().startsWith("Tomcat"))
73                 {
74                     File tomcatHome = new File(this.infoglueInstaller.installerSkeleton.serverDialog.getApplicationServerHomePath());
75                     File tomcatWebbappsHome = new File(this.infoglueInstaller.installerSkeleton.serverDialog.getApplicationServerHomePath() + File.separator + "webapps");
76                     if(!tomcatHome.exists() || !tomcatHome.isDirectory() || !tomcatWebbappsHome.exists())
77                         throw new Exception JavaDoc("The directory you selected as tomcat home is not valid.");
78                         
79                     File applicationHome = new File(this.infoglueInstaller.installerSkeleton.serverDialog.getApplicationPath());
80                     if(!applicationHome.exists() || !applicationHome.isDirectory())
81                         throw new Exception JavaDoc("The directory you selected as application home is not valid.");
82                 }
83                 else if(this.infoglueInstaller.installerSkeleton.serverDialog.getApplicationServer().startsWith("JBoss"))
84                 {
85                     File jBossHome = new File(this.infoglueInstaller.installerSkeleton.serverDialog.getApplicationServerHomePath());
86                     File jBossDeployHome = new File(this.infoglueInstaller.installerSkeleton.serverDialog.getApplicationServerHomePath() + File.separator + "server" + File.separator + "default" + File.separator + "deploy");
87                     if(!jBossHome.exists() || !jBossHome.isDirectory() || !jBossDeployHome.exists())
88                         throw new Exception JavaDoc("The directory you selected as jboss home is not valid.");
89                 }
90                 
91                 //this.infoglueInstaller.setupPropertyFiles();
92
this.infoglueInstaller.installerSkeleton.showFinishDialog();
93             }
94             catch(Exception JavaDoc exception)
95             {
96                 this.infoglueInstaller.installerSkeleton.serverDialog.setErrorMessage(exception.getMessage());
97                 this.infoglueInstaller.logProgress("An error occurred:" + exception.getMessage());
98                 exception.printStackTrace();
99             }
100         }
101         else if(actionCommand.equalsIgnoreCase("ShowDoneDialog"))
102         {
103             try
104             {
105                 this.infoglueInstaller.installerSkeleton.showInstallingDialog();
106                 //this.infoglueInstaller.finishInstallation();
107
//this.infoglueInstaller.installerSkeleton.showDoneDialog();
108
Thread JavaDoc t = new Thread JavaDoc(new FinishThread(this.infoglueInstaller));
109                 t.start();
110             }
111             catch(Exception JavaDoc exception)
112             {
113                 this.infoglueInstaller.installerSkeleton.finishDialog.setErrorMessage(exception.getMessage());
114                 this.infoglueInstaller.logProgress("An error occurred:" + exception.getMessage());
115                 exception.printStackTrace();
116             }
117         }
118         else if(actionCommand.equalsIgnoreCase("Exit"))
119         {
120             Logger.logInfo("Exiting application");
121             System.exit(0);
122         }
123             
124     }
125
126 }
127
128 class FinishThread implements Runnable JavaDoc
129 {
130     private InfoGlueInstaller infoglueInstaller = null;
131     
132     public FinishThread(InfoGlueInstaller infoglueInstaller)
133     {
134         this.infoglueInstaller = infoglueInstaller;
135     }
136     
137     public void run()
138     {
139         try
140         {
141             this.infoglueInstaller.finishInstallation();
142             this.infoglueInstaller.installerSkeleton.showDoneDialog();
143         }
144         catch(Exception JavaDoc exception)
145         {
146             this.infoglueInstaller.installerSkeleton.finishDialog.setErrorMessage(exception.getMessage());
147             this.infoglueInstaller.logProgress("An error occurred:" + exception.getMessage());
148             exception.printStackTrace();
149         }
150     }
151     
152 }
153
Popular Tags