1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package org.openoffice.setup.Controller; 25 26 import org.openoffice.setup.InstallData; 27 import org.openoffice.setup.PanelController; 28 import org.openoffice.setup.Panel.ChooseInstallationType; 29 import org.openoffice.setup.SetupData.PackageDescription; 30 import org.openoffice.setup.SetupData.SetupDataProvider; 31 import org.openoffice.setup.Util.Calculator; 32 import org.openoffice.setup.Util.Dumper; 33 import org.openoffice.setup.Util.ModuleCtrl; 34 import java.awt.event.ActionEvent; 35 import java.awt.event.ActionListener; 36 import java.util.Vector; 37 import org.openoffice.setup.Util.PackageCollector; 38 39 public class ChooseInstallationTypeCtrl extends PanelController implements ActionListener { 40 41 private String helpFile; 42 ChooseInstallationTypeCtrl()43 public ChooseInstallationTypeCtrl() { 44 super("ChooseInstallationType", new ChooseInstallationType()); 45 helpFile = "String_Helpfile_ChooseInstallationType"; 46 } 47 getNext()48 public String getNext() { 49 50 InstallData data = InstallData.getInstance(); 51 52 if ( data.getInstallationType().equals(data.getCustomActionCommand()) ) { 53 return new String("ChooseComponents"); 54 } else if ( data.getInstallationType().equals(data.getTypicalActionCommand()) ) { 55 return new String("InstallationImminent"); 56 } else { 57 System.err.println("Error: Unknown installation type!" ); 58 return new String("Error"); 59 } 60 } 61 getPrevious()62 public String getPrevious() { 63 64 InstallData data = InstallData.getInstance(); 65 66 if ( data.isRootInstallation() ) { 67 if ( data.hideEula() ) { 68 return new String("Prologue"); 69 } else { 70 return new String("AcceptLicense"); 71 } 72 } else { 73 return new String("ChooseDirectory"); 74 } 75 } 76 getHelpFileName()77 public final String getHelpFileName () { 78 return this.helpFile; 79 } 80 beforeShow()81 public void beforeShow() { 82 83 InstallData data = InstallData.getInstance(); 84 85 ChooseInstallationType panel = (ChooseInstallationType)getPanel(); 86 panel.setActionListener((ChooseInstallationTypeCtrl)this); 87 panel.setTypicalActionCommand(data.getTypicalActionCommand()); 88 panel.setCustomActionCommand(data.getCustomActionCommand()); 89 } 90 afterShow(boolean nextButtonPressed)91 public boolean afterShow(boolean nextButtonPressed) { 92 boolean repeatDialog = false; 93 ChooseInstallationType panel = (ChooseInstallationType)getPanel(); 94 panel.removeActionListener((ChooseInstallationTypeCtrl)this); 95 96 if ( nextButtonPressed ) { 97 98 InstallData data = InstallData.getInstance(); 99 PackageDescription packageData = SetupDataProvider.getPackageDescription(); 100 101 if ( data.getInstallationType().equals(data.getTypicalActionCommand()) ) { 102 103 // If typical selection state values have been saved before, 104 // it is now time to restore them 105 106 if ( data.typicalSelectionStateSaved()) { 107 // System.err.println("Restoring typical selection states"); 108 ModuleCtrl.restoreTypicalSelectionStates(packageData); 109 } 110 111 if ( data.logModuleStates() ) { 112 Dumper.logModuleStates(packageData, "ChooseInstallationType: Before setHiddenModuleSettingsInstall"); 113 } 114 115 // For standard installation type, the hidden modules have to be defined here. 116 // Then it is possible to calculate the size of the installed product, to show a warning 117 // and to set the repeatDialog value to true 118 ModuleCtrl.setHiddenModuleSettingsInstall(packageData); 119 // Dumper.dumpInstallPackages(packageData); 120 121 if ( data.logModuleStates() ) { 122 Dumper.logModuleStates(packageData, "ChooseInstallationType: After setHiddenModuleSettingsInstall"); 123 } 124 125 // Collecting packages to install 126 Vector installPackages = new Vector(); 127 PackageCollector.collectInstallPackages(packageData, installPackages); 128 data.setInstallPackages(installPackages); 129 130 // Check disc space 131 if ( Calculator.notEnoughDiscSpace(data) ) { 132 repeatDialog = true; 133 } 134 } 135 136 // Custom installation type 137 if (( data.getInstallationType().equals(data.getCustomActionCommand() ))) { 138 // Saving typical selection state values, if they are not already saved. 139 if ( ! data.typicalSelectionStateSaved()) { 140 // System.err.println("Saving typical selection states"); 141 ModuleCtrl.saveTypicalSelectionStates(packageData); 142 data.setTypicalSelectionStateSaved(true); 143 } 144 145 // Setting custom selection state values, if they have been saved before. 146 if ( data.customSelectionStateSaved() ) { 147 // System.err.println("Restoring custom selection states"); 148 ModuleCtrl.restoreCustomSelectionStates(packageData); 149 } 150 } 151 } 152 153 return repeatDialog; 154 } 155 actionPerformed(ActionEvent evt)156 public void actionPerformed(ActionEvent evt) { 157 158 InstallData data = InstallData.getInstance(); 159 160 if (evt.getActionCommand().equals(data.getTypicalActionCommand())) { 161 data.setInstallationType(data.getTypicalActionCommand()); 162 // System.err.println("Setting installation type: " + data.getTypicalActionCommand()); 163 } else if (evt.getActionCommand().equals(data.getCustomActionCommand())) { 164 data.setInstallationType(data.getCustomActionCommand()); 165 // System.err.println("Setting installation type: " + data.getCustomActionCommand()); 166 } 167 168 } 169 170 } 171