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.Controller; 29 30 import org.openoffice.setup.InstallData; 31 import org.openoffice.setup.Installer.Installer; 32 import org.openoffice.setup.Installer.InstallerFactory; 33 import org.openoffice.setup.PanelController; 34 import org.openoffice.setup.Panel.Prologue; 35 import org.openoffice.setup.SetupData.PackageDescription; 36 import org.openoffice.setup.SetupData.SetupDataProvider; 37 import org.openoffice.setup.Util.Controller; 38 import org.openoffice.setup.Util.Dumper; 39 import org.openoffice.setup.Util.ModuleCtrl; 40 import org.openoffice.setup.Util.SystemManager; 41 42 public class PrologueCtrl extends PanelController { 43 44 private String helpFile; 45 46 public PrologueCtrl() { 47 super("Prologue", new Prologue()); 48 helpFile = "String_Helpfile_Prologue"; 49 } 50 51 // public void beforeShow() { 52 public void duringShow() { 53 getSetupFrame().setButtonEnabled(false, getSetupFrame().BUTTON_PREVIOUS); 54 55 Thread t = new Thread() { 56 public void run() { 57 InstallData installData = InstallData.getInstance(); 58 if ( ! installData.preInstallDone() ) { 59 getSetupFrame().setButtonEnabled(false, getSetupFrame().BUTTON_NEXT); 60 61 Controller.checkPackagePathExistence(installData); 62 Controller.checkPackageFormat(installData); 63 64 if (( installData.getOSType().equalsIgnoreCase("SunOS") ) && ( installData.isMultiLingual() )) { 65 Controller.collectSystemLanguages(installData); 66 } 67 68 PackageDescription packageData = SetupDataProvider.getPackageDescription(); 69 Installer installer = InstallerFactory.getInstance(); 70 installer.preInstall(packageData); 71 72 installData.setPreInstallDone(true); 73 74 if ( SystemManager.logModuleStates() ) { 75 installData.setLogModuleStates(true); 76 } 77 78 if ( installData.logModuleStates() ) { 79 Dumper.logModuleStates(packageData, "Prologue Dialog"); 80 } 81 82 if (( installData.getOSType().equalsIgnoreCase("SunOS") ) && ( installData.isMultiLingual() )) { 83 ModuleCtrl.checkLanguagesPackages(packageData, installData); 84 85 // int count = installData.getPreselectedLanguages(); 86 // System.err.println("Number of preselected language packages: " + count); 87 88 if ( installData.getPreselectedLanguages() == 0 ) { 89 // Something misterious happened. Setting all languages again. 90 ModuleCtrl.setLanguagesPackages(packageData); 91 } 92 93 if ( installData.logModuleStates() ) { 94 Dumper.logModuleStates(packageData, "Prologue Dialog Language Selection"); 95 } 96 } 97 98 if ( ! installData.isMultiLingual() ) { 99 ModuleCtrl.setHiddenLanguageModuleDefaultSettings(packageData); 100 101 if ( installData.logModuleStates() ) { 102 Dumper.logModuleStates(packageData, "after setHiddenLanguageModuleDefaultSettings"); 103 } 104 } 105 106 if (( installData.isRootInstallation() ) && ( installData.getOSType().equalsIgnoreCase("SunOS") )) { 107 // Check, if root has write access in /usr and /etc . 108 // In sparse zones with imported directories this is not always the case. 109 if ( Controller.reducedRootWritePrivileges() ) { 110 ModuleCtrl.setIgnoreNonRelocatablePackages(packageData); 111 } 112 113 if ( installData.logModuleStates() ) { 114 Dumper.logModuleStates(packageData, "after setIgnoreNonRelocatablePackages"); 115 } 116 } 117 118 if ( installData.isRootInstallation() ) { 119 120 // Setting installation directory! 121 String dir = "/"; 122 installData.setInstallDir(dir); 123 installData.setInstallDefaultDir(installData.getDefaultDir()); 124 125 Controller.checkForNewerVersion(installData); 126 127 // Check Write privileges in installation directory (installData.getInstallDefaultDir()) 128 // If the directory exists, is has to be tested, whether the user has write access 129 dir = installData.getInstallDefaultDir(); 130 131 if ( SystemManager.exists_directory(dir) ) { 132 if ( ! Controller.createdSubDirectory(dir) ) { 133 System.err.println("ERROR: No write privileges inside directory: " + dir); 134 System.exit(1); 135 } 136 } 137 138 // If the directory does not exist, is has to be tested, whether the user can create it 139 if ( ! SystemManager.exists_directory(dir)) { 140 if ( ! Controller.createdDirectory(dir) ) { 141 System.err.println("ERROR: No privileges to create directory: " + dir); 142 System.exit(1); 143 } 144 } 145 146 // Setting macro 147 SetupDataProvider.setNewMacro("DIR", dir); // important for string replacement 148 149 // Calculate available disc space 150 int discSpace = SystemManager.calculateDiscSpace(dir); 151 installData.setAvailableDiscSpace(discSpace); 152 153 if ( ! installData.databaseAnalyzed()) { 154 ModuleCtrl.defaultDatabaseAnalysis(installData); 155 installData.setDatabaseAnalyzed(true); 156 } 157 } 158 159 getSetupFrame().setButtonEnabled(true, getSetupFrame().BUTTON_NEXT); 160 } 161 } 162 }; 163 t.start(); 164 } 165 166 public boolean afterShow(boolean nextButtonPressed) { 167 boolean repeatDialog = false; 168 getSetupFrame().setButtonEnabled(true, getSetupFrame().BUTTON_PREVIOUS); 169 return repeatDialog; 170 } 171 172 public String getNext() { 173 InstallData data = InstallData.getInstance(); 174 175 if ( data.hideEula() ) { 176 if ( data.isRootInstallation() ) { 177 if ( data.olderVersionExists() ) { 178 return new String("InstallationImminent"); 179 } else if ( data.sameVersionExists() ) { 180 return new String("ChooseComponents"); 181 } else { 182 return new String("ChooseInstallationType"); 183 } 184 } else { 185 return new String("ChooseDirectory"); 186 } 187 } else { 188 return new String("AcceptLicense"); 189 } 190 } 191 192 public String getPrevious() { 193 return null; 194 } 195 196 public final String getHelpFileName() { 197 return this.helpFile; 198 } 199 200 } 201