cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [92/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/LengthValidationRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/LengthValidationRuleBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/LengthValidationRuleBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/LengthValidationRuleBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/LengthValidationRuleBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.datatype.ValidationRule;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.outerj.expression.Expression;
+import org.w3c.dom.Element;
+
+/**
+ * Builds {@link LengthValidationRule}s.
+ * 
+ * @version $Id: LengthValidationRuleBuilder.java 56582 2004-11-04 10:16:22Z sylvain $
+ */
+public class LengthValidationRuleBuilder extends AbstractValidationRuleBuilder {
+    public ValidationRule build(Element validationRuleElement) throws Exception {
+        LengthValidationRule rule = new LengthValidationRule();
+
+        String exactExprString = validationRuleElement.getAttribute("exact");
+        String minExprString = validationRuleElement.getAttribute("min");
+        String maxExprString = validationRuleElement.getAttribute("max");
+
+        if (exactExprString.length() > 0) {
+            Expression expression = parseExpression(exactExprString, validationRuleElement, "exact");
+            rule.setExactExpr(expression);
+        } else if (minExprString.length() > 0 && maxExprString.length() > 0) {
+            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
+            rule.setMinExpr(expression);
+            expression = parseExpression(maxExprString, validationRuleElement, "max");
+            rule.setMaxExpr(expression);
+        } else if (minExprString.length() > 0) {
+            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
+            rule.setMinExpr(expression);
+        } else if (maxExprString.length() > 0) {
+            Expression expression = parseExpression(maxExprString, validationRuleElement, "max");
+            rule.setMaxExpr(expression);
+        } else {
+            throw new Exception("length validation rule requires a min and/or max, or exact attribute at " + DomHelper.getLocation(validationRuleElement));
+        }
+
+        buildFailMessage(validationRuleElement, rule);
+
+        return rule;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/LengthValidationRuleBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRule.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRule.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRule.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRule.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.util.I18nMessage;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.outerj.expression.ExpressionContext;
+
+/**
+ * Performs the so called "mod 10" algorithm to check the validity of credit card numbers
+ * such as VISA.
+ *
+ * <p>In addition to this, the credit card number can be further validated by its length
+ * and prefix, but those properties are depended on the credit card type and such validation
+ * is not performed by this validation rule.
+ * 
+ * @version $Id: Mod10ValidationRule.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class Mod10ValidationRule extends AbstractValidationRule {
+    public ValidationError validate(Object value, ExpressionContext expressionContext) {
+        String numberToCheck = (String)value;
+        int nulOffset = '0';
+        int sum = 0;
+        for (int i = 1; i <= numberToCheck.length(); i++) {
+            int currentDigit = numberToCheck.charAt(numberToCheck.length() - i) - nulOffset;
+            if ((i % 2) == 0) {
+                currentDigit *= 2;
+                currentDigit = currentDigit > 9 ? currentDigit - 9 : currentDigit;
+                sum += currentDigit;
+            } else {
+                sum += currentDigit;
+            }
+        }
+        if(!((sum % 10) == 0))
+            return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.mod10", FormsConstants.I18N_CATALOGUE));
+        else
+            return null;
+    }
+
+    public boolean supportsType(Class clazz, boolean arrayType) {
+        return String.class.isAssignableFrom(clazz) && !arrayType;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRuleBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRuleBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRuleBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRuleBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.datatype.ValidationRule;
+import org.w3c.dom.Element;
+
+/**
+ * Builds {@link Mod10ValidationRule}s.
+ * 
+ * @version $Id: Mod10ValidationRuleBuilder.java 56582 2004-11-04 10:16:22Z sylvain $
+ */
+public class Mod10ValidationRuleBuilder extends AbstractValidationRuleBuilder {
+    public ValidationRule build(Element validationRuleElement) throws Exception {
+        Mod10ValidationRule rule = new Mod10ValidationRule();
+        buildFailMessage(validationRuleElement, rule);
+        return rule;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/Mod10ValidationRuleBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRule.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRule.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRule.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRule.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,124 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import java.math.BigDecimal;
+
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.formmodel.CannotYetResolveWarning;
+import org.apache.cocoon.forms.util.I18nMessage;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.outerj.expression.Expression;
+import org.outerj.expression.ExpressionContext;
+
+/**
+ * Checks numeric ranges.
+ * Works for Integer, Long, BigDecimal, Float, Double, and Date values.
+ * Numbers are converted to the BigDecimal before comparing.
+ *
+ * <p>This validation rule can perform 3 different checks:
+ * <ul>
+ *  <li>check minimum value
+ *  <li>check maximum value
+ *  <li>check min and max values (range check)
+ * </ul>
+ * 
+ * @version $Id: RangeValidationRule.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class RangeValidationRule extends AbstractValidationRule {
+    private Expression minExpr;
+	private Expression maxExpr;
+    
+    private static final String RANGE_ELEM = "range";
+    private static final String MIN_ATTR = "min";
+    private static final String MAX_ATTR = "max";
+    
+
+    public void setMinExpr(Expression minExpr) {
+        this.minExpr = minExpr;
+    }
+
+    public void setMaxExpr(Expression maxExpr) {
+        this.maxExpr = maxExpr;
+    }
+
+    public ValidationError validate(Object value, ExpressionContext expressionContext) {
+        // HACK: JDK's Comparable can't even compare Decimal to Integer
+        Comparable decimal;
+        if (value instanceof Integer) {
+            decimal = new BigDecimal(((Integer) value).intValue());
+        } else if (value instanceof Long) {
+            decimal = new BigDecimal(((Long) value).longValue()); 
+        } else if (value instanceof Float) {
+            decimal = new BigDecimal(((Float) value).floatValue()); 
+        } else if (value instanceof Double) {
+            decimal = new BigDecimal(((Double) value).doubleValue()); 
+        } else {
+            decimal = (Comparable) value;
+        }
+
+        Comparable min = null; 
+        if (minExpr != null) {
+            Object result = evaluateComparable(minExpr, expressionContext, MIN_ATTR, RANGE_ELEM);
+            if (result instanceof ValidationError) {
+                return (ValidationError) result;
+            } else if (result instanceof CannotYetResolveWarning) {
+                return null;
+            }
+            min = (Comparable) result;
+        }
+        
+        Comparable max = null;
+        if (maxExpr != null) {
+            Object result = evaluateComparable(maxExpr, expressionContext, MAX_ATTR, RANGE_ELEM);
+            if (result instanceof ValidationError) {
+                return (ValidationError) result;
+            } else if (result instanceof CannotYetResolveWarning) {
+                return null;
+            }
+            max = (Comparable) result;
+        }
+        
+        if (min != null && max != null) {
+            if (decimal.compareTo(min) < 0 || decimal.compareTo(max) > 0) {
+                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.numeric.range",
+                                                                                 new String[]{min.toString(), max.toString()},
+                                                                                 FormsConstants.I18N_CATALOGUE));
+            }
+
+            return null;
+        } else if (min != null) {
+            if (decimal.compareTo(min) < 0) {
+                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.numeric.min",
+                                                                                 new String[]{min.toString()},
+                                                                                 FormsConstants.I18N_CATALOGUE));
+            }
+            return null;
+        } else if (max != null) {
+            if (decimal.compareTo(max) > 0) {
+                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.numeric.max",
+                                                                                 new String[]{max.toString()},
+                                                                                 FormsConstants.I18N_CATALOGUE));
+            }
+            return null;
+        }
+        return null;
+    }
+
+    public boolean supportsType(Class clazz, boolean arrayType) {
+        return Comparable.class.isAssignableFrom(clazz) && !arrayType;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRuleBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRuleBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRuleBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRuleBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.datatype.ValidationRule;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.w3c.dom.Element;
+import org.outerj.expression.Expression;
+
+/**
+ * Builds {@link RangeValidationRule}s.
+ * 
+ * @version $Id: RangeValidationRuleBuilder.java 56582 2004-11-04 10:16:22Z sylvain $
+ */
+public class RangeValidationRuleBuilder extends AbstractValidationRuleBuilder {
+    public ValidationRule build(Element validationRuleElement) throws Exception {
+        RangeValidationRule rule = new RangeValidationRule();
+
+        String minExprString = validationRuleElement.getAttribute("min");
+        String maxExprString = validationRuleElement.getAttribute("max");
+
+        if (minExprString.length() > 0 && maxExprString.length() > 0) {
+            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
+            rule.setMinExpr(expression);
+            expression = parseExpression(maxExprString, validationRuleElement, "max");
+            rule.setMaxExpr(expression);
+        } else if (minExprString.length() > 0) {
+            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
+            rule.setMinExpr(expression);
+        } else if (maxExprString.length() > 0) {
+            Expression expression = parseExpression(maxExprString, validationRuleElement, "max");
+            rule.setMaxExpr(expression);
+        } else {
+            throw new Exception("range validation rule requires a min and/or max attribute at " + DomHelper.getLocation(validationRuleElement));
+        }
+
+        buildFailMessage(validationRuleElement, rule);
+
+        return rule;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RangeValidationRuleBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRule.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRule.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRule.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRule.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.util.I18nMessage;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternMatcher;
+import org.apache.oro.text.regex.Perl5Matcher;
+import org.outerj.expression.ExpressionContext;
+
+
+/**
+ * Checks that a String matches a regular expression.
+ *
+ * <p>The <a href="http://jakarta.apache.org/oro/">Jakarta ORO</a> library
+ * is used as regexp engine.
+ * 
+ * @version $Id: RegExpValidationRule.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class RegExpValidationRule extends AbstractValidationRule {
+	/** Compiled regular expression. */
+	private Pattern pattern;
+    /** Original string representation of the regexp, used for informational purposes only. */
+    private String regexp;
+
+    public ValidationError validate(Object value, ExpressionContext expressionContext) {
+    	String string = (String)value;
+    	
+    	if(matchesRegExp(string))
+	     	return null;   
+	    else
+	    	return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.regexp", new String[] {regexp}, FormsConstants.I18N_CATALOGUE));
+    }
+    
+    private boolean matchesRegExp(String string) {
+        PatternMatcher matcher = new Perl5Matcher();
+        return matcher.matches(string, pattern);
+    }
+    
+    void setPattern(String regexp, Pattern pattern) {
+        this.regexp = regexp;
+    	this.pattern = pattern;
+    }
+
+    
+    public boolean supportsType(Class clazz, boolean arrayType) {
+        return clazz.isAssignableFrom(String.class) && !arrayType;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRuleBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRuleBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRuleBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRuleBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.datatype.ValidationRule;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.w3c.dom.Element;
+
+/**
+ * Builds {@link RegExpValidationRule}s.
+ * 
+ * @version $Id: RegExpValidationRuleBuilder.java 56582 2004-11-04 10:16:22Z sylvain $
+ */
+public class RegExpValidationRuleBuilder extends AbstractValidationRuleBuilder {
+
+    public ValidationRule build(Element validationRuleElement) throws Exception {
+        RegExpValidationRule rule = new RegExpValidationRule();
+
+        String regexp = DomHelper.getAttribute(validationRuleElement, "pattern");
+        buildFailMessage(validationRuleElement, rule);
+
+        Perl5Compiler compiler = new Perl5Compiler();
+        Pattern pattern = null;
+        try {
+            pattern = compiler.compile(regexp, Perl5Compiler.READ_ONLY_MASK);
+        } catch (MalformedPatternException e) {
+            throw new Exception("Invalid regular expression at " + DomHelper.getLocation(validationRuleElement) + ": " + e.getMessage());
+        }
+        rule.setPattern(regexp, pattern);
+
+        buildFailMessage(validationRuleElement, rule);
+
+        return rule;
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/RegExpValidationRuleBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRule.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRule.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRule.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRule.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,126 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.formmodel.CannotYetResolveWarning;
+import org.apache.cocoon.forms.util.I18nMessage;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.outerj.expression.ExpressionContext;
+import org.outerj.expression.Expression;
+
+import java.math.BigDecimal;
+
+/**
+ * Checks the number of values (i.e. the size of the array). This only works for Datatypes
+ * for which {@link org.apache.cocoon.forms.datatype.Datatype#isArrayType()} returns
+ * true.
+ *
+ * <p>This validation rule can perform 4 different checks:
+ * <ul>
+ *  <li>check exact array size
+ *  <li>check minimum array size
+ *  <li>check maximum array size
+ *  <li>check min and max array size
+ * </ul>
+ * 
+ * @version $Id: ValueCountValidationRule.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class ValueCountValidationRule extends AbstractValidationRule {
+    private Expression exactExpr;
+    private Expression minExpr;
+    private Expression maxExpr;
+
+    public void setExactExpr(Expression exactExpr) {
+        this.exactExpr = exactExpr;
+    }
+
+    public void setMinExpr(Expression minExpr) {
+        this.minExpr = minExpr;
+    }
+
+    public void setMaxExpr(Expression maxExpr) {
+        this.maxExpr = maxExpr;
+    }
+
+    public ValidationError validate(Object value, ExpressionContext expressionContext) {
+        Object[] array = (Object[])value;
+
+        if (exactExpr != null) {
+            Object result = evaluateNumeric(exactExpr, expressionContext, "exact", "value-count");
+            if (result instanceof ValidationError) {
+                return (ValidationError)result;
+            } else if (result instanceof CannotYetResolveWarning) {
+                return null;
+            }
+            int length = ((BigDecimal)result).intValue();
+            if (array.length != length) {
+                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.exact-valuecount", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
+            }
+            return null;
+        } else if (minExpr != null && maxExpr != null) {
+            Object result = evaluateNumeric(minExpr, expressionContext, "min", "value-count");
+            if (result instanceof ValidationError) {
+                return (ValidationError)result;
+            } else if (result instanceof CannotYetResolveWarning) {
+                return null;
+            }
+            int minLength = ((BigDecimal)result).intValue();
+
+            result = evaluateNumeric(maxExpr, expressionContext, "max", "value-count");
+            if (result instanceof ValidationError) {
+                return (ValidationError)result;
+            } else if (result instanceof CannotYetResolveWarning) {
+                return null;
+            }
+            int maxLength = ((BigDecimal)result).intValue();
+
+            if (array.length < minLength || array.length > maxLength) {
+                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.range-valuecount", new String[] {String.valueOf(minLength), String.valueOf(maxLength)}, FormsConstants.I18N_CATALOGUE));
+            }
+            return null;
+        } else if (minExpr != null) {
+            Object result = evaluateNumeric(minExpr, expressionContext, "min", "value-count");
+            if (result instanceof ValidationError) {
+                return (ValidationError)result;
+            } else if (result instanceof CannotYetResolveWarning) {
+                return null;
+            }
+            int length = ((BigDecimal)result).intValue();
+            if (array.length < length) {
+                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.min-valuecount", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
+            }
+            return null;
+        } else if (maxExpr != null) {
+            Object result = evaluateNumeric(maxExpr, expressionContext, "max", "value-count");
+            if (result instanceof ValidationError) {
+                return (ValidationError)result;
+            } else if (result instanceof CannotYetResolveWarning) {
+                return null;
+            }
+            int length = ((BigDecimal)result).intValue();
+            if (array.length > length) {
+                return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.array.max-valuecount", new String[] {String.valueOf(length)}, FormsConstants.I18N_CATALOGUE));
+            }
+            return null;
+        }
+        return null;
+    }
+
+    public boolean supportsType(Class clazz, boolean arrayType) {
+        return arrayType;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRuleBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRuleBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRuleBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRuleBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.datatype.validationruleimpl;
+
+import org.apache.cocoon.forms.datatype.ValidationRule;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.w3c.dom.Element;
+import org.outerj.expression.Expression;
+
+/**
+ * Builds {@link ValueCountValidationRule}s.
+ * 
+ * @version $Id: ValueCountValidationRuleBuilder.java 56582 2004-11-04 10:16:22Z sylvain $
+ */
+public class ValueCountValidationRuleBuilder extends AbstractValidationRuleBuilder {
+    public ValidationRule build(Element validationRuleElement) throws Exception {
+        ValueCountValidationRule rule = new ValueCountValidationRule();
+
+        String exactExprString = validationRuleElement.getAttribute("exact");
+        String minExprString = validationRuleElement.getAttribute("min");
+        String maxExprString = validationRuleElement.getAttribute("max");
+
+        if (exactExprString.length() > 0) {
+            Expression expression = parseExpression(exactExprString, validationRuleElement, "exact");
+            rule.setExactExpr(expression);
+        } else if (minExprString.length() > 0 && maxExprString.length() > 0) {
+            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
+            rule.setMinExpr(expression);
+            expression = parseExpression(maxExprString, validationRuleElement, "max");
+            rule.setMaxExpr(expression);
+        } else if (minExprString.length() > 0) {
+            Expression expression = parseExpression(minExprString, validationRuleElement, "min");
+            rule.setMinExpr(expression);
+        } else if (maxExprString.length() > 0) {
+            Expression expression = parseExpression(maxExprString, validationRuleElement, "max");
+            rule.setMaxExpr(expression);
+        } else {
+            throw new Exception("value-count validation rule requires a min and/or max, or exact attribute at " + DomHelper.getLocation(validationRuleElement));
+        }
+
+        buildFailMessage(validationRuleElement, rule);
+
+        return rule;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/datatype/validationruleimpl/ValueCountValidationRuleBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/AbstractFormHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/AbstractFormHandler.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/AbstractFormHandler.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/AbstractFormHandler.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * Abstract implementation of {@link FormHandler}, which checks the type
+ * of the WidgetEvent and calls the more specific {@link #handleActionEvent(ActionEvent)}
+ * or {@link #handleValueChangedEvent(ValueChangedEvent)} methods.
+ * 
+ * @version $Id: AbstractFormHandler.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public abstract class AbstractFormHandler implements FormHandler {
+
+    public void handleEvent(WidgetEvent widgetEvent) {
+        if (widgetEvent instanceof ActionEvent)
+            handleActionEvent((ActionEvent)widgetEvent);
+        else if (widgetEvent instanceof ValueChangedEvent)
+            handleValueChangedEvent((ValueChangedEvent)widgetEvent);
+    }
+
+    /**
+     * Called when an ActionEvent occured.
+     */
+    public abstract void handleActionEvent(ActionEvent actionEvent);
+
+    /**
+     * Called when an ValueChangedEvent occured.
+     */
+    public abstract void handleValueChangedEvent(ValueChangedEvent valueChangedEvent);
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/AbstractFormHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import org.apache.cocoon.forms.formmodel.Widget;
+
+/**
+ * Currently this event originates from a {@link org.apache.cocoon.forms.formmodel.Action Button}
+ * widget.
+ * 
+ * @version $Id: ActionEvent.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class ActionEvent extends WidgetEvent {
+    String actionCommand;
+    
+    public ActionEvent(Widget source, String actionCommand) {
+        super(source);
+        this.actionCommand = actionCommand;
+    }
+    
+    public String getActionCommand() {
+        return this.actionCommand; 
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * Listeners for {@link ActionEvent}s
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: ActionListener.java 151179 2005-02-03 16:55:16Z tim $
+ */
+
+public interface ActionListener extends WidgetListener {
+    void actionPerformed(ActionEvent event);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListenerEnabled.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListenerEnabled.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListenerEnabled.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListenerEnabled.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * Interface to be implemented by Widgets on which ActionListeners
+ * can be registered.
+ */
+public interface ActionListenerEnabled {
+    public void addActionListener(ActionListener listener);
+
+    public void removeActionListener(ActionListener listener);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ActionListenerEnabled.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import org.apache.cocoon.forms.formmodel.Widget;
+
+/**
+ * An event raised when a widget is created, once it has been fully set up. For
+ * container widgets, this occurs after child widgets, if any, have been created.
+ * 
+ * @version $Id: CreateEvent.java 155211 2005-02-24 17:05:51Z sylvain $
+ */
+public class CreateEvent extends WidgetEvent {
+    
+    public CreateEvent(Widget source) {
+        super(source);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * Listeners for {@link CreateEvent}s
+ * 
+ * @version $Id: CreateListener.java 151179 2005-02-03 16:55:16Z tim $
+ */
+
+public interface CreateListener extends WidgetListener {
+    void widgetCreated(CreateEvent event);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/CreateListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/DeferredValueChangedEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/DeferredValueChangedEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/DeferredValueChangedEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/DeferredValueChangedEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,39 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import org.apache.cocoon.forms.formmodel.Widget;
+
+/**
+ * A {@link ValueChangedEvent} that defers getting the new value from the widget
+ * until it's actually requested.
+ * <p>
+ * This allows widget validity to be checked only if a listener actually uses the
+ * value, thus avoiding unnecessary validation warnings when a user clicks an action.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: DeferredValueChangedEvent.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class DeferredValueChangedEvent extends ValueChangedEvent {
+    
+    public DeferredValueChangedEvent(Widget source, Object oldValue) {
+        super(source, oldValue, null);
+    }
+    
+    public Object getNewValue() {
+        return getSourceWidget().getValue();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/DeferredValueChangedEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/FormHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/FormHandler.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/FormHandler.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/FormHandler.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * A FormHandler can be registered with a {@link org.apache.cocoon.forms.formmodel.Form Form},
+ * and will then receive all events fired by widgets on the form.
+ *
+ * <p>It provides an alternative way of handling events, instead of specifying the eventhandlers
+ * in the form definition.
+ *
+ * <p>It is useful when you want to write your event-handling code in Java, have all events
+ * handled by one class (which could of course again delegate to other classes), and when
+ * you want the event handler to have access to objects it would not be able to get access
+ * to if they were part of the form definition.
+ * 
+ * @version $Id: FormHandler.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public interface FormHandler {
+
+    public void handleEvent(WidgetEvent widgetEvent);
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/FormHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ImageMapEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ImageMapEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ImageMapEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ImageMapEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import org.apache.cocoon.forms.formmodel.Widget;
+import org.apache.cocoon.forms.formmodel.ImageMap;
+
+/**
+ * Currently this event originates from a {@link org.apache.cocoon.forms.formmodel.ImageMap}
+ * widget.
+ * 
+ * @author Luca Morandini 
+ */
+public class ImageMapEvent extends ActionEvent {
+
+    public ImageMapEvent(Widget source, String actionCommand) {
+        super(source, actionCommand);
+    }
+    
+    public int getX() {
+    	return ((ImageMap)(source)).getX();
+    }
+
+    public int getY() {
+    	return ((ImageMap)(source)).getY();
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ImageMapEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.enums.ValuedEnum;
+
+/**
+ * Type-safe enumeration of the various form processing phases.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: ProcessingPhase.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class ProcessingPhase extends ValuedEnum {
+
+    protected ProcessingPhase(String name, int value) {
+        super(name, value);
+    }
+    
+    public static final int LOAD_MODEL_VALUE = 0;
+    public static final ProcessingPhase LOAD_MODEL = new ProcessingPhase("Load model", LOAD_MODEL_VALUE);
+    
+    public static final int READ_FROM_REQUEST_VALUE = 1;
+    public static final ProcessingPhase READ_FROM_REQUEST = new ProcessingPhase("Read from request", READ_FROM_REQUEST_VALUE);
+    
+    public static final int VALIDATE_VALUE = 2;
+    public static final ProcessingPhase VALIDATE = new ProcessingPhase("Validate", VALIDATE_VALUE);
+    
+    public static final int SAVE_MODEL_VALUE = 3;
+    public static final ProcessingPhase SAVE_MODEL = new ProcessingPhase("Save model", SAVE_MODEL_VALUE);
+     
+    public static ProcessingPhase getEnum(String name) {
+      return (ProcessingPhase) getEnum(ProcessingPhase.class, name);
+    }
+    
+    public static ProcessingPhase getEnum(int value) {
+      return (ProcessingPhase) getEnum(ProcessingPhase.class, value);
+    }
+
+    public static Map getEnumMap() {
+      return getEnumMap(ProcessingPhase.class);
+    }
+ 
+    public static List getEnumList() {
+      return getEnumList(ProcessingPhase.class);
+    }
+ 
+    public static Iterator iterator() {
+      return iterator(ProcessingPhase.class);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,43 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import org.apache.cocoon.forms.formmodel.Form;
+
+/**
+ * Event raised when a form processing phase is finished.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: ProcessingPhaseEvent.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class ProcessingPhaseEvent extends WidgetEvent {
+    
+    private ProcessingPhase phase;
+
+    public ProcessingPhaseEvent(Form form, ProcessingPhase phase) {
+        super(form);
+        this.phase = phase;
+    }
+    
+    public Form getForm() {
+        return (Form)this.getSource();
+    }
+    
+    public ProcessingPhase getPhase() {
+        return this.phase;
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,25 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * Listener invoked when a form processing phase ends.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ */
+public interface ProcessingPhaseListener extends WidgetListener {
+    public void phaseEnded(ProcessingPhaseEvent event);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ProcessingPhaseListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,45 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import org.apache.cocoon.forms.formmodel.Widget;
+
+/**
+ * Event raised when a field value changes.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: ValueChangedEvent.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class ValueChangedEvent extends WidgetEvent {
+    
+    private Object oldValue;
+    private Object newValue;
+    
+    public ValueChangedEvent(Widget source, Object oldValue, Object newValue) {
+        super(source);
+        this.oldValue = oldValue;
+        this.newValue = newValue;
+    }
+    
+    public Object getOldValue() {
+        return this.oldValue;
+    }
+    
+    public Object getNewValue() {
+        return this.newValue;
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * Listener invoked when a field value changes.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: ValueChangedListener.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public interface ValueChangedListener extends WidgetListener {
+    
+    void valueChanged(ValueChangedEvent event);
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListenerEnabled.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListenerEnabled.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListenerEnabled.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListenerEnabled.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * 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 org.apache.cocoon.forms.event;
+
+/**
+ * Interface to be implemented by Widgets on which ValueChangedListeners
+ * can be registered.
+ */
+public interface ValueChangedListenerEnabled {
+    public void addValueChangedListener(ValueChangedListener listener);
+
+    public void removeValueChangedListener(ValueChangedListener listener);
+    
+    public boolean hasValueChangedListeners();
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/ValueChangedListenerEnabled.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import java.util.EventObject;
+
+import org.apache.cocoon.forms.formmodel.Widget;
+
+/**
+ * Base class for events sent by form widgets.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: WidgetEvent.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public abstract class WidgetEvent extends EventObject {
+    
+    protected WidgetEvent(Widget sourceWidget) {
+        super(sourceWidget);
+    }
+    
+    /**
+     * The widget on which this event occured.
+     */
+    public Widget getSourceWidget() {
+        return (Widget)this.source;
+    }
+    
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEventMulticaster.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEventMulticaster.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEventMulticaster.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEventMulticaster.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,121 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import java.awt.AWTEventMulticaster;
+import java.util.EventListener;
+
+import org.apache.cocoon.forms.formmodel.tree.TreeSelectionEvent;
+import org.apache.cocoon.forms.formmodel.tree.TreeSelectionListener;
+
+/**
+ * Convenience class to handle all widget event listeners. See
+ * <code>java.awt.AWTEventMulticaster</code> for more information on its use.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: WidgetEventMulticaster.java 190962 2005-06-16 17:17:00Z sylvain $
+ */
+public class WidgetEventMulticaster extends AWTEventMulticaster implements
+    ActionListener, ValueChangedListener, ProcessingPhaseListener {
+
+    protected WidgetEventMulticaster(EventListener a, EventListener b) {
+        super(a, b);
+    }
+    
+    //-- Create ---------------------------------------------------------------
+    
+    public static CreateListener add(CreateListener a, CreateListener b) {
+        return (CreateListener)addInternal(a, b);
+    }
+    
+    public static CreateListener remove(CreateListener l, CreateListener oldl) {
+        return (CreateListener)removeInternal(l, oldl);
+    }
+    
+    public void widgetCreated(CreateEvent e) {
+        ((CreateListener)a).widgetCreated(e);
+        ((CreateListener)b).widgetCreated(e);
+    }
+
+    //-- Action ---------------------------------------------------------------
+
+    public static ActionListener add(ActionListener a, ActionListener b) {
+        return (ActionListener)addInternal(a, b);
+    }
+    
+    public static ActionListener remove(ActionListener l, ActionListener oldl) {
+        return (ActionListener)removeInternal(l, oldl);
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        ((ActionListener)a).actionPerformed(e);
+        ((ActionListener)b).actionPerformed(e);
+    }
+
+    //-- ValueChanged ---------------------------------------------------------
+
+    public static ValueChangedListener add(ValueChangedListener a, ValueChangedListener b) {
+        return (ValueChangedListener)addInternal(a, b);
+    }
+    
+    public static ValueChangedListener remove(ValueChangedListener l, ValueChangedListener oldl) {
+        return (ValueChangedListener)removeInternal(l, oldl);
+    }
+    
+    public void valueChanged(ValueChangedEvent e) {
+        ((ValueChangedListener)a).valueChanged(e);
+        ((ValueChangedListener)b).valueChanged(e);
+    }
+    
+    //-- ProcessingPhase ------------------------------------------------------
+
+    public void phaseEnded(ProcessingPhaseEvent e) {
+        ((ProcessingPhaseListener)a).phaseEnded(e);
+        ((ProcessingPhaseListener)b).phaseEnded(e);
+    }
+    
+    public static ProcessingPhaseListener add(ProcessingPhaseListener a, ProcessingPhaseListener b) {
+        return (ProcessingPhaseListener)addInternal(a, b);
+    }
+    
+    public static ProcessingPhaseListener remove(ProcessingPhaseListener l, ProcessingPhaseListener oldl) {
+        return (ProcessingPhaseListener)removeInternal(l, oldl);
+    }
+    
+    //-- TreeSelectionChanged ---------------------------------------------------------
+
+    public static TreeSelectionListener add(TreeSelectionListener a, TreeSelectionListener b) {
+        return (TreeSelectionListener)addInternal(a, b);
+    }
+    
+    public static TreeSelectionListener remove(TreeSelectionListener l, TreeSelectionListener oldl) {
+        return (TreeSelectionListener)removeInternal(l, oldl);
+    }
+    
+    public void selectionChanged(TreeSelectionEvent e) {
+        ((TreeSelectionListener)a).selectionChanged(e);
+        ((TreeSelectionListener)b).selectionChanged(e);
+    }
+
+    /**
+     * Can't use the superclass method since it creates an AWTEventMulticaster
+     */
+    protected static EventListener addInternal(EventListener a, EventListener b) {
+        if (a == null)  return b;
+        if (b == null)  return a;
+        return new WidgetEventMulticaster(a, b);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetEventMulticaster.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import java.util.EventListener;
+
+/**
+ * Base interface for all widget event listeners.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: WidgetListener.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public interface WidgetListener extends EventListener {
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListenerBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListenerBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListenerBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListenerBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event;
+
+import org.w3c.dom.Element;
+
+/**
+ * A component that build widget event listeners.
+ * 
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: WidgetListenerBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public interface WidgetListenerBuilder {
+    
+    public static final String ROLE = WidgetListenerBuilder.class.getName();
+    
+    public WidgetListener buildListener(Element element, Class listenerClass) throws Exception;
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/WidgetListenerBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/impl/JavaClassWidgetListenerBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/impl/JavaClassWidgetListenerBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/impl/JavaClassWidgetListenerBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/impl/JavaClassWidgetListenerBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * 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 org.apache.cocoon.forms.event.impl;
+
+import org.apache.cocoon.forms.event.WidgetListener;
+import org.apache.cocoon.forms.event.WidgetListenerBuilder;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.util.ClassUtils;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.w3c.dom.Element;
+
+/**
+ * A {@link WidgetListenerBuilder} that creates java classes.
+ * <p>
+ * The syntax for this listener is as follows :<br/>
+ * <pre>
+ *   &lt;java class="com.my.SuperListener"/&gt;
+ * </pre>
+ *
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: JavaClassWidgetListenerBuilder.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class JavaClassWidgetListenerBuilder implements WidgetListenerBuilder, ThreadSafe {
+
+    public WidgetListener buildListener(Element element, Class listenerClass) throws Exception {
+
+        String name = DomHelper.getAttribute(element, "class");
+
+        Object listener = ClassUtils.newInstance(name);
+        if (listenerClass.isAssignableFrom(listener.getClass())) {
+            // FIXME : apply filecyclehelper
+            return (WidgetListener)listener;
+        } else {
+            throw new Exception("Class " + listener.getClass() + " is not a " + listenerClass);
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-forms-block/impl/src/main/java/org/apache/cocoon/forms/event/impl/JavaClassWidgetListenerBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message