Commits

Ingo Schmidt  committed c855f66

native373 #i117751# version check for JRE

  • Participants
  • Parent commits e962efe

Comments (0)

Files changed (1)

File javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java

 package org.openoffice.setup.Util;
 
 import org.openoffice.setup.InstallData;
+import org.openoffice.setup.Installer.Installer;
+import org.openoffice.setup.Installer.InstallerFactory;
 import org.openoffice.setup.SetupData.PackageDescription;
 import java.util.Enumeration;
 import java.util.Vector;
     static public void collectInstallPackages(PackageDescription packageData, Vector allPackages) {
             	
         if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.INSTALL )) {
-            allPackages.add(packageData);
-            // System.err.println("Adding to collector 1: " + packageData.getPackageName());
+            boolean doAdd = true;
+            // Special handling for jre package, because this is not necessarily older, if an older product is updated.
+            if ( packageData.isJavaPackage() ) {
+                Installer installer = InstallerFactory.getInstance();
+                InstallData data = InstallData.getInstance();
+                if ( installer.isPackageInstalled(packageData, data) ) {
+                    if ( ! installer.isInstalledPackageOlder(packageData, data) ) {
+                        doAdd = false;
+                    }
+                }
+            }
+
+            if ( doAdd ) {
+                allPackages.add(packageData);
+                System.err.println("Adding to collector 1: " + packageData.getPackageName());
+            }
         }
         
         // also allowing packages at nodes! 
                 ( ! packageData.getPackageName().equals("")) &&
                 (( packageData.getSelectionState() == packageData.INSTALL ) ||
                 ( packageData.getSelectionState() == packageData.INSTALL_SOME ))) {
-            allPackages.add(packageData);            
-            // System.err.println("Adding to collector 2: " + packageData.getPackageName());
+            boolean doAdd = true;
+            // Special handling for jre package, because this is not necessarily older, if an older product is updated.
+            if ( packageData.isJavaPackage() ) {
+                Installer installer = InstallerFactory.getInstance();
+                InstallData data = InstallData.getInstance();
+                if ( installer.isPackageInstalled(packageData, data) ) {
+                    if ( ! installer.isInstalledPackageOlder(packageData, data) ) {
+                        doAdd = false;
+                    }
+                }
+            }
+
+            if ( doAdd ) {
+                allPackages.add(packageData);
+                // System.err.println("Adding to collector 2: " + packageData.getPackageName());
+            }
         }
         
         for (Enumeration e = packageData.children(); e.hasMoreElements(); ) {