Jaxx-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
January 2011
- 2 participants
- 38 discussions
Author: tchemit
Date: 2011-01-25 15:08:37 +0100 (Tue, 25 Jan 2011)
New Revision: 2167
Url: http://nuiton.org/repositories/revision/jaxx/2167
Log:
Evolution #1233: Updates nuiton-i18n to 2.2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-01-25 13:26:57 UTC (rev 2166)
+++ trunk/pom.xml 2011-01-25 14:08:37 UTC (rev 2167)
@@ -424,7 +424,7 @@
<projectId>jaxx</projectId>
<nuitonUtilsVersion>2.0-SNAPSHOT</nuitonUtilsVersion>
- <nuitonI18nVersion>2.1</nuitonI18nVersion>
+ <nuitonI18nVersion>2.2</nuitonI18nVersion>
<jxLayerVersion>3.0.3</jxLayerVersion>
1
0
r2166 - in trunk: jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui
by tchemit@users.nuiton.org 25 Jan '11
by tchemit@users.nuiton.org 25 Jan '11
25 Jan '11
Author: tchemit
Date: 2011-01-25 14:26:57 +0100 (Tue, 25 Jan 2011)
New Revision: 2166
Url: http://nuiton.org/repositories/revision/jaxx/2166
Log:
clean code + improve tutorial rules
Modified:
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
Modified: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml 2011-01-25 13:09:59 UTC (rev 2165)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml 2011-01-25 13:26:57 UTC (rev 2166)
@@ -1,27 +1,3 @@
-<!--
- #%L
- JAXX :: Tutorial Validation
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2008 - 2011 CodeLutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Lesser Public License for more details.
-
- You should have received a copy of the GNU General Lesser Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/lgpl-3.0.html>.
- #L%
- -->
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
@@ -29,7 +5,7 @@
<field name="title">
<field-validator type="fieldexpression">
<param name="expression">
- <![CDATA[ title == null]]></param>
+ <![CDATA[ title == null || title.empty ]]></param>
<message>Title is filled.</message>
</field-validator>
</field>
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2011-01-25 13:09:59 UTC (rev 2165)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2011-01-25 13:26:57 UTC (rev 2166)
@@ -87,23 +87,6 @@
if (scope != null) {
BufferedImage icon = icons.get(scope);
g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
-// switch (scope) {
-// case FATAL:
-// icon = fatalIcon;
-// break;
-// case ERROR:
-// icon = errorIcon;
-// break;
-// case WARNING:
-// icon = warningIcon;
-// break;
-// case INFO:
-// icon = infoIcon;
-// break;
-// }
-// if (icon != null) {
-// g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
-// }
}
}
}
1
0
r2165 - in trunk: jaxx-compiler/src/main/java/jaxx/compiler/finalizers jaxx-compiler/src/main/java/jaxx/compiler/tags/validator jaxx-validator/src/main/java/jaxx/runtime/validator/swing
by tchemit@users.nuiton.org 25 Jan '11
by tchemit@users.nuiton.org 25 Jan '11
25 Jan '11
Author: tchemit
Date: 2011-01-25 14:09:59 +0100 (Tue, 25 Jan 2011)
New Revision: 2165
Url: http://nuiton.org/repositories/revision/jaxx/2165
Log:
use the BeanValidatorFactory
Modified:
trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2011-01-25 12:03:38 UTC (rev 2164)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2011-01-25 13:09:59 UTC (rev 2165)
@@ -126,7 +126,7 @@
for (CompiledBeanValidator validator : validators) {
validator.registerValidator(compiler, javaFile);
}
-
+
// StringBuilder registerValidatorFieldsMethod = new StringBuilder();
// registerValidatorFieldsMethod.append(SwingValidatorUtil.class.getSimpleName()).append(".installFields(this);");
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2011-01-25 12:03:38 UTC (rev 2164)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2011-01-25 13:09:59 UTC (rev 2165)
@@ -748,8 +748,13 @@
String beanClassName = beanInfo.getJAXXBeanDescriptor().getClassDescriptor().getName();
// contextName must be in constructor to able to init validator with his correct contextName
- setConstructorParams(beanClassName + ".class, " +
- TypeManager.getJavaCode(contextName));
+ String constructorParams = beanClassName + ".class, " +
+ TypeManager.getJavaCode(contextName);
+// setConstructorParams(constructorParams);
+ setInitializer(
+ SwingValidatorUtil.class.getSimpleName() + ".newValidator(" + constructorParams + ")"
+ );
+
// add generic type to validator
setGenericTypes(new String[]{beanClassName});
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2011-01-25 12:03:38 UTC (rev 2164)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2011-01-25 13:09:59 UTC (rev 2165)
@@ -31,7 +31,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ReflectUtil;
+import org.nuiton.validator.NuitonValidatorProvider;
import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.BeanValidator;
+import org.nuiton.validator.bean.BeanValidatorFactory;
import org.nuiton.validator.bean.BeanValidatorUtil;
import javax.swing.ImageIcon;
@@ -55,7 +58,7 @@
import static org.nuiton.i18n.I18n.n_;
/**
- * The helper class for validation module.
+ * The helper class for swing validation module.
*
* @author tchemit <chemit(a)codelutin.com>
*/
@@ -120,6 +123,18 @@
// no instance
}
+ public static <O> SwingValidator<O> newValidator(Class<O> type, String context) {
+
+ if (BeanValidatorFactory.isDefaultCreator()) {
+
+ // set the swing bean validator creator
+ BeanValidatorFactory.setCreator(new DefaultSwingValidatorCreator());
+ }
+ SwingValidator<O> validator =
+ (SwingValidator<O>) BeanValidatorFactory.newBeanValidator(type, context);
+ return validator;
+ }
+
public static List<String> initUI(JAXXValidator ui) {
List<String> validatorIds = new ArrayList<String>();
Map<Field, Validator> validators = ReflectUtil.getFieldAnnotation(
@@ -191,8 +206,6 @@
// reload attached bean (to see validation on uis)
validator.reloadBean();
}
-
-
}
/**
@@ -336,7 +349,10 @@
* @param ui ui to refresh when context name has changed
* @since 2.2.1
*/
- public static void listenValidatorContextNameAndRefreshFields(SwingValidator<?> validator, final JAXXValidator ui) {
+ public static void listenValidatorContextNameAndRefreshFields(
+ SwingValidator<?> validator,
+ final JAXXValidator ui) {
+
PropertyChangeListener listener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -353,4 +369,22 @@
listener
);
}
+
+ /**
+ * Default bean validator creator to use in the {@link BeanValidatorFactory}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.1
+ */
+ public static class DefaultSwingValidatorCreator implements BeanValidatorFactory.BeanValidatorCreator {
+ @Override
+ public <O> BeanValidator<O> newBeanValidator(NuitonValidatorProvider provider, Class<O> type, String context, NuitonValidatorScope... scopes) {
+ BeanValidator<O> beanValidator = new SwingValidator<O>(provider,
+ type,
+ context,
+ scopes
+ );
+ return beanValidator;
+ }
+ }
}
1
0
r2164 - in trunk: jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta
by tchemit@users.nuiton.org 25 Jan '11
by tchemit@users.nuiton.org 25 Jan '11
25 Jan '11
Author: tchemit
Date: 2011-01-25 13:03:38 +0100 (Tue, 25 Jan 2011)
New Revision: 2164
Url: http://nuiton.org/repositories/revision/jaxx/2164
Log:
add license headers
Modified:
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java
Modified: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml 2011-01-25 12:03:38 UTC (rev 2164)
@@ -1,3 +1,27 @@
+<!--
+ #%L
+ JAXX :: Tutorial Validation
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
Modified: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml 2011-01-25 12:03:38 UTC (rev 2164)
@@ -1,3 +1,27 @@
+<!--
+ #%L
+ JAXX :: Tutorial Validation
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
Modified: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml 2011-01-25 12:03:38 UTC (rev 2164)
@@ -1,3 +1,27 @@
+<!--
+ #%L
+ JAXX :: Tutorial Validation
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
Modified: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml 2011-01-25 12:03:38 UTC (rev 2164)
@@ -1,3 +1,27 @@
+<!--
+ #%L
+ JAXX :: Tutorial Validation
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
Modified: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml 2011-01-25 12:03:38 UTC (rev 2164)
@@ -1,3 +1,27 @@
+<!--
+ #%L
+ JAXX :: Tutorial Validation
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2011 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java 2011-01-25 11:58:22 UTC (rev 2163)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java 2011-01-25 12:03:38 UTC (rev 2164)
@@ -1,3 +1,27 @@
+/*
+ * #%L
+ * JAXX :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package jaxx.runtime.validator.swing.meta;
import java.lang.annotation.ElementType;
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java 2011-01-25 11:58:22 UTC (rev 2163)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java 2011-01-25 12:03:38 UTC (rev 2164)
@@ -1,3 +1,27 @@
+/*
+ * #%L
+ * JAXX :: Validator
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
package jaxx.runtime.validator.swing.meta;
import java.lang.annotation.ElementType;
1
0
Author: tchemit
Date: 2011-01-25 12:58:22 +0100 (Tue, 25 Jan 2011)
New Revision: 2163
Url: http://nuiton.org/repositories/revision/jaxx/2163
Log:
Evolution #1178: Use nuiton-validator 2.0
Evolution #1240: Review the validation api
Evolution #1239: Add a validation tutorial
Added:
trunk/jaxx-tutorial-validation/
trunk/jaxx-tutorial-validation/LICENSE.txt
trunk/jaxx-tutorial-validation/README.txt
trunk/jaxx-tutorial-validation/changelog.txt
trunk/jaxx-tutorial-validation/pom.xml
trunk/jaxx-tutorial-validation/src/
trunk/jaxx-tutorial-validation/src/license/
trunk/jaxx-tutorial-validation/src/license/THIRD-PARTY.properties
trunk/jaxx-tutorial-validation/src/main/
trunk/jaxx-tutorial-validation/src/main/filters/
trunk/jaxx-tutorial-validation/src/main/filters/jaxx-demo.properties
trunk/jaxx-tutorial-validation/src/main/java/
trunk/jaxx-tutorial-validation/src/main/java/jaxx/
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/DemoConfig.java
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/RunDemo.java
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/AbstractDemoBean.java
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/Movie.java
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/People.java
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.css
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.jaxx
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUIHandler.java
trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/ValidationTableDemo.jaxx
trunk/jaxx-tutorial-validation/src/main/resources/
trunk/jaxx-tutorial-validation/src/main/resources/i18n/
trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_en_GB.properties
trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_fr_FR.properties
trunk/jaxx-tutorial-validation/src/main/resources/icons/
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-about.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-accept.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-block.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-close.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-config.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-exit.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-fullscreen.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-help.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-i18n-fr.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-i18n-uk.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-leave-fullscreen.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-reload-application.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-reload-ui.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-show-help.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-site.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/action-translate.png
trunk/jaxx-tutorial-validation/src/main/resources/icons/jaxx.png
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml
trunk/jaxx-tutorial-validation/src/main/resources/log4j.properties
trunk/jaxx-tutorial-validation/src/site/
trunk/jaxx-tutorial-validation/src/site/rst/
trunk/jaxx-tutorial-validation/src/site/rst/images/
trunk/jaxx-tutorial-validation/src/site/rst/images/webstart.gif
trunk/jaxx-tutorial-validation/src/site/rst/index.rst
trunk/jaxx-tutorial-validation/src/site/site_fr.xml
Modified:
trunk/jaxx-demo/pom.xml
trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java
trunk/jaxx-tutorial/pom.xml
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2011-01-25 11:57:12 UTC (rev 2162)
+++ trunk/jaxx-demo/pom.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -101,9 +101,8 @@
<!-- test dependencies -->
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-validator</artifactId>
- <version>${project.version}</version>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-validator</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
Modified: trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java
===================================================================
--- trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java 2011-01-25 11:57:12 UTC (rev 2162)
+++ trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java 2011-01-25 11:58:22 UTC (rev 2163)
@@ -27,37 +27,57 @@
import jaxx.demo.entities.Identity;
import jaxx.demo.entities.Model;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.validator.AbstractValidatorDetectorTest;
+import org.nuiton.validator.NuitonValidator;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.ValidatorTestHelper;
+import org.nuiton.validator.xwork2.XWork2NuitonValidatorProvider;
import java.io.File;
import java.util.Iterator;
import java.util.SortedSet;
-import jaxx.runtime.validator.AbstractBeanValidatorDetectorTest;
-import jaxx.runtime.validator.BeanValidator;
-import org.junit.BeforeClass;
-import static org.junit.Assert.*;
-/**
- *
- * @author tchemit <chemit(a)codelutin.com>
- */
-public class BeanValidatorDetectorTest extends AbstractBeanValidatorDetectorTest {
+/** @author tchemit <chemit(a)codelutin.com> */
+public class BeanValidatorDetectorTest extends AbstractValidatorDetectorTest {
- @BeforeClass
- public static void setUpClass() throws Exception {
- AbstractBeanValidatorDetectorTest.setUpClass();
- }
-
public BeanValidatorDetectorTest() {
// prefer do tests on target copy instead of original files
- super(new File(basedir, "target" + File.separator + "classes"), Identity.class, Model.class);
+ super(XWork2NuitonValidatorProvider.PROVIDER_NAME);
}
+ @Test
+ public void detectAllValidators() {
+ SortedSet<NuitonValidator<?>> result;
+ NuitonValidator<?> validator;
+ Iterator<NuitonValidator<?>> iterator;
+
+ // test with all context and all scopes : 2 validators (Identity+ Model)
+
+ result = detectValidators(Identity.class, Model.class);
+
+ Assert.assertNotNull(result);
+ Assert.assertEquals(2, result.size());
+
+
+ iterator = result.iterator();
+ validator = iterator.next();
+
+ ValidatorTestHelper.assertValidatorModel(validator, null, Identity.class, NuitonValidatorScope.values());
+ ValidatorTestHelper.assertValidatorEffectiveScopes(validator, NuitonValidatorScope.ERROR, NuitonValidatorScope.WARNING, NuitonValidatorScope.INFO);
+// ValidatorTestHelper.assertValidatorEffectiveFields(validator, NuitonValidatorScope.ERROR, Person.PROPERTY_NAME, Person.PROPERTY_FIRSTNAME);
+// ValidatorTestHelper.assertValidatorEffectiveFields(validator, NuitonValidatorScope.WARNING, Person.PROPERTY_PET);
+
+ validator = iterator.next();
+ ValidatorTestHelper.assertValidatorModel(validator, null, Model.class, NuitonValidatorScope.values());
+ ValidatorTestHelper.assertValidatorEffectiveScopes(validator, NuitonValidatorScope.ERROR, NuitonValidatorScope.WARNING, NuitonValidatorScope.INFO);
+// ValidatorTestHelper.assertValidatorEffectiveFields(validator, NuitonValidatorScope.ERROR, Pet.PROPERTY_NAME);
+
+ }
+
@Override
- protected void assertDetect(SortedSet<BeanValidator<?>> validators) {
- assertFalse(validators.isEmpty());
- assertEquals(2, validators.size());
- Iterator<BeanValidator<?>> itrV = validators.iterator();
- assertValidator(Identity.class, null, itrV.next());
- assertValidator(Model.class, null, itrV.next());
+ protected File getRootDirectory(File basedir) {
+ return new File(basedir, "target" + File.separator + "classes");
}
}
Modified: trunk/jaxx-tutorial/pom.xml
===================================================================
--- trunk/jaxx-tutorial/pom.xml 2011-01-25 11:57:12 UTC (rev 2162)
+++ trunk/jaxx-tutorial/pom.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -47,6 +47,7 @@
<module>../jaxx-tutorial-css</module>
<module>../jaxx-tutorial-databinding</module>
<module>../jaxx-tutorial-config</module>
+ <module>../jaxx-tutorial-validation</module>
</modules>
<!-- ************************************************************* -->
@@ -111,7 +112,7 @@
<plugin>
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
- <version>2.0.1</version>
+ <version>2.1</version>
</plugin>
</plugins>
Property changes on: trunk/jaxx-tutorial-validation
___________________________________________________________________
Added: svn:ignore
+ target
*.ipr
*.iml
*.iws
.project
.classpath
.settings
*.log
Added: trunk/jaxx-tutorial-validation/LICENSE.txt
===================================================================
--- trunk/jaxx-tutorial-validation/LICENSE.txt (rev 0)
+++ trunk/jaxx-tutorial-validation/LICENSE.txt 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Property changes on: trunk/jaxx-tutorial-validation/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/README.txt
===================================================================
--- trunk/jaxx-tutorial-validation/README.txt (rev 0)
+++ trunk/jaxx-tutorial-validation/README.txt 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Property changes on: trunk/jaxx-tutorial-validation/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/changelog.txt
===================================================================
--- trunk/jaxx-tutorial-validation/changelog.txt (rev 0)
+++ trunk/jaxx-tutorial-validation/changelog.txt 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,2 @@
+1.7.2
+ * 20091003 [chemit] - initial release (insparated from obsolote jaxx-example module)
Property changes on: trunk/jaxx-tutorial-validation/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/pom.xml
===================================================================
--- trunk/jaxx-tutorial-validation/pom.xml (rev 0)
+++ trunk/jaxx-tutorial-validation/pom.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,326 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ JAXX :: Demo
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton.jaxx</groupId>
+ <artifactId>jaxx-tutorial</artifactId>
+ <version>2.3-SNAPSHOT</version>
+ <relativePath>../jaxx-tutorial</relativePath>
+ </parent>
+
+ <groupId>org.nuiton.jaxx</groupId>
+ <artifactId>jaxx-tutorial-validation</artifactId>
+
+ <dependencies>
+
+ <!-- JAXX dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-validator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-widgets</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>JAXX :: Tutorial Validation</name>
+ <description>JAXX Tutorial Validation</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <!-- Jaxx version -->
+
+ <jaxxVersion>${project.version}</jaxxVersion>
+
+ <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath>
+ <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>
+ <jaxx.autoImportCss>true</jaxx.autoImportCss>
+
+ <!-- main class to run -->
+
+ <maven.jar.main.class>jaxx.demo.validation.RunDemo</maven.jar.main.class>
+
+ <!-- compiler configuration -->
+
+ <maven.compiler.source>1.6</maven.compiler.source>
+ <maven.compiler.source>1.6</maven.compiler.source>
+
+ <!-- default encoding -->
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
+ <!-- to generate jnlp launcher while releasing jaxx -->
+ <jnlp.skip>false</jnlp.skip>
+
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+
+ <!-- generate license bundled files -->
+ <license.generateBundle>true</license.generateBundle>
+
+ </properties>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/filters</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>jaxx-demo.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <configuration>
+ <treateDefaultEntry>true</treateDefaultEntry>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java/</basedir>
+ </entry>
+ </entries>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ <goal>bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <outputDirectory>target/lib</outputDirectory>
+ <silent>true</silent>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-licenses</id>
+ <goals>
+ <goal>update-project-license</goal>
+ <goal>add-third-party</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-jnlp-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <!-- key store secrets availables -->
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-helper-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>get-keystore</id>
+ <goals>
+ <goal>share-server-secret</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <serverId>codelutin-keystore</serverId>
+ <privateKeyOut>keystorepath</privateKeyOut>
+ <passwordOut>keystorepass</passwordOut>
+ <usernameOut>keyalias</usernameOut>
+ <passphraseOut>keypass</passphraseOut>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- make webstart -->
+ <plugin>
+ <groupId>org.nuiton.thirdparty</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-jnlp</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jnlp-inline</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.thirdparty</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <version>${webstartPluginVersion}</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ <profile>
+ <id>staging-site-profile</id>
+ <activation>
+ <property>
+ <name>stagingSite</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <properties>
+ <jnlp.codebase>
+ http://maven-site.liosalfar/jaxx/jaxx-demo/jnlp
+ </jnlp.codebase>
+ </properties>
+ </profile>
+
+ </profiles>
+
+</project>
Property changes on: trunk/jaxx-tutorial-validation/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/jaxx-tutorial-validation/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/jaxx-tutorial-validation/src/license/THIRD-PARTY.properties 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,17 @@
+# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD License
+# - Lesser General Public License (LGPL)
+# - Lesser General Public License (LGPL) v 3.0
+# - Sun Microsystems, Inc. Binary Code License Agreement for the JDK 5.0
+# - The Apache Software License, Version 2.0
+# - The OpenSymphony Software License 1.1
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Dec 30 09:35:11 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+javax.help--javahelp--2.0.02--jar=Sun Microsystems, Inc. Binary Code License Agreement for the JDK 5.0
+opensymphony--ognl--2.6.11--jar=The OpenSymphony Software License 1.1
Property changes on: trunk/jaxx-tutorial-validation/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/jaxx-tutorial-validation/src/main/filters/jaxx-demo.properties (from rev 2156, trunk/jaxx-demo/src/main/filters/jaxx-demo.properties)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/filters/jaxx-demo.properties (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/filters/jaxx-demo.properties 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,34 @@
+###
+# #%L
+# JAXX :: Demo
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2008 - 2010 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+application.name=${project.name}
+application.version=${project.version}
+application.site.url=http://maven-site.nuiton.org/jaxx/jaxx-demo
+application.icon.path=/icons/jaxx.png
+application.license.path=META-INF/${project.artifactId}-LICENSE.txt
+application.third-party.path=META-INF/${project.artifactId}-THIRD-PARTY.txt
+#licence.name=${project.licenses[0].license.name}
+#licence.url=${project.licenses.0.url}
+application.organisation.name=${project.organization.name}
+application.organisation.url=${project.organization.url}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/DemoConfig.java (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/DemoConfig.java (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/DemoConfig.java 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,296 @@
+/*
+ * #%L
+ * JAXX :: Demo
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package jaxx.demo.validation;
+
+import jaxx.runtime.JAXXUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.Version;
+import org.nuiton.util.VersionUtil;
+
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+import java.util.Properties;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * La configuration de l'application.
+ * <p/>
+ * Il s'agit de l'objet partagé par toutes les démos.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.7.2
+ */
+public class DemoConfig extends ApplicationConfig {
+
+ /** Logger */
+ static private Log log = LogFactory.getLog(DemoConfig.class);
+
+ /**
+ * le fichier de configuration de l'application avec les informations sur
+ * le projet (version, license,...) et la configuration des ui (icons, ...)
+ */
+ public static final String APPLICATION_PROPERTIES = "/jaxx-demo.properties";
+
+ public static final String PROPERTY_FULLSCREEN = "fullscreen";
+
+ public static final String PROPERTY_LOCALE = "locale";
+
+ public static final String PROPERTY_FONT_SIZE = "fontSize";
+
+ public DemoConfig() {
+
+ setConfigFileName(Option.CONFIG_FILE.defaultValue);
+
+ // chargement de la configuration interne
+
+ InputStream stream =
+ getClass().getResourceAsStream(APPLICATION_PROPERTIES);
+
+ Properties p = new Properties();
+ try {
+ p.load(stream);
+ for (Object k : p.keySet()) {
+ String key = k + "";
+ Object value = p.get(k);
+ if (log.isDebugEnabled()) {
+ log.debug("install properties " + k + " : " + value);
+ }
+ setDefaultOption(key, "" + value);
+ }
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ for (Option o : Option.values()) {
+ setDefaultOption(o.key, o.defaultValue);
+ }
+
+ // on supprime le stamp de snapshot s'il existe
+ String sVersion = VersionUtil.removeSnapshot(
+ getOption("application.version"));
+ Version version = VersionUtil.valueOf(sVersion);
+ setDefaultOption("version", version.getVersion());
+
+ installSaveUserAction(PROPERTY_FULLSCREEN,
+ PROPERTY_FONT_SIZE,
+ PROPERTY_LOCALE);
+ }
+
+ public String getCopyrightText() {
+ return "Version " + getVersion() + " Codelutin @ 2008-2009";
+ }
+
+ /** @return la version de l'application. */
+ public Version getVersion() {
+ Version option = getOption(Version.class, "version");
+ return option;
+ }
+
+ public boolean isFullScreen() {
+ Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
+ return result != null && result;
+ }
+
+ public Locale getLocale() {
+ Locale result = getOption(Locale.class, Option.LOCALE.key);
+ return result;
+ }
+
+ public Float getFontSize() {
+ Float result = getOption(Float.class, Option.FONT_SIZE.key);
+ return result;
+ }
+
+ public void setFullscreen(boolean fullscreen) {
+ Object oldValue = null;
+ setOption(Option.FULL_SCREEN.key, fullscreen + "");
+ firePropertyChange(PROPERTY_FULLSCREEN, oldValue, fullscreen);
+ }
+
+ public void setLocale(Locale newLocale) {
+ setOption(Option.LOCALE.key, newLocale.toString());
+ firePropertyChange(PROPERTY_LOCALE, null, newLocale);
+ }
+
+ public void setFontSize(Float newFontSize) {
+ Float oldValue = getFontSize();
+ if (log.isDebugEnabled()) {
+ log.debug("changing font-size to " + newFontSize);
+ }
+ setOption(Option.FONT_SIZE.key, newFontSize.toString());
+ firePropertyChange(PROPERTY_FONT_SIZE, oldValue, newFontSize);
+ }
+
+ /**
+ * Save configuration, in user home directory using the
+ * {@link #getConfigFileName}. Default, env and commande line note saved
+ */
+ public void saveForUser() {
+ // shoudl we never save any conf ?
+ super.saveForUser();
+ }
+
+ public static final String[] DEFAULT_JAXX_PCS = {
+ PROPERTY_FULLSCREEN,
+ PROPERTY_LOCALE,
+ PROPERTY_FONT_SIZE,
+ ADJUSTING_PROPERTY
+ };
+
+ public void removeJaxxPropertyChangeListener() {
+ PropertyChangeListener[] toRemove;
+ toRemove = JAXXUtil.findJaxxPropertyChangeListener(
+ DEFAULT_JAXX_PCS,
+ getPropertyChangeListeners());
+ if (toRemove == null || toRemove.length == 0) {
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("before remove : " + getPropertyChangeListeners().length);
+ log.debug("toRemove : " + toRemove.length);
+ }
+ for (PropertyChangeListener listener : toRemove) {
+ removePropertyChangeListener(listener);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("after remove : " + getPropertyChangeListeners().length);
+ }
+ }
+
+ //////////////////////////////////////////////////
+ // Toutes les options disponibles
+ //////////////////////////////////////////////////
+
+ public enum Option implements OptionDef {
+
+ CONFIG_FILE(
+ CONFIG_FILE_NAME,
+ _("jaxxdemo.config.configFileName.description"),
+ "jaxxdemo",
+ String.class,
+ true,
+ true),
+ FULL_SCREEN(
+ "ui.fullscreen",
+ _("jaxxdemo.config.ui.fullscreen"),
+ "false",
+ Boolean.class,
+ false,
+ false),
+ LOCALE(
+ "ui." + PROPERTY_LOCALE,
+ _("jaxxdemo.config.ui.locale"),
+ Locale.FRANCE.toString(),
+ Locale.class,
+ false,
+ false),
+ FONT_SIZE(
+ "ui." + PROPERTY_FONT_SIZE,
+ _("jaxxdemo.config.ui.fontSize"),
+ "10f",
+ Float.class,
+ false,
+ false);
+
+ public final String key;
+
+ public final String description;
+
+ public String defaultValue;
+
+ public final Class<?> type;
+
+ public boolean _transient;
+
+ public boolean _final;
+
+ Option(String key,
+ String description,
+ String defaultValue,
+ Class<?> type,
+ boolean _transient,
+ boolean _final) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public void setTransient(boolean _transient) {
+ this._transient = _transient;
+ }
+
+ @Override
+ public void setFinal(boolean _final) {
+ this._final = _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+
+
+ }
+}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/RunDemo.java (from rev 2156, trunk/jaxx-tutorial-config/src/main/java/jaxx/demo/config/RunDemo.java)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/RunDemo.java (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/RunDemo.java 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,270 @@
+/*
+ * #%L
+ * JAXX :: Tutorial Config
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package jaxx.demo.validation;
+
+import jaxx.demo.validation.ui.DemoUI;
+import jaxx.demo.validation.ui.DemoUIHandler;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.context.DefaultApplicationContext;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.editor.config.ConfigUIHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+import org.nuiton.util.StringUtil;
+
+import javax.swing.JOptionPane;
+import java.util.Arrays;
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.2
+ */
+public class RunDemo {
+
+ /** Logger */
+ private static Log log = LogFactory.getLog(RunDemo.class);
+
+ /** The singleton instance of the main context */
+ protected static DefaultApplicationContext context;
+
+ public static void main(String[] args) {
+
+ long startingTime = System.nanoTime();
+ log.info("JAXX Demo start at " + new Date() + " args: " + Arrays.toString(args));
+
+ try {
+
+ // init root context
+ // to enable javassist on webstart, must remove any securityManager,
+ // see if this can be dangerous (should not be since jnlp is signed ?)
+ // moreover it speeds up the loading :)
+ System.setSecurityManager(null);
+
+ long t0 = System.nanoTime();
+
+ I18n.init(new DefaultI18nInitializer("jaxx-tutorial-validation-i18n"), null);
+
+ Runtime.getRuntime().addShutdownHook(new ShutdownHook());
+
+ // init root context
+ DefaultApplicationContext rootContext = init();
+
+ // share a tree helper
+// rootContext.setContextValue(new DemoTreeHelper(new DemoDataProvider()));
+
+ // init config
+ DemoConfig config = new DemoConfig();
+ config.parse(args);
+
+ // share the config
+ rootContext.setContextValue(config);
+
+ // init decorator provider
+// DecoratorProvider p = new DemoDecoratorProvider();
+
+ // share the decorator provider
+// rootContext.setContextValue(p);
+
+ long t00 = System.nanoTime();
+
+ // init i18n
+ I18n.setDefaultLocale(config.getLocale());
+
+ log.info("language : " + config.getLocale());
+
+ if (log.isDebugEnabled()) {
+ log.debug("i18n loading time : " + StringUtil.convertTime(t00, System.nanoTime()));
+ }
+
+ log.info(_("jaxxdemo.message.config.loaded", config.getVersion()));
+
+ // prepare ui look&feel and load ui properties
+
+ try {
+ SwingUtil.initNimbusLoookAndFeel();
+ } catch (Exception e) {
+ // could not find nimbus look-and-feel
+ log.warn(_("jaxxdemo.warning.nimbus.landf"));
+ } catch (Throwable e) {
+ log.warn(_("jaxxdemo.warning.no.ui"));
+
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("init done in " + StringUtil.convertTime(t0, System.nanoTime()));
+ }
+
+ log.info(_("jaxxdemo.init.context.done", StringUtil.convertTime(startingTime, System.nanoTime())));
+
+ // on affiche l'ui principale
+ DemoUIHandler handler = new DemoUIHandler();
+
+ DemoUI ui = handler.initUI(rootContext, config);
+
+ log.info(_("jaxxdemo.init.ui.done"));
+
+ handler.displayUI(ui);
+
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ ErrorDialogUI.showError(e);
+ System.exit(1);
+ }
+ }
+
+ public static void buildConfigUI(ConfigUIHelper helper) {
+
+ Runnable reloadUICallback = new Runnable() {
+
+ @Override
+ public void run() {
+ if (log.isInfoEnabled()) {
+ log.info("will say Hello world");
+ }
+ JOptionPane.showMessageDialog(null, "Hello World!");
+ }
+ };
+
+ Runnable reloadApplicationCallback = new Runnable() {
+
+ @Override
+ public void run() {
+ if (log.isInfoEnabled()) {
+ log.info("will reload appplication");
+ }
+ if (log.isInfoEnabled()) {
+ log.info("will say Good Bye world");
+ }
+ JOptionPane.showMessageDialog(null, "Good Bye World!");
+ }
+ };
+
+ helper.registerCallBack("ui",
+ n_("demo.action.reload.ui"),
+ SwingUtil.createActionIcon("reload-ui"),
+ reloadUICallback);
+
+ helper.registerCallBack("application",
+ n_("demo.action.reload.application"),
+ SwingUtil.createActionIcon("reload-application"),
+ reloadApplicationCallback);
+
+ // categorie repertoires
+
+ helper.addCategory(n_("jaxxdemo.config.category.directories"),
+ n_("jaxxdemo.config.category.directories.description"));
+
+ helper.addOption(DemoConfig.Option.CONFIG_FILE);
+
+ // others
+ helper.addCategory(n_("jaxxdemo.config.category.other"),
+ n_("jaxxdemo.config.category.other.description"));
+
+ helper.addOption(DemoConfig.Option.FULL_SCREEN);
+ helper.setOptionPropertyName(DemoConfig.PROPERTY_FULLSCREEN);
+ helper.setOptionCallBack("ui");
+
+ helper.addOption(DemoConfig.Option.FONT_SIZE);
+ helper.setOptionPropertyName(DemoConfig.PROPERTY_FONT_SIZE);
+ helper.setOptionCallBack("application");
+
+ helper.addOption(DemoConfig.Option.LOCALE);
+ helper.setOptionPropertyName(DemoConfig.PROPERTY_LOCALE);
+ helper.setOptionCallBack("ui");
+
+ helper.buildUI(new JAXXInitialContext(),
+ "jaxxdemo.config.category.other");
+
+ }
+
+ /**
+ * @return <code>true</code> si le context a été initialisé via la méthode
+ * {@link #init()}, <ocde>false</code> autrement.
+ */
+ protected static boolean isInit() {
+ return context != null;
+ }
+
+ /**
+ * Permet l'initialisation du contexte applicatif et positionne
+ * l'context partagée.
+ * <p/>
+ * Note : Cette méthode ne peut être appelée qu'une seule fois.
+ *
+ * @return l'context partagée
+ * @throws IllegalStateException si un contexte applicatif a déja été positionné.
+ */
+ protected static synchronized DefaultApplicationContext init() throws IllegalStateException {
+ if (isInit()) {
+ throw new IllegalStateException("there is an already application context registred.");
+ }
+ context = new DefaultApplicationContext();
+ return context;
+ }
+
+ /**
+ * Récupération du contexte applicatif.
+ *
+ * @return l'context partagé du contexte.
+ * @throws IllegalStateException si le contexte n'a pas été initialisé via
+ * la méthode {@link #init()}
+ */
+ public static DefaultApplicationContext get() throws IllegalStateException {
+ if (!isInit()) {
+ throw new IllegalStateException("no application context registred.");
+ }
+ return context;
+ }
+
+ protected static class ShutdownHook extends Thread {
+
+ public ShutdownHook() {
+ super("shutdown JAXXDemo");
+ }
+
+ @Override
+ public void run() {
+ try {
+ super.run();
+
+ // force to kill main thread
+
+ log.info(_("jaxxdemo.init.closed", new Date()));
+ Runtime.getRuntime().halt(0);
+ } catch (Exception ex) {
+ log.error("error while closing " + ex.getMessage(), ex);
+ Runtime.getRuntime().halt(1);
+ }
+ }
+ }
+
+}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/AbstractDemoBean.java (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/entities/AbstractDemoBean.java)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/AbstractDemoBean.java (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/AbstractDemoBean.java 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,106 @@
+/*
+ * #%L
+ * JAXX :: Demo
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package jaxx.demo.validation.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Abstract demo bean.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2
+ */
+public abstract class AbstractDemoBean implements Serializable {
+
+ static {
+ n_("jaxxdemo.common.id");
+ n_("jaxxdemo.common.image");
+ }
+
+ public static final String PROPERTY_ID = "id";
+
+ public static final String PROPERTY_IMAGE = "image";
+
+ protected String id;
+
+ protected String image;
+
+ protected final PropertyChangeSupport p;
+
+ public AbstractDemoBean() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ protected AbstractDemoBean(String id, String image) {
+ this();
+ this.id = id;
+ this.image = image;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setId(String id) {
+ String old = this.id;
+ this.id = id;
+ firePropertyChange(PROPERTY_ID, old, id);
+ }
+
+
+ public void setImage(String image) {
+ Object oldValue = this.image;
+ this.image = image;
+ firePropertyChange(PROPERTY_IMAGE, oldValue, image);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ p.firePropertyChange(propertyName, oldValue, newValue);
+ }
+}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/Movie.java (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/entities/Movie.java)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/Movie.java (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/Movie.java 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,141 @@
+/*
+ * #%L
+ * JAXX :: Demo
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package jaxx.demo.validation.model;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.7.2
+ */
+public class Movie extends AbstractDemoBean {
+
+ static {
+ n_("jaxxdemo.common.movie");
+ n_("jaxxdemo.common.title");
+ n_("jaxxdemo.common.year");
+ n_("jaxxdemo.common.actors");
+ }
+
+ protected String title;
+
+ protected int year;
+
+ protected List<People> actors;
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String PROPERTY_ACTORS = "actors";
+
+ private static final String PROPERTY_TITLE = "title";
+
+ private static final String PROPERTY_YEAR = "year";
+
+ private static final String PROPERTY_IMAGE = "image";
+
+ public Movie(String id, String title, int year, String image) {
+ super(id, image);
+ this.title = title;
+ this.year = year;
+ actors = new ArrayList<People>();
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setActors(List<People> actors) {
+ Object oldValue = this.actors;
+ this.actors = actors;
+ firePropertyChange(PROPERTY_ACTORS, null, actors);
+ }
+
+ public void setTitle(String title) {
+ Object oldValue = this.title;
+ this.title = title;
+ firePropertyChange(PROPERTY_TITLE, oldValue, title);
+ }
+
+ public void setYear(int year) {
+ Object oldValue = this.year;
+ this.year = year;
+ firePropertyChange(PROPERTY_YEAR, oldValue, year);
+ }
+
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ firePropertyChange(PROPERTY_ACTORS, null, actors);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Movie other = (Movie) obj;
+ return !(id == null ? other.id != null : !id.equals(other.id));
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append(PROPERTY_ID, id);
+ b.append(PROPERTY_TITLE, title);
+ b.append(PROPERTY_IMAGE, image);
+ b.append(PROPERTY_YEAR, year);
+ b.append(PROPERTY_ACTORS, actors);
+ return b.toString();
+ }
+}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/People.java (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/entities/People.java)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/People.java (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/model/People.java 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,137 @@
+/*
+ * #%L
+ * JAXX :: Demo
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package jaxx.demo.validation.model;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.7.2
+ */
+public class People extends AbstractDemoBean {
+
+ static {
+ n_("jaxxdemo.common.people");
+ n_("jaxxdemo.common.firstName");
+ n_("jaxxdemo.common.lastName");
+ n_("jaxxdemo.common.age");
+ }
+
+ public static final String PROPERTY_FIRST_NAME = "firstName";
+
+ public static final String PROPERTY_LAST_NAME = "lastName";
+
+ public static final String PROPERTY_AGE = "age";
+
+ protected String firstName;
+
+ protected String lastName;
+
+ protected int age;
+
+ private static final long serialVersionUID = 1L;
+
+ public People() {
+ }
+
+ public People(String id,
+ String firstName,
+ String lastName,
+ int age,
+ String image) {
+ super(id, image);
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setAge(int age) {
+ int old = this.age;
+ this.age = age;
+ firePropertyChange(PROPERTY_AGE, old, age);
+ }
+
+ public void setFirstName(String firstName) {
+ String old = this.firstName;
+ this.firstName = firstName;
+ firePropertyChange(PROPERTY_FIRST_NAME, old, firstName);
+ }
+
+ public void setLastName(String lastName) {
+ String old = this.lastName;
+ this.lastName = lastName;
+ firePropertyChange(PROPERTY_LAST_NAME, old, lastName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ People other = (People) obj;
+ return !(id == null ? other.id != null : !id.equals(other.id));
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append(PROPERTY_ID, id);
+ b.append(PROPERTY_FIRST_NAME, firstName);
+ b.append(PROPERTY_LAST_NAME, lastName);
+ b.append(PROPERTY_IMAGE, image);
+ b.append(PROPERTY_AGE, age);
+ return b.toString();
+ }
+}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.css (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.css (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.css 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,144 @@
+/*
+ * #%L
+ * JAXX :: Demo
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+JToolBar {
+ borderPainted:false;
+ floatable:false;
+ opaque:false;
+}
+
+#mainFrame {
+ title:"JAXX Demo";
+ iconImage:{jaxx.runtime.SwingUtil.createIcon(getConfig().getOption("application.icon.path")).getImage()};
+ undecorated:{getConfig().isFullScreen()};
+}
+
+#menu {
+ _help:{"ui.main.menu"};
+}
+
+#menuFile {
+ text:"jaxxdemo.menu.file";
+ mnemonic:F;
+ _help:{"ui.main.menu.file"};
+}
+
+#menuFileConfiguration {
+ text:"jaxxdemo.action.configuration";
+ toolTipText:"jaxxdemo.action.configuration.tip";
+ actionIcon:"config";
+ mnemonic:C;
+ _help:{"ui.main.menu.file.configuration"};
+}
+
+#menuFileLanguage {
+ text:"jaxxdemo.menu.file.locale";
+ toolTipText:"jaxxdemo.menu.file.locale";
+ actionIcon:"translate";
+ mnemonic:C;
+ _help:{"ui.main.menu.file.locale"};
+}
+
+
+#menuFileLanguageFR {
+ text:"jaxxdemo.action.locale.fr";
+ toolTipText:"jaxxdemo.action.locale.fr.tip";
+ actionIcon:"i18n-fr";
+ enabled:{!acceptLocale(getConfig().getLocale(), "fr_FR")};
+ mnemonic:F;
+ _help:{"ui.main.menu.file.locale.fr"};
+}
+
+#menuFileLanguageUK {
+ text:"jaxxdemo.action.locale.uk";
+ toolTipText:"jaxxdemo.action.locale.uk.tip";
+ actionIcon:"i18n-uk";
+ enabled:{!acceptLocale(getConfig().getLocale(), "en_GB")};
+ mnemonic:U;
+ _help:{"ui.main.menu.file.locale.uk"};
+}
+
+#menuFileFullscreen {
+ text:"jaxxdemo.action.fullscreen";
+ toolTipText:"jaxxdemo.action.fullscreen.tip";
+ actionIcon:"fullscreen";
+ mnemonic:P;
+ visible:{!isUndecorated()};
+ _help:{"ui.main.menu.file.fullscreen"};
+}
+
+#menuFileNormalscreen {
+ text:"jaxxdemo.action.normalscreen";
+ toolTipText:"jaxxdemo.action.normalscreen.tip";
+ actionIcon:"leave-fullscreen";
+ mnemonic:N;
+ visible:{isUndecorated()};
+_help:{"ui.main.menu.file.leave-fullscreen"};
+}
+
+#menuFileExit {
+ text:"jaxxdemo.action.exit";
+ toolTipText:"jaxxdemo.action.exit.tip";
+ actionIcon:"exit";
+ mnemonic:X;
+ _help:{"ui.main.menu.file.exit"};
+}
+
+#menuHelp {
+ text:"jaxxdemo.menu.help";
+ mnemonic:e;
+ _help:{"ui.main.menu.help"};
+}
+
+#menuHelpHelp {
+ text:"jaxxdemo.action.help";
+ toolTipText:"jaxxdemo.action.help.tip";
+ actionIcon:"help";
+ mnemonic:e;
+ _help:{"ui.main.menu.help.help"};
+}
+
+#menuHelpSite {
+ text:"jaxxdemo.action.site";
+ toolTipText:"jaxxdemo.action.site.tip";
+ actionIcon:"site";
+ mnemonic:s;
+ _help:{"ui.main.menu.help.site"};
+}
+
+#menuHelpAbout {
+ text:"jaxxdemo.action.about";
+ toolTipText:"jaxxdemo.action.about.tip";
+ actionIcon:"about";
+ mnemonic:A;
+ _help:{"ui.main.menu.help.about"};
+}
+
+#showHelp {
+ toolTipText:"jaxxdemo.action.showHelp.tip";
+ actionIcon:"show-help";
+ borderPainted:false;
+ visible:true;
+}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.jaxx (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.jaxx (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUI.jaxx 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,97 @@
+<!--
+ #%L
+ JAXX :: Demo
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+
+<JFrame id='mainFrame' width='1024' height='800'
+ decorator='help'
+ onWindowClosing='getHandler().close(mainFrame)'>
+
+ <import>
+ jaxx.demo.validation.*;
+ jaxx.runtime.swing.CardLayout2
+ jaxx.runtime.swing.StatusMessagePanel
+
+ java.util.Locale
+ </import>
+
+ <CardLayout2 id='contentLayout'/>
+
+ <DemoConfig id='config' initializer='getContextValue(DemoConfig.class)'/>
+
+ <DemoUIHandler id='handler'
+ initializer='getContextValue(DemoUIHandler.class)'/>
+
+ <script><![CDATA[
+
+public boolean acceptLocale(Locale l, String expected) {
+ return l !=null && l.toString().equals(expected);
+}
+
+private void $afterCompleteSetup() {
+ getHandler().initUI(this);
+}
+]]>
+ </script>
+
+ <JMenuBar id='menu'>
+
+ <JMenu id='menuFile'>
+ <JMenuItem id='menuFileConfiguration'
+ onActionPerformed="getHandler().showConfig(this)"/>
+ <JMenu id='menuFileLanguage'>
+ <JMenuItem id='menuFileLanguageFR'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/>
+ <JMenuItem id='menuFileLanguageUK'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/>
+ </JMenu>
+ <JSeparator/>
+ <JMenuItem id='menuFileFullscreen'
+ onActionPerformed="getHandler().changeScreen(this, true)"/>
+ <JMenuItem id='menuFileNormalscreen'
+ onActionPerformed="getHandler().changeScreen(this, false)"/>
+ <JSeparator/>
+ <JMenuItem id='menuFileExit'
+ onActionPerformed="getHandler().close(this)"/>
+ </JMenu>
+
+ <JMenu id='menuHelp'>
+ <JMenuItem id='menuHelpHelp'
+ onActionPerformed="getHandler().showHelp(this, null)"/>
+ <JMenuItem id='menuHelpSite'
+ onActionPerformed="getHandler().gotoSite(this)"/>
+ <JMenuItem id='menuHelpAbout'
+ onActionPerformed="getHandler().showAbout(this)"/>
+ </JMenu>
+
+ </JMenuBar>
+
+ <JPanel id='mainPane' layout='{new BorderLayout()}'>
+
+ <ValidationTableDemo id='tableDemo' constraints='BorderLayout.CENTER'/>
+
+ <StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/>
+
+ </JPanel>
+</JFrame>
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUIHandler.java (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUIHandler.java (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/DemoUIHandler.java 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,450 @@
+/*
+ * #%L
+ * JAXX :: Demo
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+/**
+ * *##%
+ * JAXX Demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.validation.ui;
+
+import jaxx.demo.validation.DemoConfig;
+import jaxx.demo.validation.RunDemo;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.context.DefaultApplicationContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.AboutPanel;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.editor.config.ConfigUIHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.i18n.I18n;
+
+import javax.swing.SwingUtilities;
+import java.awt.Desktop;
+import java.net.URL;
+import java.util.Locale;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Le handler de l'ui principale.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @see DemoUI
+ */
+public class DemoUIHandler { //implements JAXXHelp {
+
+ /** Logger */
+ static private Log log = LogFactory.getLog(DemoUIHandler.class);
+
+ static final JAXXContextEntryDef<DemoUI> MAIN_UI_ENTRY_DEF = JAXXUtil.newContextEntryDef("mainui", DemoUI.class);
+
+ /**
+ * Methode pour initialiser l'ui principale sans l'afficher.
+ *
+ * @param rootContext le context applicatif
+ * @param config la configuration a utiliser
+ * @return l'ui instancie et initialisee mais non visible encore
+ */
+ public DemoUI initUI(DefaultApplicationContext rootContext, DemoConfig config) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("fullscreen ? " + config.isFullScreen());
+ }
+
+// DecoratorProvider decoratorProvider = rootContext.getContextValue(DecoratorProvider.class);
+
+ if (!config.getLocale().equals(I18n.getDefaultLocale())) {
+ if (log.isInfoEnabled()) {
+ log.info("re-init I18n with locale " + config.getLocale());
+ }
+ // change i18n language
+ I18n.setDefaultLocale(config.getLocale());
+ // reload decorators
+// decoratorProvider.reload();
+ }
+
+ // create restrict context for ui
+ JAXXInitialContext context = new JAXXInitialContext();
+
+ // share handler
+ context.add(this);
+
+ // share config
+ context.add(rootContext.getContextValue(DemoConfig.class));
+
+ // share a unique DecoratorProvider
+// context.add(decoratorProvider);
+
+ // share a unique DecoratorProviderListCellRenderer
+// context.add(new DecoratorProviderListCellRenderer(decoratorProvider));
+
+ // instanciate ui
+ DemoUI ui = new DemoUI(context);
+
+ // keep it in root context
+ MAIN_UI_ENTRY_DEF.setContextValue(rootContext, ui);
+
+ // synch to error dialog
+ ErrorDialogUI.init(ui);
+
+ // set fullscreen propery on main ui
+ ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(config.isFullScreen() ? ui : null);
+
+ return ui;
+ }
+
+ public void initUI(final DemoUI ui) {
+//
+// // Creation of selection listener to open ui when tree selection change
+// TreeSelectionListener listener = new TreeSelectionListener() {
+// @Override
+// public void valueChanged(TreeSelectionEvent event) {
+// TreePath path = event.getPath();
+// DemoNode node = (DemoNode) path.getLastPathComponent();
+//
+// if (log.isDebugEnabled()) {
+// log.debug("Select node " + node);
+// }
+//
+// if (node == null || node.isStringNode()) {
+//
+// // noeud de présentation, rien a faire
+// return;
+// }
+// showUI(ui, node.getInternalClass());
+// }
+// };
+//
+// JTree tree = ui.getNavigation();
+//
+// ui.getTreeHelper().setUI(tree, true, listener);
+//
+// // auto-expand node when selected
+// SwingUtil.addExpandOnClickListener(tree);
+
+ }
+
+// protected void showUI(DemoUI ui, Class<?> type) {
+//
+// JPanel content = ui.getContent();
+//
+// String constraints = type.getName();
+//
+// log.info("Show for " + constraints);
+//
+// // Verify if instance is existing
+// DemoTab demoContent = getContentIfExist(ui, constraints);
+//
+// if (demoContent == null) {
+//
+// log.info("Will instanciate a new " + constraints);
+// try {
+// // Get constructor
+// Constructor<?> constructor =
+// type.getConstructor(JAXXContext.class);
+//
+// JAXXInitialContext tx =
+// new JAXXInitialContext().add(ui.getDelegateContext());
+//
+// DemoPanel panel = (DemoPanel) constructor.newInstance(tx);
+//
+// log.info("Demo panel to use : " + panel);
+//
+// demoContent = new DemoTab(tx.add("content", panel));
+//
+// } catch (Exception eee) {
+// log.error(eee, eee);
+// ErrorDialogUI.showError(eee);
+// }
+//
+// // Add to content panel
+// content.add(demoContent, constraints);
+// }
+//
+// // show ui
+// ui.getContentLayout().show(content, constraints);
+// }
+
+// Get content if exist in content, else return null
+
+// protected <E extends Component> E getContentIfExist(DemoUI ui, String constraints) {
+// if (log.isDebugEnabled()) {
+// log.debug("Get content if exist " + constraints);
+// }
+// if (!ui.getContentLayout().contains(constraints)) {
+// return null;
+// }
+// return (E) ui.getContentLayout().getComponent(ui.getContent(), constraints);
+// }
+
+ public void displayUI(final DemoUI ui) {
+
+ // show ui after all (in another invocation, tu avoid layout adjustement
+ // to be seen).
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ // show ui
+ ui.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Permet de recharger l'ui principale et de changer de le mode d'affichage.
+ *
+ * @param rootContext le contexte applicatif
+ * @param config la configuration a utiliser
+ */
+ public void reloadUI(DefaultApplicationContext rootContext,
+ DemoConfig config) {
+
+ // scan main ui
+ DemoUI ui = getUI(rootContext);
+
+ if (ui != null) {
+
+ ui.getConfig().removeJaxxPropertyChangeListener();
+
+
+ ErrorDialogUI.init(null);
+
+ ui.dispose();
+
+ ui.setVisible(false);
+
+ MAIN_UI_ENTRY_DEF.removeContextValue(rootContext);
+ }
+
+ ui = initUI(rootContext, config);
+
+ displayUI(ui);
+ }
+
+ /**
+ * Méthode pour changer de mode d'affichage.
+ * <p/>
+ * Si <code>fullscreen</code> est à <code>true</code> alors on passe en
+ * mode console (c'est à dire en mode plein écran exclusif), sinon on
+ * passe en mode fenetré normal.
+ *
+ * @param context l'ui principale de l'application
+ * @param fullscreen le nouvel état requis.
+ */
+ public void changeScreen(JAXXContext context, boolean fullscreen) {
+
+ DemoUI ui = getUI(context);
+
+ // sauvegarde de l'état dans la configuration
+ DemoConfig config = ui.getConfig();
+ config.setFullscreen(fullscreen);
+
+ // rechargement de l'ui
+ reloadUI(RunDemo.get(), config);
+ }
+
+ public void changeLanguage(JAXXContext context, Locale newLocale) {
+
+ DemoUI ui = getUI(context);
+
+ DemoConfig config = ui.getConfig();
+
+ // sauvegarde de la nouvelle locale
+ config.setLocale(newLocale);
+
+ // rechargement de l'ui
+ reloadUI(RunDemo.get(), config);
+ }
+
+ /**
+ * Ferme l'application.
+ *
+ * @param context l'ui principale de l'application
+ */
+ public void close(JAXXContext context) {
+ log.info("JAXX Demo quitting...");
+ try {
+
+ DemoUI ui = getUI(context);
+ ui.dispose();
+ } finally {
+ System.exit(0);
+ }
+ }
+
+ final Runnable reloadUICallback = new Runnable() {
+
+ @Override
+ public void run() {
+ if (log.isInfoEnabled()) {
+ log.info("will reload ui");
+ }
+ DefaultApplicationContext context = RunDemo.get();
+ DemoUI ui = getUI(context);
+ DemoConfig config = ui.getConfig();
+ reloadUI(context, config);
+ }
+ };
+
+ final Runnable reloadApplicationCallback = new Runnable() {
+
+ @Override
+ public void run() {
+ if (log.isInfoEnabled()) {
+ log.info("will reload appplication");
+ }
+ close(RunDemo.get());
+ }
+ };
+
+ public void showConfig(JAXXContext context) {
+ DemoUI ui = getUI(context);
+ DemoConfig config = ui.getConfig();
+
+ ConfigUIHelper helper = new ConfigUIHelper(config);
+
+ helper.registerCallBack("ui",
+ n_("demo.action.reload.ui"),
+ SwingUtil.createActionIcon("reload-ui"),
+ reloadUICallback);
+
+ helper.registerCallBack("application",
+ n_("demo.action.reload.application"),
+ SwingUtil.createActionIcon("reload-application"),
+ reloadApplicationCallback);
+
+ // categorie repertoires
+
+ helper.addCategory(n_("jaxxdemo.config.category.directories"),
+ n_("jaxxdemo.config.category.directories.description"));
+
+ helper.addOption(DemoConfig.Option.CONFIG_FILE);
+
+ // others
+ helper.addCategory(n_("jaxxdemo.config.category.other"),
+ n_("jaxxdemo.config.category.other.description"));
+
+ helper.addOption(DemoConfig.Option.FULL_SCREEN);
+ helper.setOptionPropertyName(DemoConfig.PROPERTY_FULLSCREEN);
+ helper.setOptionCallBack("ui");
+
+ helper.addOption(DemoConfig.Option.FONT_SIZE);
+ helper.setOptionPropertyName(DemoConfig.PROPERTY_FONT_SIZE);
+ helper.setOptionCallBack("application");
+
+ helper.addOption(DemoConfig.Option.LOCALE);
+ helper.setOptionPropertyName(DemoConfig.PROPERTY_LOCALE);
+ helper.setOptionCallBack("ui");
+
+ helper.buildUI(context, "jaxxdemo.config.category.other");
+
+ helper.displayUI(ui, false);
+ }
+
+ public void showHelp(JAXXContext context, String helpId) {
+ log.info(context + " :: " + helpId);
+// DemoUI mainUI = getUI(context);
+// ObserveHelpBroker helpBroker = context.getContextValue(ObserveHelpBroker.class);
+//
+// if (helpId == null) {
+// helpId = helpBroker.getDefaultID();
+// }
+// log.debug("show help " + helpId);
+// mainUI.getHelp().setCurrentID(helpId);
+ }
+
+ public void gotoSite(JAXXContext context) {
+
+ DemoUI ui = getUI(context);
+ DemoConfig config = ui.getConfig();
+
+ URL siteURL = config.getOptionAsURL("application.site.url");
+
+ log.info(_("jaxxdemo.message.goto.site", siteURL));
+
+ if (log.isDebugEnabled()) {
+ log.debug("goto " + siteURL);
+ }
+ if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
+ try {
+ Desktop.getDesktop().browse(siteURL.toURI());
+ } catch (Exception ex) {
+ log.error(ex.getMessage(), ex);
+ ErrorDialogUI.showError(ex);
+ }
+ }
+ }
+
+ public void showAbout(DemoUI ui) {
+
+ DemoConfig config = ui.getConfig();
+
+ String iconPath = config.getOption("application.icon.path");
+ String licensePath = config.getOption("application.license.path");
+ String thirdPartyPath = config.getOption("application.third-party.path");
+
+ AboutPanel about = new AboutPanel();
+ about.setTitle(_("jaxxdemo.title.about"));
+ about.setAboutText(_("jaxxdemo.about.message"));
+ about.setBottomText(ui.getConfig().getCopyrightText());
+ about.setIconPath(iconPath);
+ about.setLicenseFile(licensePath);
+ about.setThirdpartyFile(thirdPartyPath);
+ about.buildTopPanel();
+ about.init();
+ about.showInDialog(ui, true);
+ }
+
+ DemoUI getUI(JAXXContext context) {
+ if (context instanceof DemoUI) {
+ return (DemoUI) context;
+ }
+ DemoUI ui = MAIN_UI_ENTRY_DEF.getContextValue(context);
+ return ui;
+ }
+}
Copied: trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/ValidationTableDemo.jaxx (from rev 2156, trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx)
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/ValidationTableDemo.jaxx (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/java/jaxx/demo/validation/ui/ValidationTableDemo.jaxx 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,173 @@
+<!--
+ #%L
+ JAXX :: Demo
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<JPanel>
+ <!--<style source="Validation.css"/>-->
+
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel;
+import jaxx.demo.validation.model.Movie;
+
+void $afterCompleteSetup() {
+ SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer());
+}
+
+protected void changeContext(String context) {
+ if (context==null) { return; }
+ validator.setContext(context);
+ validator.setBean(movie);
+ SwingValidatorUtil.installUI(this);
+}
+
+/*protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Validation.css",
+ "Identity.java", "Identity-error-validation.xml", "Identity-info-validation.xml", "Identity-warning-validation.xml",
+ "Model.java", "Model-error-validation.xml", "Model-info-validation.xml", "Model-warning-validation.xml"
+ };
+}*/
+]]></script>
+
+ <!-- models -->
+ <Movie id='movie'/>
+
+ <!-- errors model -->
+ <SwingValidatorMessageTableModel id='errors2'
+ onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='movie' autoField='true'
+ contextName='create'
+ uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ </BeanValidator>
+
+ <Table fill='both'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0' columns="2">
+ <JPanel border='{BorderFactory.createTitledBorder("Configuration")}'
+ layout='{new GridLayout()}'>
+ <JAXXComboBox id='contexts' editable='false' onActionPerformed='changeContext(String.valueOf(contexts.getSelectedItem()))'>
+ <item value='create' selected='true'/>
+ <item value='update'/>
+ </JAXXComboBox>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Movie")}'
+ layout='{new GridLayout()}'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Title :'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='title' text='{movie.getTitle()}'
+ onKeyReleased='movie.setTitle(title.getText())'
+ _validatorLabel='{n_("movie.title")}'
+ />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Year:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='year' text='{movie.getYear() + ""}'
+ onKeyReleased='movie.setYear(Integer.valueOf(year.getText()))'
+ _validatorLabel='{n_("movie.year")}'
+ />
+ </cell>
+ </row>
+
+ <!--row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
+ onStateChanged='model1.setRatio(ratio.getValue())'/>
+ </cell>
+ </row-->
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Movie")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Title:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{movie.getTitle()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Year:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{movie.getYear() + ""}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}'
+ layout='{new GridLayout()}' height='200'
+ width='500'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true'
+ autoCreateRowSorter='true'
+ autoResizeMode='2' cellSelectionEnabled='false'
+ selectionMode='0'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel' text='cancel'
+ onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ <JButton id='ok' text='valid'
+ onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</JPanel>
Added: trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_en_GB.properties
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_en_GB.properties (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_en_GB.properties 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,58 @@
+JAXX\ Demo=
+Title\ \:=
+Title\:=
+Year\:=
+cancel=
+demo.action.reload.application=Reload application
+demo.action.reload.ui=Reload UI
+jaxxdemo.about.message=<h3>JAXX Validator Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-tutorial/jaxx-tutorial-validation">website of the project</a>.
+jaxxdemo.action.about=About...
+jaxxdemo.action.about.tip=About JAXXDemo...
+jaxxdemo.action.configuration=Preferences
+jaxxdemo.action.configuration.tip=Change the preferences of the application
+jaxxdemo.action.exit=Quit
+jaxxdemo.action.exit.tip=Quit JAXXDemo
+jaxxdemo.action.fullscreen=Full screen
+jaxxdemo.action.fullscreen.tip=Change to full screen mode
+jaxxdemo.action.help=
+jaxxdemo.action.help.tip=Display help
+jaxxdemo.action.locale.fr=French
+jaxxdemo.action.locale.fr.tip=Change to french language
+jaxxdemo.action.locale.uk=English
+jaxxdemo.action.locale.uk.tip=Change to english language
+jaxxdemo.action.normalscreen=Normal screen
+jaxxdemo.action.normalscreen.tip=Change to normal screen mode
+jaxxdemo.action.site=Web site
+jaxxdemo.action.site.tip=Go to the web site
+jaxxdemo.common.actors=Actors
+jaxxdemo.common.age=Age
+jaxxdemo.common.firstName=First name
+jaxxdemo.common.id=Id
+jaxxdemo.common.image=Image
+jaxxdemo.common.lastName=Last name
+jaxxdemo.common.movie=Movie
+jaxxdemo.common.people=People
+jaxxdemo.common.title=Title
+jaxxdemo.common.year=Year
+jaxxdemo.config.category.directories=Files
+jaxxdemo.config.category.directories.description=Files used by application
+jaxxdemo.config.category.other=Others
+jaxxdemo.config.category.other.description=Others preferences
+jaxxdemo.config.configFileName.description=Configuration file name
+jaxxdemo.config.ui.fontSize=default font size to use in sources
+jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen)
+jaxxdemo.config.ui.locale=Language used in application
+jaxxdemo.init.closed=JAXXDemo was closed at %1$s
+jaxxdemo.init.context.done=Context initialized in %1$s
+jaxxdemo.init.ui.done=UI initialized.
+jaxxdemo.menu.file=File
+jaxxdemo.menu.file.locale=Languages
+jaxxdemo.menu.help=
+jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded.
+jaxxdemo.message.goto.site=Go to JAXXDemo Web site
+jaxxdemo.title.about=About JAXXDemo...
+jaxxdemo.warning.nimbus.landf=Could not init nymbus look and feel, you need at leasr version 1.6u10 of java.
+jaxxdemo.warning.no.ui=No ui environnement detected
+movie.title=
+movie.year=
+valid=
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_en_GB.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_fr_FR.properties
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_fr_FR.properties (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_fr_FR.properties 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,58 @@
+JAXX\ Demo=
+Title\ \:=
+Title\:=
+Year\:=
+cancel=Annuler
+demo.action.reload.application=Redemarrer l'application
+demo.action.reload.ui=Recharger l'interface graphique
+jaxxdemo.about.message=<h3>JAXX Validation Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx-tutorial/jaxx-tutorial-validation">site du projet</a>.
+jaxxdemo.action.about=A propos
+jaxxdemo.action.about.tip=A propos de JAXX Demo...
+jaxxdemo.action.configuration=Configuration
+jaxxdemo.action.configuration.tip=Modifier la configuration
+jaxxdemo.action.exit=Quitter
+jaxxdemo.action.exit.tip=Quitter JAXX Demo
+jaxxdemo.action.fullscreen=Plein \u00E9cran
+jaxxdemo.action.fullscreen.tip=Passer en mode pleine \u00E9cran
+jaxxdemo.action.help=Aide
+jaxxdemo.action.help.tip=Affichier l'aide
+jaxxdemo.action.locale.fr=Fran\u00E7ais
+jaxxdemo.action.locale.fr.tip=Changer la langue en fran\u00E7ais
+jaxxdemo.action.locale.uk=Anglais
+jaxxdemo.action.locale.uk.tip=Changer la langue en anglais
+jaxxdemo.action.normalscreen=Ecran normal
+jaxxdemo.action.normalscreen.tip=Revenir en mode normal
+jaxxdemo.action.site=Site internet
+jaxxdemo.action.site.tip=Acc\u00E9der au site de l'application sur internet
+jaxxdemo.common.actors=Acteurs
+jaxxdemo.common.age=Age
+jaxxdemo.common.firstName=Pr\u00E9nom
+jaxxdemo.common.id=Identifiant
+jaxxdemo.common.image=Image
+jaxxdemo.common.lastName=Nom
+jaxxdemo.common.movie=Film
+jaxxdemo.common.people=Acteur
+jaxxdemo.common.title=Titre
+jaxxdemo.common.year=Ann\u00E9e
+jaxxdemo.config.category.directories=R\u00E9pertoires
+jaxxdemo.config.category.directories.description=R\u00E9pertoires de l'application
+jaxxdemo.config.category.other=Autre
+jaxxdemo.config.category.other.description=Autres options
+jaxxdemo.config.configFileName.description=Le nom du fichier de configuration
+jaxxdemo.config.ui.fontSize=La taille de la police \u00E0 utiliser pour visualiser dans les sources
+jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran
+jaxxdemo.config.ui.locale=La langue utilis\u00E9e par l'application
+jaxxdemo.init.closed=JAXX Demo a \u00E9t\u00E9 ferm\u00E9 \u00E0 %1$s
+jaxxdemo.init.context.done=Initialisation du contexte termin\u00E9e en %1$s.
+jaxxdemo.init.ui.done=Initialisation de l'interface graphique termin\u00E9e.
+jaxxdemo.menu.file=Fichier
+jaxxdemo.menu.file.locale=Langues
+jaxxdemo.menu.help=Aide
+jaxxdemo.message.config.loaded=Configuration de JAXX Demo v. %1$s charg\u00E9e.
+jaxxdemo.message.goto.site=Acc\u00E9der au site de JAXX Demo (%1$s)
+jaxxdemo.title.about=A propos de JAXX Demo...
+jaxxdemo.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
+jaxxdemo.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9
+movie.title=
+movie.year=
+valid=valide
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/i18n/jaxx-tutorial-validation_fr_FR.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-about.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-about.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-accept.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-accept.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-block.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-block.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-close.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-close.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-config.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-config.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-exit.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-exit.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-fullscreen.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-fullscreen.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-help.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-help.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-i18n-fr.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-i18n-fr.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-i18n-uk.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-i18n-uk.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-leave-fullscreen.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-leave-fullscreen.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-reload-application.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-reload-application.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-reload-ui.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-reload-ui.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-show-help.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-show-help.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-site.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-site.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-translate.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/action-translate.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/icons/jaxx.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/icons/jaxx.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,20 @@
+
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <field name="title">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a title.</message>
+ </field-validator>
+ </field>
+ <field name="year">
+ <field-validator type="required" short-circuit="true">
+ <message>You must enter a year.</message>
+ </field-validator>
+ <field-validator type="int">
+ <param name="min">1900</param>
+ <message>Year must be after 1900</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,18 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <field name="title">
+ <field-validator type="fieldexpression">
+ <param name="expression">
+ <![CDATA[ title != null && title.length() > 1]]></param>
+ <message>Title should be more than One caracter.</message>
+ </field-validator>
+ </field>
+ <field name="year">
+ <field-validator type="int">
+ <param name="min">1920</param>
+ <message>Year should be after 1920</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-create-warning-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,20 @@
+
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!--field name="title">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a title.</message>
+ </field-validator>
+ </field-->
+ <field name="year">
+ <field-validator type="required" short-circuit="true">
+ <message>You must enter a year.</message>
+ </field-validator>
+ <field-validator type="int">
+ <param name="min">1900</param>
+ <message>Year must be after 1900</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,12 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <field name="title">
+ <field-validator type="fieldexpression">
+ <param name="expression">
+ <![CDATA[ title == null]]></param>
+ <message>Title is filled.</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-info-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,18 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <field name="title">
+ <field-validator type="fieldexpression">
+ <param name="expression">
+ <![CDATA[ title != null && title.length() > 1]]></param>
+ <message>Title should be more than One caracter.</message>
+ </field-validator>
+ </field>
+ <field name="year">
+ <field-validator type="int">
+ <param name="min">1920</param>
+ <message>Year should be after 1920</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/jaxx/demo/validation/model/Movie-update-warning-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/main/resources/log4j.properties
===================================================================
--- trunk/jaxx-tutorial-validation/src/main/resources/log4j.properties (rev 0)
+++ trunk/jaxx-tutorial-validation/src/main/resources/log4j.properties 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,38 @@
+###
+# #%L
+# JAXX :: Tutorial Config
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2008 - 2010 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+log4j.logger.jaxx.demo=INFO
+#log4j.logger.jaxx.demo.config.DemoConfig=DEBUG
+log4j.logger.jaxx.runtime.swing.editor.config=INFO
+#log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG
+log4j.logger.org.nuiton=WARN
+log4j.logger.org.nuiton.validator=INFO
+log4j.logger.jaxx.runtime.validator=DEBUG
Property changes on: trunk/jaxx-tutorial-validation/src/main/resources/log4j.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-tutorial-validation/src/site/rst/images/webstart.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-tutorial-validation/src/site/rst/images/webstart.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/site/rst/index.rst
===================================================================
--- trunk/jaxx-tutorial-validation/src/site/rst/index.rst (rev 0)
+++ trunk/jaxx-tutorial-validation/src/site/rst/index.rst 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,46 @@
+.. -
+.. * #%L
+.. * JAXX :: Tutorial Config
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2008 - 2010 CodeLutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
+===============
+Tutorial Config
+===============
+
+TODO
+
+Set it in action
+----------------
+
+|webstart|
+
+To run this example in `Java Web Start`_, click the `following link`_.
+
+For more details about the `Jaxx Demo webstart`_.
+
+.. _Java Web Start: http://java.sun.com/products/javawebstart/
+
+.. |webstart| image:: images/webstart.gif
+
+.. _following link: ./jnlp/launch.jnlp
+
+.. _Jaxx Demo webstart: jnlp-report.html
Property changes on: trunk/jaxx-tutorial-validation/src/site/rst/index.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/jaxx-tutorial-validation/src/site/site_fr.xml
===================================================================
--- trunk/jaxx-tutorial-validation/src/site/site_fr.xml (rev 0)
+++ trunk/jaxx-tutorial-validation/src/site/site_fr.xml 2011-01-25 11:58:22 UTC (rev 2163)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ JAXX :: Tutorial Config
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2008 - 2010 CodeLutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <src>${site.home.url}/jaxx.png</src>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur" inherited="top">
+ <item name="Accueil" href="index.html"/>
+ <item name="Lancer la démo" href="jnlp/launch.jnlp"/>
+ </menu>
+
+ </body>
+</project>
Property changes on: trunk/jaxx-tutorial-validation/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r2162 - in trunk/jaxx-compiler/src/main/java/jaxx/compiler: finalizers tags/validator
by tchemit@users.nuiton.org 25 Jan '11
by tchemit@users.nuiton.org 25 Jan '11
25 Jan '11
Author: tchemit
Date: 2011-01-25 12:57:12 +0100 (Tue, 25 Jan 2011)
New Revision: 2162
Url: http://nuiton.org/repositories/revision/jaxx/2162
Log:
Evolution #1178: Use nuiton-validator 2.0
Evolution #1240: Review the validation api
Modified:
trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2011-01-25 11:56:47 UTC (rev 2161)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/ValidatorFinalizer.java 2011-01-25 11:57:12 UTC (rev 2162)
@@ -37,9 +37,11 @@
import jaxx.compiler.reflect.ClassDescriptorHelper;
import jaxx.compiler.tags.validator.BeanValidatorHandler;
import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
-import jaxx.compiler.types.TypeManager;
import jaxx.runtime.JAXXValidator;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.meta.Validator;
+import jaxx.runtime.validator.swing.meta.ValidatorField;
import java.lang.reflect.Modifier;
import java.util.List;
@@ -96,42 +98,69 @@
}
String eol = JAXXCompiler.getLineSeparator();
StringBuilder builder = new StringBuilder();
- // register validator
+ // register validators
List<CompiledBeanValidator> validators =
BeanValidatorHandler.getValidators(compiler);
+ javaFile.addImport(Validator.class);
+ javaFile.addImport(ValidatorField.class);
+ javaFile.addImport(SwingValidatorUtil.class);
+ compiler.getJavaFile().addMethod(JavaFileGenerator.newMethod(
+ Modifier.PUBLIC,
+ "void",
+ "registerValidatorFields",
+ SwingValidatorUtil.class.getSimpleName() + ".installFields(this);",
+ true)
+ );
builder.append("// register ");
builder.append(validators.size());
builder.append(" validator(s)");
builder.append(eol);
- builder.append("registerValidatorFields();");
- StringBuilder registerValidatorFieldsMethod = new StringBuilder();
+ builder.append("validatorIds = ");
+ builder.append(SwingValidatorUtil.class.getSimpleName()).append(".initUI(this);");
+ builder.append(eol);
+// builder.append("registerValidatorFields();");
+// builder.append(eol);
+ builder.append(SwingValidatorUtil.class.getSimpleName()).append(".installUI(this);");
+ builder.append(eol);
+ compiler.appendLateInitializer(builder.toString());
for (CompiledBeanValidator validator : validators) {
- String id = TypeManager.getJavaCode(validator.getId());
- builder.append("validatorIds.add(");
- builder.append(id);
- builder.append(");");
- builder.append(eol);
- builder.append("getValidator(");
- builder.append(id);
- builder.append(").installUIs();");
- builder.append(eol);
- builder.append("getValidator(");
- builder.append(id);
- builder.append(").reloadBean();");
- builder.append(eol);
- // init fields
- validator.addFieldRepresentations(compiler, registerValidatorFieldsMethod);
+ validator.registerValidator(compiler, javaFile);
}
- builder.append("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
- builder.append(eol);
- compiler.appendLateInitializer(builder.toString());
- compiler.getJavaFile().addMethod(JavaFileGenerator.newMethod(
- Modifier.PUBLIC,
- "void",
- "registerValidatorFields",
- registerValidatorFieldsMethod.toString(),
- true)
- );
+
+// StringBuilder registerValidatorFieldsMethod = new StringBuilder();
+// registerValidatorFieldsMethod.append(SwingValidatorUtil.class.getSimpleName()).append(".installFields(this);");
+
+// for (CompiledBeanValidator validator : validators) {
+// validator.registerValidator(compiler, javaFile);
+//
+// String id = TypeManager.getJavaCode(validator.getId());
+
+
+// builder.append("validatorIds.add(");
+// builder.append(id);
+// builder.append(");");
+// builder.append(eol);
+// builder.append("getValidator(");
+// builder.append(id);
+// builder.append(").installUIs();");
+// builder.append(eol);
+// builder.append("getValidator(");
+// builder.append(id);
+// builder.append(").reloadBean();");
+// builder.append(eol);
+ // init fields
+// validator.addFieldRepresentations(compiler, registerValidatorFieldsMethod);
+// }
+// builder.append("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
+// builder.append(eol);
+// compiler.appendLateInitializer(builder.toString());
+// compiler.getJavaFile().addMethod(JavaFileGenerator.newMethod(
+// Modifier.PUBLIC,
+// "void",
+// "registerValidatorFields",
+// SwingValidatorUtil.class.getSimpleName() + ".installFields(this);",
+// true)
+// );
}
@Override
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2011-01-25 11:56:47 UTC (rev 2161)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2011-01-25 11:57:12 UTC (rev 2162)
@@ -31,6 +31,8 @@
import jaxx.compiler.beans.JAXXBeanInfo;
import jaxx.compiler.beans.JAXXPropertyDescriptor;
import jaxx.compiler.binding.DataBindingHelper;
+import jaxx.compiler.java.JavaField;
+import jaxx.compiler.java.JavaFile;
import jaxx.compiler.reflect.ClassDescriptor;
import jaxx.compiler.reflect.ClassDescriptorHelper;
import jaxx.compiler.tags.DefaultObjectHandler;
@@ -38,6 +40,8 @@
import jaxx.runtime.JAXXValidator;
import jaxx.runtime.validator.swing.SwingValidator;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.meta.Validator;
+import jaxx.runtime.validator.swing.meta.ValidatorField;
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -784,14 +788,16 @@
}
/**
+ * Register in buffer all field representation to init (and to record in method {@link JAXXValidator#registerValidatorFields()}
*
- * @param tag
- * @param compiler
- * @deprecated since 2.2.1, prefer use the methdo {@link #addFieldRepresentations(JAXXCompiler, StringBuilder)}
+ * @param compiler the compiler used
+ * @param javaFile generated file
+ * @param buffer the buffer where to add code
+ * @since 2.2.1
*/
- @Deprecated
- protected void addFieldRepresentations(Element tag,
- JAXXCompiler compiler) {
+ public void addFieldRepresentations(JAXXCompiler compiler,
+ JavaFile javaFile,
+ StringBuilder buffer) {
for (Entry<String, String> entry : fields.entrySet()) {
String propertyName = entry.getKey();
String component = entry.getValue();
@@ -799,24 +805,41 @@
// property not find on bean
continue;
}
+ String validatorId = TypeManager.getJavaCode(getId());
+ String keyCode = TypeManager.getJavaCode(propertyName);
+ String editorCode = TypeManager.getJavaCode(component);
+ JavaField editor = javaFile.getField(component);
+ String annotation = ValidatorField.class.getSimpleName() +
+ "( validatorId = " + validatorId + "," +
+ " propertyName = " + keyCode + "," +
+ " editorName = " + editorCode + "" +
+ ")";
+ editor.addAnnotation(annotation);
+
// if (!compiler.checkReference(tag, component, true, null)) {
// // editor component not find on ui
// continue;
// }
- String keyCode = TypeManager.getJavaCode(propertyName);
- appendAdditionCode(getJavaCode() + ".setFieldRepresentation(" +
- keyCode + ", " + component + ");");
+
+// buffer.append(getJavaCode());
+// buffer.append(".setFieldRepresentation(");
+// buffer.append(keyCode);
+// buffer.append(", ");
+// buffer.append(component);
+// buffer.append(");\n");
}
}
- /**
- * Register in buffer all field representation to init (and to record in method {@link JAXXValidator#registerValidatorFields()}
- *
- * @param compiler the compiler used
- * @param buffer the buffer where to add code
- * @since 2.2.1
- */
- public void addFieldRepresentations(JAXXCompiler compiler, StringBuilder buffer) {
+ public void registerValidator(JAXXCompiler compiler,
+ JavaFile javaFile) {
+
+ JavaField validatorField = javaFile.getField(getId());
+
+ String validatorId = TypeManager.getJavaCode(getId());
+ String validatorAnnotation = Validator.class.getSimpleName() +
+ "( validatorId = " + validatorId +
+ ")";
+ validatorField.addAnnotation(validatorAnnotation);
for (Entry<String, String> entry : fields.entrySet()) {
String propertyName = entry.getKey();
String component = entry.getValue();
@@ -824,17 +847,15 @@
// property not find on bean
continue;
}
-// if (!compiler.checkReference(tag, component, true, null)) {
-// // editor component not find on ui
-// continue;
-// }
String keyCode = TypeManager.getJavaCode(propertyName);
- buffer.append(getJavaCode());
- buffer.append(".setFieldRepresentation(");
- buffer.append(keyCode);
- buffer.append(", ");
- buffer.append(component);
- buffer.append(");\n");
+ String editorCode = TypeManager.getJavaCode(component);
+ JavaField editor = javaFile.getField(component);
+ String annotation = ValidatorField.class.getSimpleName() +
+ "( validatorId = " + validatorId + "," +
+ " propertyName = " + keyCode + "," +
+ " editorName = " + editorCode + "" +
+ ")";
+ editor.addAnnotation(annotation);
}
}
1
0
r2161 - in trunk/jaxx-validator: . src/main/java/jaxx/runtime src/main/java/jaxx/runtime/validator src/main/java/jaxx/runtime/validator/swing src/main/java/jaxx/runtime/validator/swing/meta src/main/java/jaxx/runtime/validator/swing/ui src/test/java/jaxx/runtime
by tchemit@users.nuiton.org 25 Jan '11
by tchemit@users.nuiton.org 25 Jan '11
25 Jan '11
Author: tchemit
Date: 2011-01-25 12:56:47 +0100 (Tue, 25 Jan 2011)
New Revision: 2161
Url: http://nuiton.org/repositories/revision/jaxx/2161
Log:
Evolution #1178: Use nuiton-validator 2.0
Evolution #1240: Review the validation api
Added:
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java
Removed:
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/ValidatorsMap.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
trunk/jaxx-validator/src/test/java/jaxx/runtime/validator/
Modified:
trunk/jaxx-validator/pom.xml
trunk/jaxx-validator/src/main/java/jaxx/runtime/JAXXValidator.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
Modified: trunk/jaxx-validator/pom.xml
===================================================================
--- trunk/jaxx-validator/pom.xml 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/pom.xml 2011-01-25 11:56:47 UTC (rev 2161)
@@ -62,6 +62,11 @@
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-validator</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
</dependency>
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/JAXXValidator.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/JAXXValidator.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/JAXXValidator.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -25,7 +25,7 @@
package jaxx.runtime;
-import jaxx.runtime.validator.BeanValidator;
+import org.nuiton.validator.bean.BeanValidator;
import jaxx.runtime.validator.swing.SwingValidator;
import javax.swing.JComponent;
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,637 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-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.nuiton.util.converter.ConverterUtil;
-
-import javax.swing.event.EventListenerList;
-import java.beans.EventSetDescriptor;
-import java.beans.Introspector;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * A customized validator for a given bean.
- * <p/>
- * <b>Note:</b> The bean must be listenable on properyChange events (means must
- * have public addPropertychangeListener and removePropertyChangeListener
- * methods).
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @param <B> type of the bean to validate.
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class BeanValidator<B> {
-
- /** la nom de la propriété bean */
- static public final String BEAN_PROERTY = "bean";
-
- /** la nom de la propriété contextName */
- static public final String CONTEXT_NAME_PROPERTY = "contextName";
-
- /** la nom de l'état valid */
- static public final String VALID_PROERTY = "valid";
-
- /** la nom de l'état changed */
- static public final String CHANGED_PROERTY = "changed";
-
- /** Logger */
- static protected final Log log = LogFactory.getLog(BeanValidator.class);
-
- protected static final BeanValidatorScope[] FILTER_SCOPES_EMPTY =
- new BeanValidatorScope[0];
-
- /** the type of bean to watch */
- protected final Class<B> beanClass;
-
- /** the validation named context (can be null) */
- protected String contextName;
-
- /** to chain to a prent validator */
- protected BeanValidator<?> parentValidator;
-
- /**
- * state to indicate that validator has changed since the last time bean was
- * setted
- */
- protected boolean changed;
-
- /** state of the validator (is true if no errors of error scope is found) */
- protected boolean valid = true;
-
- /** bean to be watched */
- protected B bean;
-
- /** to add and remove PropertyChangeListener on watched beans */
- protected EventSetDescriptor beanEventDescriptor;
-
- /** list of fields watched by this validator */
- protected Set<BeanValidatorField<B>> fields;
-
- /** map of conversion errors detected by this validator */
- protected Map<String, String> conversionErrors;
-
- /** xworks scope validator * */
- protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators;
-
- /** filter scopes (if {@code null}, no filter on scopes) */
- protected BeanValidatorScope[] filterScopes;
-
- /** listener that listens on bean modification */
- protected PropertyChangeListener l;
-
- /** delegate property change support */
- protected PropertyChangeSupport pcs;
-
- /** A list of event listeners for this validators */
- protected EventListenerList listenerList = new EventListenerList();
-
- public BeanValidator(Class<B> beanClass,
- String contextName) {
- this(beanClass,
- contextName,
- BeanValidatorScope.values()
- );
- }
-
- public BeanValidator(Class<B> beanClass,
- String contextName,
- BeanValidatorScope... filterScopes) {
- this.beanClass = beanClass;
- if (filterScopes != null && filterScopes.length > 0) {
- this.filterScopes = filterScopes;
- }
- pcs = new PropertyChangeSupport(this);
- conversionErrors = new TreeMap<String, String>();
- validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(
- BeanValidatorScope.class);
-
- setContextName(contextName);
-
- l = new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- // chaque modification lance la validation
- doValidate();
- }
- };
- }
-
- public Class<B> getBeanClass() {
- return beanClass;
- }
-
- public BeanValidator<?> getParentValidator() {
- return parentValidator;
- }
-
- public String getContextName() {
- return contextName;
- }
-
- public Set<BeanValidatorField<B>> getFields() {
- return fields;
- }
-
- public Set<BeanValidatorScope> getScopes() {
- return new HashSet<BeanValidatorScope>(validators.keySet());
- }
-
- /**
- * Retourne vrai si l'objet bean a ete modifie depuis le dernier {@link
- * #setBean}
- *
- * @return <code>true</code> if bean was modify since last {@link
- * #setBean(Object)} invocation
- */
- public boolean isChanged() {
- return changed;
- }
-
- public boolean isValid() {
- return valid;
- }
-
- public B getBean() {
- return bean;
- }
-
- public BeanValidatorField<B> getField(String fieldName) {
- for (BeanValidatorField<B> field : fields) {
- if (fieldName.equals(field.getName())) {
- return field;
- }
- }
- return null;
- }
-
- public boolean hasFatalErrors() {
- for (BeanValidatorField<B> field : fields) {
- if (field.hasFatalErrors()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasErrors() {
- for (BeanValidatorField<B> field : fields) {
- if (field.hasErrors()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasWarnings() {
- for (BeanValidatorField<B> field : fields) {
- if (field.hasWarnings()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasInfos() {
- for (BeanValidatorField<B> field : fields) {
- if (field.hasInfos()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Test a the validator contains the field given his name
- *
- * @param fieldName the name of the searched field
- * @return <code>true</code> if validator contaisn this field,
- * <code>false</code> otherwise
- */
- public boolean containsField(String fieldName) {
- BeanValidatorField<B> field = getField(fieldName);
- return field != null;
- }
-
- public boolean isValid(String fieldName) {
- BeanValidatorField<B> field = getField(fieldName);
- if (field == null) {
- throw new IllegalArgumentException(
- "could not find a validator field " + fieldName);
- }
- return field.isValid();
- }
-
- /**
- * Permet de force la remise a false de l'etat de changement du bean
- *
- * @param changed flag to force reset of property {@link #changed}
- */
- public void setChanged(boolean changed) {
- this.changed = changed;
- // force the property to be fired (never pass the older value)
- pcs.firePropertyChange(CHANGED_PROERTY, null, changed);
- }
-
- public void setValid(boolean valid) {
- this.valid = valid;
- // force the property to be fired (never pass the older value)
- pcs.firePropertyChange(VALID_PROERTY, null, valid);
- }
-
- public void setBean(B bean) {
- B oldBean = this.bean;
- if (log.isDebugEnabled()) {
- log.debug(this + " : " + bean);
- }
-
- // clean conversions of previous bean
- conversionErrors.clear();
-
- if (oldBean != null) {
- try {
- EventSetDescriptor descriptor = getBeanEventDescriptor(oldBean);
- descriptor.getRemoveListenerMethod().invoke(oldBean, l);
- } catch (Exception eee) {
- if (log.isInfoEnabled()) {
- log.info("Can't register as listener for bean " + beanClass +
- " for reason " + eee.getMessage(), eee);
- }
- }
- }
- this.bean = bean;
-
- if (bean == null) {
-
- // remove all messages for all fields of the validator
-
- for (BeanValidatorField<B> f : fields) {
-
- f.updateMessages(this, null, null);
- }
-
- } else {
- try {
- EventSetDescriptor descriptor = getBeanEventDescriptor(bean);
- descriptor.getAddListenerMethod().invoke(bean, l);
- } catch (Exception eee) {
- if (log.isInfoEnabled()) {
- log.info("Can't register as listener for bean " + beanClass +
- " for reason " + eee.getMessage(), eee);
- }
- }
- validate();
- }
- setChanged(false);
- setValid(!hasFatalErrors() && !hasErrors());
- pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean);
- }
-
- public void setContextName(String contextName) {
- String oldContextName = this.contextName;
- this.contextName = contextName;
- // changing contextName could change fields definition
- // so dettach bean, must rebuild the fields
- if (bean != null) {
- setBean(null);
- }
- // rebuild the fields
- initFields();
- pcs.firePropertyChange(CONTEXT_NAME_PROPERTY,
- oldContextName,
- contextName
- );
- }
-
- /**
- * Sets the filter scopes.
- *
- * @param filterScopes the scopes to used
- */
- public void setFilterScopes(BeanValidatorScope... filterScopes) {
- this.filterScopes = filterScopes;
- // changing contextName could change fields definition
- // so dettach bean, must rebuild the fields
- if (bean != null) {
- setBean(null);
- }
- // rebuild the fields
- initFields();
- }
-
- public void setParentValidator(BeanValidator<?> parentValidator) {
- this.parentValidator = parentValidator;
- }
-
- /**
- * Convert a value.
- * <p/>
- * If an error occurs, then add an error in validator.
- *
- * @param <T> the type of conversion
- * @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
- */
- @SuppressWarnings({"unchecked"})
- public <T> T convert(String fieldName, String value, Class<T> valueClass) {
- if (fieldName == null) {
- throw new IllegalArgumentException("fieldName can not be null");
- }
- 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 (!canValidate() || 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);
- /* Why this test ? if (result != null && !value.equals(result.toString())) {
- conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
- result = null;
- validate();
- }*/
- } catch (ConversionException e) {
- // get
- String s = Introspector.decapitalize(valueClass.getSimpleName());
- conversionErrors.put(fieldName, "error.convertor." + s);
- result = null;
- validate();
- }
- return result;
- }
-
- /**
- * Methode pour forcer la revalidation d'un bean en mettant a jour les etats
- * internes.
- * <p/>
- * La méthode appelle {@link #validate()} puis met à jour les etats internes
- * {@link #valid} et {@link #changed}.
- *
- * @since 1.5
- */
- public void doValidate() {
- validate();
- setValid(!hasFatalErrors() && !hasErrors());
- setChanged(true);
- }
-
- /**
- * 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 solicitations.
- * Cette method est public pour permettre de force une validation par
- * programmation, ce qui est utile par exemple si le bean ne supporte pas
- * les {@link PropertyChangeListener}
- * <p/>
- * <b>Note:</b> la methode est protected et on utilise la methode
- * {@link #doValidate()} car la méthode ne modifie pas les etats
- * internes et cela en rend son utilisation delicate (le validateur entre
- * dans un etat incoherent par rapport aux messages envoyés).
- */
- protected void validate() {
-
- // on ne valide que si il y a un bean et que le resultat de la validation
- // pourra etre affiche quelque part
- if (!canValidate()) {
- return;
- }
-
- for (BeanValidatorScope scope : validators.keySet()) {
-
- XWorkBeanValidator<B> validator = validators.get(scope);
-
- Map<String, List<String>> newMessages = validator.validate(bean);
-
- if (scope == BeanValidatorScope.ERROR) {
- // treate conversion errors
- // reinject them
- for (Entry<String, String> entry : conversionErrors.entrySet()) {
- // remove from validation, errors occurs on this field
- List<String> errors = newMessages.get(entry.getKey());
- String conversionError = entry.getValue();
- if (errors != null) {
- errors.clear();
- errors.add(conversionError);
- } else {
- errors = Collections.singletonList(conversionError);
- if (XWorkBeanValidator.EMPTY_RESULT.equals(newMessages)) {
- newMessages = new HashMap<String, List<String>>();
- }
- // add the concrete conversion error
- newMessages.put(entry.getKey(), errors);
- }
- }
- }
-
- // for each field, update his list of messages
- for (BeanValidatorField<B> field : fields) {
- List<String> messagesForField = newMessages.get(field.getName());
- if (field.getScopes().contains(scope)) {
- field.updateMessages(this, scope, messagesForField);
- }
- }
- }
-
- if (parentValidator != null) {
- // chained validation
- // the parent validator should not be changed from this validation
- boolean wasModified = parentValidator.isChanged();
- parentValidator.doValidate();
- if (!wasModified) {
- // push back old state
- parentValidator.setChanged(false);
- }
- }
-
- }
-
- @Override
- public String toString() {
- return super.toString() + "<beanClass:" + beanClass +
- ", contextName:" + contextName + ">";
- }
-
- public void addBeanValidatorListener(BeanValidatorListener listener) {
- listenerList.add(BeanValidatorListener.class, listener);
- }
-
- public void removeBeanValidatorListener(BeanValidatorListener listener) {
- listenerList.remove(BeanValidatorListener.class, listener);
- }
-
- public BeanValidatorListener[] getBeanValidatorListeners() {
- return listenerList.getListeners(BeanValidatorListener.class);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- /**
- * @return <code>true</code> if validation is enabled, <code>false</code>
- * otherwise.
- */
- protected boolean canValidate() {
- return !(bean == null || fields.isEmpty());
- }
-
- protected void fireFieldChanged(BeanValidatorField<B> field,
- BeanValidatorScope scope,
- String[] toAdd,
- String[] toDelete) {
-
- BeanValidatorEvent evt = new BeanValidatorEvent(
- this,
- field,
- scope,
- toAdd,
- toDelete
- );
-
- for (BeanValidatorListener listener :
- listenerList.getListeners(BeanValidatorListener.class)) {
- listener.onFieldChanged(evt);
- }
- }
-
- protected void initFields() {
-
- Set<String> detectedFieldNames = new HashSet<String>();
- EnumMap<BeanValidatorScope, Set<String>> tmp;
- tmp = new EnumMap<BeanValidatorScope, Set<String>>(
- BeanValidatorScope.class
- );
- Set<BeanValidatorField<B>> detectedFields =
- new HashSet<BeanValidatorField<B>>();
-
- validators.clear();
-
- BeanValidatorScope[] scopeUniverse;
- if (filterScopes == null) {
- // use all scopes
- scopeUniverse = BeanValidatorScope.values();
- } else {
- // use customized scopes
- scopeUniverse = filterScopes;
- }
-
- for (BeanValidatorScope scope : scopeUniverse) {
- String scopeContext =
- (contextName == null ? "" : contextName + "-") +
- scope.name().toLowerCase();
-
- XWorkBeanValidator<B> newValidator =
- new XWorkBeanValidator<B>(beanClass, scopeContext, false);
- Set<String> fieldNames = newValidator.getFieldNames();
- if (log.isDebugEnabled()) {
- log.debug("detected validators for scope " + scopeContext +
- " : " + fieldNames);
- }
- if (!fieldNames.isEmpty()) {
- // fields detected in this validator, keep it
- validators.put(scope, newValidator);
- detectedFieldNames.addAll(fieldNames);
- tmp.put(scope, fieldNames);
- }
- }
-
- List<BeanValidatorScope> scopes = new ArrayList<BeanValidatorScope>();
- for (String fieldName : detectedFieldNames) {
- scopes.clear();
- // detect scopes for the field
- for (BeanValidatorScope scope : scopeUniverse) {
- if (tmp.containsKey(scope) &&
- tmp.get(scope).contains(fieldName)) {
- scopes.add(scope);
- }
- }
- BeanValidatorField<B> f =
- new BeanValidatorField<B>(beanClass, fieldName, scopes);
- detectedFields.add(f);
- }
- tmp.clear();
- detectedFieldNames.clear();
-
- fields = Collections.unmodifiableSet(detectedFields);
- }
-
- protected EventSetDescriptor getBeanEventDescriptor(B bean) {
- if (beanEventDescriptor == null) {
- // check that the bean is listenable, otherwise, can't use the
- // validator on it
- beanEventDescriptor =
- BeanValidatorUtil.getPropertyChangeListenerDescriptor(
- bean.getClass()
- );
- }
- return beanEventDescriptor;
- }
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,344 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import org.apache.commons.beanutils.ConstructorUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Un detecteur de validateurs pour un liste de classes données et un répertoire
- * où chercher les fichiers de validation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.6.0
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class BeanValidatorDetector {
-
- /** Logger */
- private static final Log log =
- LogFactory.getLog(BeanValidatorDetector.class);
-
- public SortedSet<BeanValidator<?>> detect(File sourceRoot,
- Class<?>... types) {
- SortedSet<BeanValidator<?>> result =
- detect(BeanValidator.class, sourceRoot, null, types);
- return result;
- }
-
- public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass,
- File sourceRoot,
- Pattern contextFilter,
- Class<?>... types) {
- SortedSet<BeanValidator<?>> result = detect(validatorClass,
- sourceRoot,
- contextFilter,
- null,
- types);
- return result;
- }
-
- public SortedSet<BeanValidator<?>> detect(Class<?> validatorClass,
- File sourceRoot,
- Pattern contextFilter,
- BeanValidatorScope[] scopes,
- Class<?>... types) {
-
- SortedSet<BeanValidator<?>> result =
- new TreeSet<BeanValidator<?>>(new BeanValidatorComparator());
-
- for (Class<?> c : types) {
- File dir = getClassDir(sourceRoot, c);
- if (!dir.exists()) {
-
- // pas de repertoire adequate
- if (log.isDebugEnabled()) {
- log.debug("skip non existing directory " + dir);
- }
- continue;
- }
- String[] contexts = getContexts(c, dir);
- if (log.isDebugEnabled()) {
- log.debug("contexts : " + Arrays.toString(contexts));
- }
-
- if (contexts.length > 0) {
- String[] realContexts = getContextsWithoutScopes(contexts);
-
- if (log.isDebugEnabled()) {
- log.debug("realContexts : " +
- Arrays.toString(realContexts));
- }
-
- if (contextFilter != null) {
-
- // filter contexts
- realContexts = getFilterContexts(contextFilter,
- realContexts
- );
- if (log.isDebugEnabled()) {
- log.debug("filterContexts : " +
- Arrays.toString(realContexts));
- }
- }
-
- for (String context : realContexts) {
-
- // on cherche le validateur
- BeanValidator<?> validator = getValidator(
- validatorClass,
- c,
- context.isEmpty() ? null : context,
- scopes
- );
- if (validator != null) {
- // on enregistre le validateur
- result.add(validator);
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Pour un context et un type d'entité donné, instancie un validateur et
- * test si ce validateur est utilisable (i.e qu'il admet des champs à
- * valider).
- * <p/>
- * Si aucun champ n'est trouvé dans le validateur, alors on retourne null.
- *
- * @param <B> le type du bean
- * @param validatorClass le type de validateur a instancie
- * @param klass le type du bean
- * @param context le context du validateur
- * @param scopes les scopes a utiliser (si {@code null} alors pas de
- * filtre sur les scopes)
- * @return le validateur initialisé, ou <code>null</code> si aucun scope
- * détecté dans le validateur.
- */
- protected <B> BeanValidator<B> getValidator(Class<?> validatorClass,
- Class<B> klass,
- String context,
- BeanValidatorScope... scopes) {
-
- BeanValidator<B> valitator;
- valitator = createValidator(validatorClass, klass, context, scopes);
-
- Set<BeanValidatorScope> resultScopes = valitator.getScopes();
- if (resultScopes.isEmpty()) {
- valitator = null;
- if (log.isDebugEnabled()) {
- log.debug(klass + " : validator skip (no scopes detected)");
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug(klass + " : keep validator " + valitator);
- }
- }
- return valitator;
- }
-
- protected <B> BeanValidator<B> createValidator(
- Class<?> validatorClass,
- Class<B> klass,
- String context,
- BeanValidatorScope[] scopes) {
- BeanValidator<B> valitator;
- Constructor<?> con;
- try {
- con = ConstructorUtils.getAccessibleConstructor(
- validatorClass,
- new Class<?>[]{
- Class.class,
- String.class,
- BeanValidatorScope[].class
- }
- );
- if (con != null) {
-
- valitator = (BeanValidator<B>) con.newInstance(
- klass,
- context, scopes
- );
-
- } else {
- con = ConstructorUtils.getAccessibleConstructor(
- validatorClass,
- new Class<?>[]{
- Class.class,
- String.class,
- BeanValidatorScope[].class
- }
- );
-
- if (con == null) {
- throw new IllegalStateException(
- "could not find a constructor with " +
- "(Class.class, String) or " +
- "(Class,String BeanValidatorScope[])");
- }
-
- valitator = (BeanValidator<B>) con.newInstance(
- klass,
- context
- );
- if (scopes != null && scopes.length > 0) {
- valitator.setFilterScopes(scopes);
- }
- }
-
- } catch (Exception ex) {
- throw new RuntimeException(
- "could not instanciate validator " + validatorClass +
- " for reason " + ex.getMessage(), ex);
- }
- return valitator;
- }
-
- protected File getClassDir(File sourceRoot, Class<?> clazz) {
- String path = clazz.getPackage().getName();
- path = path.replaceAll("\\.", File.separator);
- File dir = new File(sourceRoot, path);
- return dir;
- }
-
- protected String[] getContexts(Class<?> clazz, File dir) {
- Set<String> result = new TreeSet<String>();
- ValidatorFilenameFilter filter = new ValidatorFilenameFilter(clazz);
- if (log.isDebugEnabled()) {
- log.debug("dir : " + dir);
- }
- String[] files = dir.list(filter);
- for (String file : files) {
- if (log.isDebugEnabled()) {
- log.debug("file " + file);
- }
- String context = file.substring(
- filter.prefix.length(),
- file.length() - ValidatorFilenameFilter.SUFFIX.length()
- );
- if (log.isDebugEnabled()) {
- log.debug("detect " + clazz.getSimpleName() +
- " context [" + context + "]");
- }
- result.add(context);
- }
- return result.toArray(new String[result.size()]);
- }
-
- protected String[] getContextsWithoutScopes(String[] contexts) {
- Set<String> result = new TreeSet<String>();
- BeanValidatorScope[] scopes = BeanValidatorScope.values();
- for (String context : contexts) {
- for (BeanValidatorScope scope : scopes) {
- String scopeName = scope.name().toLowerCase();
- if (!context.endsWith(scopeName)) {
- // pas concerne par ce scope
- continue;
- }
- if (log.isDebugEnabled()) {
- log.debug("detect context : " + context);
- }
- String realContext = context.substring(
- 0,
- context.length() - scopeName.length()
- );
- if (realContext.endsWith("-")) {
- realContext = realContext.substring(
- 0,
- realContext.length() - 1
- );
- }
- result.add(realContext);
- }
- }
- return result.toArray(new String[result.size()]);
- }
-
- protected String[] getFilterContexts(Pattern contextFilter,
- String[] realContexts) {
- List<String> result = new ArrayList<String>();
- for (String c : realContexts) {
- Matcher m = contextFilter.matcher(c);
- if (m.matches()) {
- result.add(c);
- }
- }
- return result.toArray(new String[result.size()]);
- }
-
- protected static class ValidatorFilenameFilter implements FilenameFilter {
-
- protected static final String SUFFIX = "-validation.xml";
-
- protected Class<?> clazz;
-
- protected String prefix;
-
- public ValidatorFilenameFilter(Class<?> clazz) {
- this.clazz = clazz;
- prefix = clazz.getSimpleName() + "-";
- }
-
- @Override
- public boolean accept(File dir, String name) {
- boolean result = name.endsWith(SUFFIX);
- if (result) {
- result = name.startsWith(prefix);
- }
- return result;
- }
- }
-
- protected static class BeanValidatorComparator implements Comparator<BeanValidator<?>> {
-
- @Override
- public int compare(BeanValidator<?> o1, BeanValidator<?> o2) {
- String contextName1 =
- o1.getBeanClass().getSimpleName() + "-" +
- (o1.getContextName() == null ? "" : o1.getContextName());
- String contextName2 =
- o2.getBeanClass().getSimpleName() + "-" +
- (o2.getContextName() == null ? "" : o2.getContextName());
- return contextName1.compareTo(contextName2);
- }
- }
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,88 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import java.util.EventObject;
-
-/**
- * The definition of an event on {@link BeanValidatorListener}
- * to be fired by a {@link BeanValidator}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class BeanValidatorEvent extends EventObject {
-
- private static final long serialVersionUID = 1L;
-
- /** the field impacted by the validator */
- protected BeanValidatorField<?> field;
-
- /** the scope impacted by the event */
- protected BeanValidatorScope scope;
-
- protected String[] messagestoAdd;
-
- protected String[] messagestoDelete;
-
- public BeanValidatorEvent(BeanValidator<?> source,
- BeanValidatorField<?> field,
- BeanValidatorScope scope,
- String[] messagestoAdd,
- String[] messagestoDelete) {
- super(source);
- this.field = field;
- this.scope = scope;
- this.messagestoAdd = messagestoAdd;
- this.messagestoDelete = messagestoDelete;
- }
-
- @Override
- public BeanValidator<?> getSource() {
- return (BeanValidator<?>) super.getSource();
- }
-
- public String getFieldName() {
- return field.getName();
- }
-
- public String[] getMessagesToAdd() {
- return messagestoAdd;
- }
-
- public String[] getMessagesToDelete() {
- return messagestoDelete;
- }
-
- public BeanValidatorScope getScope() {
- return scope;
- }
-
- public BeanValidatorField<?> getField() {
- return field;
- }
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,288 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.FieldValidator;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Definition of a field to be handled in a {@link BeanValidator}.
- * <p/>
- * A such class is only registred in {@link BeanValidator } when the field of
- * the bean was found in validator xml configuration file for a {@link
- * FieldValidator} only.
- * <p/>
- * This class use properties {@link #beanClass}, {@link #name} to define his
- * naturel order.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @param <B> the type of the bean handled by the validator and this field of
- * validation.
- * @since 1.3
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class BeanValidatorField<B> implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /** the class of bean */
- protected final Class<B> beanClass;
-
- /** name of field in bean */
- protected final String name;
-
- protected EnumMap<BeanValidatorScope, Set<String>> messages;
-
- public BeanValidatorField(Class<B> beanClass,
- String name,
- List<BeanValidatorScope> scopes) {
- this.beanClass = beanClass;
- this.name = name;
- messages = new EnumMap<BeanValidatorScope, Set<String>>(
- BeanValidatorScope.class
- );
- for (BeanValidatorScope scope : scopes) {
- messages.put(scope, new HashSet<String>());
- }
- }
-
- public String getName() {
- return name;
- }
-
- public Class<B> getBeanClass() {
- return beanClass;
- }
-
- /**
- * @return {@code true} if this field is valid : no fatal errors and no
- * errors), {@code false} otherwise.
- */
- public boolean isValid() {
- return !hasFatalErrors() && !hasErrors();
- }
-
- public BeanValidatorScope getScope() {
- if (hasErrors()) {
- return BeanValidatorScope.ERROR;
- }
- if (hasWarnings()) {
- return BeanValidatorScope.WARNING;
- }
- if (hasInfos()) {
- return BeanValidatorScope.INFO;
- }
- return null;
- }
-
- public Set<BeanValidatorScope> getScopes() {
- return messages.keySet();
- }
-
- public boolean hasFatalErrors() {
- return hasMessages(BeanValidatorScope.FATAL);
- }
-
- public boolean hasErrors() {
- return hasMessages(BeanValidatorScope.ERROR);
- }
-
- public boolean hasWarnings() {
- return hasMessages(BeanValidatorScope.WARNING);
- }
-
- public boolean hasInfos() {
- return hasMessages(BeanValidatorScope.INFO);
- }
-
- public Set<String> getFatalErrors() {
- return getMessages(BeanValidatorScope.FATAL);
- }
-
- public Set<String> getErrors() {
- return getMessages(BeanValidatorScope.ERROR);
- }
-
- public Set<String> getWarnings() {
- return getMessages(BeanValidatorScope.WARNING);
- }
-
- public Set<String> getInfos() {
- return getMessages(BeanValidatorScope.INFO);
- }
-
- public boolean hasMessages(BeanValidatorScope scope) {
- return messages.containsKey(scope) && !getMessages(scope).isEmpty();
- }
-
- public Set<String> getMessages(BeanValidatorScope scope) {
- return messages.get(scope);
- }
-
- public void updateMessages(BeanValidator<B> validator,
- BeanValidatorScope scope,
- List<String> messages) {
-
- if (scope == null) {
-
- // special case to reset all messages from all scopes
-
- for (BeanValidatorScope s : getScopes()) {
-
- clearMessages(s, validator);
- }
- return;
- }
-
- if (!this.messages.containsKey(scope)) {
- throw new IllegalArgumentException(
- "the scope " + scope + " was not registred for " + this);
- }
-
- if (messages == null || messages.isEmpty()) {
-
- // no incoming message for this scope
-
- clearMessages(scope, validator);
- return;
- }
-
- // build the diff of messages (the one to delete, the one to add)
-
- boolean hasChanged = false;
-
- Set<String> currentMessages = getMessages(scope);
-
- // detect messages to delete
- Set<String> toDelete = new HashSet<String>(currentMessages);
- toDelete.removeAll(messages);
-
- if (!toDelete.isEmpty()) {
- // apply delete
- currentMessages.removeAll(toDelete);
- hasChanged = true;
- }
-
- // detect messages to add
- Set<String> toAdd = new HashSet<String>(messages);
- toAdd.removeAll(currentMessages);
-
- if (!toAdd.isEmpty()) {
- // apply add
- currentMessages.addAll(toAdd);
- hasChanged = true;
- }
-
- if (hasChanged) {
-
- // something has changed, fire notifications
- String[] del = toDelete.toArray(new String[toDelete.size()]);
- String[] add = toAdd.toArray(new String[toAdd.size()]);
-
- validator.fireFieldChanged(this, scope, add, del);
- }
- toAdd.clear();
- toDelete.clear();
-
- }
-
- public String getI18nError(String error) {
- String text;
- if (!error.contains("##")) {
- text = _(error);
- } else {
- StringTokenizer stk = new StringTokenizer(error, "##");
- String errorName = stk.nextToken();
- List<String> args = new ArrayList<String>();
- while (stk.hasMoreTokens()) {
- args.add(stk.nextToken());
- }
- text = _(errorName, args.toArray());
- }
- return text;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof BeanValidatorField<?>)) {
- return false;
- }
-
- BeanValidatorField<?> that = (BeanValidatorField<?>) o;
- return beanClass.equals(that.beanClass) && name.equals(that.name);
- }
-
- @Override
- public int hashCode() {
- int result = beanClass.hashCode();
- result = 31 * result + name.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("<").append(super.toString());
- sb.append(" beanClass:").append(beanClass);
- sb.append(", name:").append(name);
- sb.append(", scopes:");
- sb.append(messages == null ? "[]" : messages.keySet());
- sb.append(", scope:").append(getScope());
- //sb.append(", errors:").append(errors);
- sb.append('>');
- return sb.toString();
- }
-
- protected void clearMessages(BeanValidatorScope scope,
- BeanValidator<B> validator) {
- // remove all messages
- Set<String> toDelete = getMessages(scope);
-
- if (!toDelete.isEmpty()) {
-
- // there is some messages to delete
- String[] toDel = toDelete.toArray(new String[toDelete.size()]);
-
- // apply deletion
- toDelete.clear();
-
- // fire
- validator.fireFieldChanged(this, scope, null, toDel);
- }
- }
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,45 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import java.util.EventListener;
-
-/**
- * The listener contract to be used on {@link BeanValidator}
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public interface BeanValidatorListener extends EventListener {
-
- /**
- * Invoked when a validator detects some changes on a field.
- *
- * @param event the event
- */
- void onFieldChanged(BeanValidatorEvent event);
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,120 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-/**
- * The object to box a validation message.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @param <E> type of message (use for override {@link #compareTo(Object)}
- * method.
- * @since 1.3
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> {
-
- /** the validator that produce the message */
- protected BeanValidator<?> validator;
-
- /** the field that produce the message */
- protected BeanValidatorField<?> field;
-
- /** the label of the message (to be displayed somewhere) */
- protected String message;
-
- /** the scope of the message */
- protected BeanValidatorScope scope;
-
- public BeanValidatorMessage(BeanValidator<?> validator,
- BeanValidatorField<?> field,
- String message,
- BeanValidatorScope scope) {
- this.field = field;
- this.validator = validator;
- this.message = message == null ? null : message.trim();
- this.scope = scope;
- }
-
- public BeanValidator<?> getValidator() {
- return validator;
- }
-
- public BeanValidatorField<?> getField() {
- return field;
- }
-
- public BeanValidatorScope getScope() {
- return scope;
- }
-
- public String getMessage() {
- return message;
- }
-
- @Override
- public int compareTo(E o) {
- // sort on scope
- int result = getScope().compareTo(o.getScope());
- if (result == 0) {
- // sort on field name
- result = field.getName().compareTo(o.field.getName());
- if (result == 0) {
- // sort on message
- result = message.compareTo(o.message);
- }
- }
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- BeanValidatorMessage<?> that = (BeanValidatorMessage<?>) o;
-
- return field.equals(that.field) &&
- message.equals(that.message) &&
- scope == that.scope;
- }
-
- @Override
- public int hashCode() {
- int result = field.hashCode();
- result = 31 * result + message.hashCode();
- result = 31 * result + scope.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return scope + " - " + field.getI18nError(message);
- }
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,81 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import static org.nuiton.i18n.I18n.n_;
-
-/**
- * The differents levels of messages in validation process.
- * <p/>
- * The order of the enum defines the severity of validation.
- * <p/>
- * Always begin with fatal, then error, then if no error found, try warning, then info...
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public enum BeanValidatorScope {
-
- /**
- * the fatal error scope level.
- * <p/>
- * When a message of a such scope is found on a validator, then the
- * validator is invalid and modified.
- * @since 2.2.4
- */
- FATAL(n_("validator.scope.fatal.label")),
- /**
- * the error scope level.
- * <p/>
- * When a message of a such scope is found on a validator, then the
- * validator is invalid and modified.
- */
- ERROR(n_("validator.scope.error.label")),
- /**
- * the warning scope level.
- * <p/>
- * When a message of a such scope is found on a validator, then the
- * validator is still valid but modified.
- */
- WARNING(n_("validator.scope.warning.label")),
- /**
- * the information scope level.
- * <p/>
- * When a message of a sucg scope is found on a validator, then the
- * validator is still valid and not modified.
- */
- INFO(n_("validator.scope.info.label"));
-
- private final String label;
-
- BeanValidatorScope(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,268 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.ConfigurationManager;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.JAXXValidator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.List;
-
-/**
- * The helper class for validation module.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class BeanValidatorUtil {
-
- /** Logger */
- static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
-
- /**
- * a shared value stack to allow external operations on it (for example add
- * some datas in stack to be usedby validators
- */
- static private ValueStack sharedValueStack;
-
- public static ValueStack getSharedValueStack() {
- if (sharedValueStack == null) {
-
- // init context
- ConfigurationManager confManager = new ConfigurationManager();
- Configuration conf = confManager.getConfiguration();
-
- Container container = conf.getContainer();
- ValueStackFactory stackFactory = container.getInstance(
- ValueStackFactory.class);
- sharedValueStack = stackFactory.createValueStack();
- if (log.isDebugEnabled()) {
- log.debug("init shared value stack " + sharedValueStack);
- }
- }
- return sharedValueStack;
- }
-
- protected BeanValidatorUtil() {
- // no instance
- }
-
- /**
- * Convinient method to attach a bean to all validators of an JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param bean the bean to attach in validators (can be null)
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorBean(JAXXObject ui,
- Object bean,
- String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator beanValidator =
- jaxxValidator.getValidator(validatorId);
- if (bean == null || beanValidator.getBeanClass().isAssignableFrom(
- bean.getClass())) {
- // touch validator, only if fits the bean type (or bean is null)
- beanValidator.setBean(bean);
- }
- }
- }
-
- /**
- * Convinient method to set the changed property to all validators of an
- * JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param newValue the new value to set in changed validator property
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorChanged(JAXXObject ui,
- boolean newValue,
- String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator<?> beanValidator =
- jaxxValidator.getValidator(validatorId);
- beanValidator.setChanged(newValue);
- }
- }
-
- /**
- * 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 (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("could not obtain beanInfo for " +
- valueClass.getClass() + ", reason : " +
- e.getMessage(), e);
- }
- }
- } else {
- //fixme : conversion failed, we should be able to notify ui
- // that values has changed ?
- // otherwise, bean value has not changed,...
- }
- }
-
- public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class<?> beanClass) {
- try {
- // check that the bean is listenable, otherwise, can't use
- // the validator on it
- BeanInfo infos = Introspector.getBeanInfo(beanClass);
- EventSetDescriptor[] events = infos.getEventSetDescriptors();
- for (EventSetDescriptor event : events) {
- if ("propertyChange".equals(event.getName())) {
-
- if (event.getAddListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException(
- "no addPropertyChangeListener method found " +
- "for " + beanClass);
- }
- if (event.getRemoveListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException(
- "no removePropertyChangeListener method found" +
- " for " + beanClass);
- }
- return event;
- }
- }
-
- // no property event listener, so can not use the validator
- throw new IllegalStateException(
- "no PropertyChangeListener access method found for " +
- beanClass);
- } catch (IntrospectionException ex) {
- throw new IllegalStateException(
- "could not acquire PropertyChangeListener bean info for " +
- beanClass + " for reason " + ex.getMessage(), ex);
- }
- }
-
- public static EnumSet<BeanValidatorScope> getScopes(
- List<BeanValidatorMessage<?>> messages) {
- EnumSet<BeanValidatorScope> result =
- EnumSet.noneOf(BeanValidatorScope.class);
- for (BeanValidatorMessage<?> m : messages) {
- result.add(m.getScope());
- }
- return result;
- }
-
- public static EnumMap<BeanValidatorScope, Integer> getScopesCount(
- List<BeanValidatorMessage<?>> messages) {
- EnumMap<BeanValidatorScope, Integer> result =
- new EnumMap<BeanValidatorScope, Integer>(BeanValidatorScope.class);
- for (BeanValidatorScope s : BeanValidatorScope.values()) {
- result.put(s, 0);
- }
- for (BeanValidatorMessage<?> m : messages) {
-
- BeanValidatorScope scope = m.getScope();
-
- result.put(scope, result.get(scope) + 1);
- }
-
- for (BeanValidatorScope s : BeanValidatorScope.values()) {
- if (result.get(s) == 0) {
- result.remove(s);
- }
- }
- return result;
- }
-
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/ValidatorsMap.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/ValidatorsMap.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/ValidatorsMap.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,128 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Un dictionnaire de validateurs ordonnees par le type de leur bean.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class ValidatorsMap implements Map<Class<?>, BeanValidator<?>> {
-
- protected final Map<Class<?>, BeanValidator<?>> delegate;
-
- public ValidatorsMap() {
- delegate = new HashMap<Class<?>, BeanValidator<?>>();
- }
-
- public BeanValidatorScope[] getScopes() {
- EnumSet<BeanValidatorScope> result =
- EnumSet.noneOf(BeanValidatorScope.class);
- for (BeanValidator<?> b : values()) {
- result.addAll(b.getScopes());
- }
- return result.toArray(new BeanValidatorScope[result.size()]);
- }
-
-// public <X> BeanValidator<X> getValidator(X klass) {
-// BeanValidator<X> beanValidator = (BeanValidator<X>) get(klass.getClass());
-// return beanValidator;
-// }
-
- public <X> BeanValidator<X> getValidator(Class<X> klass) {
- BeanValidator<X> beanValidator = (BeanValidator<X>) get(klass);
- return beanValidator;
- }
-
- @Override
- public int size() {
- return delegate.size();
- }
-
- @Override
- public boolean isEmpty() {
- return delegate.isEmpty();
- }
-
- @Override
- public boolean containsKey(Object key) {
- return delegate.containsKey(key);
- }
-
- @Override
- public boolean containsValue(Object value) {
- return delegate.containsValue(value);
- }
-
- @Override
- public BeanValidator<?> get(Object key) {
- return delegate.get(key);
- }
-
- @Override
- public BeanValidator<?> put(Class<?> key, BeanValidator<?> value) {
- return delegate.put(key, value);
- }
-
- @Override
- public BeanValidator<?> remove(Object key) {
- return delegate.remove(key);
- }
-
- @Override
- public void putAll(Map<? extends Class<?>, ? extends BeanValidator<?>> m) {
- delegate.putAll(m);
- }
-
- @Override
- public void clear() {
- delegate.clear();
- }
-
- @Override
- public Set<Class<?>> keySet() {
- return delegate.keySet();
- }
-
- @Override
- public Collection<BeanValidator<?>> values() {
- return delegate.values();
- }
-
- @Override
- public Set<Entry<Class<?>, BeanValidator<?>>> entrySet() {
- return delegate.entrySet();
- }
-
-}
Deleted: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -1,326 +0,0 @@
-/*
- * #%L
- * JAXX :: Validator
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ValidationAwareSupport;
-import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.ConfigurationManager;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import com.opensymphony.xwork2.validator.DelegatingValidatorContext;
-import com.opensymphony.xwork2.validator.FieldValidator;
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.Validator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A customized validator for a given bean.
- * <p/>
- * Use the method {@link #validate(Object)} to obtain the messages detected by
- * the validator for the given bean.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @param <B> type of the bean to validate.
- * @since 1.3
- * @deprecated since 2.2.4, the code is moved into the org.nuiton:nuiton-validator project, will be removed in version 2.3
- */
-@Deprecated
-public class XWorkBeanValidator<B> {
-
- /** Logger */
- private static final Log log = LogFactory.getLog(XWorkBeanValidator.class);
-
- protected final static Map<String, List<String>> EMPTY_RESULT =
- Collections.unmodifiableMap(new HashMap<String, List<String>>());
-
- /** the type of bean to validate */
- protected final Class<B> beanClass;
-
- /** the validation named context (can be null) */
- protected String contextName;
-
- /** the list of field names detected for this validator */
- protected Set<String> fieldNames;
-
- /** a flag to include or not the default context validators */
- protected boolean includeDefaultContext;
-
- // --
- // XWorks fields
- // --
-
- protected ValidationAwareSupport validationSupport;
-
- protected DelegatingValidatorContext validationContext;
-
- protected ActionValidatorManager validator;
-
- protected ActionContext context;
-
- public XWorkBeanValidator(Class<B> beanClass, String contextName) {
- this(beanClass,
- contextName,
- true,
- BeanValidatorUtil.getSharedValueStack()
- );
- }
-
- public XWorkBeanValidator(Class<B> beanClass,
- String contextName,
- ValueStack vs) {
- this(beanClass, contextName, true, vs);
- }
-
- public XWorkBeanValidator(Class<B> beanClass,
- String contextName,
- boolean includeDefaultContext) {
- this(beanClass,
- contextName,
- includeDefaultContext,
- BeanValidatorUtil.getSharedValueStack()
- );
- }
-
- public XWorkBeanValidator(Class<B> beanClass,
- String contextName,
- boolean includeDefaultContext,
- ValueStack vs) {
-
- this.beanClass = beanClass;
- this.includeDefaultContext = includeDefaultContext;
- validationSupport = new ValidationAwareSupport();
- validationContext = new DelegatingValidatorContext(validationSupport);
-
- if (vs == null) {
- // create a standalone value stack
- ConfigurationManager confManager = new ConfigurationManager();
- Configuration conf = confManager.getConfiguration();
- Container container = conf.getContainer();
- ValueStackFactory stackFactory =
- container.getInstance(ValueStackFactory.class);
- vs = stackFactory.createValueStack();
- if (log.isDebugEnabled()) {
- log.debug("create a standalone value stack " + vs);
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("use given value stack " + vs);
- }
- }
-
- context = new ActionContext(vs.getContext());
- ActionContext.setContext(context);
-
- // init validator
- Container container = context.getContainer();
- validator = container.getInstance(ActionValidatorManager.class,
- "no-annotations"
- );
-
- // init context
- setContextName(contextName);
- }
-
- public boolean isIncludeDefaultContext() {
- return includeDefaultContext;
- }
-
- public Class<B> getBeanClass() {
- return beanClass;
- }
-
- public String getContextName() {
- return contextName;
- }
-
- public Set<String> getFieldNames() {
- return fieldNames;
- }
-
- public ActionValidatorManager getValidator() {
- return validator;
- }
-
- /**
- * Test a the validator contains the field given his name
- *
- * @param fieldName the name of the searched field
- * @return <code>true</code> if validator contaisn this field,
- * <code>false</code> otherwise
- */
- public boolean containsField(String fieldName) {
- return fieldNames.contains(fieldName);
- }
-
- public void setIncludeDefaultContext(boolean includeDefaultContext) {
- this.includeDefaultContext = includeDefaultContext;
- if (contextName != null) {
- // reload context
- setContextName(contextName);
- }
- }
-
- public void setContextName(String contextName) {
- this.contextName = contextName;
- // changing contextName may change fields definition
- // so reload fields
- initFields();
- }
-
- /**
- * Valide le bean donné et retourne les messages produits.
- *
- * @param bean le bean a valider (il doit etre non null)
- * @return le dictionnaire des messages produits par la validation indexées
- * par le nom du champs du bean impacté.
- */
- public Map<String, List<String>> validate(B bean) {
-
- if (bean == null) {
- throw new NullPointerException(
- "bean can not be null in method validate");
- }
-
- Map<String, List<String>> result = EMPTY_RESULT;
-
- // on lance la validation uniquement si des champs sont a valider
- if (!fieldNames.isEmpty()) {
-
- try {
-
- //TC - 20081024 : since context is in a ThreadLocal variable,
- // we must do the check
- if (ActionContext.getContext() == null) {
- ActionContext.setContext(context);
- }
-
- validator.validate(bean, contextName, validationContext);
-
- if (log.isTraceEnabled()) {
- log.trace("Action errors: " +
- validationContext.getActionErrors());
- log.trace("Action messages: " +
- validationContext.getActionMessages());
- log.trace("Field errors: " +
- validationContext.getFieldErrors());
- }
-
- if (log.isDebugEnabled()) {
- log.debug(this + " : " +
- validationContext.getFieldErrors());
- }
-
- // retreave errors by field
- if (validationContext.hasFieldErrors()) {
- Map<?, ?> messages = validationContext.getFieldErrors();
- result = new HashMap<String, List<String>>(messages.size());
- for (Object fieldName : messages.keySet()) {
- Collection<?> c =
- (Collection<?>) messages.get(fieldName);
- List<String> mm = new ArrayList<String>(c.size());
- for (Object message : c) {
- // tchemit 2010-08-28 : trim the incoming message
- // (I18n will not translate it otherwise)
- String messageStr = message == null ? "" : message + "";
- mm.add(messageStr.trim());
- }
- result.put(fieldName + "", mm);
- }
- }
-
- } catch (ValidationException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Error during validation on " + beanClass +
- " for reason : " + eee.getMessage(), eee);
- }
-
- } finally {
- // on nettoye toujours le validateur apres operation
- validationSupport.clearErrorsAndMessages();
- }
- }
-
- return result;
- }
-
- @Override
- public String toString() {
- return super.toString() + "<beanClass:" + beanClass +
- ", contextName:" + contextName + ">";
- }
-
- /** update the property {@link #fieldNames}, says search in XWorks */
- protected void initFields() {
-
- if (fieldNames != null) {
- fieldNames = null;
- }
-
- Set<String> detectedFieldNames = new HashSet<String>();
-
- int skip = 0;
- if (contextName != null && !includeDefaultContext) {
- // count the number of validator to skip
- for (Validator<?> v : validator.getValidators(beanClass, null)) {
- // we only work on FieldValidator at the moment
- if (v instanceof FieldValidator) {
- skip++;
- }
- }
- }
-
- for (Validator<?> v : validator.getValidators(beanClass, contextName)) {
- // we only work on FieldValidator at the moment
- if (v instanceof FieldValidator) {
- if (skip > 0) {
- skip--;
- continue;
- }
- FieldValidator fieldValidator = (FieldValidator) v;
- if (log.isDebugEnabled()) {
- log.debug("context " + contextName + " - field " +
- fieldValidator.getFieldName());
- }
- String fName = fieldValidator.getFieldName();
- detectedFieldNames.add(fName);
- }
- }
-
- fieldNames = Collections.unmodifiableSet(detectedFieldNames);
- }
-}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,17 +24,17 @@
*/
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidator;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorScope;
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.runtime.validator.swing.ui.IconValidationUI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.jxlayer.JXLayer;
+import org.nuiton.validator.NuitonValidatorFactory;
+import org.nuiton.validator.NuitonValidatorProvider;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.BeanValidator;
import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
import java.awt.Container;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -116,10 +116,10 @@
* }
* </pre>
*
+ * @param <B> le type de bean a valider
* @author poussin <poussin(a)codelutin.com>
* @author tchemit <chemit(a)codelutin.com>
* @version 1.0
- * @param <B> le type de bean a valider
*/
public class SwingValidator<B> extends BeanValidator<B> {
@@ -144,15 +144,27 @@
/** ui renderer class */
protected Class<? extends AbstractBeanValidatorUI> uiClass;
+ public SwingValidator(NuitonValidatorProvider provider,
+ Class<B> beanClass,
+ String contextName,
+ NuitonValidatorScope... filterScopes) {
+ super(provider, beanClass, contextName, filterScopes);
+ fieldRepresentation = new HashMap<String, JComponent>();
+ }
+
public SwingValidator(Class<B> beanClass,
String contextName,
- BeanValidatorScope... filterScopes) {
- super(beanClass, contextName, filterScopes);
+ NuitonValidatorScope... filterScopes) {
+ super(NuitonValidatorFactory.getDefaultProvider(),
+ beanClass,
+ contextName,
+ filterScopes
+ );
fieldRepresentation = new HashMap<String, JComponent>();
}
public SwingValidator(Class<B> beanClass, String contextName) {
- this(beanClass, contextName, FILTER_SCOPES_EMPTY);
+ this(beanClass, contextName, NuitonValidatorScope.values());
}
/**
@@ -163,6 +175,9 @@
*/
public void reloadBean() {
B b = getBean();
+ if (log.isInfoEnabled()) {
+ log.info("Will reload bean : " + b);
+ }
if (b != null) {
setBean(null);
setBean(b);
@@ -200,14 +215,18 @@
}
@Override
- public void setContextName(String contextName) {
+ public void setContext(String context) {
+ String oldContext = getContext();
- super.setContextName(contextName);
+ super.setContext(context);
- // install uis only when fieldRepresentation is not null
- // this case is possible since we come here from parent in constructor.
+ if (context == null && oldContext == null || context != null && context.equals(oldContext)) {
+
+ // same context do nothing
+ return;
+ }
if (fieldRepresentation != null) {
-
+
// must reinstall ui
installUIs();
}
@@ -221,8 +240,10 @@
* @param c the editor component for the field
*/
public void setFieldRepresentation(String fieldname, JComponent c) {
- BeanValidatorField<B> field = getField(fieldname);
- if (field == null) {
+ boolean fieldFound = getDelegate().getEffectiveFields().contains(fieldname);
+
+// BeanValidatorField<B> field = getField(fieldname);
+ if (!fieldFound) {
// no field registred in the validator
if (log.isWarnEnabled()) {
log.warn("the field '" + fieldname +
@@ -261,29 +282,47 @@
"fieldRepresentation is null, must init before " +
"invoking installUIs method...");
}
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if (uiClass == null) {
- // use the default one
- uiClass = DEFAULT_UI_CLASS;
- }
- for (Entry<String, JComponent> entry :
- fieldRepresentation.entrySet()) {
- try {
- setMessageRepresentation(
- entry.getKey(),
- null,
- entry.getValue(),
- uiClass
- );
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ if (uiClass == null) {
+ // use the default one
+ uiClass = DEFAULT_UI_CLASS;
+ }
+ for (Entry<String, JComponent> entry :
+ fieldRepresentation.entrySet()) {
+ try {
+ setMessageRepresentation(
+ entry.getKey(),
+ null,
+ entry.getValue(),
+ uiClass
+ );
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
- });
+ }
+// SwingUtilities.invokeLater(new Runnable() {
+//
+// @Override
+// public void run() {
+// if (uiClass == null) {
+// // use the default one
+// uiClass = DEFAULT_UI_CLASS;
+// }
+// for (Entry<String, JComponent> entry :
+// fieldRepresentation.entrySet()) {
+// try {
+// setMessageRepresentation(
+// entry.getKey(),
+// null,
+// entry.getValue(),
+// uiClass
+// );
+// } catch (Exception e) {
+// throw new RuntimeException(e);
+// }
+// }
+// }
+// });
}
protected void setMessageRepresentation(
@@ -299,9 +338,12 @@
// same component, nothing to do
return;
}
- BeanValidatorField<B> field = getField(fieldname);
- if (field == null) {
+ boolean fieldFound = getDelegate().getEffectiveFields().contains(fieldname);
+
+// BeanValidatorField<B> field = getField(fieldname);
+
+ if (!fieldFound) {
// this case should not appear since fieldName has already been
// check in method addFieldRepresentation
return;
@@ -323,14 +365,21 @@
// ajout du jxlayer sous ce composant
Container container = c.getParent();
if (container instanceof JXLayer<?>) {
+ JXLayer jx = (JXLayer<?>) container;
+ Object oldUI = jx.getUI();
+ if (oldUI != null && oldUI instanceof AbstractBeanValidatorUI) {
+
+ // supression de l'ancien layer
+ removeBeanValidatorListener((AbstractBeanValidatorUI) oldUI);
+ }
Constructor<? extends AbstractBeanValidatorUI> cons =
- uiClass.getConstructor(BeanValidatorField.class);
- AbstractBeanValidatorUI ui = cons.newInstance(field);
+ uiClass.getConstructor(String.class);
+ AbstractBeanValidatorUI ui = cons.newInstance(fieldname);
ui.setEnabled(true);
- JXLayer<JComponent> jx = (JXLayer<JComponent>) container;
addBeanValidatorListener(ui);
jx.setUI(ui);
}
}
}
+
}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,9 +24,8 @@
*/
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorMessage;
-import jaxx.runtime.validator.BeanValidatorScope;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.BeanValidatorMessage;
import javax.swing.JComponent;
@@ -39,28 +38,17 @@
*/
public class SwingValidatorMessage extends BeanValidatorMessage<SwingValidatorMessage> {
+ private static final long serialVersionUID = 1L;
+
/** the optional field's editor */
protected JComponent editor;
- protected String fieldName;
-
public SwingValidatorMessage(SwingValidator<?> validator,
- BeanValidatorField<?> field,
- String message,
- BeanValidatorScope scope,
- JComponent editor) {
- super(validator, field, message, scope);
- fieldName = field.getName();
- this.editor = editor;
- }
-
- public SwingValidatorMessage(SwingValidator<?> validator,
String fieldName,
String message,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
JComponent editor) {
- super(validator, null, message, scope);
- this.fieldName = fieldName;
+ super(validator, fieldName, message, scope);
this.editor = editor;
}
@@ -68,53 +56,58 @@
return editor;
}
+ /**
+ * @return the field name
+ * @deprecated since 2.3, will not be replaced
+ */
+ @Deprecated
public String getFieldName() {
- return fieldName;
+ return getField();
}
- @Override
- public int compareTo(SwingValidatorMessage o) {
- // sort on scope
- int result = getScope().compareTo(o.getScope());
- if (result == 0) {
- // sort on field name
- result = fieldName.compareTo(o.getFieldName());
- if (result == 0) {
- // sort on message
- result = message.compareTo(o.getMessage());
- }
- }
- return result;
- }
+// @Override
+// public int compareTo(SwingValidatorMessage o) {
+// // sort on scope
+// int result = getScope().compareTo(o.getScope());
+// if (result == 0) {
+// // sort on field name
+// result = fieldName.compareTo(o.getField());
+// if (result == 0) {
+// // sort on message
+// result = message.compareTo(o.getMessage());
+// }
+// }
+// return result;
+// }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
+// @Override
+// public boolean equals(Object o) {
+// if (this == o) {
+// return true;
+// }
+// if (o == null || getClass() != o.getClass()) {
+// return false;
+// }
+//
+// SwingValidatorMessage that = (SwingValidatorMessage) o;
+//
+// return fieldName.equals(that.fieldName) &&
+// message.equals(that.message) &&
+// scope == that.scope;
+// }
- SwingValidatorMessage that = (SwingValidatorMessage) o;
+// @Override
+// public int hashCode() {
+// int result = fieldName.hashCode();
+// result = 31 * result + message.hashCode();
+// result = 31 * result + scope.hashCode();
+// return result;
+// }
- return fieldName.equals(that.fieldName) &&
- message.equals(that.message) &&
- scope == that.scope;
- }
-
@Override
- public int hashCode() {
- int result = fieldName.hashCode();
- result = 31 * result + message.hashCode();
- result = 31 * result + scope.hashCode();
- return result;
- }
-
- @Override
public String toString() {
String s = scope + " - " +
- (field == null ? message : field.getI18nError(message));
+ (field == null ? message : field + " - " + message);
if (editor == null) {
return s;
}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,12 +24,11 @@
*/
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidatorEvent;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
-import jaxx.runtime.validator.BeanValidatorScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.BeanValidatorEvent;
+import org.nuiton.validator.bean.BeanValidatorListener;
import javax.swing.AbstractListModel;
import javax.swing.JComponent;
@@ -100,8 +99,8 @@
public void onFieldChanged(BeanValidatorEvent event) {
String[] toDelete = event.getMessagesToDelete();
String[] toAdd = event.getMessagesToAdd();
- BeanValidatorField<?> field = event.getField();
- BeanValidatorScope scope = event.getScope();
+ String field = event.getField();
+ NuitonValidatorScope scope = event.getScope();
boolean mustAdd = toAdd != null && toAdd.length > 0;
boolean mustDel = toDelete != null && toDelete.length > 0;
@@ -135,12 +134,12 @@
}
protected void addMessages(SwingValidator<?> validator,
- BeanValidatorField<?> field,
- BeanValidatorScope scope,
+ String field,
+ NuitonValidatorScope scope,
boolean sort,
String... messages) {
- JComponent editor = validator.getFieldRepresentation(field.getName());
+ JComponent editor = validator.getFieldRepresentation(field);
// add new errors
for (String error : messages) {
SwingValidatorMessage row = new SwingValidatorMessage(
@@ -167,8 +166,8 @@
}
protected void removeMessages(SwingValidator<?> validator,
- BeanValidatorField<?> field,
- BeanValidatorScope scope,
+ String field,
+ NuitonValidatorScope scope,
boolean notify,
String... messages) {
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,7 +24,7 @@
*/
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidatorScope;
+import org.nuiton.validator.NuitonValidatorScope;
import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
@@ -89,7 +89,7 @@
// field name
String fieldName = getFieldName(
list,
- model.getField().getName(),
+ model.getField(),
index
);
@@ -113,7 +113,7 @@
return rendererComponent;
}
- public ImageIcon getIcon(BeanValidatorScope scope) {
+ public ImageIcon getIcon(NuitonValidatorScope scope) {
ImageIcon icon = SwingValidatorUtil.getIcon(scope);
return icon;
}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,12 +24,11 @@
*/
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidatorEvent;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
-import jaxx.runtime.validator.BeanValidatorScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.BeanValidatorEvent;
+import org.nuiton.validator.bean.BeanValidatorListener;
import javax.swing.JComponent;
import javax.swing.table.AbstractTableModel;
@@ -60,7 +59,7 @@
{"validator.scope", "validator.field", "validator.message"};
public static final Class<?>[] columnClasses =
- {BeanValidatorScope.class, String.class, String.class};
+ {NuitonValidatorScope.class, String.class, String.class};
/** list of registred validators */
protected transient List<SwingValidator<?>> validators;
@@ -93,27 +92,20 @@
public void addMessages(SwingValidator<?> validator,
String fieldName,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
String... messages) {
addMessages(validator, fieldName, scope, true, messages);
}
public void addMessages(JComponent editor,
String fieldName,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
String... messages) {
addMessages(editor, fieldName, scope, true, messages);
}
- public void addMessages(SwingValidator<?> validator,
- BeanValidatorField<?> field,
- BeanValidatorScope scope,
- String... messages) {
- addMessages(validator, field, scope, true, messages);
- }
+ public void removeMessages(JComponent editor, NuitonValidatorScope scope) {
- public void removeMessages(JComponent editor, BeanValidatorScope scope) {
-
if (editor == null) {
// no editor, so nothing to do
return;
@@ -134,24 +126,17 @@
public void removeMessages(SwingValidator<?> validator,
String fieldName,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
String... messages) {
removeMessages(validator, fieldName, scope, true, messages);
}
public void removeMessages(JComponent editor,
String fieldName,
- BeanValidatorScope scope) {
+ NuitonValidatorScope scope) {
removeMessages(editor, fieldName, scope, true);
}
- public void removeMessages(SwingValidator<?> validator,
- BeanValidatorField<?> field,
- BeanValidatorScope scope,
- String... messages) {
- removeMessages(validator, field, scope, true, messages);
- }
-
public void clear() {
int i = data.size();
if (i > 0) {
@@ -200,8 +185,8 @@
public void onFieldChanged(BeanValidatorEvent event) {
String[] toDelete = event.getMessagesToDelete();
String[] toAdd = event.getMessagesToAdd();
- BeanValidatorField<?> field = event.getField();
- BeanValidatorScope scope = event.getScope();
+ String field = event.getField();
+ NuitonValidatorScope scope = event.getScope();
boolean mustAdd = toAdd != null && toAdd.length > 0;
boolean mustDel = toDelete != null && toDelete.length > 0;
@@ -248,7 +233,7 @@
}
if (columnIndex == 1) {
// the field
- return row.getFieldName();
+ return row.getField();
}
if (columnIndex == 2) {
// the message
@@ -278,43 +263,8 @@
}
protected void addMessages(SwingValidator<?> validator,
- BeanValidatorField<?> field,
- BeanValidatorScope scope,
- boolean sort,
- String... messages) {
-
- JComponent editor = validator == null ?
- null :
- validator.getFieldRepresentation(field.getName());
- // add new errors
- for (String error : messages) {
- SwingValidatorMessage row =
- new SwingValidatorMessage(
- validator,
- field,
- error,
- scope,
- editor
- );
- data.add(row);
- if (!sort) {
- fireTableRowsInserted(data.size() - 1, data.size() - 1);
- }
- }
-
- if (sort) {
-
- // resort datas
- Collections.sort(data);
-
- // notify
- fireTableDataChanged();
- }
- }
-
- protected void addMessages(SwingValidator<?> validator,
String fieldName,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
boolean sort,
String... messages) {
@@ -349,7 +299,7 @@
protected void addMessages(JComponent editor,
String fieldName,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
boolean sort,
String... messages) {
@@ -380,35 +330,8 @@
}
protected void removeMessages(SwingValidator<?> validator,
- BeanValidatorField<?> field,
- BeanValidatorScope scope,
- boolean notify,
- String... messages) {
-
- List<String> messagesToDel =
- new ArrayList<String>(Arrays.asList(messages));
-
- // do it in reverse mode (only one pass in that way since index
- // will stay coherent while removing them)
-
- for (int i = getRowCount() - 1; i > -1; i--) {
- SwingValidatorMessage error = data.get(i);
- if (validator.equals(error.getValidator()) &&
- error.getScope() == scope &&
- error.getFieldName().equals(field.getName()) &&
- messagesToDel.contains(error.getMessage())) {
- // remove the message
- data.remove(i);
- if (notify) {
- fireTableRowsDeleted(i, i);
- }
- }
- }
- }
-
- protected void removeMessages(SwingValidator<?> validator,
String fieldName,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
boolean notify,
String... messages) {
@@ -422,7 +345,7 @@
SwingValidatorMessage error = data.get(i);
if (validator.equals(error.getValidator()) &&
error.getScope() == scope &&
- error.getFieldName().equals(fieldName) &&
+ error.getField().equals(fieldName) &&
messagesToDel.contains(error.getMessage())) {
// remove the message
data.remove(i);
@@ -435,7 +358,7 @@
protected void removeMessages(JComponent editor,
String fieldName,
- BeanValidatorScope scope,
+ NuitonValidatorScope scope,
boolean notify) {
// do it in reverse mode (only one pass in that way since index
@@ -445,7 +368,7 @@
SwingValidatorMessage error = data.get(i);
if (editor.equals(error.getEditor()) &&
(scope == null || error.getScope() == scope) &&
- error.getFieldName().equals(fieldName)) {
+ error.getField().equals(fieldName)) {
// remove the message
data.remove(i);
if (notify) {
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,7 +24,7 @@
*/
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidatorScope;
+import org.nuiton.validator.NuitonValidatorScope;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
@@ -72,11 +72,10 @@
row = table.getRowSorter().convertRowIndexToModel(row);
}
-
switch (column) {
case 0:
// scope
- BeanValidatorScope scope = (BeanValidatorScope) value;
+ NuitonValidatorScope scope = (NuitonValidatorScope) value;
icon = SwingValidatorUtil.getIcon(scope);
String label = _(scope.getLabel());
toolTipText = _("validator.scope.tip", label);
@@ -101,7 +100,7 @@
return rendererComponent;
}
- public ImageIcon getIcon(BeanValidatorScope scope) {
+ public ImageIcon getIcon(NuitonValidatorScope scope) {
ImageIcon icon = SwingValidatorUtil.getIcon(scope);
return icon;
}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -26,10 +26,13 @@
import jaxx.runtime.JAXXValidator;
import jaxx.runtime.SwingUtil;
-import jaxx.runtime.validator.BeanValidatorScope;
-import jaxx.runtime.validator.BeanValidatorUtil;
+import jaxx.runtime.validator.swing.meta.Validator;
+import jaxx.runtime.validator.swing.meta.ValidatorField;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ReflectUtil;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.BeanValidatorUtil;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
@@ -37,10 +40,17 @@
import javax.swing.JTable;
import javax.swing.RowSorter;
import javax.swing.SortOrder;
+import java.awt.Color;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
import static org.nuiton.i18n.I18n.n_;
@@ -51,48 +61,138 @@
*/
public class SwingValidatorUtil extends BeanValidatorUtil {
- static ImageIcon fatalIcon;
+ /** Logger */
+ static private final Log log = LogFactory.getLog(SwingValidatorUtil.class);
- static ImageIcon errorIcon;
+ protected static EnumMap<NuitonValidatorScope, ImageIcon> icons;
- static ImageIcon warningIcon;
+ protected static EnumMap<NuitonValidatorScope, Color> colors;
- static ImageIcon infoIcon;
+ public static EnumMap<NuitonValidatorScope, ImageIcon> getIcons() {
+ if (icons == null) {
+ icons = new EnumMap<NuitonValidatorScope, ImageIcon>(NuitonValidatorScope.class);
+ icons.put(NuitonValidatorScope.FATAL, SwingUtil.createImageIcon("fatal.png"));
+ icons.put(NuitonValidatorScope.ERROR, SwingUtil.createImageIcon("error.png"));
+ icons.put(NuitonValidatorScope.WARNING, SwingUtil.createImageIcon("warning.png"));
+ icons.put(NuitonValidatorScope.INFO, SwingUtil.createImageIcon("info.png"));
+ }
+ return icons;
+ }
- /** Logger */
- static private final Log log = LogFactory.getLog(SwingValidatorUtil.class);
+ public static EnumMap<NuitonValidatorScope, Color> getColors() {
+ if (colors == null) {
+ colors = new EnumMap<NuitonValidatorScope, Color>(NuitonValidatorScope.class);
+ colors.put(NuitonValidatorScope.FATAL, Color.MAGENTA);
+ colors.put(NuitonValidatorScope.ERROR, Color.RED);
+ colors.put(NuitonValidatorScope.WARNING, Color.YELLOW);
+ colors.put(NuitonValidatorScope.INFO, Color.GREEN);
+ }
+ return colors;
+ }
+ public static Color getColor(NuitonValidatorScope scope) {
+ Color c = scope == null ? null : getColors().get(scope);
+ return c;
+ }
+ public static ImageIcon getIcon(NuitonValidatorScope scope) {
+ ImageIcon icon = scope == null ? null : getIcons().get(scope);
+ return icon;
+ }
+
public static ImageIcon getFatalIcon() {
- if (fatalIcon == null) {
- fatalIcon = SwingUtil.createImageIcon("fatal.png");
- }
- return fatalIcon;
+ return getIcons().get(NuitonValidatorScope.FATAL);
}
public static ImageIcon getErrorIcon() {
- if (errorIcon == null) {
- errorIcon = SwingUtil.createImageIcon("error.png");
- }
- return errorIcon;
+ return getIcons().get(NuitonValidatorScope.ERROR);
}
+ public static ImageIcon getWarningIcon() {
+ return getIcons().get(NuitonValidatorScope.WARNING);
+ }
+
public static ImageIcon getInfoIcon() {
- if (infoIcon == null) {
- infoIcon = SwingUtil.createImageIcon("info.png");
+ return getIcons().get(NuitonValidatorScope.INFO);
+ }
+
+ protected SwingValidatorUtil() {
+ // no instance
+ }
+
+ public static List<String> initUI(JAXXValidator ui) {
+ List<String> validatorIds = new ArrayList<String>();
+ Map<Field, Validator> validators = ReflectUtil.getFieldAnnotation(
+ ui.getClass(),
+ Validator.class
+ );
+
+ for (Map.Entry<Field, Validator> entry : validators.entrySet()) {
+ Field field = entry.getKey();
+ Validator annotation = entry.getValue();
+ String validatorId = annotation.validatorId();
+ validatorIds.add(validatorId);
+ if (log.isInfoEnabled()) {
+ log.info("Detect validator [" + annotation.validatorId() + "] on field " + field.getName());
+ }
}
- return infoIcon;
+ return Collections.unmodifiableList(validatorIds);
}
- public static ImageIcon getWarningIcon() {
- if (warningIcon == null) {
- warningIcon = SwingUtil.createImageIcon("warning.png");
+ public static void installFields(JAXXValidator ui) {
+
+ Map<Field, ValidatorField> validatorFields = ReflectUtil.getFieldAnnotation(
+ ui.getClass(),
+ ValidatorField.class
+ );
+
+ List<String> validatorIds = ui.getValidatorIds();
+
+ try {
+ for (String validatorId : validatorIds) {
+ SwingValidator<?> validator = (SwingValidator<?>) ui.getValidator(validatorId);
+ for (Map.Entry<Field, ValidatorField> fieldEntry : validatorFields.entrySet()) {
+ Field validatorField = fieldEntry.getKey();
+ validatorField.setAccessible(true);
+ ValidatorField fieldAnnotation = fieldEntry.getValue();
+ JComponent editor = (JComponent) validatorField.get(ui);
+ if (!validatorId.equals(fieldAnnotation.validatorId())) {
+
+ // not good validator, skip this field
+ continue;
+ }
+ String propertyName = fieldAnnotation.propertyName();
+ if (log.isInfoEnabled()) {
+ log.info("Detects for validator [" + validatorId + "] property " + propertyName + " for editor " + fieldAnnotation.editorName());
+ }
+ validator.setFieldRepresentation(propertyName, editor);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new IllegalStateException("Could not init validators on ui " + ui, e);
}
- return warningIcon;
+
}
- protected SwingValidatorUtil() {
- // no instance
+ public static void installUI(JAXXValidator ui) {
+
+ // first install fields with validation
+ installFields(ui);
+
+ // for each validator install uis + reload bean
+
+ List<String> validatorIds = ui.getValidatorIds();
+ for (String validatorId : validatorIds) {
+ SwingValidator<?> validator = (SwingValidator<?>) ui.getValidator(validatorId);
+
+ // install uis
+ validator.installUIs();
+
+ // reload attached bean (to see validation on uis)
+ validator.reloadBean();
+ }
+
+
}
/**
@@ -206,7 +306,7 @@
public static String getMessage(SwingValidatorMessage model) {
String text = model.getMessage();
if (model.getField() != null) {
- text = model.getField().getI18nError(text);
+ text = model.getI18nError(text);
}
return text;
}
@@ -228,25 +328,6 @@
return text;
}
- public static ImageIcon getIcon(BeanValidatorScope scope) {
- ImageIcon icon = null;
- switch (scope) {
- case FATAL:
- icon = getFatalIcon();
- break;
- case ERROR:
- icon = getErrorIcon();
- break;
- case WARNING:
- icon = getWarningIcon();
- break;
- case INFO:
- icon = getInfoIcon();
- break;
- }
- return icon;
- }
-
/**
* Method to listen the modification of the context name and at each time
* reload fields of the ui.
@@ -262,13 +343,13 @@
SwingValidator<?> validator = (SwingValidator<?>) evt.getSource();
if (log.isInfoEnabled()) {
log.info("Context name changed to [" + evt.getNewValue() +
- "] for validator " + validator.getBeanClass());
+ "] for validator " + validator.getType());
}
ui.registerValidatorFields();
}
};
validator.addPropertyChangeListener(
- SwingValidator.CONTEXT_NAME_PROPERTY,
+ SwingValidator.CONTEXT_PROPERTY,
listener
);
}
Added: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java (rev 0)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -0,0 +1,24 @@
+package jaxx.runtime.validator.swing.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to put on each field validator.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Validator {
+
+ /**
+ * Obtain the id of the validator.
+ *
+ * @return the id of the validator.
+ */
+ String validatorId();
+}
Property changes on: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/Validator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java (rev 0)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -0,0 +1,39 @@
+package jaxx.runtime.validator.swing.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to put on each field linked to a validator.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface ValidatorField {
+ /**
+ * Obtain the id of the validator used for the field.
+ *
+ * @return the id of the validator used for the field.
+ */
+ String validatorId();
+
+ /**
+ * Obtain the name of the bean property to validate.
+ *
+ * @return the name of the property to validate
+ */
+ String propertyName();
+
+ /**
+ * Obtain the name of the property editor.
+ * <p/>
+ * If empty, then use the {@link #propertyName()}.
+ *
+ * @return the name of the property editor
+ */
+ String editorName() default "";
+}
Property changes on: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/meta/ValidatorField.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,12 +24,12 @@
*/
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.validator.BeanValidatorEvent;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.jxlayer.plaf.AbstractLayerUI;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.BeanValidatorEvent;
+import org.nuiton.validator.bean.BeanValidatorListener;
import javax.swing.JComponent;
@@ -43,19 +43,36 @@
/** Logger */
private static final Log log = LogFactory.getLog(AbstractBeanValidatorUI.class);
- /** the field to render */
- protected BeanValidatorField<?> field;
+ /**
+ * Actual scope to display in the layer.
+ * <p/>
+ * This field will be recomputed each time a new event arrived on this
+ * field.
+ */
+ protected NuitonValidatorScope scope;
- public AbstractBeanValidatorUI(BeanValidatorField<?> field) {
+ /** Field name in validator. */
+ protected final String field;
+
+ public AbstractBeanValidatorUI(String field) {
this.field = field;
if (log.isDebugEnabled()) {
log.debug("install " + this + "<field:" + field + ">");
}
}
+ public NuitonValidatorScope getScope() {
+ return scope;
+ }
+
@Override
public void onFieldChanged(BeanValidatorEvent event) {
if (field.equals(event.getField())) {
+
+ scope = event.getSource().getHighestScope(field);
+ if (log.isDebugEnabled()) {
+ log.debug("set new scope : " + scope + " to field " + field);
+ }
// ask to repaint the layer
setDirty(true);
}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,9 +24,9 @@
*/
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorScope;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
import org.jdesktop.jxlayer.JXLayer;
+import org.nuiton.validator.NuitonValidatorScope;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
@@ -34,6 +34,7 @@
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
+import java.util.EnumMap;
/**
@@ -46,28 +47,17 @@
// The icon to be shown at the layer's corner
- protected static BufferedImage fatalIcon;
+ protected EnumMap<NuitonValidatorScope, BufferedImage> icons;
- protected static BufferedImage errorIcon;
+ public IconValidationUI(String field) {
+ super(field);
+ icons = new EnumMap<NuitonValidatorScope, BufferedImage>(NuitonValidatorScope.class);
- protected static BufferedImage warningIcon;
+ for (NuitonValidatorScope scope : NuitonValidatorScope.values()) {
- protected static BufferedImage infoIcon;
-
- public IconValidationUI(BeanValidatorField<?> field) {
- super(field);
- if (fatalIcon == null) {
- fatalIcon = prepareIcon(Color.MAGENTA);
+ BufferedImage image = prepareIcon(SwingValidatorUtil.getColor(scope));
+ icons.put(scope, image);
}
- if (errorIcon == null) {
- errorIcon = prepareIcon(Color.RED);
- }
- if (warningIcon == null) {
- warningIcon = prepareIcon(Color.ORANGE);
- }
- if (infoIcon == null) {
- infoIcon = prepareIcon(Color.GREEN);
- }
}
@Override
@@ -86,26 +76,10 @@
protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
super.paintLayer(g2, l);
// There is no need to take insets into account for this painter
- BeanValidatorScope scope = field.getScope();
+ NuitonValidatorScope scope = getScope();
if (scope != null) {
- BufferedImage icon = null;
- switch (scope) {
- case FATAL:
- icon = fatalIcon;
- break;
- case ERROR:
- icon = errorIcon;
- break;
- case WARNING:
- icon = warningIcon;
- break;
- case INFO:
- icon = infoIcon;
- break;
- }
- if (icon != null) {
- g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
- }
+ BufferedImage icon = icons.get(scope);
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
}
}
@@ -124,4 +98,6 @@
g2.dispose();
return icon;
}
+
+
}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,10 +24,9 @@
*/
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorScope;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
import org.jdesktop.jxlayer.JXLayer;
+import org.nuiton.validator.NuitonValidatorScope;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
@@ -35,6 +34,7 @@
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
+import java.util.EnumMap;
/**
@@ -45,28 +45,17 @@
*/
public class ImageValidationUI extends AbstractBeanValidatorUI {
- protected static BufferedImage fatalIcon;
+ protected EnumMap<NuitonValidatorScope, BufferedImage> icons;
- protected static BufferedImage errorIcon;
+ public ImageValidationUI(String field) {
+ super(field);
+ icons = new EnumMap<NuitonValidatorScope, BufferedImage>(NuitonValidatorScope.class);
- protected static BufferedImage warningIcon;
+ for (NuitonValidatorScope scope : NuitonValidatorScope.values()) {
- protected static BufferedImage infoIcon;
-
- public ImageValidationUI(BeanValidatorField<?> field) {
- super(field);
- if (fatalIcon == null) {
- fatalIcon = prepareIcon(SwingUtil.createImageIcon("fatal.png"));
+ BufferedImage image = prepareIcon(SwingValidatorUtil.getIcon(scope));
+ icons.put(scope, image);
}
- if (errorIcon == null) {
- errorIcon = prepareIcon(SwingUtil.createImageIcon("error.png"));
- }
- if (warningIcon == null) {
- warningIcon = prepareIcon(SwingUtil.createImageIcon("warning.png"));
- }
- if (infoIcon == null) {
- infoIcon = prepareIcon(SwingUtil.createImageIcon("info.png"));
- }
}
protected static BufferedImage prepareIcon(ImageIcon image) {
@@ -94,26 +83,27 @@
@Override
protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
super.paintLayer(g2, l);
- BeanValidatorScope scope = field.getScope();
+ NuitonValidatorScope scope = getScope();
if (scope != null) {
- BufferedImage icon = null;
- switch (scope) {
- case FATAL:
- icon = fatalIcon;
- break;
- case ERROR:
- icon = errorIcon;
- break;
- case WARNING:
- icon = warningIcon;
- break;
- case INFO:
- icon = infoIcon;
- break;
- }
- if (icon != null) {
- g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
- }
+ BufferedImage icon = icons.get(scope);
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+// switch (scope) {
+// case FATAL:
+// icon = fatalIcon;
+// break;
+// case ERROR:
+// icon = errorIcon;
+// break;
+// case WARNING:
+// icon = warningIcon;
+// break;
+// case INFO:
+// icon = infoIcon;
+// break;
+// }
+// if (icon != null) {
+// g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+// }
}
}
}
Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
===================================================================
--- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2011-01-25 11:44:38 UTC (rev 2160)
+++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2011-01-25 11:56:47 UTC (rev 2161)
@@ -24,9 +24,9 @@
*/
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorScope;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
import org.jdesktop.jxlayer.JXLayer;
+import org.nuiton.validator.NuitonValidatorScope;
import javax.swing.JComponent;
import java.awt.AlphaComposite;
@@ -44,20 +44,8 @@
*/
public class TranslucentValidationUI extends AbstractBeanValidatorUI {
- protected Color fatalHightlight;
-
- protected Color errorHightlight;
-
- protected Color warningHightlight;
-
- protected Color infoHightlight;
-
- public TranslucentValidationUI(BeanValidatorField<?> field) {
+ public TranslucentValidationUI(String field) {
super(field);
- fatalHightlight = Color.MAGENTA;
- errorHightlight = Color.RED;
- warningHightlight = Color.YELLOW;
- infoHightlight = Color.GREEN;
}
@Override
@@ -76,27 +64,10 @@
view.getWidth() - insets.left - insets.right,
view.getHeight() - insets.top - insets.bottom));
- BeanValidatorScope scope = field.getScope();
+ NuitonValidatorScope scope = getScope();
- if (scope == null) {
- g2.setColor(Color.WHITE);
- } else {
- switch (scope) {
- case FATAL:
- g2.setColor(fatalHightlight);
- break;
- case ERROR:
- g2.setColor(errorHightlight);
- break;
- case WARNING:
- g2.setColor(warningHightlight);
- break;
- case INFO:
- g2.setColor(infoHightlight);
- break;
- }
- }
-
+ Color c = scope == null ? Color.WHITE : SwingValidatorUtil.getColor(scope);
+ g2.setColor(c);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f));
g2.fillRect(0, 0, l.getWidth(), l.getHeight());
}
1
0
Author: tchemit
Date: 2011-01-25 12:44:38 +0100 (Tue, 25 Jan 2011)
New Revision: 2160
Url: http://nuiton.org/repositories/revision/jaxx/2160
Log:
use common-collections
Modified:
trunk/jaxx-compiler/pom.xml
Modified: trunk/jaxx-compiler/pom.xml
===================================================================
--- trunk/jaxx-compiler/pom.xml 2011-01-25 11:44:23 UTC (rev 2159)
+++ trunk/jaxx-compiler/pom.xml 2011-01-25 11:44:38 UTC (rev 2160)
@@ -67,6 +67,11 @@
</dependency>
<dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
1
0
25 Jan '11
Author: tchemit
Date: 2011-01-25 12:44:23 +0100 (Tue, 25 Jan 2011)
New Revision: 2159
Url: http://nuiton.org/repositories/revision/jaxx/2159
Log:
Evolution #1238: Add getField method on JavaFile
Evolution #1236: Can generate annotations on fields
Reformat code
Modified:
trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java 2011-01-24 20:12:47 UTC (rev 2158)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaElement.java 2011-01-25 11:44:23 UTC (rev 2159)
@@ -25,22 +25,35 @@
package jaxx.compiler.java;
+import org.apache.commons.collections.CollectionUtils;
+
import java.lang.reflect.Modifier;
+import java.util.ArrayList;
import java.util.Comparator;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Base Java element
+ *
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.0
*/
public abstract class JavaElement {
-// private String lineSeparator;
+ // private String lineSeparator;
private String name;
+
private int modifiers;
+ /**
+ * List of annoations.
+ *
+ * @since 2.3
+ */
+ private List<String> annotations;
+
public JavaElement(int modifiers, String name) {
this.modifiers = modifiers;
this.name = name;
@@ -58,8 +71,8 @@
return name;
}
- public final void setName(String className) {
- this.name = className;
+ public final void setName(String name) {
+ this.name = name;
}
public final String getModifiersText() {
@@ -70,6 +83,21 @@
}
}
+ public List<String> getAnnotations() {
+ if (annotations == null) {
+ annotations = new ArrayList<String>();
+ }
+ return annotations;
+ }
+
+ public boolean hasAnnotations() {
+ return CollectionUtils.isNotEmpty(annotations);
+ }
+
+ public void addAnnotation(String annotation) {
+ getAnnotations().add(annotation);
+ }
+
public static final Comparator<JavaElement> JavaElementComparator = new Comparator<JavaElement>() {
final Pattern NAME_PATTERN = Pattern.compile("(.+)([0-9]+)");
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java 2011-01-24 20:12:47 UTC (rev 2158)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaField.java 2011-01-25 11:44:23 UTC (rev 2159)
@@ -26,7 +26,13 @@
package jaxx.compiler.java;
import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.List;
/**
* Represents a field in a Java source file being generated for output. <code>JavaFields</code> are created
@@ -34,17 +40,13 @@
*/
public class JavaField extends JavaElement implements Comparable<JavaField> {
- /**
- * type of field (fqn)
- */
+ /** type of field (fqn) */
private String type;
- /**
- * initializer of field (can be null)
- */
+
+ /** initializer of field (can be null) */
private String initializer;
- /**
- * flag to known where a field overrides a super-field
- */
+
+ /** flag to known where a field overrides a super-field */
private boolean override;
/**
@@ -57,7 +59,10 @@
* @param name the field's name
* @param override flag to add @Override annotation on getter and setter
*/
- public JavaField(int modifiers, String type, String name, boolean override) {
+ public JavaField(int modifiers,
+ String type,
+ String name,
+ boolean override) {
this(modifiers, type, name, override, null);
}
@@ -74,7 +79,11 @@
* @param override {@code true} if method should be marked as overriden
* @param initializer the initial value of the field, as it would appear in Java source code
*/
- public JavaField(int modifiers, String type, String name, boolean override, String initializer) {
+ public JavaField(int modifiers,
+ String type,
+ String name,
+ boolean override,
+ String initializer) {
super(modifiers, name);
this.type = type;
this.initializer = initializer;
@@ -166,8 +175,11 @@
@Override
public boolean accept(JavaField field) {
return true;
- }};
+ }
+ };
+
private final String header;
+
private int modifier;
FieldOrder(int modifier, String header) {
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java 2011-01-24 20:12:47 UTC (rev 2158)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFile.java 2011-01-25 11:44:23 UTC (rev 2159)
@@ -205,4 +205,13 @@
public void setSuperGenericType(String superGenericType) {
this.superGenericType = superGenericType;
}
+
+ public JavaField getField(String componentId) {
+ for (JavaField field : fields) {
+ if (componentId.equals(field.getName())) {
+ return field;
+ }
+ }
+ return null;
+ }
}
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java 2011-01-24 20:12:47 UTC (rev 2158)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/java/JavaFileGenerator.java 2011-01-25 11:44:23 UTC (rev 2159)
@@ -45,9 +45,7 @@
*/
public class JavaFileGenerator {
- /**
- * Logger
- */
+ /** Logger */
static private final Log log = LogFactory.getLog(JavaFileGenerator.class);
public static JavaField newField(int modifiers, String returnType, String name, boolean override) {
@@ -82,17 +80,13 @@
return all + eol + "/*--" + new String(prefix) + " " + header + " " + new String(prefix) + "--*/" + eol + all + eol;
}
- /**
- * End of line
- */
+ /** End of line */
protected final String eol;
- /**
- * verbose flag when generates
- */
+
+ /** verbose flag when generates */
protected final boolean verbose;
- /**
- * current prefix indent size
- */
+
+ /** current prefix indent size */
protected int indentationLevel = 0;
public JavaFileGenerator(String eol, boolean verbose) {
@@ -245,6 +239,7 @@
}
}
StringBuffer result = new StringBuffer();
+ generateAnnotations(f, result, eol);
result.append(f.getModifiersText());
result.append(f.getType()).append(' ').append(f.getName());
if (f.getInitializer() != null) {
@@ -254,6 +249,19 @@
return result.toString();
}
+ protected void generateAnnotations(JavaElement element,
+ StringBuffer result,
+ String separator) {
+ if (element.hasAnnotations()) {
+ for (String annotation : element.getAnnotations()) {
+ if (!annotation.startsWith("@")) {
+ result.append("@");
+ }
+ result.append(annotation).append(separator);
+ }
+ }
+ }
+
public String generateMethod(JavaMethod m) {
if (verbose) {
log.info(m.getName());
1
0
Author: tchemit
Date: 2011-01-24 21:12:47 +0100 (Mon, 24 Jan 2011)
New Revision: 2158
Url: http://nuiton.org/repositories/revision/jaxx/2158
Log:
Evolution #1233: Updates to nuiton-i18n 2.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-01-24 19:23:19 UTC (rev 2157)
+++ trunk/pom.xml 2011-01-24 20:12:47 UTC (rev 2158)
@@ -424,7 +424,7 @@
<projectId>jaxx</projectId>
<nuitonUtilsVersion>2.0-SNAPSHOT</nuitonUtilsVersion>
- <nuitonI18nVersion>2.1-SNAPSHOT</nuitonI18nVersion>
+ <nuitonI18nVersion>2.1</nuitonI18nVersion>
<jxLayerVersion>3.0.3</jxLayerVersion>
1
0