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 31 public class InfoCtrl { 32 33 private InfoCtrl() { 34 } 35 36 static public String setHtmlFrame(String position, String htmlInfoText) { 37 if ( position.equals("header") ) { 38 htmlInfoText = "<html><body><font face=\"sans-serif\" size=3>"; 39 } 40 else if ( position.equals("end")) { 41 htmlInfoText = htmlInfoText + "</font></body></html>"; 42 } 43 44 return htmlInfoText; 45 } 46 47 static public String setReadyToInstallInfoText(ProductDescription productData, String htmlInfoText) { 48 // String oneline = "-------------------------------------------------------------------"; 49 String oneline = "-------------------------------------------------------------"; 50 htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>"; 51 InstallData data = InstallData.getInstance(); 52 htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDefaultDir() + "<br>"; 53 htmlInfoText = htmlInfoText + oneline + "<br>"; 54 55 return htmlInfoText; 56 } 57 58 static public String setReadyToInstallInfoText(PackageDescription packageData, String htmlInfoText) { 59 // setHtmlInfoText(packageData, 0); 60 InstallData data = InstallData.getInstance(); 61 if ( data.isInstallationMode() ) { 62 htmlInfoText = setReadyToInstallInfoText(packageData, "", htmlInfoText); 63 } else { 64 htmlInfoText = setReadyToUninstallInfoText(packageData, "", htmlInfoText); 65 } 66 return htmlInfoText; 67 } 68 69 // private void setReadyToInstallInfoText(PackageDescription packageData, Integer indent) { 70 static private String setReadyToInstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) { 71 // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">"; 72 // System.out.println(ind); 73 if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) { 74 if ( ! packageData.isHidden() ) { 75 if ( packageData.getSelectionState() == packageData.INSTALL ) { 76 // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>"; 77 htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; 78 } 79 } 80 } 81 82 if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) { 83 if ( ! packageData.isHidden() ) { 84 if (( packageData.getSelectionState() == packageData.INSTALL ) || 85 ( packageData.getSelectionState() == packageData.INSTALL_SOME )) { 86 // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>"; 87 // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>"; 88 htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; 89 } 90 } 91 92 indent = indent + ".."; 93 94 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 95 PackageDescription child = (PackageDescription) e.nextElement(); 96 htmlInfoText = setReadyToInstallInfoText(child, indent, htmlInfoText); 97 } 98 } 99 100 return htmlInfoText; 101 } 102 103 // private void setReadyToUninstallInfoText(PackageDescription packageData, Integer indent, String htmlInfoText) { 104 static private String setReadyToUninstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) { 105 // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">"; 106 // System.out.println(ind); 107 if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) { 108 if ( ! packageData.isHidden() ) { 109 if ( packageData.getSelectionState() == packageData.REMOVE ) { 110 // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>"; 111 htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; 112 } 113 } 114 } 115 116 if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) { 117 if ( ! packageData.isHidden() ) { 118 if (( packageData.getSelectionState() == packageData.REMOVE ) || 119 ( packageData.getSelectionState() == packageData.REMOVE_SOME )) { 120 // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>"; 121 // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>"; 122 htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; 123 } 124 } 125 126 indent = indent + ".."; 127 128 for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { 129 PackageDescription child = (PackageDescription) e.nextElement(); 130 htmlInfoText = setReadyToUninstallInfoText(child, indent, htmlInfoText); 131 } 132 } 133 134 return htmlInfoText; 135 } 136 137 static public String setInstallLogInfoText(ProductDescription productData, String htmlInfoText) { 138 // String separatorline = "-------------------------------------------------------------------"; 139 String separatorline = "-------------------------------------------------------------"; 140 htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>"; 141 InstallData data = InstallData.getInstance(); 142 htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDir() + "<br>"; 143 htmlInfoText = htmlInfoText + "<b>Operating system</b>: " + data.getOSType() + "<br>"; 144 if ( data.isUserInstallation() ) { 145 htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "User installation" + "<br>"; 146 } else { 147 htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "Root installation" + "<br>"; 148 } 149 150 htmlInfoText = htmlInfoText + separatorline + "<br>"; 151 152 htmlInfoText = LogManager.publishLogfileContent(htmlInfoText, separatorline); 153 htmlInfoText = LogManager.publishCommandsLogfileContent(htmlInfoText); 154 155 return htmlInfoText; 156 } 157 158 } 159