Search code examples
pluginsizpack

IzPack: Require at least one of multiple packs


I've got a software that consists of different plugins that can be selected during installation in IzPack. These plugins provide different features to the software: input, processing, output. The software needs at least one input and output plugin to work. How do I specify that at least one plugin providing a certain feature is selected in the PackPanel?


Solution

  • I believe that this was implemented in izpack v5.0.0-rc5 and newer. PacksPanel does not allow you to continue if you have deselected all the options.

    enter image description here

    Based on your comment I would solve this by using conditionvalidator: Basically add condition for each of your packs:

    <condition type="packselection" id="pack1inputselected">
      <name>Pack 1 input</name>
    </condition>
    

    Then make OR conditions with groups of your packs (input, processing, output), e.g. like this:

    <condition type="or" id="inputgroup">
      <condition type="ref" refid="pack1inputselected" />
      <condition type="ref" refid="pack2inputselected" />
    </condition>
    

    Then add a final AND validation condition (id is crucial as it has to always start by conditionvalidator word! The conditionvalidator class gets to validate all the conditions starting with conditionvalidator.):

    <condition type="and" id="conditionvalidator.packsselected">
      <condition type="ref" refid="inputgroup" />
      <condition type="ref" refid="processinggroup" />
      <condition type="ref" refid="outputgroup" />
    </condition>
    

    Add conditionvalidator to PacksPanel in panels element:

    <panel classname="PacksPanel" id="panel.packs">
      <validator classname="com.izforge.izpack.installer.validator.ConditionValidator" />
    </panel>
    

    There. Everytime the condition that is validated (when clicking on next) by conditionvalidator will not be true (that is if you will not have the correct packs selected), it will throw a message and will not allow you to continue. You can change the message by adding string to CustomLangPack with .error.message (e.g. in this example conditionvalidator.packsselected.error.message).