KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > wminstaller > screens > ScreenFinish


1 package de.webman.wminstaller.screens;
2
3 import de.webman.wminstaller.app.*;
4 import javax.swing.*;
5 import java.awt.event.*;
6 import java.awt.*;
7 import java.io.*;
8 import java.net.URL JavaDoc;
9 import java.beans.*;
10 import de.webman.wminstaller.install.*;
11
12 /**
13  * Implementierung des Finish screens
14  *
15  * @author <a HREF="mailto:ulf@webman.de">Ulf Goldammer</a>, <a HREF="mailto:gregor@webman.de">Gregor Klinke</a>
16  * @version $Revision: 1.3 $
17  **/

18 public class ScreenFinish extends InstallerScreen
19     implements PropertyChangeListener
20 {
21     /* $Id: ScreenFinish.java,v 1.3 2002/03/08 14:39:31 gregor Exp $ */
22     private JEditorPane details = null;
23
24     /**
25      * this holds the index of the screen in the card layout
26      */

27     private int cardIdx = 0;
28     private JPanel wmPanel;
29
30     public ScreenFinish( Installer wmi, int bt) {
31         super( wmi, bt);
32
33         JPanel wmPanel = new JPanel( new BorderLayout( 0, 12));
34         
35         /* the message board */
36 // JEditorPane ep = new JEditorPane();
37
// ep.setEditable(false);
38
// File f = new File( wmi.getDataDir(), getDataName() + ".html");
39
// try {
40
// ep.setPage(f.toString());
41
// }
42
// catch ( IOException e) {
43
// ep.setText("Could not load file.");
44
// System.out.println("Could not load file: " + f.toString());
45
// }
46
// JScrollPane sp = new JScrollPane(ep);
47
// p.add(sp, BorderLayout.NORTH);
48

49         /* the detail screen */
50         details = new JEditorPane();
51         details.setEditable(false);
52         details.setContentType("text/html");
53         JScrollPane sp2 = new JScrollPane(details);
54         
55         wmPanel.add(sp2, BorderLayout.CENTER);
56         
57         wmi.getPCL().addPropertyChangeListener(EventConstants.ENTER_SCREEN, this);
58         
59         cardIdx = addScreen("Beginn der Installation\n" +
60                             "Webman wird nun auf Ihrem System installiert.\n" +
61                             "Dieser Vorgang beschränkt sich auf die Erzeugung\n" +
62                             "von Dateien im vorgegebenen Verzeichnis.\n" +
63                             "Weitergehende Systemeingriffe erfolgen nicht.", wmPanel);
64     }
65     
66     public boolean storeValues() {
67         // nop
68
return true;
69     }
70
71     public boolean startInstallation() {
72         try {
73             new InstallationMgr().run(wmi.getDictionary());
74         }
75         catch (InstallationException ie) {
76             Object JavaDoc[] options = {"Abbrechen?", "Erneut"};
77             
78             int n = JOptionPane.showOptionDialog(wmPanel,
79                                                  "Installation war nicht erfolgreich:\n" +
80                                                  ie.getMessage(),
81                                                  "Installationsabbruch",
82                                                  JOptionPane.YES_NO_OPTION,
83                                                  JOptionPane.QUESTION_MESSAGE,
84                                                  null, //don't use a custom Icon
85
options, //the titles of buttons
86
options[0]); //default button title
87
switch (n) {
88             case JOptionPane.YES_OPTION:
89                 wmi.leave(-1);
90                 break;
91             case JOptionPane.NO_OPTION:
92                 return false;
93             }
94         }
95         return true;
96     }
97
98
99     public void propertyChange(PropertyChangeEvent e) {
100         if (EventConstants.ENTER_SCREEN.equals(e.getPropertyName()) &&
101             ((Integer JavaDoc)e.getNewValue()).intValue() == cardIdx) {
102             System.out.println("Entered screen finished");
103             details.setText(getDetailScreen());
104         }
105     }
106     
107
108
109
110     /* ----------------------------------------------------------------------
111        create a html text, which displayes the details of the previous
112        screens.
113        ---------------------------------------------------------------------- */

114     private static final String JavaDoc BGROUP = "bgroup";
115     private static final String JavaDoc EGROUP = "egroup";
116     private static final String JavaDoc PROP = "prop";
117     private static final String JavaDoc TEXT = "text";
118     private static final String JavaDoc HPROP = "hprop";
119     private static final String JavaDoc IGNIF = "ignif";
120     private static final String JavaDoc IGNIFN = "ignifn";
121     private static final String JavaDoc IGNEND = "ignend";
122
123     /**
124      * this array helds the information how the detail page will be
125      * constructed and which information it contains. every time the
126      * (previous) detail screen are changed, this have to be updated.<p>
127      *
128      * the syntax is as follows: every 3 string slots represent one entry.
129      * the first (0) is the type of the entry, the semantic of the
130      * following slots depend on the type. Possible values are:<p>
131      *
132      * <ul>
133      *
134      * <li>"bgroup" - begin a group, the second field (1) is the name to use,
135      * the third fild (2) is not used</li>
136      *
137      * <li>"egroup" - end a group, both second and third fields are unused</li>
138      *
139      * <li>"prop" - display the value of a property. the second field (1)
140      * gives the display description, and the third field (2) gives the
141      * property name, under which the value to display is stored in the
142      * global dictionary (<code>Installer::getDictionary()</code>)</li>
143      *
144      * <li>"hprop" - hidden property, same as "prop" but show the content
145      * as stars</li>
146      *
147      * <li>"ignif" - second field gives a compare value and third field
148      * gives a property key. if teh properties value and the compare value
149      * are equal, the following lines are ignored until the corresponding
150      * "ignend" entry. "ignif" - "ignend" can be nested, must exist for
151      * every "ignif" a corresponding "ignend"</li>
152      *
153      * <li>"ignifn" - like "ignif" but "not"</li>
154      *
155      * <li>"ignend" - ends a "ignif" and "ignifn" entry
156      *
157      * <li>"text" - fixed text (from second field)</li>
158      *
159      *</ul>
160      *
161      * further settings will evolve as needed.
162      **/

163     String JavaDoc[] details_form = {
164         BGROUP, "Dateisystem", "",
165         PROP, "Ziel-Verzeichnis", DictConstants.SELECTED_PATH,
166         EGROUP, "", "",
167         
168         BGROUP, "Datenbank", "",
169         PROP, "Typ", DictConstants.DB_TYPE,
170         PROP, "Zahl d. Lizenzen", DictConstants.DB_LICENCES,
171         PROP, "Username", DictConstants.DB_USER,
172         HPROP, "Password", DictConstants.DB_PASSWORD,
173         PROP, "Host", DictConstants.DB_SERVER,
174         PROP, "Port", DictConstants.DB_PORT,
175         
176         IGNIF, "Sybase", DictConstants.DB_TYPE,
177         PROP, "Datenbankname", DictConstants.DB_NAME,
178         IGNEND, "", "",
179         IGNIFN, "false", DictConstants.DB_INSTALL,
180         TEXT, "No Script installation", "",
181         IGNEND, "", "",
182
183         EGROUP, "", "",
184         
185         BGROUP, "Tomcat", "",
186         PROP, "HTTP-Port", DictConstants.WEB_PORT,
187         PROP, "Instanz-Name", DictConstants.WEB_INSTANCE,
188         EGROUP, "", ""
189     };
190
191     private String JavaDoc getDetailScreen() {
192         StringBuffer JavaDoc strbuf = new StringBuffer JavaDoc();
193         
194         strbuf.append("<html>");
195         strbuf.append("<body bgcolor=\"efefef\">");
196         strbuf.append("<h3><font color=\"#ff4444\">Details:</font></h3>");
197
198         /* support for conditional tests */
199         int ignore = 0;
200         int iflevel = 0;
201
202         /* add the selected path */
203         for (int di = 0; di < details_form.length; di += 3) {
204             if (ignore == 0) {
205                 if (BGROUP.equals(details_form[di])) {
206                     strbuf.append("<table border=\"0\">");
207                     strbuf.append("<tr><td colspan=\"2\"><tt><font size=\"-1\"><b>");
208                     strbuf.append(details_form[di + 1]);
209                     strbuf.append("</b></font></tt></td></tr>");
210                 }
211                 else if (EGROUP.equals(details_form[di])) {
212                     strbuf.append("</table><br>");
213                 }
214                 else if (PROP.equals(details_form[di])) {
215                     Object JavaDoc prop = wmi.getDictionary().get(details_form[di + 2]);
216                     
217                     strbuf.append("<tr><td><tt><font size=\"-1\">");
218                     strbuf.append(details_form[di + 1]);
219                     strbuf.append(":</font></tt></td><td><tt><font size=\"-1\">");
220                     
221                     if (prop != null)
222                         strbuf.append(prop.toString());
223                     
224                     strbuf.append("</font></tt></td></tr>");
225                 }
226                 else if (HPROP.equals(details_form[di])) {
227                     Object JavaDoc prop = wmi.getDictionary().get(details_form[di + 2]);
228                     String JavaDoc t = prop.toString();
229                     StringBuffer JavaDoc buf = new StringBuffer JavaDoc(t.length());
230                     for (int c = 0; c < t.length(); c++)
231                         buf.append('*');
232                     
233                     strbuf.append("<tr><td><tt><font size=\"-1\">");
234                     strbuf.append(details_form[di + 1]);
235                     strbuf.append(":</font></tt></td><td><tt><font size=\"-1\">");
236                 
237                     if (prop != null)
238                         strbuf.append(buf.toString());
239                     
240                     strbuf.append("</font></tt></td></tr>");
241                 }
242                 else if (IGNIF.equals(details_form[di])) {
243                     Object JavaDoc prop = wmi.getDictionary().get(details_form[di + 2]);
244                     String JavaDoc t = prop.toString();
245                     iflevel++;
246                     if (details_form[di + 1].equals(t))
247                         ignore = iflevel;
248                     else
249                         ignore = 0;
250                 }
251                 else if (IGNIFN.equals(details_form[di])) {
252                     Object JavaDoc prop = wmi.getDictionary().get(details_form[di + 2]);
253                     String JavaDoc t = prop.toString();
254                     iflevel++;
255                     if (details_form[di + 1].equals(t))
256                         ignore = 0;
257                     else
258                         ignore = iflevel;
259                 }
260                 else if (IGNEND.equals(details_form[di])) {
261                     iflevel--;
262                 }
263                 else if (TEXT.equals(details_form[di])) {
264                     strbuf.append("<tr><td colspan=\"2\"><tt><font size=\"-1\"><i>");
265                     strbuf.append(details_form[di + 1]);
266                     strbuf.append("</i></font></tt></td></tr>");
267                 }
268             }
269             else {
270                 if (IGNIF.equals(details_form[di]) ||
271                     IGNIFN.equals(details_form[di])) {
272                     iflevel++;
273                 }
274                 if (IGNEND.equals(details_form[di])) {
275                     if (ignore == iflevel)
276                         ignore = 0;
277                     iflevel--;
278                 }
279             }
280             
281         }
282         
283         strbuf.append("</body>");
284         strbuf.append("</html>");
285         
286         return strbuf.toString();
287     }
288 }
289
Popular Tags