<?xml version="1.0" encoding="utf-8"?>
<oor:component-schema oor:version="1.1" oor:name="JDKSelection" oor:package="org.openinstaller.JDKSelection"
 xsi:schemaLocation="http://openoffice.org/2001/registry"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:oor="http://openoffice.org/2001/registry"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xml:lang='en-US'>
<!--
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICE OR THIS HEADER.

 Copyright 2006, 2007 Sun Microsystems, Inc. All rights reserved.
 Use is subject to license terms.

 The contents of this file are subject to the terms of the Common Development
 and Distribution License("CDDL") (the "License"). You may not use this file
 except in compliance with the License.

 You can obtain a copy of the License at https://openinstaller.dev.java.net/license.html
 or http://openinstaller.dev.java.net/license.txt . See the License for the
 specific language governing permissions and limitations under the License.

 When distributing the Covered Code, include this CDDL Header Notice in each
 file and include the License file at http://openinstaller.dev.java.net/license.txt .
 If applicable, add the following below this CDDL Header, with the fields
 enclosed by brackets [] replaced by your own identifying information:
 "Portions Copyrighted [year] [name of copyright owner]"

 ident "@(#)%Name% %Revision% %Date% SMI"

-->
 <component>
     <group oor:name="directory">
        <prop oor:name="JDK_FROM_MEDIA_CHOICE" oor:type="xs:boolean">
          <value>true</value>
          <info>
            <desc xml:lang="en-US">JDK Home Directory Path.</desc>
          </info>
        </prop>
        <prop oor:name="JDK_FROM_LIST_CHOICE" oor:type="xs:boolean">
          <value>false</value>
          <info>
            <desc xml:lang="en-US">JDK Home Directory Path.</desc>
          </info>
        </prop>
        <prop oor:name="JDK_TYPED_IN_CHOICE" oor:type="xs:boolean">
          <value>false</value>
          <info>
            <desc xml:lang="en-US">JDK Home Directory Path.</desc>
          </info>
        </prop>
        <prop oor:name="JDK_LIST" oor:type="xs:string" oor:nillable="true">
          <value/>
          <info>
            <desc xml:lang="en-US">JDK List.</desc>
          </info>
        </prop>
        <prop oor:name="JDK_VERSIONRANGE" oor:type="xs:string" oor:nillable="true">
          <value>[1.5.0_12--INFINITY)</value>
          <info>
            <desc xml:lang="en-US">Version range to be reported in the JDK list.</desc>
          </info>
        </prop>
        <prop oor:name="JDK_TYPE_IN" oor:type="xs:string" oor:nillable="true">
          <value/>
          <info>
            <desc xml:lang="en-US">JDK List.</desc>
          </info>
          <actions>
            <onSet><![CDATA[
            import org.openinstaller.provider.dependency.JavaDetection;
            import org.openinstaller.util.EnhancedException;
            import org.openinstaller.provider.conf.ConfigHelper;

            theValue = (String) thisProperty.getUnconfirmedValue();
            theChoice = ConfigHelper.getBooleanValue("JDKSelection.directory.JDK_TYPED_IN_CHOICE");
            theSpec   = ConfigHelper.getStringValue("JDKSelection.directory.JDK_VERSIONRANGE");
            if (theChoice) {
              if (!new JavaDetection(theSpec).isValidDir(theValue)) {
                throw new EnhancedException("INVALID_JAVA_PER_CONSTRAINTS", new String[] {"dir=" + theValue});
              }
            }
            ]]></onSet>
          </actions>
        </prop>
        <prop oor:name="HIDDEN_JDK" oor:type="xs:string" oor:nillable="true">
          <value/>
          <info>
            <desc xml:lang="en-US">JDK Home Directory Path.</desc>
          </info>
          <actions>
            <onSet><![CDATA[
            import java.io.File;
            import org.openinstaller.provider.dependency.JavaDetection;
            import org.openinstaller.provider.dependency.DependencyControl;
            import org.openinstaller.util.EnhancedException;
            import org.openinstaller.provider.conf.ConfigHelper;

            theValue = (String) thisProperty.getUnconfirmedValue();
            theChoice1 = ConfigHelper.getBooleanValue("JDKSelection.directory.JDK_FROM_MEDIA_CHOICE");
            theChoice2 = ConfigHelper.getBooleanValue("JDKSelection.directory.JDK_FROM_LIST_CHOICE");
            theInstallHome = ConfigHelper.getStringValue("InstallHome.directory.INSTALL_HOME");
            theJDK = ConfigHelper.getStringValue("JDK.Installation.JDK_HOME_BASEDIR");
            theValueToSet = null;
            selectJDKToInstall = null;
            if (theChoice1) {
              File theFinalValue = new File(new File(theInstallHome), theJDK);
              theValueToSet = theFinalValue.getAbsolutePath();
              selectJDKToInstall = "true";
            } else if (theChoice2) {
              theValueToSet = theValue;
              selectJDKToInstall = "false";
            } else {
              try {
                theValueToSet = ConfigHelper.getStringValue("JDKSelection.directory.JDK_TYPE_IN");
              } catch (EnhancedException e) {
                theValueToSet = "";
              }
              selectJDKToInstall = "false";
            }
            ConfigHelper.setValue("JDKSelection.directory.SELECTED_JDK", theValueToSet);
            ConfigHelper.setValue("JDKSelection.directory.SELECT_JDK_TO_INSTALL", selectJDKToInstall);

            /* de-select jdk if the user chooses an existing one */
            if (selectJDKToInstall.equalsIgnoreCase("true")) {
               /* user chose to install bundled jdk so let's select it */
                ctl = new DependencyControl(DependencyControl.COMMAND.FORCE_SELECT_ELEMENT, "jdk5");
                thereq = new BusRequest("Select JDK", ctl);
                bus.publishRequest(thereq, "svc://general/Dependency");
            } else {
                /* user chose existing jdk, so we should not install a new one */
                ctl = new DependencyControl(DependencyControl.COMMAND.FORCE_DESELECT_ELEMENT, "jdk5");
                thereq = new BusRequest("Deselect JDK", ctl);
                bus.publishRequest(thereq, "svc://general/Dependency");
            }

            ]]></onSet>
          </actions>
        </prop>
        <prop oor:name="SELECTED_JDK" oor:type="xs:string" oor:nillable="true">
          <value/>
          <info>
            <desc xml:lang="en-US">JDK List.</desc>
          </info>
        </prop>
        <prop oor:name="SELECT_JDK_TO_INSTALL" oor:type="xs:boolean">
          <value>true</value>
          <info>
            <desc xml:lang="en-US">Denotes the presence (or absence) of embedded JDK</desc>
          </info>
        </prop>
        <prop oor:name="ONLOAD" oor:type="xs:string" oor:nillable="false">
         <value>true</value>
         <actions>
           <onSet><![CDATA[
	    /* JDKSelection.xcs */
            import java.util.List;
            import java.util.ArrayList;
            import org.openinstaller.provider.conf.ConfigHelper;
            import org.openinstaller.bus.ControlBus;
            import org.openinstaller.bus.BusRequest;
            import org.openinstaller.bus.BusResponse;
            import org.openinstaller.util.EnhancedException;
            import org.openinstaller.provider.dependency.JavaDetection;

            public java.util.List gJDKComponents = null;

            run(){
              theJava = new JavaDetection(ConfigHelper.getStringValue("JDKSelection.directory.JDK_VERSIONRANGE"));
              gJDKComponents = (List) theJava.getInstalledJDKDetails();


            }
            return (Runnable)this;]]>
           </onSet>
         </actions>
       </prop>
     </group>
 </component>
</oor:component-schema>


