[izpack-user] Create condition with Java

480 views
Skip to first unread message

Ricardo Cardoso

unread,
Jun 29, 2010, 12:37:17 PM6/29/10
to us...@izpack.codehaus.org
Hello
I am developing an aplication and i need in a custum action to change the value of a condition is this possible with java, if yes how?

Best Regards
Ricardo Cardoso

Dennis Reil

unread,
Jun 30, 2010, 11:15:53 AM6/30/10
to us...@izpack.codehaus.org

Could you describe your problem in more detail, e.g. by showing an example of what you want to do?

 

Regards,

   Dennis

Ricardo Cardoso

unread,
Jun 30, 2010, 12:51:03 PM6/30/10
to us...@izpack.codehaus.org
Hi,
for example my setup should check if a specified folder already exists and if so rename and add to the log that everything works okay, checking for the folder existence it is easy with an hidden panel, rename a folder it is also easy with a custom action but in that custom action before i do anything i need to know if that folder exists or not so if my hidden panel which checks for that folder could create a condition, then in my custom action could check the value of that condition and rename the folder.

Best regards, and may thanks
Ricardo Cardoso

Dennis Reil

unread,
Jul 1, 2010, 1:48:33 AM7/1/10
to us...@izpack.codehaus.org

Oh, that can be done without conditions. You simply create either an installer variable (AutomatedInstallData.setVariable(…)) or an installer attribute (AutomatedInstallData.setAttribute(..)).

You can also define a condition based on the variables value and let the custom action only execute if the condition is fulfilled.

 

Regards,

   Dennis

Ricardo Cardoso

unread,
Jul 1, 2010, 3:43:29 AM7/1/10
to us...@izpack.codehaus.org

Hello,
I solve my problem with a condition, thanks for your help.

Best regards and lots of thanks

Ricardo Cardoso

Marc DESMILLES

unread,
Jul 2, 2010, 12:38:15 AM7/2/10
to us...@izpack.codehaus.org, rfonsec...@gmail.com
Hello Ricardo,
You say you know that with your setup to test the existence of a folder to position to true or false condition.
I try to do the same thing in my installer and I can not find a solution.
Can you tell us how you doing?
Thank you in advance for your help.
Marc

2010/6/30 Ricardo Cardoso <rfonsec...@gmail.com>

Marc DESMILLES

unread,
Jul 2, 2010, 1:56:14 AM7/2/10
to us...@izpack.codehaus.org
Hi Ricardo,
You say "... It Is Easy with hidden panel ..." : OK ?
In the IzPack documentation I found the ability to program a "hidden pack" but I have not seen that one could program a "hidden panel". Is this possible? And how?
Thank you in advance for your reply.
Marc

2010/6/30 Ricardo Cardoso <rfonsec...@gmail.com>
Hi,

Ricardo Cardoso

unread,
Jul 2, 2010, 4:00:04 AM7/2/10
to us...@izpack.codehaus.org
Hello Marc,
In my installer I create an hidden panel to check for a folder existence, in order to create your hidden panel you have to create a class that extends IzPanel, create the construtor and implement the method panelActivate() in this method you put the code for the folder verficiation.
For example my hidden panel class is the following:
package com.izforge.izpack.panels;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.regex.PatternSyntaxException;

import javax.swing.JOptionPane;
import javax.swing.text.html.HTMLDocument.Iterator;

import com.izforge.izpack.installer.AutomatedInstallData;
import com.izforge.izpack.installer.InstallData;
import com.izforge.izpack.installer.InstallerFrame;
import com.izforge.izpack.installer.IzPanel;
import com.izforge.izpack.rules.Condition;
import com.izforge.izpack.rules.RulesEngine;
import com.izforge.izpack.rules.VariableCondition;
import com.izforge.izpack.util.Log;

public class HiddenVerificaDestInstExistente extends IzPanel {

    /**
     *
     */
    private static final long serialVersionUID = -958836933316524279L;
    //default constructor
    public HiddenVerificaDestInstExistente(InstallerFrame parent,
            InstallData idata) {
        super(parent, idata);
    }
    //Verification
    public void panelActivate() {
      //Folder to chek
       File fcaminhoInstalacao=new File("c:\\example_folder")
       //if that folder exists put a variable to true and create a variable condition of that variable else put the variable to false and create //and set the condtition to false
        if(fcaminhoInstalacao.exists()){
            idata.setVariable("existe", "true");
            cond.setId("i2sexiste");
            cond.setVariablename("existe");
            cond.setValue("true");
            idata.getRules().addCondition(cond);
        }
        else{
            idata.setVariable("existe", "false");
            cond.setId("i2sexiste");
            cond.setVariablename("existe");
            cond.setValue("true");
            idata.getRules().addCondition(cond);
           
        }
        parent.skipPanel();
        }
    }
Now the final part in your xml specification you need to create the following var:<variable name="existe" value="false"/>, be aware that this hidden panel won't be executed in console mode.
About that hidden pack that you talk the only thing i know is that you have an attribute in the pack tag that puts the panel invisible to the user, but if you have a treepackspanel this would result in error, because treepackspanel have the following bug:http://jira.codehaus.org/browse/IZPACK-461.

I am sorry that i couldn't help more
Best regards
Ricardo Cardoso

Bühlmann Florian

unread,
Jul 2, 2010, 4:17:03 AM7/2/10
to us...@izpack.codehaus.org

Instead of using hidden panels there would also be a way to use panel actions.

Panel actions can be called befora a panel instance is created, before a panel is presented to the user and before and after the panel data is validated.

This is much simpler than writing a hidden panel. In additon to the panel class you should also write a AutomationHelper class for your panel to avoid problems in automated installtions.

 

Regards

Florian

Marc DESMILLES

unread,
Jul 2, 2010, 6:22:32 AM7/2/10
to us...@izpack.codehaus.org
Hi Florian,
Thank you for your response and your advice. I'm going crazy not being able to program a simple solution ...
In fact, I look for simple solutions to implement, for purposes that seem simple to treat.
However, all solutions that I'm offered, require a Java programming, I can not undertake.
I recall my need : in the IzPack installer I program, I would like to condition the proposal to install some packages based on a condition which specifies whether a folder (or a file) is present in a fixed path.
Specifically, I would like the package that allows the installation of MySQL 5.1 can be selected in the "PacksPanel" only if the file "C:\Program Files\MySQL\MySQL Server 5.1" is missing on the machine currently being installation.
Is it possible to establish just such a condition ?
Thank you for your help.
Marc


2010/7/2 Bühlmann Florian <Florian....@bison-group.com>

Ricardo Cardoso

unread,
Jul 2, 2010, 7:25:46 AM7/2/10
to us...@izpack.codehaus.org
Hi Marc,
Without using a custom java program to check the existence of that file i am completely unaware of the existence of a built in condition that do that verification.

Best regards
Ricardo Cardoso
Reply all
Reply to author
Forward
0 new messages