Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 1440 discussions
r1005 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
27 Oct '08
Author: tchemit
Date: 2008-10-27 18:27:59 +0000 (Mon, 27 Oct 2008)
New Revision: 1005
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/ColorConverter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/InsetsConverter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/KeyStrokeConverter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeConverter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeManager.java
Log:
use our code format (block for 1 instruction)
remove unecessary else after a return or a throw
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/ColorConverter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/ColorConverter.java 2008-10-27 17:04:20 UTC (rev 1004)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/ColorConverter.java 2008-10-27 18:27:59 UTC (rev 1005)
@@ -15,21 +15,20 @@
public Object convertFromString(String string, Class type) {
- if (type != Color.class)
+ if (type != Color.class) {
throw new IllegalArgumentException("unsupported type: " + type);
+ }
if (string.length() == 7 && string.charAt(0) == '#') {
return new Color(Integer.parseInt(string.substring(1), 16));
- } else {
- try {
- Field color = Color.class.getField(string);
- return color.get(null);
- }
- catch (NoSuchFieldException e) {
- throw new IllegalArgumentException("colors must be of the form #xxxxxx ('#' followed by six hexadecimal digits), or the name of a constant field in java.awt.Color (found: '" + string + "')");
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
}
+ try {
+ Field color = Color.class.getField(string);
+ return color.get(null);
+ }
+ catch (NoSuchFieldException e) {
+ throw new IllegalArgumentException("colors must be of the form #xxxxxx ('#' followed by six hexadecimal digits), or the name of a constant field in java.awt.Color (found: '" + string + "')");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
}
}
\ No newline at end of file
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/InsetsConverter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/InsetsConverter.java 2008-10-27 17:04:20 UTC (rev 1004)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/InsetsConverter.java 2008-10-27 18:27:59 UTC (rev 1005)
@@ -15,19 +15,22 @@
public Object convertFromString(String string, Class type) {
- if (type != Insets.class)
+ if (type != Insets.class) {
throw new IllegalArgumentException("unsupported type: " + type);
+ }
StringTokenizer tokenizer = new StringTokenizer(string, ",");
int count = tokenizer.countTokens();
if (count == 1) {
int i = Integer.parseInt(tokenizer.nextToken().trim());
return new Insets(i, i, i, i);
- } else if (count == 4) {
+ }
+ if (count == 4) {
int[] insets = new int[count];
- for (int i = 0; tokenizer.hasMoreTokens(); i++)
+ for (int i = 0; tokenizer.hasMoreTokens(); i++) {
insets[i] = Integer.parseInt(tokenizer.nextToken().trim());
+ }
return new Insets(insets[0], insets[1], insets[2], insets[3]);
- } else
- throw new IllegalArgumentException("unable to convert string '" + string + "' to Insets");
+ }
+ throw new IllegalArgumentException("unable to convert string '" + string + "' to Insets");
}
}
\ No newline at end of file
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/KeyStrokeConverter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/KeyStrokeConverter.java 2008-10-27 17:04:20 UTC (rev 1004)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/KeyStrokeConverter.java 2008-10-27 18:27:59 UTC (rev 1005)
@@ -13,8 +13,9 @@
public Object convertFromString(String string, Class type) {
- if (type != KeyStroke.class)
+ if (type != KeyStroke.class) {
throw new IllegalArgumentException("unsupported type: " + type);
+ }
return KeyStroke.getKeyStroke(string);
}
}
\ No newline at end of file
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeConverter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeConverter.java 2008-10-27 17:04:20 UTC (rev 1004)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeConverter.java 2008-10-27 18:27:59 UTC (rev 1005)
@@ -5,7 +5,7 @@
package jaxx.types;
public interface TypeConverter {
- public String getJavaCode(Object object);
+ String getJavaCode(Object object);
- public Object convertFromString(String string, Class type);
+ Object convertFromString(String string, Class type);
}
\ No newline at end of file
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeManager.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeManager.java 2008-10-27 17:04:20 UTC (rev 1004)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/types/TypeManager.java 2008-10-27 18:27:59 UTC (rev 1005)
@@ -24,21 +24,22 @@
public static String getJavaCode(Object object) {
- if (object == null)
+ if (object == null) {
return "null";
- else {
- TypeConverter converter = getTypeConverter(object.getClass());
- if (converter == null)
- throw new IllegalArgumentException("unsupported type: " + object.getClass());
- return converter.getJavaCode(object);
}
+ TypeConverter converter = getTypeConverter(object.getClass());
+ if (converter == null) {
+ throw new IllegalArgumentException("unsupported type: " + object.getClass());
+ }
+ return converter.getJavaCode(object);
}
public static Object convertFromString(String string, Class type) {
TypeConverter converter = getTypeConverter(type);
- if (converter == null)
+ if (converter == null) {
throw new IllegalArgumentException("unsupported type: " + type);
+ }
return converter.convertFromString(string, type);
}
}
\ No newline at end of file
1
0
r1004 - lutinjaxx/trunk/jaxx-example/Components
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
27 Oct '08
Author: tchemit
Date: 2008-10-27 17:04:20 +0000 (Mon, 27 Oct 2008)
New Revision: 1004
Modified:
lutinjaxx/trunk/jaxx-example/Components/
Log:
svn ignore
Property changes on: lutinjaxx/trunk/jaxx-example/Components
___________________________________________________________________
Name: svn:ignore
- target
LICENSE.txt
+ target
LICENSE.txt
*.log
1
0
r1003 - in lutinjaxx/trunk/jaxx-core: . src/main/java/jaxx src/main/java/jaxx/compiler src/main/java/jaxx/tags src/main/java/jaxx/tags/swing
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
27 Oct '08
Author: tchemit
Date: 2008-10-27 17:01:12 +0000 (Mon, 27 Oct 2008)
New Revision: 1003
Modified:
lutinjaxx/trunk/jaxx-core/changelog
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/ClassMap.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/CompiledObject.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultComponentHandler.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java
Log:
fix bug 1722
Modified: lutinjaxx/trunk/jaxx-core/changelog
===================================================================
--- lutinjaxx/trunk/jaxx-core/changelog 2008-10-27 16:52:21 UTC (rev 1002)
+++ lutinjaxx/trunk/jaxx-core/changelog 2008-10-27 17:01:12 UTC (rev 1003)
@@ -1,4 +1,5 @@
ver-0-6 chemit 200811??
+ * 20081027 [chemit] fix bug 1722
* 20081027 [chemit] add conversion support in validator
* 20081025 [chemit] improve BeanValidator tag :
- add a errorList attribute for set a ErrorListMouseListener on the errorList
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/ClassMap.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/ClassMap.java 2008-10-27 16:52:21 UTC (rev 1002)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/ClassMap.java 2008-10-27 17:01:12 UTC (rev 1003)
@@ -6,12 +6,16 @@
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.tags.DefaultObjectHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* A Map implementation which uses Classes as keys. <code>ClassMap</code> differs from typical maps
* in that it takes subclasses into account; mapping a class to a value also maps all subclasses of
@@ -21,6 +25,9 @@
* that, with its nearest ancestor for which there exists a mapping.
*/
public class ClassMap<T> extends HashMap<ClassDescriptor, T> {
+ /** log */
+ protected static final Log log = LogFactory.getLog(ClassMap.class);
+
/**
* Keeps track of automatically-added Classes so we can distinguish them from user-added
* Classes. Unknown Classes are automatically added to the map during <code>get</code>
@@ -45,8 +52,9 @@
ClassDescriptor c = (ClassDescriptor) key;
while (c != null) {
result = super.get(c);
- if (result != null)
+ if (result != null) {
break;
+ }
c = c.getSuperclass();
}
@@ -55,8 +63,8 @@
}
if (c != key && result != null) { // no mapping for the class itself, but found one for a superclass
- put(c, result);
- autoKeys.add(c);
+ put((ClassDescriptor) key, result);
+ autoKeys.add((ClassDescriptor) key);
}
return result;
}
@@ -71,8 +79,9 @@
*/
@Override
public T put(ClassDescriptor key, T value) {
- if (!(key instanceof ClassDescriptor))
- throw new IllegalArgumentException("expected ClassDescriptor, got " + key);
+ //if (!(key instanceof ClassDescriptor)) {
+ // throw new IllegalArgumentException("expected ClassDescriptor, got " + key);
+ //}
if (autoKeys.size() > 0) { // remove all automatic keys which descend from the class being modified
Iterator<ClassDescriptor> i = autoKeys.iterator();
while (i.hasNext()) {
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/CompiledObject.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/CompiledObject.java 2008-10-27 16:52:21 UTC (rev 1002)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/CompiledObject.java 2008-10-27 17:01:12 UTC (rev 1003)
@@ -270,11 +270,12 @@
* @return the Java code for this object
*/
public String getJavaCode() {
- //if (isOverride()) // handle cases where object is overridden to be a different class
- // return "((" + JAXXCompiler.getCanonicalName(getObjectClass()) + ") " + javaCode + ")";
- //else
- //TODO Check if this is safe
- return javaCode;
+ String result = javaCode;
+ if (isOverride()) {
+ // handle cases where object is overridden to be a different class
+ result = "((" + JAXXCompiler.getCanonicalName(getObjectClass()) + ") " + javaCode + ")";
+ }
+ return result;
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-10-27 16:52:21 UTC (rev 1002)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-10-27 17:01:12 UTC (rev 1003)
@@ -7,8 +7,8 @@
import jaxx.CompilerException;
import jaxx.UnsupportedAttributeException;
import jaxx.compiler.CompiledObject;
-import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.I18nHelper;
+import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
import org.apache.commons.logging.Log;
@@ -33,9 +33,6 @@
public DefaultComponentHandler(ClassDescriptor beanClass) {
super(beanClass);
ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Component.class);
- /*if (!ClassDescriptorLoader.getClassDescriptor(Component.class).isAssignableFrom(beanClass)) {
- throw new IllegalArgumentException(getClass().getName() + " does not support the class " + beanClass.getName());
- }*/
}
@Override
@@ -45,17 +42,7 @@
containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
if (containerDelegate == null && ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass().getSuperclass())) {
- DefaultObjectHandler tagHandler = TagManager.getTagHandler(getBeanClass().getSuperclass());
- if (tagHandler instanceof DefaultComponentHandler) {
- containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
- } else {
- /*tagHandler = TagManager.getTagHandler(getBeanClass());
- if (tagHandler instanceof DefaultComponentHandler) {
- containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
- } else {*/
- log.warn("could not find componentHandler for " + getBeanClass().getSuperclass());
- //}
- }
+ containerDelegate = ((DefaultComponentHandler) TagManager.getTagHandler(getBeanClass().getSuperclass())).getContainerDelegate();
}
}
}
@@ -118,8 +105,9 @@
@Override
public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException {
if (propertyName.equals("x") || propertyName.equals("y") || propertyName.equals("width") || propertyName.equals("height") ||
- "font-size".equals(propertyName))
+ "font-size".equals(propertyName)) {
return ClassDescriptorLoader.getClassDescriptor(Integer.class);
+ }
if (propertyName.equals("font-face") || propertyName.equals("font-style") || propertyName.equals("font-weight")) {
return ClassDescriptorLoader.getClassDescriptor(String.class);
}
@@ -200,10 +188,10 @@
}
}
// ajout du support i18n
- if (I18nHelper.isI18nableAttribute(name,compiler)) {
+ if (I18nHelper.isI18nableAttribute(name, compiler)) {
valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler);
}
-
+
return super.getSetPropertyCode(id, name, valueCode, compiler);
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java 2008-10-27 16:52:21 UTC (rev 1002)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java 2008-10-27 17:01:12 UTC (rev 1003)
@@ -38,11 +38,6 @@
TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
- // Begin Try to fix bug when component handler is not found, but this is not this...
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JButton.class), DefaultComponentHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextField.class), JTextComponentHandler.class);
- // End Try to fix bug when component handler is not found, but this is not this...
-
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
1
0
r1002 - in lutinjaxx/trunk/maven-jaxx-plugin/src/test: java/org/codelutin/jaxx resources/testcases resources/testcases/bug_1722
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
27 Oct '08
Author: tchemit
Date: 2008-10-27 16:52:21 +0000 (Mon, 27 Oct 2008)
New Revision: 1002
Added:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx
Removed:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx
Modified:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/I18nTest.java
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml
Log:
use a unique DEFAULT_PREFIX fro all tests
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java 2008-10-27 16:41:11 UTC (rev 1001)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java 2008-10-27 16:52:21 UTC (rev 1002)
@@ -1,15 +1,8 @@
package org.codelutin.jaxx;
-import java.io.File;
-
/** @author chemit */
public class Bug1722Test extends JaxxBaseTest {
- protected String prefix = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "testcases" + File.separator;
-
- public String getPrefix() {
- return prefix;
- }
public void testBug_1722() throws Exception {
mojo.execute();
assertEquals(2, mojo.getFiles().length);
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-10-27 16:41:11 UTC (rev 1001)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-10-27 16:52:21 UTC (rev 1002)
@@ -11,12 +11,6 @@
public class CompilerTest extends JaxxBaseTest {
- protected String prefix = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "testcases" + File.separator;
-
- public String getPrefix() {
- return prefix;
- }
-
public void testInnerClasses() throws Exception {
mojo.execute();
assertEquals(1, mojo.getFiles().length);
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/I18nTest.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/I18nTest.java 2008-10-27 16:41:11 UTC (rev 1001)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/I18nTest.java 2008-10-27 16:52:21 UTC (rev 1002)
@@ -1,15 +1,7 @@
package org.codelutin.jaxx;
-import java.io.File;
-
public class I18nTest extends JaxxBaseTest {
- protected String prefix = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "testcases" + File.separator;
-
- public String getPrefix() {
- return prefix;
- }
-
public void testI18nText() throws Exception {
mojo.setI18nable(false);
mojo.execute();
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java 2008-10-27 16:41:11 UTC (rev 1001)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java 2008-10-27 16:52:21 UTC (rev 1002)
@@ -10,6 +10,9 @@
/** @author chemit */
public abstract class JaxxBaseTest extends AbstractMojoTestCase {
+
+ protected static final String DEFALUT_PREFIX = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "testcases" + File.separator;
+
/** log */
protected Log log;
@@ -17,7 +20,9 @@
protected File pomFile;
- public abstract String getPrefix();
+ public String getPrefix() {
+ return DEFALUT_PREFIX;
+ }
@Override
protected void setUp() throws Exception {
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml 2008-10-27 16:41:11 UTC (rev 1001)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml 2008-10-27 16:52:21 UTC (rev 1002)
@@ -12,6 +12,7 @@
<outJava>${basedir}/target/it-generated-source/java</outJava>
<outResource>${basedir}/target/it-generated-source/resources</outResource>
<force>true</force>
+ <verbose>true</verbose>
<includes>
<value>**/bug_1722/*.jaxx</value>
</includes>
Deleted: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx 2008-10-27 16:41:11 UTC (rev 1001)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx 2008-10-27 16:52:21 UTC (rev 1002)
@@ -1,5 +0,0 @@
-<DemoPanel>
- <JPanel id='demoPanel'>
- <JLabel text='override'/>
- </JPanel>
-</DemoPanel>
\ No newline at end of file
Added: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx (rev 0)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx 2008-10-27 16:52:21 UTC (rev 1002)
@@ -0,0 +1,5 @@
+<DemoPanel>
+ <JPanel id='demoPanel'>
+ <JLabel text='override'/>
+ </JPanel>
+</DemoPanel>
\ No newline at end of file
1
0
r1001 - in lutinjaxx/trunk/jaxx-example: . Components
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
27 Oct '08
Author: tchemit
Date: 2008-10-27 16:41:11 +0000 (Mon, 27 Oct 2008)
New Revision: 1001
Modified:
lutinjaxx/trunk/jaxx-example/Components/pom.xml
lutinjaxx/trunk/jaxx-example/pom.xml
Log:
fix bug 1722 : this example works again
Modified: lutinjaxx/trunk/jaxx-example/Components/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-example/Components/pom.xml 2008-10-27 11:08:21 UTC (rev 1000)
+++ lutinjaxx/trunk/jaxx-example/Components/pom.xml 2008-10-27 16:41:11 UTC (rev 1001)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx-example</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>0.6-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx-example</groupId>
Modified: lutinjaxx/trunk/jaxx-example/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-example/pom.xml 2008-10-27 11:08:21 UTC (rev 1000)
+++ lutinjaxx/trunk/jaxx-example/pom.xml 2008-10-27 16:41:11 UTC (rev 1001)
@@ -26,7 +26,7 @@
<modules>
<module>Calculator</module>
- <!--module>Components</module-->
+ <module>Components</module>
<module>Counter</module>
<module>LabelStyle</module>
<module>Validation</module>
1
0
r1000 - in lutinjaxx/trunk/jaxx-core: . src/main/java/jaxx/runtime src/main/java/jaxx/runtime/validator
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
27 Oct '08
Author: tchemit
Date: 2008-10-27 11:08:21 +0000 (Mon, 27 Oct 2008)
New Revision: 1000
Modified:
lutinjaxx/trunk/jaxx-core/changelog
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorListModel.java
Log:
add conversion support in validator
Modified: lutinjaxx/trunk/jaxx-core/changelog
===================================================================
--- lutinjaxx/trunk/jaxx-core/changelog 2008-10-27 10:40:48 UTC (rev 999)
+++ lutinjaxx/trunk/jaxx-core/changelog 2008-10-27 11:08:21 UTC (rev 1000)
@@ -1,4 +1,5 @@
ver-0-6 chemit 200811??
+ * 20081027 [chemit] add conversion support in validator
* 20081025 [chemit] improve BeanValidator tag :
- add a errorList attribute for set a ErrorListMouseListener on the errorList
- add a beanInitializer attribute for set the validator's bean at runtime
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java 2008-10-27 10:40:48 UTC (rev 999)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java 2008-10-27 11:08:21 UTC (rev 1000)
@@ -1,5 +1,6 @@
package jaxx.runtime;
+import jaxx.runtime.validator.BeanValidator;
import jaxx.runtime.validator.ErrorListMouseListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -276,6 +277,38 @@
}
/**
+ * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
+ *
+ * @param validator validator to be involved
+ * @param fieldName the name of the bean property
+ * @param value the actual value to convert
+ * @param valueClass the type of the conversion
+ */
+ public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
+
+ Object result = validator.convert(fieldName, value, valueClass);
+ if (result != null) {
+ try {
+ BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
+
+ for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
+ if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
+
+ descriptor.getWriteMethod().invoke(validator.getBean(), result);
+ break;
+ }
+ }
+ } catch (IntrospectionException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ }
+ }
+ }
+
+ /**
* recherche les composants portant le meme nom que les champs de la classe
* clazz. Cette methode est statique pour pouvoir eventuellement l'utiliser
* dans un autre context (je pense par exemple a la generation jaxx).
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java 2008-10-27 10:40:48 UTC (rev 999)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java 2008-10-27 11:08:21 UTC (rev 1000)
@@ -32,13 +32,17 @@
import com.opensymphony.xwork2.validator.ValidationException;
import jaxx.runtime.validator.ui.AbstractBeanValidatorUI;
import jaxx.runtime.validator.ui.IconValidationUI;
+import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.Converter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ConverterUtil;
import org.jdesktop.jxlayer.JXLayer;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import java.awt.Container;
+import java.beans.Introspector;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -46,8 +50,12 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
/**
* <p/>
@@ -153,17 +161,20 @@
/** Object servant a contenir la liste des erreurs */
protected BeanValidatorErrorListModel errorListModel;
- /** ui renderer class*/
+ /** ui renderer class */
protected Class<? extends AbstractBeanValidatorUI> uiClass;
/** validator context */
protected ActionContext context;
-
+
+ protected Map<String, String> conversionErrors;
+
public BeanValidator() {
pcs = new PropertyChangeSupport(this);
validationSupport = new ValidationAwareSupport();
validationContext = new DelegatingValidatorContext(validationSupport);
fieldRepresentation = new HashMap<String, JComponent>();
+ conversionErrors = new TreeMap<String, String>();
}
public BeanValidatorErrorListModel getErrorListModel() {
@@ -229,6 +240,9 @@
public void setBean(T bean) {
T oldBean = this.bean;
+
+ // clean conversions of previous bean
+ conversionErrors.clear();
if (this.bean != null) {
try {
Method method = this.bean.getClass().getMethod("removePropertyChangeListener", PropertyChangeListener.class);
@@ -261,7 +275,7 @@
/** @return <code>true</code> if errors are detected, <code>false</code> otherwise */
public boolean hasErrors() {
//todo should also detecte actionErrors ?
- return validationContext.hasFieldErrors();
+ return validationContext.hasFieldErrors() || !conversionErrors.isEmpty();
//return validationContext.hasFieldErrors() || validationContext.hasActionErrors();
}
@@ -277,6 +291,10 @@
return validationContext.getActionMessages();
}
+ public Map<String, String> getConversionErrors() {
+ return conversionErrors;
+ }
+
/** install ui on required components */
public void installUIs() {
SwingUtilities.invokeLater(new Runnable() {
@@ -298,6 +316,52 @@
}
/**
+ * Convert a value.
+ * <p/>
+ * If an error occurs, then add an error in validator.
+ *
+ * @param fieldName the name of the bean property
+ * @param value the value to convert
+ * @param valueClass the type of converted value
+ * @return the converted value, or null if conversion was not ok
+ */
+ public <T> T convert(String fieldName, String value, Class<T> valueClass) {
+ if (valueClass == null) {
+ throw new IllegalArgumentException("valueClass can not be null");
+ }
+
+ // on ne convertit pas si il y a un bean et que le resultat de la validation
+ // pourra etre affiche quelque part
+ if (bean == null || getErrorListModel() == null || fieldRepresentation.size() == 0 || value == null) {
+ return null;
+ }
+
+ // remove the previous conversion error for the field
+ conversionErrors.remove(fieldName);
+
+ T result;
+ try {
+ Converter converter = ConverterUtil.getConverter(valueClass);
+ if (converter == null) {
+ throw new RuntimeException("could not find converter for the type " + valueClass);
+ }
+ result = (T) converter.convert(valueClass, value);
+ if (result != null && !value.equals(result.toString())) {
+ conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ result = null;
+ validate();
+ }
+ } catch (ConversionException e) {
+ // get
+ conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ result = null;
+ validate();
+ }
+
+ return result;
+ }
+
+ /**
* il faut eviter le code re-intrant (durant une validation, une autre est
* demandee). Pour cela on fait la validation dans un thread, et tant
* que la premiere validation n'est pas fini, on ne repond pas aux
@@ -319,6 +383,9 @@
getValidator().validate(bean, null, validationContext);
+ // add the registred conversion errors
+ transfertConversionErrorsToFieldErrors();
+
if (log.isDebugEnabled()) {
log.debug("Action errors: " + validationContext.getActionErrors());
log.debug("Action messages: " + validationContext.getActionMessages());
@@ -357,7 +424,7 @@
ActionValidatorManager.class, "no-annotations");
}
//TC - 20081024 : since context is in a ThreadLocal variable, we must do the check
- if (ActionContext.getContext()==null) {
+ if (ActionContext.getContext() == null) {
ActionContext.setContext(context);
}
return validator;
@@ -387,6 +454,29 @@
}
}
+ /**
+ * Transfer the registred conversion errors to fieldErrors.
+ * <p/>
+ * The previously filed errors of a given field where a conversion error occurs will be removed.
+ */
+ protected void transfertConversionErrorsToFieldErrors() {
+ Map map = getFieldErrors();
+ for (Entry<String, String> entry : conversionErrors.entrySet()) {
+ // remove from validation, errors occurs on this field
+ List errors = (List) map.get(entry.getKey());
+ if (errors != null) {
+ errors.clear();
+ errors.add(entry.getValue());
+ } else {
+ errors = Collections.singletonList(entry.getValue());
+ }
+ // add the concrete conversion error
+ map.put(entry.getKey(), errors);
+ }
+ validationContext.setFieldErrors(map);
+ }
+
+
protected class Listener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent evt) {
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorListModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorListModel.java 2008-10-27 10:40:48 UTC (rev 999)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorListModel.java 2008-10-27 11:08:21 UTC (rev 1000)
@@ -93,7 +93,6 @@
Map.Entry<?, ?> r = (Map.Entry<?, ?>) o;
BeanValidatorError<T> error;
String field = (String) r.getKey();
-
JComponent component = validator.getFieldRepresentation(field);
if (component!=null) {
for (Object errorString : (List<?>) r.getValue()) {
1
0
r999 - in lutinjaxx/trunk/maven-jaxx-plugin/src/test: java/org/codelutin/jaxx resources/testcases resources/testcases/bug_1722
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
by tchemit@users.labs.libre-entreprise.org 27 Oct '08
27 Oct '08
Author: tchemit
Date: 2008-10-27 10:40:48 +0000 (Mon, 27 Oct 2008)
New Revision: 999
Added:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/DemoPanel.jaxx
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx
Log:
add test to solve bug 1722... so actually maven-jaxx-plugin will not successfull compile since to that bug.
Added: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java (rev 0)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/Bug1722Test.java 2008-10-27 10:40:48 UTC (rev 999)
@@ -0,0 +1,17 @@
+package org.codelutin.jaxx;
+
+import java.io.File;
+
+/** @author chemit */
+public class Bug1722Test extends JaxxBaseTest {
+
+ protected String prefix = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "testcases" + File.separator;
+
+ public String getPrefix() {
+ return prefix;
+ }
+ public void testBug_1722() throws Exception {
+ mojo.execute();
+ assertEquals(2, mojo.getFiles().length);
+ }
+}
Copied: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml (from rev 948, lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences.xml)
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml (rev 0)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml 2008-10-27 10:40:48 UTC (rev 999)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <src>${basedir}/src/test/resources</src>
+ <outJava>${basedir}/target/it-generated-source/java</outJava>
+ <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <force>true</force>
+ <includes>
+ <value>**/bug_1722/*.jaxx</value>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Property changes on: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/DemoPanel.jaxx (from rev 948, lutinjaxx/trunk/jaxx-example/Components/src/main/java/examples/Components/DemoPanel.jaxx)
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/DemoPanel.jaxx (rev 0)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/DemoPanel.jaxx 2008-10-27 10:40:48 UTC (rev 999)
@@ -0,0 +1,7 @@
+<JTabbedPane id='top'>
+ <tab title='Title'>
+ <JPanel id='demoPanel'>
+ <JLabel text='override'/>
+ </JPanel>
+ </tab>
+</JTabbedPane>
\ No newline at end of file
Property changes on: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/DemoPanel.jaxx
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx (from rev 948, lutinjaxx/trunk/jaxx-example/Components/src/main/java/examples/Components/JButtonDemo.jaxx)
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx (rev 0)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx 2008-10-27 10:40:48 UTC (rev 999)
@@ -0,0 +1,5 @@
+<DemoPanel>
+ <JPanel id='demoPanel'>
+ <JLabel text='override'/>
+ </JPanel>
+</DemoPanel>
\ No newline at end of file
Property changes on: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/bug_1722/JButtonDemo.jaxx
___________________________________________________________________
Name: svn:mergeinfo
+
1
0
r998 - in lutinjaxx/trunk/jaxx-core/src/main: java/jaxx/runtime/validator java/jaxx/runtime/validator/field resources
by tchemit@users.labs.libre-entreprise.org 26 Oct '08
by tchemit@users.labs.libre-entreprise.org 26 Oct '08
26 Oct '08
Author: tchemit
Date: 2008-10-26 14:37:30 +0000 (Sun, 26 Oct 2008)
New Revision: 998
Added:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java
Removed:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingDirectoryFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingFileFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingDirectoryFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingFileFieldValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/RequiredFileFieldValidator.java
Modified:
lutinjaxx/trunk/jaxx-core/src/main/resources/validators.xml
Log:
create package field
Deleted: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingDirectoryFieldValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingDirectoryFieldValidator.java 2008-10-25 19:57:53 UTC (rev 997)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingDirectoryFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -1,72 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
-
-import java.io.File;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * ExistingDirectoryFieldValidator checks that a File field exists and is a directory.
- * <!-- END SNIPPET: javadoc -->
- * <p/>
- * <p/>
- * <!-- START SNIPPET: parameters -->
- * <ul>
- * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
- * </ul>
- * <!-- END SNIPPET: parameters -->
- * <p/>
- * <p/>
- * <pre>
- * <!-- START SNIPPET: examples -->
- * <validators>
- * <!-- Plain-Validator Syntax -->
- * <validator type="existingDirectory">
- * <param name="fieldName">tmp</param>
- * <message>tmp is not an existing directory</message>
- * </validator>
- * <p/>
- * <!-- Field-Validator Syntax -->
- * <field name="tmp">
- * <field-validator type="existingDirectory">
- * <message>tmp is not an existing directory</message>
- * </field-validator>
- * </field>
- * </validators>
- * <!-- END SNIPPET: examples -->
- * </pre>
- *
- * @author chemit
- */
-public class ExistingDirectoryFieldValidator extends FieldValidatorSupport {
-
- public void validate(Object object) throws ValidationException {
- String fieldName = getFieldName();
- Object value = this.getFieldValue(fieldName, object);
- if (value==null) {
- // no value defined
- addFieldError(fieldName, object);
- return;
- }
- File f;
- if (value instanceof File) {
- f = (File) value;
- } else if (value instanceof String) {
- f = new File((String) value);
- } else {
- addFieldError(fieldName, object);
- return;
- }
-
- if (!(f.isDirectory() && f.exists())) {
- // f is not a directory, nor exists
- addFieldError(fieldName, object);
- }
- }
-
- @Override
- public String getValidatorType() {
- return "existingDirectory";
- }
-}
\ No newline at end of file
Deleted: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingFileFieldValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingFileFieldValidator.java 2008-10-25 19:57:53 UTC (rev 997)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingFileFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -1,72 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
-
-import java.io.File;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * ExistingFileFieldValidator checks that a File field exists. *
- * <!-- END SNIPPET: javadoc -->
- * <p/>
- * <p/>
- * <!-- START SNIPPET: parameters -->
- * <ul>
- * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
- * </ul>
- * <!-- END SNIPPET: parameters -->
- * <p/>
- * <p/>
- * <pre>
- * <!-- START SNIPPET: examples -->
- * <validators>
- * <!-- Plain-Validator Syntax -->
- * <validator type="fileExisting">
- * <param name="fieldName">tmp</param>
- * <message>tmp is not an existing file</message>
- * </validator>
- * <p/>
- * <!-- Field-Validator Syntax -->
- * <field name="tmp">
- * <field-validator type="fileExisting">
- * <message>tmp is not an existing file</message>
- * </field-validator>
- * </field>
- * </validators>
- * <!-- END SNIPPET: examples -->
- * </pre>
- *
- * @author chemit
- */
-public class ExistingFileFieldValidator extends FieldValidatorSupport {
-
- public void validate(Object object) throws ValidationException {
- String fieldName = getFieldName();
- Object value = this.getFieldValue(fieldName, object);
- if (value == null) {
- // no value defined
- addFieldError(fieldName, object);
- return;
- }
- File f;
- if (value instanceof File) {
- f = (File) value;
- } else if (value instanceof String) {
- f = new File((String) value);
- } else {
- addFieldError(fieldName, object);
- return;
- }
-
- if (!(f.isFile() && f.exists())) {
- // f is not a file nor exists
- addFieldError(fieldName, object);
- }
- }
-
- @Override
- public String getValidatorType() {
- return "existingFile";
- }
-}
Deleted: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingDirectoryFieldValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingDirectoryFieldValidator.java 2008-10-25 19:57:53 UTC (rev 997)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingDirectoryFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -1,72 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
-
-import java.io.File;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * NotExistingDirectoryFieldValidator checks that a File field as a directory does not exist. *
- * <!-- END SNIPPET: javadoc -->
- * <p/>
- * <p/>
- * <!-- START SNIPPET: parameters -->
- * <ul>
- * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
- * </ul>
- * <!-- END SNIPPET: parameters -->
- * <p/>
- * <p/>
- * <pre>
- * <!-- START SNIPPET: examples -->
- * <validators>
- * <!-- Plain-Validator Syntax -->
- * <validator type="notExistingDirectory">
- * <param name="fieldName">tmp</param>
- * <message>tmp is an existing directory</message>
- * </validator>
- * <p/>
- * <!-- Field-Validator Syntax -->
- * <field name="tmp">
- * <field-validator type="notExistingDirectory">
- * <message>tmp is an existing directory</message>
- * </field-validator>
- * </field>
- * </validators>
- * <!-- END SNIPPET: examples -->
- * </pre>
- *
- * @author chemit
- */
-public class NotExistingDirectoryFieldValidator extends FieldValidatorSupport {
-
- @Override
- public void validate(Object object) throws ValidationException {
- String fieldName = getFieldName();
- Object value = this.getFieldValue(fieldName, object);
- if (value == null) {
- // no value defined
- addFieldError(fieldName, object);
- return;
- }
- File f;
- if (value instanceof File) {
- f = (File) value;
- } else if (value instanceof String) {
- f = new File((String) value);
- } else {
- addFieldError(fieldName, object);
- return;
- }
-
- if (f.exists() || f.isFile()) {
- addFieldError(fieldName, object);
- }
- }
-
- @Override
- public String getValidatorType() {
- return "notExistingDirectory";
- }
-}
\ No newline at end of file
Deleted: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingFileFieldValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingFileFieldValidator.java 2008-10-25 19:57:53 UTC (rev 997)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingFileFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -1,73 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
-
-import java.io.File;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * NotExistingFileFieldValidator checks that a File field as a file does not exist. *
- * <!-- END SNIPPET: javadoc -->
- * <p/>
- * <p/>
- * <!-- START SNIPPET: parameters -->
- * <ul>
- * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
- * </ul>
- * <!-- END SNIPPET: parameters -->
- * <p/>
- * <p/>
- * <pre>
- * <!-- START SNIPPET: examples -->
- * <validators>
- * <!-- Plain-Validator Syntax -->
- * <validator type="notExistingFile">
- * <param name="fieldName">tmp</param>
- * <message>tmp is an existing file</message>
- * </validator>
- * <p/>
- * <!-- Field-Validator Syntax -->
- * <field name="tmp">
- * <field-validator type="notExistingFile">
- * <message>tmp is an existing file</message>
- * </field-validator>
- * </field>
- * </validators>
- * <!-- END SNIPPET: examples -->
- * </pre>
- *
- * @author chemit
- */
-public class NotExistingFileFieldValidator extends FieldValidatorSupport {
-
- @Override
- public void validate(Object object) throws ValidationException {
- String fieldName = getFieldName();
- Object value = this.getFieldValue(fieldName, object);
- if (value==null) {
- // no value defined
- addFieldError(fieldName, object);
- return;
- }
- File f;
- if (value instanceof File) {
- f = (File) value;
- } else if (value instanceof String) {
- f = new File((String) value);
- } else {
- addFieldError(fieldName, object);
- return;
- }
-
- if (f.exists() || f.isDirectory()) {
- // f is not a file and exist
- addFieldError(fieldName, object);
- }
- }
-
- @Override
- public String getValidatorType() {
- return "notExistingFile";
- }
-}
\ No newline at end of file
Deleted: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/RequiredFileFieldValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/RequiredFileFieldValidator.java 2008-10-25 19:57:53 UTC (rev 997)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/RequiredFileFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -1,72 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
-
-import java.io.File;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * RequiredFileFieldValidator checks that a File field is not null nor have an empty filename.
- * <!-- END SNIPPET: javadoc -->
- * <p/>
- * <p/>
- * <!-- START SNIPPET: parameters -->
- * <ul>
- * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
- * </ul>
- * <!-- END SNIPPET: parameters -->
- * <p/>
- * <p/>
- * <pre>
- * <!-- START SNIPPET: examples -->
- * <validators>
- * <!-- Plain-Validator Syntax -->
- * <validator type="requiredFile">
- * <param name="fieldName">tmp</param>
- * <message>tmp is required</message>
- * </validator>
- * <p/>
- * <!-- Field-Validator Syntax -->
- * <field name="tmp">
- * <field-validator type="requiredFile">
- * <message>tmp is required</message>
- * </field-validator>
- * </field>
- * </validators>
- * <!-- END SNIPPET: examples -->
- * </pre>
- *
- * @author chemit
- */
-public class RequiredFileFieldValidator extends FieldValidatorSupport {
-
- public void validate(Object object) throws ValidationException {
- String fieldName = getFieldName();
- Object value = this.getFieldValue(fieldName, object);
- if (value == null) {
- // no value defined
- addFieldError(fieldName, object);
- return;
- }
- File f;
- if (value instanceof File) {
- f = (File) value;
- } else if (value instanceof String) {
- f = new File((String) value);
- } else {
- addFieldError(fieldName, object);
- return;
- }
-
- if (f.getPath().trim().isEmpty()) {
- // f is not a directory nor exists
- addFieldError(fieldName, object);
- }
- }
-
- @Override
- public String getValidatorType() {
- return "requiredFile";
- }
-}
\ No newline at end of file
Copied: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java (from rev 981, lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingDirectoryFieldValidator.java)
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -0,0 +1,72 @@
+package jaxx.runtime.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * ExistingDirectoryFieldValidator checks that a File field exists and is a directory.
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="existingDirectory">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is not an existing directory</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="existingDirectory">
+ * <message>tmp is not an existing directory</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author chemit
+ */
+public class ExistingDirectoryFieldValidator extends FieldValidatorSupport {
+
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = this.getFieldValue(fieldName, object);
+ if (value==null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (!(f.isDirectory() && f.exists())) {
+ // f is not a directory, nor exists
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "existingDirectory";
+ }
+}
\ No newline at end of file
Copied: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java (from rev 981, lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/ExistingFileFieldValidator.java)
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -0,0 +1,72 @@
+package jaxx.runtime.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * ExistingFileFieldValidator checks that a File field exists. *
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="fileExisting">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is not an existing file</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="fileExisting">
+ * <message>tmp is not an existing file</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author chemit
+ */
+public class ExistingFileFieldValidator extends FieldValidatorSupport {
+
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = this.getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (!(f.isFile() && f.exists())) {
+ // f is not a file nor exists
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "existingFile";
+ }
+}
Copied: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java (from rev 981, lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingDirectoryFieldValidator.java)
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingDirectoryFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -0,0 +1,72 @@
+package jaxx.runtime.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * NotExistingDirectoryFieldValidator checks that a File field as a directory does not exist. *
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="notExistingDirectory">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is an existing directory</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="notExistingDirectory">
+ * <message>tmp is an existing directory</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author chemit
+ */
+public class NotExistingDirectoryFieldValidator extends FieldValidatorSupport {
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = this.getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (f.exists() || f.isFile()) {
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "notExistingDirectory";
+ }
+}
\ No newline at end of file
Copied: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java (from rev 981, lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/NotExistingFileFieldValidator.java)
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -0,0 +1,73 @@
+package jaxx.runtime.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * NotExistingFileFieldValidator checks that a File field as a file does not exist. *
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="notExistingFile">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is an existing file</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="notExistingFile">
+ * <message>tmp is an existing file</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author chemit
+ */
+public class NotExistingFileFieldValidator extends FieldValidatorSupport {
+
+ @Override
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = this.getFieldValue(fieldName, object);
+ if (value==null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (f.exists() || f.isDirectory()) {
+ // f is not a file and exist
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "notExistingFile";
+ }
+}
\ No newline at end of file
Property changes on: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/NotExistingFileFieldValidator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java (from rev 983, lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/RequiredFileFieldValidator.java)
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2008-10-26 14:37:30 UTC (rev 998)
@@ -0,0 +1,72 @@
+package jaxx.runtime.validator.field;
+
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
+
+import java.io.File;
+
+/**
+ * <!-- START SNIPPET: javadoc -->
+ * RequiredFileFieldValidator checks that a File field is not null nor have an empty filename.
+ * <!-- END SNIPPET: javadoc -->
+ * <p/>
+ * <p/>
+ * <!-- START SNIPPET: parameters -->
+ * <ul>
+ * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li>
+ * </ul>
+ * <!-- END SNIPPET: parameters -->
+ * <p/>
+ * <p/>
+ * <pre>
+ * <!-- START SNIPPET: examples -->
+ * <validators>
+ * <!-- Plain-Validator Syntax -->
+ * <validator type="requiredFile">
+ * <param name="fieldName">tmp</param>
+ * <message>tmp is required</message>
+ * </validator>
+ * <p/>
+ * <!-- Field-Validator Syntax -->
+ * <field name="tmp">
+ * <field-validator type="requiredFile">
+ * <message>tmp is required</message>
+ * </field-validator>
+ * </field>
+ * </validators>
+ * <!-- END SNIPPET: examples -->
+ * </pre>
+ *
+ * @author chemit
+ */
+public class RequiredFileFieldValidator extends FieldValidatorSupport {
+
+ public void validate(Object object) throws ValidationException {
+ String fieldName = getFieldName();
+ Object value = this.getFieldValue(fieldName, object);
+ if (value == null) {
+ // no value defined
+ addFieldError(fieldName, object);
+ return;
+ }
+ File f;
+ if (value instanceof File) {
+ f = (File) value;
+ } else if (value instanceof String) {
+ f = new File((String) value);
+ } else {
+ addFieldError(fieldName, object);
+ return;
+ }
+
+ if (f.getPath().trim().isEmpty()) {
+ // f is not a directory nor exists
+ addFieldError(fieldName, object);
+ }
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "requiredFile";
+ }
+}
\ No newline at end of file
Property changes on: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: lutinjaxx/trunk/jaxx-core/src/main/resources/validators.xml
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/resources/validators.xml 2008-10-25 19:57:53 UTC (rev 997)
+++ lutinjaxx/trunk/jaxx-core/src/main/resources/validators.xml 2008-10-26 14:37:30 UTC (rev 998)
@@ -5,10 +5,10 @@
<!-- START SNIPPET: validators -->
<validators>
- <validator name="requiredFile" class="jaxx.runtime.validator.RequiredFileFieldValidator"/>
- <validator name="existingFile" class="jaxx.runtime.validator.ExistingFileFieldValidator"/>
- <validator name="notExistingFile" class="jaxx.runtime.validator.NotExistingFileFieldValidator"/>
- <validator name="existingDirectory" class="jaxx.runtime.validator.ExistingDirectoryFieldValidator"/>
- <validator name="notExistingDirectory" class="jaxx.runtime.validator.NotExistingDirectoryFieldValidator"/>
+ <validator name="requiredFile" class="jaxx.runtime.validator.field.RequiredFileFieldValidator"/>
+ <validator name="existingFile" class="jaxx.runtime.validator.field.ExistingFileFieldValidator"/>
+ <validator name="notExistingFile" class="jaxx.runtime.validator.field.NotExistingFileFieldValidator"/>
+ <validator name="existingDirectory" class="jaxx.runtime.validator.field.ExistingDirectoryFieldValidator"/>
+ <validator name="notExistingDirectory" class="jaxx.runtime.validator.field.NotExistingDirectoryFieldValidator"/>
</validators>
<!-- END SNIPPET: validators -->
1
0
r997 - in lutinjaxx/trunk/jaxx-core/src/main/java/jaxx: runtime tags/validator
by tchemit@users.labs.libre-entreprise.org 25 Oct '08
by tchemit@users.labs.libre-entreprise.org 25 Oct '08
25 Oct '08
Author: tchemit
Date: 2008-10-25 19:57:53 +0000 (Sat, 25 Oct 2008)
New Revision: 997
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
Log:
register only one ErrorListMouseListener
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java 2008-10-25 19:47:06 UTC (rev 996)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java 2008-10-25 19:57:53 UTC (rev 997)
@@ -1,13 +1,16 @@
package jaxx.runtime;
+import jaxx.runtime.validator.ErrorListMouseListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.jxlayer.JXLayer;
import javax.swing.JComponent;
+import javax.swing.JList;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.event.MouseListener;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
@@ -343,4 +346,18 @@
layer.add(component);
return layer;
}
+
+ public static void registerErrorListMouseListener(JList list) {
+ if (list == null) {
+ return;
+ }
+ for (MouseListener listener : list.getMouseListeners()) {
+ if (listener instanceof ErrorListMouseListener) {
+ // already have a such listener
+ log.info("already registered a such MouseListener : " + listener);
+ return;
+ }
+ }
+ list.addMouseListener(new ErrorListMouseListener());
+ }
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2008-10-25 19:47:06 UTC (rev 996)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2008-10-25 19:57:53 UTC (rev 997)
@@ -11,8 +11,8 @@
import jaxx.introspection.JAXXPropertyDescriptor;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.Util;
import jaxx.runtime.validator.BeanValidator;
-import jaxx.runtime.validator.ErrorListMouseListener;
import jaxx.runtime.validator.ui.AbstractBeanValidatorUI;
import jaxx.tags.DefaultObjectHandler;
import jaxx.types.TypeManager;
@@ -314,7 +314,7 @@
}
}
- String code = errorList + ".addMouseListener(new " + ErrorListMouseListener.class.getName() + "());";
+ String code = Util.class.getName() + ".registerErrorListMouseListener(" + errorList + ");";
appendAdditionCode(code);
return false;
1
0
r996 - in lutinjaxx/trunk/maven-jaxx-plugin/src/test: java/org/codelutin/jaxx resources/testcases/validator/errors
by tchemit@users.labs.libre-entreprise.org 25 Oct '08
by tchemit@users.labs.libre-entreprise.org 25 Oct '08
25 Oct '08
Author: tchemit
Date: 2008-10-25 19:47:06 +0000 (Sat, 25 Oct 2008)
New Revision: 996
Added:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorList.jaxx
Modified:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorListModel.jaxx
Log:
add a errorList attribute for set a ErrorListMouseListener on the errorList
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-10-25 19:46:47 UTC (rev 995)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-10-25 19:47:06 UTC (rev 996)
@@ -186,7 +186,7 @@
// init mojo to get alls files to treate
mojo.init();
String[] files = mojo.getFiles();
- assertEquals(16, mojo.getFiles().length);
+ assertEquals(17, mojo.getFiles().length);
mojo.setLog(new SystemStreamLog() {
@Override
public boolean isErrorEnabled() {
Copied: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorList.jaxx (from rev 968, lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorListModel.jaxx)
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorList.jaxx (rev 0)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorList.jaxx 2008-10-25 19:47:06 UTC (rev 996)
@@ -0,0 +1,85 @@
+<Application title="Validation.jaxx">
+
+ <!-- models -->
+ <Model id='model'/>
+
+ <jaxx.runtime.validator.BeanValidatorErrorListModel id='errors'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='model' errorList='fake'>
+ <field name="text"/>
+ <field name="text2"/>
+ <field name="ratio"/>
+ </BeanValidator>
+ <Table fill='both'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='{model.getText()}'
+ onKeyReleased='model.setText(text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text2' text='{model.getText2()}'
+ onKeyReleased='model.setText2(text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100' value='{model.getRatio()}'
+ onStateChanged='model.setRatio(ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</Application>
Property changes on: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorList.jaxx
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorListModel.jaxx
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorListModel.jaxx 2008-10-25 19:46:47 UTC (rev 995)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/UnfoundErrorListModel.jaxx 2008-10-25 19:47:06 UTC (rev 996)
@@ -2,23 +2,13 @@
<!-- models -->
<Model id='model'/>
- <Model id='model2'/>
- <!-- errors model -->
- <jaxx.runtime.validator.BeanValidatorErrorListModel id='errors' onContentsChanged='ok.setEnabled(errors.size()==0)'/>
-
<!-- validators -->
<BeanValidator id='validator' bean='model' errorListModel='fake'>
<field name="text"/>
<field name="text2"/>
<field name="ratio"/>
</BeanValidator>
- <BeanValidator id='validator2' bean='model2' errorListModel='errors' uiClass="jaxx.runtime.validator.ui.IconValidationUI">
- <field name="text" component="_text"/>
- <field name="text2" component="_text2"/>
- <field name="ratio" component="_ratio"/>
- </BeanValidator>
-
<Table fill='both'>
<row>
<cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
@@ -89,178 +79,5 @@
</JPanel>
</cell>
</row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text' text='{model2.getText()}'
- onKeyReleased='model2.setText(_text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text2' text='{model2.getText2()}'
- onKeyReleased='model2.setText2(_text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}'
- onStateChanged='model2.setRatio(_ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model2.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
- layout='{new GridLayout()}' width='250' height='140'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='firstName' text='{identity.getFirstName()}'
- onKeyReleased='identity.setFirstName(firstName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='lastName' text='{identity.getLastName()}'
- onKeyReleased='identity.setLastName(lastName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='email2' text='{identity.getEmail()}'
- onKeyReleased='identity.setEmail(email2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
- onStateChanged='identity.setAge(age.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getFirstName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getLastName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getEmail()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getAge()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' width='500'>
- <JScrollPane>
- <JList model='{errors}'/>
- </JScrollPane>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel layout='{new GridLayout(1,2,0,0)}'>
- <JButton text='cancel' onActionPerformed='dispose()'/>
- <JButton id='ok' text='valid' onActionPerformed='dispose()'/>
- </JPanel>
- </cell>
- </row>
-
</Table>
</Application>
1
0