[izpack-changes] r1996 - in izpack-src/trunk: . src src/doc-reST src/lib/com/izforge/izpack/panels src/lib/com/izforge/izpack/util

noreply at berlios.de noreply at berlios.de
Sun Jan 20 21:45:07 CET 2008


Author: jponge
Date: 2008-01-20 21:45:00 +0100 (Sun, 20 Jan 2008)
New Revision: 1996

Added:
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/TextInputField.java
Modified:
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/build.xml
   izpack-src/trunk/src/doc-reST/user-input.txt
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/PasswordGroup.java
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/ProcessingClient.java
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/RuleInputField.java
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/UserInputPanel.java
   izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java
Log:
- Text fields now can support validators (Piotr Skowronek via Julien Ponge)
- UserInputPanel: substitution support for text fields (Piotr Skowronek via Julien Ponge)


Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/Versions.txt	2008-01-20 20:45:00 UTC (rev 1996)
@@ -85,6 +85,8 @@
 - InstallationGroupPanel UI improvements (Jeff Gordon via Julien Ponge)
 - HTMLInfoPanel: open external links in a web browser on Mac OS X as well (Alexander Maslov via Julien Ponge)
 - UserInputPanel: some variables were not saved for silent installers (Piotr Skowronek via Julien Ponge)
+- Text fields now can support validators (Piotr Skowronek via Julien Ponge)
+- UserInputPanel: substitution support for text fields (Piotr Skowronek via Julien Ponge)
 
   > 3.10.2 (build 2007.05.11)
 

Modified: izpack-src/trunk/src/build.xml
===================================================================
--- izpack-src/trunk/src/build.xml	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/build.xml	2008-01-20 20:45:00 UTC (rev 1996)
@@ -644,6 +644,7 @@
             <include name="com/izforge/izpack/panels/Processor.java" />
             <include name="com/izforge/izpack/panels/RuleInputField.java" />
             <include name="com/izforge/izpack/panels/RuleTextField.java" />
+            <include name="com/izforge/izpack/panels/TextInputField.java" />
             <include name="com/izforge/izpack/panels/UserInputPanel.java" />
             <include name="com/izforge/izpack/panels/UserInputPanelAutomationHelper.java" />
             <include name="com/izforge/izpack/panels/Validator.java" />
@@ -655,6 +656,7 @@
             <include name="com/izforge/izpack/panels/Processor.java" />
             <include name="com/izforge/izpack/panels/RuleInputField.java" />
             <include name="com/izforge/izpack/panels/RuleTextField.java" />
+            <include name="com/izforge/izpack/panels/TextInputField.java" />
             <include name="com/izforge/izpack/panels/UserInputPanel.java" />
             <include name="com/izforge/izpack/panels/UserInputPanelAutomationHelper.java" />
             <include name="com/izforge/izpack/panels/Validator.java" />

Modified: izpack-src/trunk/src/doc-reST/user-input.txt
===================================================================
--- izpack-src/trunk/src/doc-reST/user-input.txt	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/doc-reST/user-input.txt	2008-01-20 20:45:00 UTC (rev 1996)
@@ -214,7 +214,27 @@
 after the packs panel for this feature to work.
 
 
+There is a possibility to use variables in those elements where the text is 
+supplied via ``txt`` attribute. This includes static fields and input fields 
+(spec, description). The text can contain unlimited number of variables that 
+will be substituted. Variable substitution also works with language packs, 
+just use variables in your language pack, and they will be still subsituted 
+properly.
 
+
+**Example**
+
+In the following example, the variables: name1, name2, name3 will be substituted.
+
+::
+
+    <field type="text" variable="value1">
+      <description align="left" txt="Configuration for $name1 and $name2" id=""/>
+      <spec txt="The value for $name3:" id="" size="20" set="default value" />
+    </field>
+
+
+
 Internationalization
 --------------------
 
@@ -327,7 +347,8 @@
 ``type`` attribute with a value of ``staticText``. In addition to the ``
 txt`` and ``id`` attributes, the text can be justified ``left``, ``center``
 or ``right`` with the ``align`` attribute. It is not possible to format this
-text in any way.
+text in any way. You can also use variables in the text (as it was mentioned
+above), they will be substituted with variable's value.
 
 
 **Example**
