Better, Faster, Freer

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: i386 ]
Version: HEAD ]

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: PackageCollector.java,v $
010  * $Revision: 1.5 $
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.Enumeration;
035 import java.util.Vector;
036 
037 public class PackageCollector {
038     
039     private PackageCollector() {
040     }
041 
042     static public void collectInstallPackages(PackageDescription packageData, Vector allPackages) {
043                 
044         if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.INSTALL )) {
045             allPackages.add(packageData);
046             // System.err.println("Adding to collector 1: " + packageData.getPackageName());
047         }
048         
049         // also allowing packages at nodes! 
050         if (( ! packageData.isLeaf() ) &&
051                 ( packageData.getPackageName() != null ) &&
052                 ( ! packageData.getPackageName().equals("")) &&
053                 (( packageData.getSelectionState() == packageData.INSTALL ) ||
054                 ( packageData.getSelectionState() == packageData.INSTALL_SOME ))) {
055             allPackages.add(packageData);            
056             // System.err.println("Adding to collector 2: " + packageData.getPackageName());
057         }
058         
059         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
060             PackageDescription child = (PackageDescription) e.nextElement();
061             collectInstallPackages(child, allPackages);
062         }
063         
064     }
065 
066     static public void collectUninstallPackages(PackageDescription packageData, Vector allPackages) {
067         if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.REMOVE )) {
068             allPackages.add(0, packageData);
069         }
070  
071         // also allowing packages at nodes! 
072         if (( ! packageData.isLeaf() ) &&
073                 ( packageData.getPackageName() != null ) &&
074                 ( ! packageData.getPackageName().equals("")) &&
075                 ( packageData.getSelectionState() == packageData.REMOVE )) {
076             allPackages.add(0, packageData);
077         }
078                 
079         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {
080             PackageDescription child = (PackageDescription) e.nextElement();
081             collectUninstallPackages(child, allPackages);
082         }   
083     }
084 
085     static public void sortPackages(Vector allPackages, Vector sortedPackages, String mode) {
086         for (int i = 0; i < allPackages.size(); i++) {
087             boolean integrated = false;
088             PackageDescription packageData = (PackageDescription) allPackages.get(i);
089             
090             if ( i == 0 ) {
091                 sortedPackages.add(packageData);
092                 integrated = true;
093             } else {
094                 int position = packageData.getOrder();
095                 for (int j = 0; j < sortedPackages.size(); j++) {
096                     PackageDescription sortedPackageData = (PackageDescription) sortedPackages.get(j);
097                     int compare = sortedPackageData.getOrder();
098                 
099                     if ( position < compare ) {
100                         sortedPackages.add(j, packageData);
101                         integrated = true;
102                         break;
103                     }
104                 }
105                 
106                 // no break used -> adding at the end
107                 if ( ! integrated ) {
108                     sortedPackages.add(packageData);
109                 }
110             }
111         }
112         
113         // reverse order for uninstallation
114         if ( mode.equalsIgnoreCase("uninstall")) {
115             int number = sortedPackages.size();
116             for (int i = 0; i < number; i++) {
117                 if ( i > 0 ) {
118                     PackageDescription sortPackageData = (PackageDescription) sortedPackages.remove(i);
119                     sortedPackages.add(0,sortPackageData);
120                 }
121             }
122         } 
123     }
124 
125 }

source navigation ] diff markup ] identifier search ] general search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!