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