1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.setup.Util;
25 
26 import org.openoffice.setup.InstallData;
27 import org.openoffice.setup.SetupData.PackageDescription;
28 import org.openoffice.setup.SetupData.ProductDescription;
29 import java.util.Enumeration;
30 import java.util.Vector;
31 
32 public class InfoCtrl {
33 
InfoCtrl()34     private InfoCtrl() {
35     }
36 
setHtmlFrame(String position, String htmlInfoText)37     static public String setHtmlFrame(String position, String htmlInfoText) {
38         if ( position.equals("header") ) {
39             htmlInfoText = "<HTML><BODY><FONT FACE=\"sans-serif\" SIZE=3>";
40         }
41         else if ( position.equals("end")) {
42             htmlInfoText = htmlInfoText + "</FONT></BODY></HTML>";
43         }
44 
45         return htmlInfoText;
46     }
47 
setReadyToInstallInfoText(ProductDescription productData, String htmlInfoText)48     static public String setReadyToInstallInfoText(ProductDescription productData, String htmlInfoText) {
49         // String oneline = "-------------------------------------------------------------------";
50         String oneline = "-------------------------------------------------------------";
51         htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>";
52         InstallData data = InstallData.getInstance();
53         htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDefaultDir() + "<br>";
54         htmlInfoText = htmlInfoText + oneline + "<br>";
55 
56         return htmlInfoText;
57     }
58 
setReadyToInstallInfoText(PackageDescription packageData, String htmlInfoText)59     static public String setReadyToInstallInfoText(PackageDescription packageData, String htmlInfoText) {
60         // setHtmlInfoText(packageData, 0);
61         InstallData data = InstallData.getInstance();
62         if ( data.isInstallationMode() ) {
63             htmlInfoText = setReadyToInstallInfoText(packageData, "", htmlInfoText);
64         } else {
65             htmlInfoText = setReadyToUninstallInfoText(packageData, "", htmlInfoText);
66         }
67         return htmlInfoText;
68     }
69 
70     // private void setReadyToInstallInfoText(PackageDescription packageData, Integer indent) {
setReadyToInstallInfoText(PackageDescription packageData, String indent, String htmlInfoText)71     static private String setReadyToInstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) {
72         // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">";
73         // System.out.println(ind);
74         if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) {
75             if ( ! packageData.isHidden() ) {
76                 if ( packageData.getSelectionState() == packageData.INSTALL ) {
77                     // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>";
78                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
79                 }
80             }
81         }
82 
83         if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) {
84             if ( ! packageData.isHidden() ) {
85                 if (( packageData.getSelectionState() == packageData.INSTALL ) ||
86                     ( packageData.getSelectionState() == packageData.INSTALL_SOME )) {
87                     // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>";
88                     // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>";
89                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
90                 }
91             }
92 
93             indent = indent + "..";
94 
95             for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
96                 PackageDescription child = (PackageDescription) e.nextElement();
97                 htmlInfoText = setReadyToInstallInfoText(child, indent, htmlInfoText);
98             }
99         }
100 
101         return htmlInfoText;
102     }
103 
104     // private void setReadyToUninstallInfoText(PackageDescription packageData, Integer indent, String htmlInfoText) {
setReadyToUninstallInfoText(PackageDescription packageData, String indent, String htmlInfoText)105     static private String setReadyToUninstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) {
106         // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">";
107         // System.out.println(ind);
108         if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) {
109             if ( ! packageData.isHidden() ) {
110                 if ( packageData.getSelectionState() == packageData.REMOVE ) {
111                     // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>";
112                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
113                 }
114             }
115         }
116 
117         if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) {
118             if ( ! packageData.isHidden() ) {
119                 if (( packageData.getSelectionState() == packageData.REMOVE ) ||
120                     ( packageData.getSelectionState() == packageData.REMOVE_SOME )) {
121                     // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>";
122                     // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>";
123                     htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>";
124                 }
125             }
126 
127             indent = indent + "..";
128 
129             for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
130                 PackageDescription child = (PackageDescription) e.nextElement();
131                 htmlInfoText = setReadyToUninstallInfoText(child, indent, htmlInfoText);
132             }
133         }
134 
135         return htmlInfoText;
136     }
137 
setInstallLogInfoText(ProductDescription productData, String htmlInfoText)138     static public String  setInstallLogInfoText(ProductDescription productData, String htmlInfoText) {
139         // String separatorline = "-------------------------------------------------------------------";
140         String separatorline = "-------------------------------------------------------------";
141         htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>";
142         InstallData data = InstallData.getInstance();
143         htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDir() + "<br>";
144         htmlInfoText = htmlInfoText + "<b>Operating system</b>: " + data.getOSType() + "<br>";
145         if ( data.isUserInstallation() ) {
146             htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "User installation" + "<br>";
147         } else {
148             htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "Root installation" + "<br>";
149         }
150 
151         htmlInfoText = htmlInfoText + separatorline + "<br>";
152 
153         htmlInfoText = LogManager.publishLogfileContent(htmlInfoText, separatorline);
154         htmlInfoText = LogManager.publishCommandsLogfileContent(htmlInfoText);
155 
156         return htmlInfoText;
157     }
158 
159 }
160