@@ -338,7 +359,7 @@
 ::
 
     <field type="staticText" align="left"
-           txt="This is just some simple static text."
+           txt="This is just some simple static text with variable substitution in here: $myvariable."
            id="staticText.text"/>
 
 Visual Separation
@@ -730,8 +751,8 @@
 Validating the Field Content
 --------------------------------------------
 
-You can provide runtime validation for user input into a rule field via the
-``validator`` element (which is a child of the ``field`` element. There are
+You can provide runtime validation for user input into a text field and rule field 
+via the ``validator`` element (which is a child of the ``field`` element. There are
 two types of built-in validators already provided: a ``NotEmptyValidator``
 and a ``RegularExpressionValidator``. You can also easily create your own
 validator. In all cases, if the chosen validator returns ``false``, a
@@ -773,6 +794,8 @@
 would validate an e-mail address:
 
 
+The example of using Regexp validator in rule input field:
+
 ::
 
     <field type="rule" variable="EMAILaddress">
@@ -793,11 +816,32 @@
     </field>
 
 
+The example of using Regexp validator in text input field:
+
+::
+
+    <field type="text" variable="EMAILaddress">
+      <spec
+          txt="Your Email address:" set="you at domain.com" size="20" id=""
+      />
+      <validator
+      class="com.izforge.izpack.util.RegularExpressionValidator"
+          txt="Invalid email address!">
+        <param
+            name="pattern"
+            value="[a-zA-Z0-9._-]{3,}@[a-zA-Z0-9._-]+([.][a-zA-Z0
+            -9_-]+)*[.][a-zA-Z0-9._-]{2,4}"
+        />
+      </validator>
+    </field>
+
+
 You can test your own regular expressions using the handy applet at
 http://jakarta.apache.org/regexp/applet.html.
 
 
 
+
 Creation Your Own Custom Validator
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/PasswordGroup.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/PasswordGroup.java	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/PasswordGroup.java	2008-01-20 20:45:00 UTC (rev 1996)
@@ -21,6 +21,7 @@
 
 package com.izforge.izpack.panels;
 
+import java.util.Map;
 import java.util.Vector;
 
 import javax.swing.JPasswordField;
@@ -177,11 +178,29 @@
 
             if (fields.size() > 0)
             {
-                contents = new String(((JPasswordField) fields.elementAt(0)).getPassword());
+                contents = getText();
             }
 
             return (contents);
         }
     }
+
+    // javadoc inherited
+    public String getText()
+    {
+        return new String(((JPasswordField) fields.elementAt(0)).getPassword());
+    }
+
+    // javadoc inherited
+    public Map getValidatorParams()
+    {
+        return null;
+    }
+
+    // javadoc inherited
+    public boolean hasParams()
+    {
+        return false;
+    }
 }
 /*---------------------------------------------------------------------------*/

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/ProcessingClient.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/ProcessingClient.java	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/ProcessingClient.java	2008-01-20 20:45:00 UTC (rev 1996)
@@ -21,6 +21,8 @@
 
 package com.izforge.izpack.panels;
 
+import java.util.Map;
+
 /*---------------------------------------------------------------------------*/
 /**
  * Implement this interface in any class that wants to use processing or validation services.
@@ -56,5 +58,32 @@
      */
     /*--------------------------------------------------------------------------*/
     public String getFieldContents(int index);
+
+    /*---------------------------------------------------------------------------*/
+    /**
+     * Returns the field contents.
+     * 
+     * @return the field contents
+     */
+    /*--------------------------------------------------------------------------*/
+    public String getText();
+
+    /*--------------------------------------------------------------------------*/
+    /**
+     * @return true if this instance has any parameters to pass to the Validator instance.
+     */
+    /*--------------------------------------------------------------------------*/
+    public boolean hasParams();
+
+    /*--------------------------------------------------------------------------*/
+    /**
+     * Returns the validator parameters, if any. The caller should check for the existence of
+     * validator parameters via the <code>hasParams()</code> method prior to invoking this method.
+     * 
+     * @return a java.util.Map containing the validator parameters.
+     */
+    /*--------------------------------------------------------------------------*/
+    public Map getValidatorParams();
+
 }
 /*---------------------------------------------------------------------------*/

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/RuleInputField.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/RuleInputField.java	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/RuleInputField.java	2008-01-20 20:45:00 UTC (rev 1996)
@@ -152,9 +152,8 @@
      */
     private Processor encryptionService;
 
