[izpack-users] Setting Built-In Variable

dinh thi thu thao thuthao_d at yahoo.com
Wed Oct 18 12:22:28 CEST 2006


Thanks Klaus for your support.

----- Original Message ----
From: "Bartz, Klaus" <Klaus.Bartz at coi.de>
To: izpack-users at lists.berlios.de
Sent: Wednesday, October 18, 2006 3:42:54 PM
Subject: Re: [izpack-users] Setting Built-In Variable

Hi Thao,
I thought a little bit about your problem, but the only resolution
I have seen is to create a custom panel.
Following my custom panel to ask for the BEA path.
In my properties file I do not use $FILE_SEPARATOR because it is
something like readonly, else I use a custom variable named
EJBProperties.ServerHomeDir. In method isValidated you can see
how to make the separators we need. There are two variables,
one with UNIX, one with DOS separator.
For creating a custom panel see the docu you have installed (I hope).
There are also some threads in the izpack-users list, e.g. 
https://lists.berlios.de/pipermail/izpack-users/2006-October/002697.html
https://lists.berlios.de/pipermail/izpack-users/2006-October/002729.html
Some threads are broken on the mail archive, therefore search with
"subject" sorting.

Cheers

Klaus

-----------------------------------------------------------------------------
package com.coi.tools.install.panels;

import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;

import javax.swing.JCheckBox;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import com.izforge.izpack.installer.InstallData;
import com.izforge.izpack.installer.InstallerFrame;
import com.izforge.izpack.panels.PathInputPanel;
import com.izforge.izpack.util.IoHelper;

/**
 * Panel which asks for the path of BEA and whether extended configuration should be performed or
 * not. Additional the host of the EJB will be verified.
 * 
 * @author Klaus Bartz
 */
public class BEAPathPanel extends PathInputPanel
{

    private static final String[] testFiles = new String[] { "server" + File.separator + "lib"
            + File.separator + "weblogic.jar"};

    /** The text field for the host name. */
    protected JTextField hostName;

    /** The 'extended button. */
    protected JCheckBox extendedCheckBox;

    /**
     * The constructor.
     * 
     * @param parent The parent window.
     * @param idata The installation data.
     */
    public BEAPathPanel(InstallerFrame parent, InstallData idata)
    {
        super(parent, idata);
        setMustExist(true);
        setExistFiles(BEAPathPanel.testFiles);

    }

    /**
     * This method will be called from ctor of PathInputPanel, after standard components are
     * defined.
     */
    public void createLayoutBottom()
    {
        hostName = CustomPanel.createHostNameFieldIfNeeded(this);
        extendedCheckBox = new JCheckBox(parent.langpack.getString("customCommon.extended"), false);
        extendedCheckBox.setBorder( new EmptyBorder( 0,0,0,0 ) );
        add(extendedCheckBox, NEXT_LINE);
    }

    /**
     * Indicates wether the panel has been validated or not.
     * 
     * @return Wether the panel has been validated or not.
     */
    public boolean isValidated()
    {
        if(idata.getVariable("PANEL_LAYOUT_TEST") != null)
            return(true);
        if (!super.isValidated()) return (false);
        String chosenPath = pathSelectionPanel.getPath();
        if (chosenPath == null || chosenPath.length() < 1) return (false);
        String hostNameStr = null;
        try
        {
            hostNameStr = (hostName != null) ? hostName.getText() : idata.getVariable("LocalHost");
            InetAddress.getByName(hostNameStr);
        }
        catch (UnknownHostException e)
        {
            emitError(parent.langpack.getString("installer.error"), parent.langpack
                    .getString("SelectEJBTypePanel.invalidHost"));
            return (false);
        }
        idata.setVariable("EJBProperties.EJB_Host", hostNameStr);

        idata.setVariable("EJBPath", chosenPath);
        idata.setVariable("BEAExtendedConfig", extendedCheckBox.isSelected() ? "yes" : "no");
        String path = chosenPath;
        path = IoHelper.replaceString(path, "\\", "/");
        idata.setVariable("EJBProperties.ServerHomeDir", path);
        path = IoHelper.replaceString(path, "/", "\\");
        idata.setVariable("ServerHomeDirDOS", path);
        path = IoHelper.replaceString(path, "\\", "\\\\");
        idata.setVariable("EJBProperties.ServerHomeDirDOS", path);

        return (true);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.izforge.izpack.installer.IzPanel#panelActivate()
     */
    public void panelActivate()
    {
        super.panelActivate();
        if (!SelectEJBTypePanel.isTypeChoosen(idata, SelectEJBTypePanel.BEA)
                && idata.getVariable("PANEL_LAYOUT_TEST") == null)
            parent.skipPanel();
        else
        {
            String defaultPath = IoHelper.getenv("WLS_HOME");
            if (defaultPath == null) defaultPath = "";
            if (idata.getVariable("EJBPath") != null)
                pathSelectionPanel.setPath(idata.getVariable("EJBPath"));
            else
                pathSelectionPanel.setPath(defaultPath);
            if (hostName != null)
            {
                if (idata.getVariable("EJBProperties.EJB_Host") != null)
                    hostName.setText(idata.getVariable("EJBProperties.EJB_Host"));
                else
                    hostName.setText(idata.getVariable("LocalHost"));
            }
        }
    }

}

----------------------------------------------------------------------


>-----Original Message-----
>From: izpack-users-bounces at lists.berlios.de
>[mailto:izpack-users-bounces at lists.berlios.de]On Behalf Of thach thao
>Sent: Wednesday, October 18, 2006 6:29 AM
>To: izpack-users at lists.berlios.de
>Subject: [izpack-users] Setting Built-In Variable
>
>
>
>Hi all,
>
>I set the value for $FILE_SEPARATOR but it same does not work :-(.
>
>I have a variable named $tomcat_home, during installing, this 
>variable will
>receive the real-value of tomcat home of user machine.
>
>In window, the value will be as the same "c:\Program Files\Apache
>Group\Tomcat 4.1\" and i want to change it to "c:/Program Files/Apache
>Group/Tomcat 4.1/" before installer use it for parsering in files.
>
>How I can do it?
>
>I attach the installation.xml file and a example files need to parse.
>
>Thanks so much for your support.
>Thach Thao.
>
>http://www.nabble.com/file/3730/Installation.xml Installation.xml 
>http://www.nabble.com/file/3731/log4j.properties%20%28Using%20f
or%20Package%29
log4j.properties (Using for Package) 
http://www.nabble.com/file/3732/log4j.properties%28After%20installed%29
log4j.properties(After installed) 

-- 
View this message in context: http://www.nabble.com/-izpack-users--Setting-Built-In-Variable-tf2464102.html#a6869262
Sent from the izpack users mailing list archive at Nabble.com.

_______________________________________________
izpack-users mailing list
izpack-users at lists.berlios.de
https://lists.berlios.de/mailman/listinfo/izpack-users
_______________________________________________
izpack-users mailing list
izpack-users at lists.berlios.de
https://lists.berlios.de/mailman/listinfo/izpack-users






-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/izpack-users/attachments/20061018/c5cb4146/attachment.html 


More information about the izpack-users mailing list