|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||||
|
||||||
001 /************************************************************************* 002 * 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * Copyright 2008 by Sun Microsystems, Inc. 006 * 007 * OpenOffice.org - a multi-platform office productivity suite 008 * 009 * $RCSfile: Calculator.java,v $ 010 * $Revision: 1.3 $ 011 * 012 * This file is part of OpenOffice.org. 013 * 014 * OpenOffice.org is free software: you can redistribute it and/or modify 015 * it under the terms of the GNU Lesser General Public License version 3 016 * only, as published by the Free Software Foundation. 017 * 018 * OpenOffice.org is distributed in the hope that it will be useful, 019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 021 * GNU Lesser General Public License version 3 for more details 022 * (a copy is included in the LICENSE file that accompanied this code). 023 * 024 * You should have received a copy of the GNU Lesser General Public License 025 * version 3 along with OpenOffice.org. If not, see 026 * <http://www.openoffice.org/license.html> 027 * for a copy of the LGPLv3 License. 028 * 029 ************************************************************************/ 030 031 package org.openoffice.setup.Util; 032 033 import org.openoffice.setup.SetupData.PackageDescription; 034 import java.util.Vector; 035 import org.openoffice.setup.InstallData; 036 import org.openoffice.setup.ResourceManager; 037 038 public class Calculator { 039 040 private Calculator() { 041 } 042 043 static private int calculateInstallSize(Vector allPackages) { 044 045 int value = 0; 046 047 for (int i = 0; i < allPackages.size(); i++) { 048 PackageDescription packageData = (PackageDescription)allPackages.get(i); 049 int size = packageData.getSize(); 050 value = value + size; 051 } 052 053 return value; 054 } 055 056 static private boolean missingDiscSpace(int required, int available) { 057 boolean missingDiscSpace = true; 058 059 if ( required < available ) { 060 missingDiscSpace = false; 061 } 062 063 // missingDiscSpace = true; // for testing reasons 064 return missingDiscSpace; 065 } 066 067 static public boolean notEnoughDiscSpace(InstallData data) { 068 069 Vector installPackages = data.getInstallPackages(); 070 // Calculate size of selected modules 071 int installationSize = calculateInstallSize(installPackages); 072 073 // Compare with available space 074 int availableDiscSpace = data.getAvailableDiscSpace(); 075 076 // Show warning and repeat dialog, if not sufficient disc space available 077 boolean insufficientDiscSpace = missingDiscSpace(installationSize, availableDiscSpace); 078 079 if ( insufficientDiscSpace ) { 080 String message = ResourceManager.getString("String_Discspace_Insufficient") + "\n" + 081 ResourceManager.getString("String_Discspace_Required") + ": " + installationSize + " kB." + "\n" + 082 ResourceManager.getString("String_Discspace_Available") + ": " + availableDiscSpace + " kB." + "\n" + 083 ResourceManager.getString("String_Discspace_Tip"); 084 String title = ResourceManager.getString("String_Error"); 085 Informer.showErrorMessage(message, title); 086 } 087 088 return insufficientDiscSpace; 089 } 090 091 }
| [ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |
| This page was automatically generated by the LXR engine. The LXR team |
|