xref: /AOO41X/main/javainstaller2/src/JavaSetup/org/openoffice/setup/Controller/ChooseComponentsCtrl.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 java.util.Vector;
27cdf0e10cSrcweir import org.openoffice.setup.InstallData;
28cdf0e10cSrcweir import org.openoffice.setup.PanelController;
29cdf0e10cSrcweir import org.openoffice.setup.Panel.ChooseComponents;
30cdf0e10cSrcweir import org.openoffice.setup.ResourceManager;
31cdf0e10cSrcweir import org.openoffice.setup.SetupData.PackageDescription;
32cdf0e10cSrcweir import org.openoffice.setup.SetupData.SetupDataProvider;
33cdf0e10cSrcweir import org.openoffice.setup.Util.Calculator;
34cdf0e10cSrcweir import org.openoffice.setup.Util.Dumper;
35cdf0e10cSrcweir import org.openoffice.setup.Util.Informer;
36cdf0e10cSrcweir import org.openoffice.setup.Util.ModuleCtrl;
37cdf0e10cSrcweir import org.openoffice.setup.Util.PackageCollector;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir public class ChooseComponentsCtrl extends PanelController {
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     private String helpFile;
42cdf0e10cSrcweir 
ChooseComponentsCtrl()43cdf0e10cSrcweir     public ChooseComponentsCtrl() {
44cdf0e10cSrcweir         super("ChooseComponents", new ChooseComponents());
45cdf0e10cSrcweir         helpFile = "String_Helpfile_ChooseComponents";
46cdf0e10cSrcweir     }
47cdf0e10cSrcweir 
getNext()48cdf0e10cSrcweir     public String getNext() {
49cdf0e10cSrcweir         return new String("InstallationImminent");
50cdf0e10cSrcweir     }
51cdf0e10cSrcweir 
getPrevious()52cdf0e10cSrcweir     public String getPrevious() {
53cdf0e10cSrcweir 
54cdf0e10cSrcweir         InstallData data = InstallData.getInstance();
55cdf0e10cSrcweir 
56cdf0e10cSrcweir         if ( data.isRootInstallation() ) {
57cdf0e10cSrcweir             if ( data.sameVersionExists() ) {
58cdf0e10cSrcweir                 if ( data.hideEula() ) {
59cdf0e10cSrcweir                     return new String("Prologue");
60cdf0e10cSrcweir                 } else {
61cdf0e10cSrcweir                     return new String("AcceptLicense");
62cdf0e10cSrcweir                 }
63cdf0e10cSrcweir             } else {
64cdf0e10cSrcweir                 return new String("ChooseInstallationType");
65cdf0e10cSrcweir             }
66cdf0e10cSrcweir         } else {
67cdf0e10cSrcweir             if ( data.sameVersionExists() ) {
68cdf0e10cSrcweir                 return new String("ChooseDirectory");
69cdf0e10cSrcweir             } else {
70cdf0e10cSrcweir                 return new String("ChooseInstallationType");
71cdf0e10cSrcweir             }
72cdf0e10cSrcweir         }
73cdf0e10cSrcweir     }
74cdf0e10cSrcweir 
getHelpFileName()75cdf0e10cSrcweir     public final String getHelpFileName () {
76cdf0e10cSrcweir         return this.helpFile;
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir 
beforeShow()79cdf0e10cSrcweir     public void beforeShow() {
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         InstallData data = InstallData.getInstance();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         // Setting the package size for node modules, that have hidden children
84cdf0e10cSrcweir         // -> Java module has three hidden children and 0 byte size
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         if ( ! data.moduleSizeSet() ) {
87cdf0e10cSrcweir             PackageDescription packageData = SetupDataProvider.getPackageDescription();
88cdf0e10cSrcweir             ModuleCtrl.setModuleSize(packageData);
89cdf0e10cSrcweir             data.setModuleSizeSet(true);
90cdf0e10cSrcweir         }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir         if ( data.sameVersionExists() ) {
93cdf0e10cSrcweir             ChooseComponents panel = (ChooseComponents)getPanel();
94cdf0e10cSrcweir             String dialogTitle = ResourceManager.getString("String_ChooseComponents1_Maintain");
95cdf0e10cSrcweir             panel.setTitleText(dialogTitle);
96cdf0e10cSrcweir         }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     }
99cdf0e10cSrcweir 
afterShow(boolean nextButtonPressed)100cdf0e10cSrcweir     public boolean afterShow(boolean nextButtonPressed) {
101cdf0e10cSrcweir         boolean repeatDialog = false;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         InstallData data = InstallData.getInstance();
104cdf0e10cSrcweir         PackageDescription packageData = SetupDataProvider.getPackageDescription();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         if ( nextButtonPressed ) {
107cdf0e10cSrcweir 
108cdf0e10cSrcweir             // Check, if at least one visible module was selected for installation
109cdf0e10cSrcweir             data.setVisibleModulesChecked(false);
110cdf0e10cSrcweir             ModuleCtrl.checkVisibleModulesInstall(packageData, data);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir             if ( data.visibleModulesChecked() ) {
113cdf0e10cSrcweir 
114cdf0e10cSrcweir                 // Check, if at least one application module was selected for installation
115cdf0e10cSrcweir                 // (not necessary, if an older product is updated or additional modules are
116cdf0e10cSrcweir                 // added in maintenance mode).
117cdf0e10cSrcweir 
118cdf0e10cSrcweir                 boolean applicationSelected = false;
119cdf0e10cSrcweir                 if ( data.olderVersionExists() || data.sameVersionExists() ) {
120cdf0e10cSrcweir                     applicationSelected = true;
121cdf0e10cSrcweir                 } else {
122cdf0e10cSrcweir                     data.setApplicationModulesChecked(false);
123cdf0e10cSrcweir                     ModuleCtrl.checkApplicationSelection(packageData, data);
124cdf0e10cSrcweir                     applicationSelected = data.applicationModulesChecked();
125cdf0e10cSrcweir                 }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir                 if ( applicationSelected ) {
128cdf0e10cSrcweir 
129cdf0e10cSrcweir                     // Check, if at least one language module was selected for installation
130cdf0e10cSrcweir                     // (not necessary, if an older product is updated or additional modules are
131cdf0e10cSrcweir                     // added in maintenance mode).
132cdf0e10cSrcweir 
133cdf0e10cSrcweir                     boolean languageSelected = false;
134cdf0e10cSrcweir                     if ( data.olderVersionExists() || data.sameVersionExists() || ( ! data.isMultiLingual())) {
135cdf0e10cSrcweir                         languageSelected = true;
136cdf0e10cSrcweir                     } else {
137cdf0e10cSrcweir                         data.setLanguageModulesChecked(false);
138cdf0e10cSrcweir                         ModuleCtrl.checkLanguageSelection(packageData, data);
139cdf0e10cSrcweir                         languageSelected = data.languageModulesChecked();
140cdf0e10cSrcweir                     }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir                     if ( languageSelected ) {
143cdf0e10cSrcweir 
144cdf0e10cSrcweir                         // Set module settings for hidden modules.
145cdf0e10cSrcweir                         // Then it is possible to calculate the size of the installed product,
146cdf0e10cSrcweir                         // to show a warning and to set the repeatDialog value to true
147cdf0e10cSrcweir 
148cdf0e10cSrcweir                         if ( data.logModuleStates() ) {
149cdf0e10cSrcweir                             Dumper.logModuleStates(packageData, "ChooseComponentsCtrl: Before setHiddenModuleSettingsInstall");
150cdf0e10cSrcweir                         }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir                         ModuleCtrl.setHiddenModuleSettingsInstall(packageData);
153cdf0e10cSrcweir                         // Dumper.dumpInstallPackages(packageData);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir                         if ( data.logModuleStates() ) {
156cdf0e10cSrcweir                             Dumper.logModuleStates(packageData, "ChooseComponentsCtrl: After setHiddenModuleSettingsInstall");
157cdf0e10cSrcweir                         }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir                         // Collecting packages to install
160cdf0e10cSrcweir                         Vector installPackages = new Vector();
161cdf0e10cSrcweir                         PackageCollector.collectInstallPackages(packageData, installPackages);
162cdf0e10cSrcweir                         data.setInstallPackages(installPackages);
163cdf0e10cSrcweir 
164cdf0e10cSrcweir                         // Check disc space
165cdf0e10cSrcweir                         if ( Calculator.notEnoughDiscSpace(data) ) {
166cdf0e10cSrcweir                             repeatDialog = true;
167cdf0e10cSrcweir                             System.err.println("Not enough disc space");
168cdf0e10cSrcweir                         }
169cdf0e10cSrcweir                     } else {   // no language modules selected for installation
170cdf0e10cSrcweir                         String message = ResourceManager.getString("String_No_Language_Selected_1") + "\n" +
171cdf0e10cSrcweir                                          ResourceManager.getString("String_No_Language_Selected_2");
172cdf0e10cSrcweir                         String title = ResourceManager.getString("String_Change_Selection");
173cdf0e10cSrcweir                         Informer.showInfoMessage(message, title);
174cdf0e10cSrcweir                         repeatDialog = true;
175cdf0e10cSrcweir                     }
176cdf0e10cSrcweir                 } else {
177cdf0e10cSrcweir                     String message = ResourceManager.getString("String_No_Application_Selected_1") + "\n" +
178cdf0e10cSrcweir                                      ResourceManager.getString("String_No_Application_Selected_2");
179cdf0e10cSrcweir                     String title = ResourceManager.getString("String_Change_Selection");
180cdf0e10cSrcweir                     Informer.showInfoMessage(message, title);
181cdf0e10cSrcweir                     repeatDialog = true;
182cdf0e10cSrcweir                 }
183cdf0e10cSrcweir             } else {  // no modules selected for installation
184cdf0e10cSrcweir                 String message = ResourceManager.getString("String_No_Components_Selected_1") + "\n" +
185cdf0e10cSrcweir                                  ResourceManager.getString("String_No_Components_Selected_2");
186cdf0e10cSrcweir                 String title = ResourceManager.getString("String_Nothing_To_Install");
187cdf0e10cSrcweir                 Informer.showInfoMessage(message, title);
188cdf0e10cSrcweir                 repeatDialog = true;
189cdf0e10cSrcweir             }
190cdf0e10cSrcweir         } else {  // the back button was pressed
191cdf0e10cSrcweir             // Saving typical selection state values (always if back button is pressed!).
192cdf0e10cSrcweir             // System.err.println("Saving custom selection states");
193cdf0e10cSrcweir             ModuleCtrl.saveCustomSelectionStates(packageData);
194cdf0e10cSrcweir             data.setCustomSelectionStateSaved(true);
195cdf0e10cSrcweir         }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir         return repeatDialog;
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir }
201