-    /**
-     * @return true if this instance has any parameters to pass to the Validator instance.
-     */
+    /*--------------------------------------------------------------------------*/
+    // javadoc inherited
     public boolean hasParams()
     {
         return hasParams;
@@ -319,12 +318,7 @@
     }
 
     /*--------------------------------------------------------------------------*/
-    /**
-     * Returns the validator parameters, if any. The caller should check for the existence of
-     * validator parameters via the <code>hasParams()</code> method prior to invoking this method.
-     * 
-     * @return a java.util.Map containing the validator parameters.
-     */
+    // javadoc inherited
     public Map getValidatorParams()
     {
         return validatorParams;

Added: izpack-src/trunk/src/lib/com/izforge/izpack/panels/TextInputField.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/TextInputField.java	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/TextInputField.java	2008-01-20 20:45:00 UTC (rev 1996)
@@ -0,0 +1,199 @@
+/*
+ * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
+ * 
+ * http://izpack.org/
+ * http://developer.berlios.de/projects/izpack/
+ * 
+ * Copyright 2008 Piotr Skowronek
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *     
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.izforge.izpack.panels;
+
+import java.util.Map;
+
+import javax.swing.JComponent;
+import javax.swing.JTextField;
+
+import com.izforge.izpack.util.Debug;
+
+/*---------------------------------------------------------------------------*/
+/**
+ * This class is a wrapper for JTextField to allow field validation.
+ * Based on RuleInputField.
+ * 
+ * @author Piotr Skowronek
+ */
+/*---------------------------------------------------------------------------*/
+public class TextInputField extends JComponent implements ProcessingClient
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 8611515659787697087L;
+
+    /**
+     * Validator parameters.
+     */
+    private Map validatorParams;
+
+    /**
+     * Holds an instance of the <code>Validator</code> if one was specified and available
+     */
+    private Validator validationService;
+
+    /**
+     * This composite can only contain one component ie JTextField
+     */
+    private JTextField field;
+    
+    /**
+     * Do we have parameters for validator?
+     */
+    private boolean hasParams = false;
+
+    /*--------------------------------------------------------------------------*/
+    /**
+     * Constructs a text input field.
+     *
+     * @param set A default value for field.
+     * @param size The size of the field.
+     * @param validator A string that specifies a class to perform validation services. The string
+     * must completely identify the class, so that it can be instantiated. The class must implement
+     * the <code>RuleValidator</code> interface. If an attempt to instantiate this class fails, no
+     * validation will be performed.
+     * @param validatorParams validator parameters.
+     */
+    /*--------------------------------------------------------------------------*/
+    public TextInputField(String set, int size, String validator, Map validatorParams) {
+        this(set, size, validator);
+        this.validatorParams = validatorParams;
+        this.hasParams = true;
+    }
+    
+
+    /*--------------------------------------------------------------------------*/
+    /**
+     * Constructs a text input field.
+     *
+     * @param set A default value for field.
+     * @param suze The size of the field.
+     * @param validator A string that specifies a class to perform validation services. The string
+     * must completely identify the class, so that it can be instantiated. The class must implement
+     * the <code>RuleValidator</code> interface. If an attempt to instantiate this class fails, no
+     * validation will be performed.
+     */
+    /*--------------------------------------------------------------------------*/
+    public TextInputField(String set, int size, String validator)
+    {
+        // ----------------------------------------------------
+        // attempt to create an instance of the Validator
+        // ----------------------------------------------------
+        try
+        {
+            if (validator != null)
+            {
+                validationService = (Validator) Class.forName(validator).newInstance();
+            }
+        }
+        catch (Throwable exception)
+        {
+            validationService = null;            
+            Debug.trace(exception);
+        }
+        
+        com.izforge.izpack.gui.FlowLayout layout = new com.izforge.izpack.gui.FlowLayout();
+        layout.setAlignment(com.izforge.izpack.gui.FlowLayout.LEFT);
+        setLayout(layout);
+        
+        // ----------------------------------------------------
+        // construct the UI element and add it to the composite
+        // ----------------------------------------------------
+        field = new JTextField(set, size);
+        field.setCaretPosition(0);
+        add(field);
+    }
+
+
+    /*--------------------------------------------------------------------------*/
+    /**
+     * Returns the validator parameters, if any. The caller should check for the existence of
+     * validator parameters via the <code>hasParams()</code> method prior to invoking this method.
+     * 
+     * @return a java.util.Map containing the validator parameters.
+     */
+    public Map getValidatorParams()
+    {
+        return validatorParams;
+    }
+
+    /*---------------------------------------------------------------------------*/
+    /**
+     * Returns the field contents, assembled acording to the encryption and separator rules.
+     * 
+     * @return the field contents
+     */
+    /*--------------------------------------------------------------------------*/
+    public String getText()
+    {
+        return (field.getText());
+    }
+
+    // javadoc inherited
+    public void setText(String value)
+    {
+        field.setText(value);
+    }
+
+    // javadoc inherited
+    public String getFieldContents(int index) {
+        return field.getText();
+    }
+
+    // javadoc inherited
+    public int getNumFields() {
+        // We've got only one field
+        return 1;
+    }
+
+    /*--------------------------------------------------------------------------*/
+    /**
+     * This method validates the field content. Validating is performed through a user supplied
+     * service class that provides the validation rules.
+     * 
+     * @return <code>true</code> if the validation passes or no implementation of a validation
+     * rule exists. Otherwise <code>false</code> is returned.
+     */
+    /*--------------------------------------------------------------------------*/
+    public boolean validateContents()
+    {
+        if (validationService != null)
+        {
+            return (validationService.validate(this));
+        }
+        else
+        {
+            return (true);
+        }
+    }
+
+    // javadoc inherited
+    public boolean hasParams() {
+        return hasParams;
+    }
+    
+    // ----------------------------------------------------------------------------
+}
+/*---------------------------------------------------------------------------*/

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/UserInputPanel.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/UserInputPanel.java	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/UserInputPanel.java	2008-01-20 20:45:00 UTC (rev 1996)
@@ -780,9 +780,8 @@
             else if (TEXT_FIELD.equals(element[POS_TYPE]))
             {
                 // update TextField
-                JTextField textf = (JTextField) element[POS_FIELD];
+                TextInputField textf = (TextInputField) element[POS_FIELD];
 
-                // System.out.println("Textfield: " + value);
                 if (value == null)
                 {
                     value = textf.getText();
@@ -1419,11 +1418,13 @@
     {
         RuleInputField ruleField = null;
         String variable = null;
+	String message = null;
 
         try
         {
             ruleField = (RuleInputField) field[POS_FIELD];
             variable = (String) field[POS_VARIABLE];
+            message = (String) field[POS_MESSAGE]; 
         }
         catch (Throwable exception)
         {
@@ -1431,24 +1432,11 @@
         }
         if ((variable == null) || (ruleField == null)) { return (true); }
 
+
         boolean success = !validating || ruleField.validateContents();
         if (!success)
         {
-            String message = "";
-            try
-            {
-                message = langpack.getString((String) field[POS_MESSAGE]);
-                if ("".equals(message))
-                {
-                    message = (String) field[POS_MESSAGE];
-                }
-            }
-            catch (Throwable t)
-            {
-                message = (String) field[POS_MESSAGE];
-            }
-            JOptionPane.showMessageDialog(parentFrame, message, parentFrame.langpack
-                    .getString("UserInputPanel.error.caption"), JOptionPane.WARNING_MESSAGE);
+            showWarningMessageDialog(parentFrame, message);
             return (false);
         }
 
@@ -1472,7 +1460,14 @@
         JLabel label;
         String set;
         int size;
+        HashMap validateParamMap = null;
+        Vector validateParams = null;
+        String validator = null;
+        String message = null;
+        boolean hasParams = false;
+        TextInputField inputField;
 
+
         String variable = spec.getAttribute(VARIABLE);
         if ((variable == null) || (variable.length() == 0)) { return; }
 
@@ -1519,6 +1514,37 @@
         }
 
         // ----------------------------------------------------
+        // get the validator if was defined
+        // ----------------------------------------------------
+        element = spec.getFirstChildNamed(VALIDATOR);
+        if (element != null)
+        {
+            validator = element.getAttribute(CLASS);
+            message = getText(element);
+            // ----------------------------------------------------------
+            // check and see if we have any parameters for this validator.
+            // If so, then add them to validateParamMap.
+            // ----------------------------------------------------------
+            validateParams = element.getChildrenNamed(RULE_PARAM);
+            if (validateParams != null && validateParams.size() > 0)
+            {
+                hasParams = true;
+
+                if (validateParamMap == null) validateParamMap = new HashMap();
+
+                for (Iterator it = validateParams.iterator(); it.hasNext();)
+                {
+                    element = (XMLElement) it.next();
+                    String paramName = element.getAttribute(RULE_PARAM_NAME);
+                    String paramValue = element.getAttribute(RULE_PARAM_VALUE);
+                    validateParamMap.put(paramName, paramValue);
+                }
+
+            }
+
+        }
+
+        // ----------------------------------------------------
         // get the description and add it to the list UI
         // elements if it exists.
         // ----------------------------------------------------
@@ -1528,9 +1554,15 @@
         // ----------------------------------------------------
         // construct the UI element and add it to the list
         // ----------------------------------------------------
-        JTextField field = new JTextField(set, size);
-        field.setCaretPosition(0);
+        if (hasParams)
+        {
+            inputField = new TextInputField(set, size, validator, validateParamMap);
+        } else 
+        {
+            inputField = new TextInputField(set, size, validator);
+        }
 
+
         TwoColumnConstraints constraints = new TwoColumnConstraints();
         constraints.position = TwoColumnConstraints.WEST;
 
@@ -1540,8 +1572,8 @@
         TwoColumnConstraints constraints2 = new TwoColumnConstraints();
         constraints2.position = TwoColumnConstraints.EAST;
 
-        uiElements.add(new Object[] { null, TEXT_FIELD, variable, constraints2, field, forPacks,
-                forOs});
+        uiElements.add(new Object[] { null, TEXT_FIELD, variable, constraints2, inputField, forPacks,
+                forOs, null, null, message});
     }
 
     /*--------------------------------------------------------------------------*/
@@ -1557,14 +1589,16 @@
     /*--------------------------------------------------------------------------*/
     private boolean readTextField(Object[] field)
     {
-        JTextField textField = null;
+        TextInputField textField = null;
         String variable = null;
         String value = null;
+	String message = null;
 
         try
         {
-            textField = (JTextField) field[POS_FIELD];
+            textField = (TextInputField) field[POS_FIELD];
             variable = (String) field[POS_VARIABLE];
+            message = (String) field[POS_MESSAGE]; 
             value = textField.getText();
         }
         catch (Throwable exception)
@@ -1573,6 +1607,14 @@
         }
         if ((variable == null) || (value == null)) { return (true); }
 
+        // validate the input
+        boolean success = textField.validateContents();
+        if (!success)
+        {
+            showWarningMessageDialog(parentFrame, message);
+            return (false);
+        }
+
         idata.setVariable(variable, value);
         entries.add(new TextValuePair(variable, value));
         return (true);
@@ -2065,11 +2107,9 @@
         passwordGroups.add(group);
 
         boolean success = !validating || group.validateContents();
-
         if (!success)
         {
-            JOptionPane.showMessageDialog(parentFrame, message, parentFrame.langpack
-                    .getString("UserInputPanel.error.caption"), JOptionPane.WARNING_MESSAGE);
+            showWarningMessageDialog(parentFrame, message);
             return (false);
         }
 
@@ -2543,6 +2583,7 @@
             if (description != null)
             {
                 String alignment = spec.getAttribute(ALIGNMENT);
+                // FIX needed: where do we use this variable at all? i dont think so... 
                 int justify = MultiLineLabel.LEFT;
 
                 if (alignment != null)
@@ -2725,8 +2766,11 @@
         {
             text = element.getAttribute(TEXT);
         }
+        
+        // try to parse the text, and substitute any variable it finds
+        VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
 
-        return (text);
+        return (vs.substitute(text, null));
     }
 
     /*--------------------------------------------------------------------------*/
@@ -3268,7 +3312,7 @@
 
         /*--------------------------------------------------------------------------*/
         /**
-         * This is called if one of the buttons has bee pressed.
+         * This is called if one of the buttons has been pressed.
          * 
          * It checks, which button caused the action and acts accordingly.
          */
@@ -3280,10 +3324,8 @@
             if (event.getSource() == this.autodetectButton)
             {
                 if (!autodetect())
-                    JOptionPane.showMessageDialog(parent, parent.langpack
-                            .getString("UserInputPanel.search.autodetect.failed.message"),
-                            parent.langpack
-                                    .getString("UserInputPanel.search.autodetect.failed.caption"),
+                    showMessageDialog(parent, "UserInputPanel.search.autodetect.failed.message", 
+                            "UserInputPanel.search.autodetect.failed.caption", 
                             JOptionPane.WARNING_MESSAGE);
             }
             else if (event.getSource() == this.browseButton)
@@ -3304,11 +3346,10 @@
                     // use any given directory directly
                     if (this.resultType != TYPE_FILE && !this.pathMatches(f.getAbsolutePath()))
                     {
-                        JOptionPane.showMessageDialog(parent, parent.langpack
-                                .getString("UserInputPanel.search.wrongselection.message"),
-                                parent.langpack
-                                        .getString("UserInputPanel.search.wrongselection.caption"),
+                        showMessageDialog(parent, "UserInputPanel.search.wrongselection.message", 
+                                "UserInputPanel.search.wrongselection.caption", 
                                 JOptionPane.WARNING_MESSAGE);
+
                     }
                 }
 
@@ -3436,7 +3477,41 @@
        validating = true;
    }
 
+    /*--------------------------------------------------------------------------*/
+    /**
+     * Show localized message dialog basing on given parameters.
+     * 
+     * @param parentFrame The parent frame.
+     * @param message The message to print out in dialog box.
+     * @param caption The caption of dialog box.
+     * @param messageType The message type (JOptionPane.*_MESSAGE)
+     */
+    /*--------------------------------------------------------------------------*/
+    private void showMessageDialog(InstallerFrame parentFrame, String message, String caption, int messageType) {
+        String localizedMessage = langpack.getString(message);
+        if ("".equals(localizedMessage))
+        {
+            localizedMessage = message;
+        }
+        JOptionPane.showMessageDialog(parentFrame, localizedMessage, caption, messageType);
+    }
+
+    /*--------------------------------------------------------------------------*/
+    /**
+     * Show localized warning message dialog basing on given parameters.
+     * 
+     * @param parentFrame parent frame.
+     * @param message the message to print out in dialog box.
+     */
+    /*--------------------------------------------------------------------------*/
+    private void showWarningMessageDialog(InstallerFrame parentFrame, String message) {
+        showMessageDialog(parentFrame, message, 
+                parentFrame.langpack.getString("UserInputPanel.error.caption"), 
+                JOptionPane.WARNING_MESSAGE);    
+    }
+
 } // public class UserInputPanel
+
 /*---------------------------------------------------------------------------*/
 class UserInputFileFilter extends FileFilter{
     String fileext = "";

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java	2008-01-20 20:39:51 UTC (rev 1995)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/util/RegularExpressionValidator.java	2008-01-20 20:45:00 UTC (rev 1996)
@@ -23,7 +23,6 @@
 import java.util.regex.Pattern;
 
 import com.izforge.izpack.panels.ProcessingClient;
-import com.izforge.izpack.panels.RuleInputField;
 import com.izforge.izpack.panels.Validator;
 
 /**
@@ -46,12 +45,10 @@
 
         String patternString;
 
-        RuleInputField field = (RuleInputField) client;
-        if (field.hasParams())
+        if (client.hasParams())
         {
-            Map paramMap = field.getValidatorParams();
+            Map paramMap = client.getValidatorParams();
             patternString = (String) paramMap.get(PATTERN_PARAM);
-
         }
         else
         {
@@ -59,7 +56,7 @@
         }
 
         Pattern pattern = Pattern.compile(patternString);
-        return pattern.matcher(((RuleInputField) client).getText()).matches();
+        return pattern.matcher(client.getText()).matches();
     }
 
 }



More information about the izpack-changes mailing list