xref: /AOO41X/main/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoCtrl.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package org.openoffice.setup.Util;
29 
30 import org.openoffice.setup.InstallData;
31 import org.openoffice.setup.SetupData.PackageDescription;
32 import org.openoffice.setup.SetupData.ProductDescription;
33 import java.util.Enumeration;
34 import java.util.Vector;
35 
36 public class InfoCtrl {
37 
38     private InfoCtrl() {
39     }
40 
41     static public String setHtmlFrame(String position, String htmlInfoText) {
42         if ( position.equals("header") ) {
43             htmlInfoText = "<HTML><BODY><FONT FACE=\"sans-serif\" SIZE=3>";
44         }
45         else if ( position.equals("end")) {
46             htmlInfoText = htmlInfoText + "</FONT></BODY></HTML>";
47         }
48 
49         return htmlInfoText;
50     }
51 
52     static public String setReadyToInstallInfoText(ProductDescription productData, String htmlInfoText) {
53         // String oneline = "-------------------------------------------------------------------";
54         String oneline = "-------------------------------------------------------------";
55         htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>";
56         InstallData data = InstallData.getInstance();
57         htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDefaultDir() + "<br>";
58         htmlInfoText = htmlInfoText + oneline + "<br>";
59 
60         return htmlInfoText;
61     }
62 
63     static public String setReadyToInstallInfoText(PackageDescription packageData, String htmlInfoText) {
64         // setHtmlInfoText(packageData, 0);
65         InstallData data = InstallData.getInstance();
66         if ( data.isInstallationMode() ) {
67             htmlInfoText = setReadyToInstallInfoText(packageData, "", htmlInfoText);
68         } else {
69             htmlInfoText = setReadyToUninstallInfoText(packageData, "", htmlInfoText);
70         }
71         return htmlInfoText;
72     }
73 
74     // private void setReadyToInstallInfoText(PackageDescription packageData, Integer indent) {
75     static private String setReadyToInstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) {
76         // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">";
77         // System.out.println(ind);
78         if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) {
79             if ( ! packageData.isHidden() ) {
80                 if ( packageData.getSelectionState() == packageData.INSTALL ) {
81                     // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>";
82                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
83                 }
84             }
85         }
86 
87         if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) {
88             if ( ! packageData.isHidden() ) {
89                 if (( packageData.getSelectionState() == packageData.INSTALL ) ||
90                     ( packageData.getSelectionState() == packageData.INSTALL_SOME )) {
91                     // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>";
92                     // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>";
93                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
94                 }
95             }
96 
97             indent = indent + "..";
98 
99             for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
100                 PackageDescription child = (PackageDescription) e.nextElement();
101                 htmlInfoText = setReadyToInstallInfoText(child, indent, htmlInfoText);
102             }
103         }
104 
105         return htmlInfoText;
106     }
107 
108     // private void setReadyToUninstallInfoText(PackageDescription packageData, Integer indent, String htmlInfoText) {
109     static private String setReadyToUninstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) {
110         // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">";
111         // System.out.println(ind);
112         if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) {
113             if ( ! packageData.isHidden() ) {
114                 if ( packageData.getSelectionState() == packageData.REMOVE ) {
115                     // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>";
116                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
117                 }
118             }
119         }
120 
121         if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) {
122             if ( ! packageData.isHidden() ) {
123                 if (( packageData.getSelectionState() == packageData.REMOVE ) ||
124                     ( packageData.getSelectionState() == packageData.REMOVE_SOME )) {
125                     // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>";
126                     // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>";
127                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
128                 }
129             }
130 
131             indent = indent + "..";
132 
133             for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
134                 PackageDescription child = (PackageDescription) e.nextElement();
135                 htmlInfoText = setReadyToUninstallInfoText(child, indent, htmlInfoText);
136             }
137         }
138 
139         return htmlInfoText;
140     }
141 
142     static public String  setInstallLogInfoText(ProductDescription productData, String htmlInfoText) {
143         // String separatorline = "-------------------------------------------------------------------";
144         String separatorline = "-------------------------------------------------------------";
145         htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>";
146         InstallData data = InstallData.getInstance();
147         htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDir() + "<br>";
148         htmlInfoText = htmlInfoText + "<b>Operating system</b>: " + data.getOSType() + "<br>";
149         if ( data.isUserInstallation() ) {
150             htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "User installation" + "<br>";
151         } else {
152             htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "Root installation" + "<br>";
153         }
154 
155         htmlInfoText = htmlInfoText + separatorline + "<br>";
156 
157         htmlInfoText = LogManager.publishLogfileContent(htmlInfoText, separatorline);
158         htmlInfoText = LogManager.publishCommandsLogfileContent(htmlInfoText);
159 
160         return htmlInfoText;
161     }
162 
163 }
164