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.Controller;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import org.openoffice.setup.InstallData;
27cdf0e10cSrcweir import org.openoffice.setup.PanelController;
28cdf0e10cSrcweir import org.openoffice.setup.Panel.InstallationImminent;
29cdf0e10cSrcweir import org.openoffice.setup.ResourceManager;
30cdf0e10cSrcweir import org.openoffice.setup.SetupData.PackageDescription;
31cdf0e10cSrcweir import org.openoffice.setup.SetupData.ProductDescription;
32cdf0e10cSrcweir import org.openoffice.setup.SetupData.SetupDataProvider;
33cdf0e10cSrcweir import org.openoffice.setup.Util.Dumper;
34cdf0e10cSrcweir import org.openoffice.setup.Util.InfoCtrl;
35cdf0e10cSrcweir import org.openoffice.setup.Util.Informer;
36cdf0e10cSrcweir import org.openoffice.setup.Util.LogManager;
37cdf0e10cSrcweir import org.openoffice.setup.Util.ModuleCtrl;
38cdf0e10cSrcweir import java.util.Vector;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir public class InstallationImminentCtrl extends PanelController {
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     private String helpFile;
43cdf0e10cSrcweir     private String htmlInfoText = "";
44cdf0e10cSrcweir 
InstallationImminentCtrl()45cdf0e10cSrcweir     public InstallationImminentCtrl() {
46cdf0e10cSrcweir         super("InstallationImminent", new InstallationImminent());
47cdf0e10cSrcweir         helpFile = "String_Helpfile_InstallationImminent";
48cdf0e10cSrcweir     }
49cdf0e10cSrcweir 
getNext()50cdf0e10cSrcweir     public String getNext() {
51cdf0e10cSrcweir         return new String("InstallationOngoing");
52cdf0e10cSrcweir     }
53cdf0e10cSrcweir 
getPrevious()54cdf0e10cSrcweir     public String getPrevious() {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir         InstallData data = InstallData.getInstance();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir         if ( data.isRootInstallation() ) {
59cdf0e10cSrcweir             if ( data.olderVersionExists() ) {
60cdf0e10cSrcweir                 if ( data.hideEula() ) {
61cdf0e10cSrcweir                     return new String("Prologue");
62cdf0e10cSrcweir                 } else {
63cdf0e10cSrcweir                     return new String("AcceptLicense");
64cdf0e10cSrcweir                 }
65cdf0e10cSrcweir             } else if ( data.sameVersionExists() ) {
66cdf0e10cSrcweir                 return new String("ChooseComponents");
67cdf0e10cSrcweir             } else {
68cdf0e10cSrcweir                 if ( data.getInstallationType().equals(data.getCustomActionCommand()) ) {
69cdf0e10cSrcweir                     return new String("ChooseComponents");
70cdf0e10cSrcweir                 } else if ( data.getInstallationType().equals(data.getTypicalActionCommand()) ) {
71cdf0e10cSrcweir                     return new String("ChooseInstallationType");
72cdf0e10cSrcweir                 } else {
73cdf0e10cSrcweir                     System.err.println("Error: Unknown installation type!" );
74cdf0e10cSrcweir                     return new String("Error");
75cdf0e10cSrcweir                 }
76cdf0e10cSrcweir             }
77cdf0e10cSrcweir         } else {
78cdf0e10cSrcweir             if ( data.olderVersionExists() ) {
79cdf0e10cSrcweir                 return new String("ChooseDirectory");
80cdf0e10cSrcweir             } else if ( data.sameVersionExists() ) {
81cdf0e10cSrcweir                 return new String("ChooseComponents");
82cdf0e10cSrcweir             } else {
83cdf0e10cSrcweir                 if ( data.getInstallationType().equals(data.getCustomActionCommand()) ) {
84cdf0e10cSrcweir                     return new String("ChooseComponents");
85cdf0e10cSrcweir                 } else if ( data.getInstallationType().equals(data.getTypicalActionCommand()) ) {
86cdf0e10cSrcweir                     return new String("ChooseInstallationType");
87cdf0e10cSrcweir                 } else {
88cdf0e10cSrcweir                     System.err.println("Error: Unknown installation type!" );
89cdf0e10cSrcweir                     return new String("Error");
90cdf0e10cSrcweir                 }
91cdf0e10cSrcweir             }
92cdf0e10cSrcweir         }
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
getHelpFileName()95cdf0e10cSrcweir     public final String getHelpFileName () {
96cdf0e10cSrcweir         return this.helpFile;
97cdf0e10cSrcweir     }
98cdf0e10cSrcweir 
beforeShow()99cdf0e10cSrcweir     public void beforeShow() {
100cdf0e10cSrcweir         String StringInstall = ResourceManager.getString("String_Install");
101cdf0e10cSrcweir         getSetupFrame().setButtonText(StringInstall, getSetupFrame().BUTTON_NEXT);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         ProductDescription productData = SetupDataProvider.getProductDescription();
104cdf0e10cSrcweir         PackageDescription packageData = SetupDataProvider.getPackageDescription();
105cdf0e10cSrcweir         // Dumper.dumpPackageSettings(packageData);
106cdf0e10cSrcweir         htmlInfoText = InfoCtrl.setHtmlFrame("header", htmlInfoText);
107cdf0e10cSrcweir         htmlInfoText = InfoCtrl.setReadyToInstallInfoText(productData, htmlInfoText);
108cdf0e10cSrcweir         htmlInfoText = InfoCtrl.setReadyToInstallInfoText(packageData, htmlInfoText);
109cdf0e10cSrcweir         htmlInfoText = InfoCtrl.setHtmlFrame("end", htmlInfoText);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         InstallationImminent panel = (InstallationImminent)getPanel();
112cdf0e10cSrcweir         panel.setInfoText(htmlInfoText);
113cdf0e10cSrcweir         panel.setCaretPosition();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         // Update mode
116cdf0e10cSrcweir         InstallData data = InstallData.getInstance();
117cdf0e10cSrcweir         if ( data.olderVersionExists() ) {
118cdf0e10cSrcweir             String dialogTitle = ResourceManager.getString("String_InstallationImminent1_Update");
119cdf0e10cSrcweir             panel.setTitleText(dialogTitle);
120cdf0e10cSrcweir         }
121cdf0e10cSrcweir     }
122cdf0e10cSrcweir 
duringShow()123cdf0e10cSrcweir     public void duringShow() {
124cdf0e10cSrcweir         InstallationImminent panel = (InstallationImminent)getPanel();
125cdf0e10cSrcweir         panel.setTabOrder();
126cdf0e10cSrcweir     }
127cdf0e10cSrcweir 
afterShow(boolean nextButtonPressed)128cdf0e10cSrcweir     public boolean afterShow(boolean nextButtonPressed) {
129cdf0e10cSrcweir         boolean repeatDialog = false;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         if ( nextButtonPressed ) {
132cdf0e10cSrcweir 
133cdf0e10cSrcweir             InstallData data = InstallData.getInstance();
134cdf0e10cSrcweir 
135cdf0e10cSrcweir             // determining the packagePath
136cdf0e10cSrcweir             if ( data.getPackagePath() != null ) {
137cdf0e10cSrcweir                 String log = "<b>Packages path:</b> " + data.getPackagePath() + "<br>";
138cdf0e10cSrcweir                 LogManager.addLogfileComment(log);
139cdf0e10cSrcweir             } else {
140cdf0e10cSrcweir                 String message = ResourceManager.getString("String_InstallationOngoing_PackagePath_Not_Found");
141cdf0e10cSrcweir                 String title = ResourceManager.getString("String_Error");
142cdf0e10cSrcweir                 Informer.showErrorMessage(message, title);
143cdf0e10cSrcweir                 String log = "<b>Error: No path for packages exists!</b><br>";
144cdf0e10cSrcweir                 LogManager.addLogfileComment(log);
145cdf0e10cSrcweir                 repeatDialog = true;
146cdf0e10cSrcweir             }
147cdf0e10cSrcweir         }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         return repeatDialog;
150cdf0e10cSrcweir     }
151cdf0e10cSrcweir }
152