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