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