Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 1440 discussions
r1055 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation
by tchemit@users.labs.libre-entreprise.org 03 Dec '08
by tchemit@users.labs.libre-entreprise.org 03 Dec '08
03 Dec '08
Author: tchemit
Date: 2008-12-03 16:23:49 +0000 (Wed, 03 Dec 2008)
New Revision: 1055
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
Log:
fix bug when go back on a PER_UI strategy
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-12-02 22:25:40 UTC (rev 1054)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-12-03 16:23:49 UTC (rev 1055)
@@ -1,6 +1,7 @@
package jaxx.runtime.swing.navigation;
import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
import org.apache.commons.logging.Log;
@@ -24,6 +25,8 @@
static public final String NAVIGATION_SELECTED_BEAN = "navigation-selected-bean";
+ static public final JAXXContextEntryDef<Boolean> GO_BACK_DEF = JAXXContextEntryDef.newDef("goBack", Boolean.class);
+
/** defined the stategy of instanciation of ui */
public enum Strategy {
/** instanciate a ui for a node */
@@ -125,6 +128,13 @@
return;
}
+ Boolean goBack = GO_BACK_DEF.getContextValue(context);
+ if (goBack != null && goBack) {
+ // do not treate this, apsecial flag told us :)
+ GO_BACK_DEF.removeContextValue(context);
+ return;
+ }
+
try {
NavigationTreeNode node = prepareNode(event);
@@ -144,6 +154,7 @@
}
if (!closeUI(event, component)) {
+ GO_BACK_DEF.setContextValue(context, Boolean.TRUE);
// previous ui was not closed, so reselect the previous node in navigation
goBackToPreviousNode(event, null);
// and quit
1
0
r1054 - in lutinjaxx/trunk/jaxx-core: . src/main/java/jaxx/runtime/validator src/main/java/jaxx/tags/swing src/main/java/jaxx/tags/validator
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
02 Dec '08
Author: tchemit
Date: 2008-12-02 22:25:40 +0000 (Tue, 02 Dec 2008)
New Revision: 1054
Added:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java
Modified:
lutinjaxx/trunk/jaxx-core/changelog
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java
Log:
can exclude field from validator
Modified: lutinjaxx/trunk/jaxx-core/changelog
===================================================================
--- lutinjaxx/trunk/jaxx-core/changelog 2008-12-02 20:59:03 UTC (rev 1053)
+++ lutinjaxx/trunk/jaxx-core/changelog 2008-12-02 22:25:40 UTC (rev 1054)
@@ -1,4 +1,5 @@
0.7 chemit 200812??
+ - can exclude field from validator
* 20081202 [chemit] - add strategy for loading ui in NavigationTreeSelectionAdapter
- fix bug when searching for a inner class
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java 2008-12-02 20:59:03 UTC (rev 1053)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java 2008-12-02 22:25:40 UTC (rev 1054)
@@ -79,10 +79,9 @@
// clean errors in model
getDataVector().clear();
- Scope scope = validator.getScope();
// reinject in list model, all the errors
for (BeanValidatorError error : newErrors) {
- addRow(new Object[]{scope, error.getFieldName(), error});
+ addRow(new Object[]{error.getScope(), error.getFieldName(), error});
}
// notify thaht the model has changed
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java 2008-12-02 20:59:03 UTC (rev 1053)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/swing/SwingInitializer.java 2008-12-02 22:25:40 UTC (rev 1054)
@@ -19,6 +19,7 @@
import jaxx.tags.TagManager;
import jaxx.tags.validator.BeanValidatorHandler;
import jaxx.tags.validator.FieldValidatorHandler;
+import jaxx.tags.validator.ExcludeFieldValidatorHandler;
import jaxx.types.KeyStrokeConverter;
import jaxx.types.TypeManager;
@@ -98,6 +99,7 @@
// validator
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(BeanValidator.class), BeanValidatorHandler.class);
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, FieldValidatorHandler.FIELD_VALIDATOR_TAG, new FieldValidatorHandler());
+ TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, FieldValidatorHandler.TAG, new FieldValidatorHandler());
+ TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, ExcludeFieldValidatorHandler.TAG, new FieldValidatorHandler());
}
}
\ No newline at end of file
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2008-12-02 20:59:03 UTC (rev 1053)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2008-12-02 22:25:40 UTC (rev 1054)
@@ -29,7 +29,7 @@
public class BeanValidatorHandler extends DefaultObjectHandler {
- public static final String BEAN_VALIDATOR_TAG = BeanValidator.class.getSimpleName();
+ public static final String TAG = BeanValidator.class.getSimpleName();
public static final String BEAN_ATTRIBUTE = "bean";
public static final String BEAN_CLASS_ATTRIBUTE = "beanClass";
public static final String BEAN_INITIALIZER_ATTRIBUTE = "beanInitializer";
@@ -71,8 +71,8 @@
if (compiler.getOptions().isVerbose()) {
log.info(tag);
}
- if (!tag.getLocalName().equals(FieldValidatorHandler.FIELD_VALIDATOR_TAG)) {
- compiler.reportError("tag '" + tag.getParentNode().getLocalName() + "' may only contain " + FieldValidatorHandler.FIELD_VALIDATOR_TAG + " as children, but found : " + tag.getLocalName());
+ if (!tag.getLocalName().equals(FieldValidatorHandler.TAG)) {
+ compiler.reportError("tag '" + tag.getParentNode().getLocalName() + "' may only contain " + FieldValidatorHandler.TAG + " as children, but found : " + tag.getLocalName());
} else {
compiler.compileFirstPass(tag);
}
@@ -146,6 +146,7 @@
public static class CompiledBeanValidator extends CompiledObject {
protected Map<String, String> fields;
+ protected Map<String, String> excludeFields;
protected String bean;
protected String beanClass;
protected String contextName;
@@ -162,16 +163,25 @@
public CompiledBeanValidator(String id, ClassDescriptor objectClass, JAXXCompiler compiler) {
super(id, objectClass, compiler);
fields = new TreeMap<String, String>();
+ excludeFields = new TreeMap<String, String>();
}
public Map<String, String> getFields() {
return fields;
}
+ public Map<String, String> getExcludeFields() {
+ return excludeFields;
+ }
+
public void setFields(Map<String, String> fields) {
this.fields = fields;
}
+ public void setExcludeFields(Map<String, String> excludeFields) {
+ this.excludeFields = excludeFields;
+ }
+
@Override
public void addProperty(String property, String value) {
@@ -319,7 +329,7 @@
@Override
public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
// do nothing
- compiler.reportError("can not add CompiledObject in the tag '" + BEAN_VALIDATOR_TAG + " (only field tags)");
+ compiler.reportError("can not add CompiledObject in the tag '" + TAG + " (only field tags)");
}
public boolean foundBean() {
@@ -554,6 +564,10 @@
// already defined in field
continue;
}
+ if (excludeFields.containsKey(descriptionName)) {
+ // exclude field
+ continue;
+ }
if (!compiler.checkReference(tag, descriptionName, getStrictMode(), null)) {
// no editor component found
continue;
@@ -561,6 +575,14 @@
// ok add the field mapping
registerField(descriptionName, descriptionName, compiler);
}
+
+ for (Entry<String, String> entry : excludeFields.entrySet()) {
+ String key = entry.getKey();
+ if (fields.containsKey(key)) {
+ compiler.reportWarning("field '" + key + "' can not be used and excluded at same time ! (field is skipped) for validator " + this);
+ fields.remove(key);
+ }
+ }
}
public void registerField(String id, String component, JAXXCompiler compiler) {
@@ -574,6 +596,17 @@
}
}
+ public void registerExcludeField(String id, String component, JAXXCompiler compiler) {
+ if (excludeFields.containsKey(id)) {
+ compiler.reportError("duplicate field '" + id + "' for validator " + this);
+ } else {
+ if (compiler.getOptions().isVerbose()) {
+ log.info("add excludeField <" + id + ":" + component + ">");
+ }
+ excludeFields.put(id, component);
+ }
+ }
+
protected boolean checkBeanProperty(JAXXCompiler compiler, String propertyName) {
for (JAXXPropertyDescriptor beanProperty : getBeanDescriptor(compiler).getJAXXPropertyDescriptors()) {
Copied: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java (from rev 1003, lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java)
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java 2008-12-02 22:25:40 UTC (rev 1054)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.tags.validator;
+
+import jaxx.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.validator.BeanValidator;
+import jaxx.tags.TagHandler;
+import jaxx.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.io.IOException;
+
+public class ExcludeFieldValidatorHandler implements TagHandler {
+
+ public static final String TAG = "excludeField";
+ public static final String NAME_ATTRIBUTE = "name";
+ public static final String COMPONENT_ATTRIBUTE = "component";
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ExcludeFieldValidatorHandler.class);
+
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getOptions().isVerbose()) {
+ log.info(tag);
+ }
+ //todo check there is no child
+ }
+
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getOptions().isVerbose()) {
+ log.debug(tag);
+ }
+
+ if (!ClassDescriptorLoader.getClassDescriptor(BeanValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag);
+ return;
+ }
+
+ CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent();
+ if (!info.getAutoField()) {
+ compiler.reportError(TAG + " tag can not be used without an 'autoField' validator : " + tag);
+ return;
+ }
+ String name = tag.getAttribute(NAME_ATTRIBUTE);
+ String component = tag.getAttribute(COMPONENT_ATTRIBUTE);
+ if (name == null || name.trim().isEmpty()) {
+ compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute");
+ return;
+ }
+ name = name.trim();
+ if (component == null || component.trim().isEmpty()) {
+ // try to use the name as component
+ if (!compiler.checkReference(tag, name, false, name)) {
+ compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute ["+name+"] for the component, but no such component found");
+ return;
+ }
+ component = name;
+ }
+ component = component.trim();
+
+ // check component is not already used by this compiled object
+ if (info.getFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " ["+component+"] already used in this validator");
+ return;
+ }
+ if (info.getExcludeFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " ["+component+"] already used in this validator");
+ return;
+ }
+ // check component exist (again perharps, but let the error knows exactly which tag failed...)
+ if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) {
+ // add a field
+ info.registerField(name, component, compiler);
+ }
+
+
+ }
+
+}
\ No newline at end of file
Property changes on: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2008-12-02 20:59:03 UTC (rev 1053)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2008-12-02 22:25:40 UTC (rev 1054)
@@ -18,7 +18,7 @@
public class FieldValidatorHandler implements TagHandler {
- public static final String FIELD_VALIDATOR_TAG = "field";
+ public static final String TAG = "field";
public static final String NAME_ATTRIBUTE = "name";
public static final String COMPONENT_ATTRIBUTE = "component";
@@ -38,7 +38,7 @@
}
if (!ClassDescriptorLoader.getClassDescriptor(BeanValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
- compiler.reportError(FIELD_VALIDATOR_TAG + " tag may only appear within " + BeanValidatorHandler.BEAN_VALIDATOR_TAG + " tag but was " + tag);
+ compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag);
return;
}
@@ -47,14 +47,14 @@
String name = tag.getAttribute(NAME_ATTRIBUTE);
String component = tag.getAttribute(COMPONENT_ATTRIBUTE);
if (name == null || name.trim().isEmpty()) {
- compiler.reportError(FIELD_VALIDATOR_TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute");
+ compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute");
return;
}
name = name.trim();
if (component == null || component.trim().isEmpty()) {
// try to use the name as component
if (!compiler.checkReference(tag, name, false, name)) {
- compiler.reportError(FIELD_VALIDATOR_TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute ["+name+"] for the component, but no such component found");
+ compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute ["+name+"] for the component, but no such component found");
return;
}
component = name;
@@ -63,7 +63,7 @@
// check component is not already used by this compiled object
if (info.getFields().containsValue(component)) {
- compiler.reportError(FIELD_VALIDATOR_TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " ["+component+"] already used in this validator");
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " ["+component+"] already used in this validator");
return;
}
// check component exist (again perharps, but let the error knows exactly which tag failed...)
1
0
r1053 - in lutinjaxx/trunk/jaxx-core: . src/main/java/jaxx/runtime/swing/navigation
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
02 Dec '08
Author: tchemit
Date: 2008-12-02 20:59:03 +0000 (Tue, 02 Dec 2008)
New Revision: 1053
Modified:
lutinjaxx/trunk/jaxx-core/changelog
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java
Log:
add strategy for loading ui in NavigationTreeSelectionAdapter
Modified: lutinjaxx/trunk/jaxx-core/changelog
===================================================================
--- lutinjaxx/trunk/jaxx-core/changelog 2008-12-02 19:25:08 UTC (rev 1052)
+++ lutinjaxx/trunk/jaxx-core/changelog 2008-12-02 20:59:03 UTC (rev 1053)
@@ -1,5 +1,7 @@
0.7 chemit 200812??
- * 20081202 [chemit] - fix bug when searching for a inner class
+ * 20081202 [chemit] - add strategy for loading ui in NavigationTreeSelectionAdapter
+ - fix bug when searching for a inner class
+
* 20081201 [chemit] - implements jaxx.runtime.JXPathDecorator
- add setcontextValue and removeContextValue on JAXXContextEntryDef
- introduce scope in BeanValidator (ERROR or WARNING) and related swing stuff
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-12-02 19:25:08 UTC (rev 1052)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-12-02 20:59:03 UTC (rev 1053)
@@ -24,6 +24,14 @@
static public final String NAVIGATION_SELECTED_BEAN = "navigation-selected-bean";
+ /** defined the stategy of instanciation of ui */
+ public enum Strategy {
+ /** instanciate a ui for a node */
+ PER_NODE,
+ /** instanciate only one a ui for a type,nodes will share the instanciation */
+ PER_UI_TYPE
+ }
+
/** la classe d'ui par defaut, associé à un noeud de l'arbe */
protected Class<? extends JAXXObject> defaultUIClass;
@@ -32,12 +40,16 @@
/** l'ui contenant l'arbre de navigation */
protected JAXXObject context;
- protected NavigationTreeSelectionAdapter(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context) {
+ protected Strategy strategy;
+
+ protected NavigationTreeSelectionAdapter(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context, Strategy strategy) {
this.defaultUIClass = defaultUIClass;
this.defaultUIHandlerClass = defaultUIHandlerClass;
this.context = context;
+ this.strategy = strategy;
}
+
protected abstract NavigationTreeModel getNavigationTreeModel();
/**
@@ -47,10 +59,10 @@
protected abstract Component getCurrentUI();
/**
- * @param path le chemin du noeud selectionne dont on veut afficher l'ui associée
+ * @param node le noeud associé à l'ui à retrouver
* @return l'ui associé au novueau noeud sélectionné
*/
- protected abstract Component getNewUI(String path);
+ protected abstract Component getUI(NavigationTreeNode node);
/**
* @param event l'evenement de selection de noeud
@@ -73,10 +85,10 @@
* Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation.
*
* @param newUI l'ui associé au noeud sélectionné à ouvrir
- * @param path le path dans le context de navigation
+ * @param node le node de l'ui a ouvrir
* @throws Exception if any
*/
- protected abstract void openUI(Component newUI, NavigationTreeNode path) throws Exception;
+ protected abstract void openUI(Component newUI, NavigationTreeNode node) throws Exception;
/**
* Retourne au noeud précdemment sélectionné dans l'arbre de navigation, avec la possibilité de notifier
@@ -123,10 +135,10 @@
log.trace(path);
}
- Component newUI = getNewUI(path);
+ Component newUI = getUI(node);
Component component = getCurrentUI();
- if (newUI != null && newUI.equals(component)) {
+ if (newUI != null && strategy == Strategy.PER_NODE && newUI.equals(component)) {
// call back from goto back to previous node, do nothing
return;
}
@@ -143,23 +155,11 @@
// before all, attach bean in context associated with the selected node in naivgation tree
Object data = getNavigationTreeModel().getJAXXContextValue(context, path);
- if (log.isDebugEnabled()) {
- log.debug("find data for contextPath <" + path + "> : " + (data == null ? null : data.getClass()));
- }
+ addSelectedBeanInContext(node, data);
- context.removeContextValue(Object.class,NAVIGATION_SELECTED_BEAN);
-
- if (data != null) {
- context.setContextValue(data, NAVIGATION_SELECTED_BEAN);
- //todo should we not use this to avoid conflict in context ?
- context.setContextValue(data);
- }
-
-
if (newUI == null) {
// instanciate a new ui associated with the selected node
newUI = createUI(node);
-
}
// save in context current node context path
@@ -179,25 +179,36 @@
}
}
- /* protected Object attachBeanFromNodeToContext(NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) {
- String path = node.getContextPath();
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + node.getContextPath() + "> : " + (data == null ? null : data.getClass()));
+ }
- NavigationTreeModel navigationModel = getNavigationTreeModel();
+ context.removeContextValue(Object.class, NAVIGATION_SELECTED_BEAN);
- //if (navigationModel != null) {
-
- Object data = navigationModel.getJAXXContextValue(context, path);
if (data != null) {
- if (log.isInfoEnabled()) {
- log.info("find data for contextPath <" + path + "> : " + data.getClass());
- }
+ context.setContextValue(data, NAVIGATION_SELECTED_BEAN);
+ //todo should we not use this to avoid conflict in context ?
context.setContextValue(data);
}
- //}
- return data;
- }*/
+ }
+ protected String getNodeConstraints(NavigationTreeNode node) {
+ String constraints;
+ switch (strategy) {
+ case PER_NODE:
+ constraints = node.getContextPath();
+ break;
+ case PER_UI_TYPE:
+ constraints = node.getJaxxClass().getName();
+ break;
+ default:
+ throw new IllegalArgumentException("could not find constraint for node : " + node);
+ }
+ return constraints;
+ }
+
protected void returnToPreviousNode(JTree tree, TreeSelectionEvent event) {
// go back to previous node
// put in context a tag to not come back again here
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java 2008-12-02 19:25:08 UTC (rev 1052)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java 2008-12-02 20:59:03 UTC (rev 1053)
@@ -4,8 +4,8 @@
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
-import jaxx.runtime.swing.CardLayout2;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -44,8 +44,8 @@
*/
protected abstract CardLayout2 getContentLayout();
- public NavigationTreeSelectionAdapterWithCardLayout(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context) {
- super(defaultUIClass, defaultUIHandlerClass, context);
+ public NavigationTreeSelectionAdapterWithCardLayout(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context, Strategy strategy) {
+ super(defaultUIClass, defaultUIHandlerClass, context,strategy);
if (getContentContainer() == null) {
throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context);
@@ -61,17 +61,19 @@
return layout.getVisibleComponent(container);
}
- protected Component getNewUI(String path) {
+ protected Component getUI(NavigationTreeNode node) {
CardLayout2 layout = getContentLayout();
JPanel container = getContentContainer();
+ String path = getNodeConstraints(node);
return layout.contains(path) ? layout.getComponent(container, path) : null;
}
protected void openUI(Component newUI, NavigationTreeNode node) throws Exception {
+
CardLayout2 layout = getContentLayout();
JPanel container = getContentContainer();
// switch layout
- layout.show(container, node.getContextPath());
+ layout.show(container, getNodeConstraints(node));
}
protected boolean closeUI(TreeSelectionEvent event, Component component) throws Exception {
@@ -99,7 +101,7 @@
log.debug("instanciate new ui " + newUI);
}
- getContentContainer().add((Component) newUI, node.getContextPath());
+ getContentContainer().add((Component) newUI, getNodeConstraints(node));
return (Component) newUI;
}
}
1
0
r1052 - in lutinjaxx/trunk/jaxx-core: . src/main/java/jaxx/compiler src/main/java/jaxx/reflect src/main/java/jaxx/runtime src/main/java/jaxx/runtime/validator src/main/java/jaxx/tags src/test/java/jaxx/junit
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
02 Dec '08
Author: tchemit
Date: 2008-12-02 19:25:08 +0000 (Tue, 02 Dec 2008)
New Revision: 1052
Modified:
lutinjaxx/trunk/jaxx-core/changelog
lutinjaxx/trunk/jaxx-core/pom.xml
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/reflect/ClassDescriptorLoader.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultObjectHandler.java
lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/junit/ClassDescriptorTest.java
Log:
fix bug when searching for a inner class
add usefullmethod to setBean on all validators of a JAXXObject
+ little stuff
Modified: lutinjaxx/trunk/jaxx-core/changelog
===================================================================
--- lutinjaxx/trunk/jaxx-core/changelog 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/changelog 2008-12-02 19:25:08 UTC (rev 1052)
@@ -1,4 +1,5 @@
0.7 chemit 200812??
+ * 20081202 [chemit] - fix bug when searching for a inner class
* 20081201 [chemit] - implements jaxx.runtime.JXPathDecorator
- add setcontextValue and removeContextValue on JAXXContextEntryDef
- introduce scope in BeanValidator (ERROR or WARNING) and related swing stuff
Modified: lutinjaxx/trunk/jaxx-core/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-core/pom.xml 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/pom.xml 2008-12-02 19:25:08 UTC (rev 1052)
@@ -52,6 +52,9 @@
<!-- ************************************************************* -->
<packaging>jar</packaging>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ </build>
<!-- ************************************************************* -->
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-12-02 19:25:08 UTC (rev 1052)
@@ -491,6 +491,8 @@
code.append("getValidator(").append(id).append(").validate();");
code.append(JAXXCompiler.getLineSeparator());
}
+ code.append("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
+ code.append(JAXXCompiler.getLineSeparator());
}
return newMethod(Modifier.PRIVATE, "void", "$completeSetup", code.toString());
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/reflect/ClassDescriptorLoader.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/reflect/ClassDescriptorLoader.java 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/reflect/ClassDescriptorLoader.java 2008-12-02 19:25:08 UTC (rev 1052)
@@ -45,11 +45,12 @@
public static synchronized ClassDescriptor getClassDescriptor(String className, ClassLoader classLoader) throws ClassNotFoundException {
ClassDescriptor result = descriptors.get(className);
if (result == null) {
- if (JAXXCompiler.getSymbolTable(className) != null)
+ if (JAXXCompiler.getSymbolTable(className) != null) {
result = createClassDescriptorFromSymbolTable(className, classLoader);
- else {
- if (classLoader == null)
+ } else {
+ if (classLoader == null) {
classLoader = ClassDescriptorLoader.class.getClassLoader();
+ }
String relativePath = className.replaceAll("\\.", "/");
String relativePathPattern = ".*";// + className + ".*"; // used to ensure that the located resource has the right character cases
@@ -57,13 +58,15 @@
// find the most recently updated source for the class -- Java source, JAXX source, or compiled class file
long javaLastModified = -1;
URL javaFile = classLoader.getResource(relativePath + ".java");
- if (javaFile != null && javaFile.toString().startsWith("file:") && javaFile.toString().matches(relativePathPattern))
+ if (javaFile != null && javaFile.toString().startsWith("file:") && javaFile.toString().matches(relativePathPattern)) {
javaLastModified = JAXXCompiler.URLtoFile(javaFile).lastModified();
+ }
long classLastModified = -1;
URL classFile = classLoader.getResource(relativePath + ".class");
- if (classFile != null && classFile.toString().startsWith("file:") && classFile.toString().matches(relativePathPattern))
+ if (classFile != null && classFile.toString().startsWith("file:") && classFile.toString().matches(relativePathPattern)) {
classLastModified = JAXXCompiler.URLtoFile(classFile).lastModified();
+ }
long jaxxLastModified = -1;
URL jaxxFile = classLoader.getResource(relativePath + ".jaxx");
@@ -73,23 +76,26 @@
String simplePath = jaxxFilePath.getPath();
simplePath = simplePath.substring(0, simplePath.length() - ".jaxx".length());
File cssFilePath = new File(simplePath + ".css");
- if (cssFilePath.exists())
+ if (cssFilePath.exists()) {
jaxxLastModified = Math.max(jaxxLastModified, cssFilePath.lastModified());
+ }
File scriptFilePath = new File(simplePath + ".script");
- if (scriptFilePath.exists())
+ if (scriptFilePath.exists()) {
jaxxLastModified = Math.max(jaxxLastModified, scriptFilePath.lastModified());
+ }
}
- if (jaxxLastModified != -1 && JAXXCompiler.getSymbolTable(className) == null)
+ if (jaxxLastModified != -1 && JAXXCompiler.getSymbolTable(className) == null) {
jaxxLastModified = -1; // file has been modified, but wasn't included in this
+ }
// compilation set so we don't have a symbol table
if (javaLastModified != -1 || classLastModified != -1 || jaxxLastModified != -1) {
- if (jaxxLastModified > classLastModified && jaxxLastModified > javaLastModified)
+ if (jaxxLastModified > classLastModified && jaxxLastModified > javaLastModified) {
result = createClassDescriptorFromSymbolTable(className, classLoader);
- else
- if (javaLastModified > classLastModified && javaLastModified > jaxxLastModified)
+ } else if (javaLastModified > classLastModified && javaLastModified > jaxxLastModified) {
result = createClassDescriptorFromJavaSource(javaFile, classLoader);
+ }
}
// else work off of the class file. This also handles the case where the class is available, but wasn't in a location where
// we could check its last modified date (in a JAR, over the network, etc.)
@@ -114,8 +120,9 @@
}
public static Class getClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
- if (className.equals("boolean"))
+ if (className.equals("boolean")) {
return boolean.class;
+ }
if (className.equals("byte")) {
return byte.class;
}
@@ -151,8 +158,27 @@
}
try {
return classLoader != null ? Class.forName(className, true, classLoader) : Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ // perharps we are in a inner class ?
+ int dotIndex = className.lastIndexOf(".");
+ if (dotIndex > -1) {
+ String parentFQN = className.substring(0, dotIndex);
+ String simpleName = className.substring(dotIndex + 1);
+ try {
+ Class<?> parentClass = classLoader != null ? Class.forName(parentFQN, true, classLoader) : Class.forName(parentFQN);
+ for (Class<?> innerClass : parentClass.getClasses()) {
+ if (simpleName.equals(innerClass.getSimpleName())) {
+ return innerClass;
+ }
+ }
+ } catch (ClassNotFoundException e1) {
+ // no super class,so let the first exception throw...
+ }
+ }
+ throw e;
}
catch (NoClassDefFoundError e) {
+
throw new ClassNotFoundException(e.toString());
}
}
@@ -180,8 +206,9 @@
private static JAXXObjectDescriptor getJAXXObjectDescriptor(Class<?> jaxxClass) {
- if (!JAXXObject.class.isAssignableFrom(jaxxClass) || jaxxClass == JAXXObject.class)
+ if (!JAXXObject.class.isAssignableFrom(jaxxClass) || jaxxClass == JAXXObject.class) {
return null;
+ }
try {
Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor", new Class[0]);
return (JAXXObjectDescriptor) getJAXXObjectDescriptor.invoke(null);
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Util.java 2008-12-02 19:25:08 UTC (rev 1052)
@@ -446,12 +446,41 @@
}
return value;
-
}
+ /**
+ * Convinient method to process more than one binding on a JAXX ui.
+ *
+ * @param src the ui to treate
+ * @param bindings the list of binding to process.
+ */
public static void processDataBinding(JAXXObject src, String... bindings) {
for (String binding : bindings) {
src.processDataBinding(binding);
}
}
+
+ /**
+ * Convient 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) {
+ List<String> validatorIds = ui.getValidatorIds();
+ if (excludeIds.length > 0) {
+ validatorIds = new ArrayList<String>(validatorIds);
+ for (String excludeId : excludeIds) {
+ validatorIds.remove(excludeId);
+ }
+ }
+ for (String validatorId : validatorIds) {
+ BeanValidator beanValidator = ui.getValidator(validatorId);
+ beanValidator.setBean(bean);
+ }
+ }
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java 2008-12-02 19:25:08 UTC (rev 1052)
@@ -520,6 +520,11 @@
}
}
+ @Override
+ public String toString() {
+ return super.toString() + "<contextName:" + contextName + ">";
+ }
+
/** @return <code>true</code> if validation is not active , <code>false</code> otherwise. */
protected boolean checkState() {
return bean == null || (getErrorListModel() == null && getErrorTableModel() == null) || fieldRepresentation.size() == 0;
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultObjectHandler.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultObjectHandler.java 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/DefaultObjectHandler.java 2008-12-02 19:25:08 UTC (rev 1052)
@@ -521,7 +521,7 @@
try {
init();
} catch (IntrospectionException e) {
- throw new RuntimeException(e);
+ throw new CompilerException(e);
}
CompiledObject object = objectMap.get(tag);
if (object == null) {
Modified: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/junit/ClassDescriptorTest.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/junit/ClassDescriptorTest.java 2008-12-02 01:07:51 UTC (rev 1051)
+++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/junit/ClassDescriptorTest.java 2008-12-02 19:25:08 UTC (rev 1052)
@@ -3,37 +3,45 @@
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
import jaxx.reflect.MethodDescriptor;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.junit.Test;
public class ClassDescriptorTest {
@Test
+ public void testGetClassDescriptor() throws Exception {
+ ClassDescriptor object = ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode");
+
+
+ }
+
+ @Test
public void testBuiltInClassName() throws ClassNotFoundException, NoSuchMethodException {
ClassDescriptor object = ClassDescriptorLoader.getClassDescriptor("java.lang.Object");
MethodDescriptor toString = object.getMethodDescriptor("toString", new ClassDescriptor[0]);
- Assert.assertEquals(toString.getName(), "toString");
- Assert.assertEquals(toString.getParameterTypes().length, 0);
+ assertEquals(toString.getName(), "toString");
+ assertEquals(toString.getParameterTypes().length, 0);
MethodDescriptor equals = object.getMethodDescriptor("equals", new ClassDescriptor[]{object});
- Assert.assertEquals(equals.getName(), "equals");
- Assert.assertEquals(equals.getParameterTypes().length, 1);
- Assert.assertEquals(equals.getParameterTypes()[0], object);
+ assertEquals(equals.getName(), "equals");
+ assertEquals(equals.getParameterTypes().length, 1);
+ assertEquals(equals.getParameterTypes()[0], object);
}
@Test
public void testBuiltInClass() throws ClassNotFoundException, NoSuchMethodException {
ClassDescriptor object1 = ClassDescriptorLoader.getClassDescriptor("java.lang.Object");
ClassDescriptor object2 = ClassDescriptorLoader.getClassDescriptor(Object.class);
- Assert.assertEquals(object1, object2);
+ assertEquals(object1, object2);
}
@Test
public void testUserClassName() throws ClassNotFoundException, NoSuchMethodException {
ClassDescriptor me = ClassDescriptorLoader.getClassDescriptor("jaxx.junit.ClassDescriptorTest", getClass().getClassLoader());
MethodDescriptor testUserClassName = me.getMethodDescriptor("testUserClassName", new ClassDescriptor[0]);
- Assert.assertEquals(testUserClassName.getName(), "testUserClassName");
- Assert.assertEquals(testUserClassName.getParameterTypes().length, 0);
+ assertEquals(testUserClassName.getName(), "testUserClassName");
+ assertEquals(testUserClassName.getParameterTypes().length, 0);
}
@Test(expected = ClassNotFoundException.class)
@@ -50,8 +58,8 @@
@Test
public void testArrays() throws ClassNotFoundException {
ClassDescriptor intArray = ClassDescriptorLoader.getClassDescriptor(int[].class);
- Assert.assertNotNull(intArray);
+ assertNotNull(intArray);
ClassDescriptor objectArray = ClassDescriptorLoader.getClassDescriptor(Object[].class);
- Assert.assertNotNull(objectArray);
+ assertNotNull(objectArray);
}
}
\ No newline at end of file
1
0
02 Dec '08
Author: tchemit
Date: 2008-12-02 01:07:51 +0000 (Tue, 02 Dec 2008)
New Revision: 1051
Modified:
lutinjaxx/trunk/jaxx-swing-action/pom.xml
Log:
fix scm values
Modified: lutinjaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-12-02 01:00:12 UTC (rev 1050)
+++ lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-12-02 01:07:51 UTC (rev 1051)
@@ -73,7 +73,7 @@
<!-- ************************************************************* -->
<scm>
<connection>${scm.connection.son}</connection>
- <developerConnection>$scm.developerConnection.son}</developerConnection>
+ <developerConnection>${scm.developerConnection.son}</developerConnection>
<url>${scm.url.son}</url>
</scm>
1
0
r1050 - in lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst: . images
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
02 Dec '08
Author: tchemit
Date: 2008-12-02 01:00:12 +0000 (Tue, 02 Dec 2008)
New Revision: 1050
Added:
lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/images/BeanDataBinding-screenshot.png
Removed:
lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/images/Validation-screenshot.png
Modified:
lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/index.rst
Log:
fix BeanDataBinding site
Added: lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/images/BeanDataBinding-screenshot.png
===================================================================
(Binary files differ)
Property changes on: lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/images/BeanDataBinding-screenshot.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/images/Validation-screenshot.png
===================================================================
(Binary files differ)
Modified: lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/index.rst
===================================================================
--- lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/index.rst 2008-12-02 00:54:46 UTC (rev 1049)
+++ lutinjaxx/trunk/jaxx-example/BeanDataBinding/src/site/fr/rst/index.rst 2008-12-02 01:00:12 UTC (rev 1050)
@@ -1,14 +1,13 @@
-===================
-Examples/Validation
-===================
+========================
+Examples/BeanDataBinding
+========================
-This example program creates a number of components which are used to control the appearance of a JLabel.
-Everything is performed through data binding; there are no script tags or explicit event handlers anywhere.
+This example program tests the bean data binding with the full java bean support.
Screen shot
-----------
-.. image:: images/Validation-screenshot.png
+.. image:: images/BeanDataBinding-screenshot.png
Set it in action
----------------
@@ -25,4 +24,4 @@
.. |webstart| image:: images/webstart.gif
-.. _following link: ./launch-Validation.jnlp
+.. _following link: ./launch-BeanDataBinding.jnlp
1
0
r1049 - in lutinjaxx/trunk: jaxx-core jaxx-swing-action jaxx-util maven-jaxx-plugin
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
02 Dec '08
Author: tchemit
Date: 2008-12-02 00:54:46 +0000 (Tue, 02 Dec 2008)
New Revision: 1049
Modified:
lutinjaxx/trunk/jaxx-core/pom.xml
lutinjaxx/trunk/jaxx-swing-action/pom.xml
lutinjaxx/trunk/jaxx-util/pom.xml
lutinjaxx/trunk/maven-jaxx-plugin/pom.xml
Log:
fix scm values
Modified: lutinjaxx/trunk/jaxx-core/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-core/pom.xml 2008-12-02 00:37:29 UTC (rev 1048)
+++ lutinjaxx/trunk/jaxx-core/pom.xml 2008-12-02 00:54:46 UTC (rev 1049)
@@ -56,8 +56,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection.son}</connection>
- <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
- <url>${maven.scm.url.son}</url>
+ <connection>${scm.connection.son}</connection>
+ <developerConnection>${scm.developerConnection.son}</developerConnection>
+ <url>${scm.url.son}</url>
</scm>
</project>
Modified: lutinjaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-12-02 00:37:29 UTC (rev 1048)
+++ lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-12-02 00:54:46 UTC (rev 1049)
@@ -72,9 +72,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection.son}</connection>
- <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
- <url>${maven.scm.url.son}</url>
+ <connection>${scm.connection.son}</connection>
+ <developerConnection>$scm.developerConnection.son}</developerConnection>
+ <url>${scm.url.son}</url>
</scm>
</project>
Modified: lutinjaxx/trunk/jaxx-util/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-util/pom.xml 2008-12-02 00:37:29 UTC (rev 1048)
+++ lutinjaxx/trunk/jaxx-util/pom.xml 2008-12-02 00:54:46 UTC (rev 1049)
@@ -39,9 +39,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection.son}</connection>
- <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
- <url>${maven.scm.url.son}</url>
+ <connection>${scm.connection.son}</connection>
+ <developerConnection>${scm.developerConnection.son}</developerConnection>
+ <url>${scm.url.son}</url>
</scm>
</project>
Modified: lutinjaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/pom.xml 2008-12-02 00:37:29 UTC (rev 1048)
+++ lutinjaxx/trunk/maven-jaxx-plugin/pom.xml 2008-12-02 00:54:46 UTC (rev 1049)
@@ -127,9 +127,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection.son}</connection>
- <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
- <url>${maven.scm.url.son}</url>
+ <connection>${scm.connection.son}</connection>
+ <developerConnection>${scm.developerConnection.son}</developerConnection>
+ <url>${scm.url.son}</url>
</scm>
</project>
\ No newline at end of file
1
0
r1048 - in lutinjaxx/trunk: jaxx-core/src/main/java/jaxx/runtime/validator jaxx-core/src/main/java/jaxx/tags/validator maven-jaxx-plugin/src/test/java/org/codelutin/jaxx maven-jaxx-plugin/src/test/resources/testcases/validator/errors
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
by tchemit@users.labs.libre-entreprise.org 02 Dec '08
02 Dec '08
Author: tchemit
Date: 2008-12-02 00:37:29 +0000 (Tue, 02 Dec 2008)
New Revision: 1048
Removed:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedFieldInOtherValidator.jaxx
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/FieldComponentDuplicated2.jaxx
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
Log:
can authorize now to have a field of a bean manage by more than one validator (for example error validator and warning one)...
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java 2008-12-01 23:59:46 UTC (rev 1047)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidator.java 2008-12-02 00:37:29 UTC (rev 1048)
@@ -398,6 +398,10 @@
//return validationContext.hasFieldErrors() || validationContext.hasActionErrors();
}
+ public boolean hasWarnings() {
+ return scope == Scope.WARNING && (validationContext.hasFieldErrors() || !conversionErrors.isEmpty());
+ }
+
/** install ui on required components */
public void installUIs() {
SwingUtilities.invokeLater(new Runnable() {
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java 2008-12-01 23:59:46 UTC (rev 1047)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/validator/BeanValidatorErrorTableModel.java 2008-12-02 00:37:29 UTC (rev 1048)
@@ -103,7 +103,7 @@
}
protected <T> void fillNewErrors(BeanValidator<T> validator, List<BeanValidatorError> newErrors) {
- if (validator.hasErrors()) {
+ if (validator.hasErrors() || validator.hasWarnings()) {
// inject this validator errors
for (Object o : validator.getFieldErrors().entrySet()) {
Map.Entry<?, ?> r = (Map.Entry<?, ?>) o;
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2008-12-01 23:59:46 UTC (rev 1047)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2008-12-02 00:37:29 UTC (rev 1048)
@@ -529,11 +529,11 @@
// editor component not find on ui
continue;
}
- if (compiler.isComponentUsedByValidator(component)) {
+ /*if (compiler.isComponentUsedByValidator(component)) {
// component is already used by another validator
compiler.reportError("component '" + component + "' is already used by another validator.");
continue;
- }
+ }*/
String keyCode = TypeManager.getJavaCode(propertyName);
appendAdditionCode(getJavaCode() + ".setFieldRepresentation(" + keyCode + ", " + component + ");");
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-12-01 23:59:46 UTC (rev 1047)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-12-02 00:37:29 UTC (rev 1048)
@@ -2,8 +2,8 @@
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXCompilerHelper;
+import jaxx.runtime.DefaultJAXXContext;
import jaxx.runtime.JAXXContext;
-import jaxx.runtime.DefaultJAXXContext;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.junit.Assert;
@@ -135,7 +135,7 @@
} catch (IllegalArgumentException e) {
Assert.assertTrue(true);
}
-
+
mojo.setJaxxContextImplementorClass(JAXXContext.class.getName());
try {
mojo.init();
@@ -144,7 +144,7 @@
Assert.assertTrue(true);
}
- mojo.setJaxxContextImplementorClass(DefaultJAXXContext.class.getName());
+ mojo.setJaxxContextImplementorClass(DefaultJAXXContext.class.getName());
mojo.init();
Assert.assertTrue(true);
@@ -214,7 +214,7 @@
// init mojo to get alls files to treate
mojo.init();
String[] files = mojo.getFiles();
- assertEquals(17, mojo.getFiles().length);
+ assertEquals(15, mojo.getFiles().length);
mojo.setLog(new SystemStreamLog() {
@Override
public boolean isErrorEnabled() {
@@ -249,7 +249,7 @@
try {
mojo.doAction();
// should never pass
- fail();
+ fail("for file " + file);
} catch (MojoExecutionException e) {
// ok jaxx compiler failed
assertTrue(true);
Deleted: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedFieldInOtherValidator.jaxx
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedFieldInOtherValidator.jaxx 2008-12-01 23:59:46 UTC (rev 1047)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedFieldInOtherValidator.jaxx 2008-12-02 00:37:29 UTC (rev 1048)
@@ -1,266 +0,0 @@
-<Application title="Validation.jaxx">
-
- <!-- models -->
- <Model id='model'/>
- <Model id='model2'/>
-
- <!-- errors model -->
- <jaxx.runtime.validator.BeanValidatorErrorListModel id='errors' onContentsChanged='ok.setEnabled(errors.size()==0)'/>
-
- <!-- validators -->
- <BeanValidator id='validator' bean='model' errorListModel='errors'>
- <field name="text"/>
- <field name="text2"/>
- <field name="ratio"/>
- </BeanValidator>
- <BeanValidator id='validator2' bean='model2' errorListModel='errors' uiClass="jaxx.runtime.validator.ui.IconValidationUI">
- <field name="text" component="text"/>
- <field name="text2" component="_text2"/>
- <field name="ratio" component="_ratio"/>
- </BeanValidator>
-
- <Table fill='both'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='{model.getText()}'
- onKeyReleased='model.setText(text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text2' text='{model.getText2()}'
- onKeyReleased='model.setText2(text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='ratio' minimum='0' maximum='100' value='{model.getRatio()}'
- onStateChanged='model.setRatio(ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text' text='{model2.getText()}'
- onKeyReleased='model2.setText(_text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text2' text='{model2.getText2()}'
- onKeyReleased='model2.setText2(_text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}'
- onStateChanged='model2.setRatio(_ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model2.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
- layout='{new GridLayout()}' width='250' height='140'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='firstName' text='{identity.getFirstName()}'
- onKeyReleased='identity.setFirstName(firstName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='lastName' text='{identity.getLastName()}'
- onKeyReleased='identity.setLastName(lastName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='email2' text='{identity.getEmail()}'
- onKeyReleased='identity.setEmail(email2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
- onStateChanged='identity.setAge(age.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getFirstName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getLastName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getEmail()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getAge()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' width='500'>
- <JScrollPane>
- <JList model='{errors}'/>
- </JScrollPane>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel layout='{new GridLayout(1,2,0,0)}'>
- <JButton text='cancel' onActionPerformed='dispose()'/>
- <JButton id='ok' text='valid' onActionPerformed='dispose()'/>
- </JPanel>
- </cell>
- </row>
-
- </Table>
-</Application>
Deleted: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/FieldComponentDuplicated2.jaxx
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/FieldComponentDuplicated2.jaxx 2008-12-01 23:59:46 UTC (rev 1047)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/FieldComponentDuplicated2.jaxx 2008-12-02 00:37:29 UTC (rev 1048)
@@ -1,266 +0,0 @@
-<Application title="Validation.jaxx">
-
- <!-- models -->
- <Model id='model'/>
- <Model id='model2'/>
-
- <!-- errors model -->
- <jaxx.runtime.validator.BeanValidatorErrorListModel id='errors' onContentsChanged='ok.setEnabled(errors.size()==0)'/>
-
- <!-- validators -->
- <BeanValidator id='validator' errorListModel='errors' bean="model">
- <field name="text" component="text"/>
- <field name="text2" />
- <field name="ratio"/>
- </BeanValidator>
- <BeanValidator id='validator2' bean='model2' errorListModel='errors' uiClass="jaxx.runtime.validator.ui.IconValidationUI">
- <field name="text" component="text"/>
- <field name="text2" component="_text2"/>
- <field name="ratio" component="_ratio"/>
- </BeanValidator>
-
- <Table fill='both'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='{model.getText()}'
- onKeyReleased='model.setText(text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text2' text='{model.getText2()}'
- onKeyReleased='model.setText2(text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='ratio' minimum='0' maximum='100' value='{model.getRatio()}'
- onStateChanged='model.setRatio(ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text' text='{model2.getText()}'
- onKeyReleased='model2.setText(_text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text2' text='{model2.getText2()}'
- onKeyReleased='model2.setText2(_text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}'
- onStateChanged='model2.setRatio(_ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model2.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
- layout='{new GridLayout()}' width='250' height='140'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='firstName' text='{identity.getFirstName()}'
- onKeyReleased='identity.setFirstName(firstName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='lastName' text='{identity.getLastName()}'
- onKeyReleased='identity.setLastName(lastName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='email2' text='{identity.getEmail()}'
- onKeyReleased='identity.setEmail(email2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
- onStateChanged='identity.setAge(age.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getFirstName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getLastName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getEmail()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getAge()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' width='500'>
- <JScrollPane>
- <JList model='{errors}'/>
- </JScrollPane>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel layout='{new GridLayout(1,2,0,0)}'>
- <JButton text='cancel' onActionPerformed='dispose()'/>
- <JButton id='ok' text='valid' onActionPerformed='dispose()'/>
- </JPanel>
- </cell>
- </row>
-
- </Table>
-</Application>
1
0
r1047 - in lutinjaxx/trunk/jaxx-core: . src/main/java/jaxx/runtime src/test/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org 01 Dec '08
by tchemit@users.labs.libre-entreprise.org 01 Dec '08
01 Dec '08
Author: tchemit
Date: 2008-12-01 23:59:46 +0000 (Mon, 01 Dec 2008)
New Revision: 1047
Modified:
lutinjaxx/trunk/jaxx-core/changelog
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
Log:
implements jaxx.runtime.JXPathDecorator
add setcontextValue and removeContextValue on JAXXContextEntryDef
Modified: lutinjaxx/trunk/jaxx-core/changelog
===================================================================
--- lutinjaxx/trunk/jaxx-core/changelog 2008-12-01 17:10:17 UTC (rev 1046)
+++ lutinjaxx/trunk/jaxx-core/changelog 2008-12-01 23:59:46 UTC (rev 1047)
@@ -1,8 +1,10 @@
- 0.7 chemit
- * 20081201 [chemit] introduce scope in BeanValidator (ERROR or WARNING)
- * 20081201 [chemit] only enter once in $initialize method in generated code
+ 0.7 chemit 200812??
+ * 20081201 [chemit] - implements jaxx.runtime.JXPathDecorator
+ - add setcontextValue and removeContextValue on JAXXContextEntryDef
+ - introduce scope in BeanValidator (ERROR or WARNING) and related swing stuff
+ - only enter once in $initialize method in generated code
- 0.6 chemit 200811
+ 0.6 chemit 20081117
* 20081118 [chemit] introduce NavigationUtil, save in context selected node
* 20081107 [chemit] improve data binding and code generation :
- make possible inheritance in binding
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java 2008-12-01 17:10:17 UTC (rev 1046)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java 2008-12-01 23:59:46 UTC (rev 1047)
@@ -10,7 +10,14 @@
protected final Class<O> internalClass;
private static final long serialVersionUID = -1L;
- public Decorator(Class<O> internalClass) {
+ /**
+ * @param internalClass the class of objects to be decorated.
+ * @throws NullPointerException if internalClass parameter is null
+ */
+ public Decorator(Class<O> internalClass) throws NullPointerException {
+ if (internalClass == null) {
+ throw new NullPointerException("internalClass can not be null.");
+ }
this.internalClass = internalClass;
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2008-12-01 17:10:17 UTC (rev 1046)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2008-12-01 23:59:46 UTC (rev 1047)
@@ -52,6 +52,14 @@
return context.getContextValue(klass, name);
}
+ public void removeContextValue(JAXXContext context) {
+ context.removeContextValue(klass, name);
+ }
+
+ public void setContextValue(JAXXContext context, O value) {
+ context.setContextValue(value, name);
+ }
+
@Override
public String toString() {
return super.toString() + "<" + klass + ":" + name + ">";
@@ -103,11 +111,8 @@
}
public boolean accept2(Class<?> klass, String name) {
- if (klass == Object.class && this.klass != Object.class) {
- // block if looking for Object.class
- return false;
- }
- return this.klass.isAssignableFrom(klass) && (this.name == null && name == null
- || (this.name != null && name != null && this.name.equals(name)));
+ return !(klass == Object.class && this.klass != Object.class) &&
+ this.klass.isAssignableFrom(klass) && (this.name == null &&
+ name == null || (this.name != null && name != null && this.name.equals(name)));
}
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-12-01 17:10:17 UTC (rev 1046)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-12-01 23:59:46 UTC (rev 1047)
@@ -5,9 +5,28 @@
import org.apache.commons.logging.LogFactory;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
-/** @author chemit */
+/**
+ * JXPath decorator based on {@link String#format(String, Object[])} method.
+ * <p/>
+ * To use it, give to him a expression where all jxpath to apply on bean are boxed in <code>${}</code>.
+ * <p/>
+ * After the jxpath token you must specifiy the formatter to apply of the jxpath token.
+ * <p/>
+ * For example :
+ * <pre>
+ * Decorator<Object> d = JXPathDecorator.newDecorator(JXPathDecorator.class,"expr = ${expressions}$s");
+ * assert "expr = %1$s" == d.getExpression();
+ * assert 1 == d.getNbToken();
+ * assert java.util.Arrays.asList("expression") == d.getTokens();
+ * assert "expr = %1$s" == d.toString(d);
+ * </pre>
+ *
+ * @author chemit
+ * @see Decorator
+ */
public class JXPathDecorator<O> extends Decorator<O> {
/** to use log facility, just put in your code: log.info(\"...\"); */
@@ -15,76 +34,103 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Factory method to instanciate a new {@link JXPathDecorator} for the given class {@link O} and expression.
+ *
+ * @param internalClass the class of the objects decorated by the new decorator
+ * @param expression the expression to use to decorated objects
+ * @param <O> the generic type of class to be decorated by the new decorator
+ * @return the new instanciated decorator
+ * @throws IllegalArgumentException if the expression is not valid, says:
+ * <p/>
+ * - a missing right brace was detected.
+ * <p/>
+ * - a ${ was found in a jxpath token.
+ * @throws NullPointerException if internalClass parameter is null.
+ */
+ public static <O> JXPathDecorator<O> newDecorator(Class<O> internalClass, String expression)
+ throws IllegalArgumentException, NullPointerException {
+ return new JXPathDecorator<O>(internalClass, expression);
+ }
+
+ /**
+ * expression to format using {@link String#format(String, Object[])}, all variables are compute
+ * using using the jxpath tokens.
+ */
protected String expression;
- protected String[] data;
+ /** list of jxpath tokens to apply on expression */
+ protected String[] tokens;
- protected Boolean[] jxPath;
-
+ /** nb jxpath tokens to compute */
protected int nbToken;
- public JXPathDecorator(Class<O> internalClass, String expression) {
+ protected JXPathDecorator(Class<O> internalClass, String expression) throws IllegalArgumentException, NullPointerException {
super(internalClass);
- this.expression = expression;
- List<String> lData = new ArrayList<String>();
- List<Boolean> ljxPath = new ArrayList<Boolean>();
-
- int index = expression.indexOf("${");
- boolean first = true;
- int end = expression.length();
- while (index > -1) {
- if (first) {
- first = false;
- if (index > 0) {
- // prefix before first jxpath
- lData.add(expression.substring(0, index ));
- ljxPath.add(false);
- }
+ List<String> lTokens = new ArrayList<String>();
+ StringBuilder buffer = new StringBuilder();
+ int size = expression.length();
+ int end = -1;
+ int start;
+ while ((start = expression.indexOf("${", end + 1)) > -1) {
+ if (start > end + 1) {
+ // prefix of next jxpath token
+ buffer.append(expression.substring(end + 1, start));
}
- // seek next }
- int last = expression.indexOf("}", index + 1);
- if (last != -1) {
- // jxpath detected
- String s = expression.substring(index + 2, last);
- lData.add(s);
- ljxPath.add(true);
+ // seek end of jxpath
+ end = expression.indexOf("}", start + 1);
+ if (end == -1) {
+ throw new IllegalArgumentException("could not find the rigth brace starting at car " + start + " : " + expression.substring(start + 2));
}
-
- index = expression.indexOf("${", last + 1);
- if (index > -1) {
- // inter jxpath code
- String s = expression.substring(last + 1, index);
- lData.add(s);
- ljxPath.add(false);
- } else {
- if (end > (last + 1)) {
- // suffix after last jxpath
- String s = expression.substring(last + 1);
- lData.add(s);
- ljxPath.add(false);
- }
+ String jxpath = expression.substring(start + 2, end);
+ // not allowed ${ inside a jxpath token
+ if (jxpath.indexOf("${") > -1) {
+ throw new IllegalArgumentException("could not find a ${ inside a jxpath expression at car " + (start + 2) + " : " + jxpath);
}
+ // save the jxpath token
+ lTokens.add(jxpath);
+ // replace jxpath token in expresion with a string format variable
+ buffer.append("%").append(lTokens.size());
}
- data = lData.toArray(new String[lData.size()]);
- jxPath = ljxPath.toArray(new Boolean[ljxPath.size()]);
- nbToken = data.length;
+ if (size > (end + 1)) {
+ // suffix after end jxpath (or all expression if no jxpath)
+ buffer.append(expression.substring(end + 1));
+ }
+
+ this.tokens = lTokens.toArray(new String[lTokens.size()]);
+ this.nbToken = tokens.length;
+ this.expression = buffer.toString();
if (log.isDebugEnabled()) {
- log.debug("lData : " + lData);
- log.debug("ljxPath : " + ljxPath);
+ log.debug(expression + " --> " + this);
}
-
}
public String toString(Object bean) {
+ if (bean == null) {
+ return null;
+ }
JXPathContext jxcontext = JXPathContext.newContext(bean);
- StringBuilder buffer = new StringBuilder();
+ Object[] args = new Object[nbToken];
for (int i = 0; i < nbToken; i++) {
- String s = data[i];
- if (jxPath[i]) {
- s = String.valueOf(jxcontext.getValue(s));
- }
- buffer.append(s);
+ args[i] = jxcontext.getValue(tokens[i]);
}
- return buffer.toString();
+ return String.format(expression, args);
}
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public String[] getTokens() {
+ return tokens;
+ }
+
+ public int getNbToken() {
+ return nbToken;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<expression:" + expression + ", tokens:" + Arrays.toString(tokens) + ">";
+ }
}
Modified: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2008-12-01 17:10:17 UTC (rev 1046)
+++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2008-12-01 23:59:46 UTC (rev 1047)
@@ -1,65 +1,90 @@
package jaxx.runtime;
+import org.junit.After;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.junit.Assert;
/** @author chemit */
public class JXPathDecoratorTest {
- public static class Model {
- protected String name;
+ protected JXPathDecorator<?> decorator;
+ protected String expected;
+ protected String result;
- protected int integervalue;
+ @After
+ public void after() {
+ decorator = null;
+ }
- public Model(String name, int integervalue) {
- this.name = name;
- this.integervalue = integervalue;
- }
+ @Test(expected = NullPointerException.class)
+ public void testNullInternalClass() throws Exception {
+ decorator = JXPathDecorator.newDecorator(null, "hello");
+ }
- public String getName() {
- return name;
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace() throws Exception {
+ decorator = JXPathDecorator.newDecorator(Object.class, "${haha");
+ }
- public void setName(String name) {
- this.name = name;
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace2() throws Exception {
+ decorator = JXPathDecorator.newDecorator(Object.class, "${haha${hum}");
+ }
- public int getIntegervalue() {
- return integervalue;
- }
+ @Test
+ public void testNullBean() throws Exception {
+ decorator = JXPathDecorator.newDecorator(Object.class, "hello");
+ expected = "hello";
+ assertEquals(expected, decorator.expression);
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.tokens.length);
- public void setIntegervalue(int integervalue) {
- this.integervalue = integervalue;
- }
+ result = decorator.toString(null);
+ assertEquals(null, result);
}
@Test
+ public void testNoJXPath() throws Exception {
+ decorator = JXPathDecorator.newDecorator(Object.class, "hello");
+ expected = "hello";
+ assertEquals(expected, decorator.expression);
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.tokens.length);
+
+ result = decorator.toString(this);
+ assertEquals(expected, result);
+ }
+
+
+ @Test
public void testDecorator() throws Exception {
- Decorator<Model> decorator;
- String expected;
- String result;
- Model m = new Model("name", 10);
+ decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d");
+ assertEquals("%1$s - %2$d", decorator.expression);
+ assertDecoratorInternal();
- decorator = new JXPathDecorator<Model>(Model.class,"${name} - ${integervalue}");
- expected = m.getName() + " - " + m.getIntegervalue();
- result = decorator.toString(m);
- Assert.assertEquals(expected, result);
+ decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}${nbToken}");
+ assertEquals("%1%2", decorator.expression);
+ assertDecoratorInternal();
- decorator = new JXPathDecorator<Model>(Model.class,"${name}${integervalue}");
- expected = m.getName() + m.getIntegervalue();
- result = decorator.toString(m);
- Assert.assertEquals(expected, result);
+ decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after");
+ assertEquals("before %1$s - %2$d after", decorator.expression);
+ assertDecoratorInternal();
- decorator = new JXPathDecorator<Model>(Model.class,"before ${name} - ${integervalue} after");
- expected = "before "+m.getName() + " - " + m.getIntegervalue()+" after";
- result = decorator.toString(m);
- Assert.assertEquals(expected, result);
+ decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter");
+ assertEquals("before%1$s-%2$dafter", decorator.expression);
+ assertDecoratorInternal();
+ }
- decorator = new JXPathDecorator<Model>(Model.class,"before${name}-${integervalue}after");
- expected = "before"+m.getName() + "-" + m.getIntegervalue()+"after";
- result = decorator.toString(m);
- Assert.assertEquals(expected, result);
+ public void assertDecoratorInternal() {
+ assertEquals(2, decorator.nbToken);
+ assertEquals(2, decorator.tokens.length);
+ assertEquals("expression", decorator.tokens[0]);
+ assertEquals("nbToken", decorator.tokens[1]);
+ expected = String.format(decorator.expression, decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
}
+
}
1
0
r1046 - in lutinjaxx/trunk/jaxx-core/src: main/java/jaxx/runtime test/java/jaxx/runtime
by chemit@users.labs.libre-entreprise.org 01 Dec '08
by chemit@users.labs.libre-entreprise.org 01 Dec '08
01 Dec '08
Author: chemit
Date: 2008-12-01 17:10:17 +0000 (Mon, 01 Dec 2008)
New Revision: 1046
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
Log:
JXPathDecorator on rocks
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-12-01 17:09:43 UTC (rev 1045)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-12-01 17:10:17 UTC (rev 1046)
@@ -4,6 +4,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
+import java.util.List;
+
/** @author chemit */
public class JXPathDecorator<O> extends Decorator<O> {
@@ -14,18 +17,74 @@
protected String expression;
+ protected String[] data;
+
+ protected Boolean[] jxPath;
+
+ protected int nbToken;
+
public JXPathDecorator(Class<O> internalClass, String expression) {
super(internalClass);
this.expression = expression;
+ List<String> lData = new ArrayList<String>();
+ List<Boolean> ljxPath = new ArrayList<Boolean>();
+
+ int index = expression.indexOf("${");
+ boolean first = true;
+ int end = expression.length();
+ while (index > -1) {
+ if (first) {
+ first = false;
+ if (index > 0) {
+ // prefix before first jxpath
+ lData.add(expression.substring(0, index ));
+ ljxPath.add(false);
+ }
+ }
+ // seek next }
+ int last = expression.indexOf("}", index + 1);
+ if (last != -1) {
+ // jxpath detected
+ String s = expression.substring(index + 2, last);
+ lData.add(s);
+ ljxPath.add(true);
+ }
+
+ index = expression.indexOf("${", last + 1);
+ if (index > -1) {
+ // inter jxpath code
+ String s = expression.substring(last + 1, index);
+ lData.add(s);
+ ljxPath.add(false);
+ } else {
+ if (end > (last + 1)) {
+ // suffix after last jxpath
+ String s = expression.substring(last + 1);
+ lData.add(s);
+ ljxPath.add(false);
+ }
+ }
+ }
+ data = lData.toArray(new String[lData.size()]);
+ jxPath = ljxPath.toArray(new Boolean[ljxPath.size()]);
+ nbToken = data.length;
+ if (log.isDebugEnabled()) {
+ log.debug("lData : " + lData);
+ log.debug("ljxPath : " + ljxPath);
+ }
+
}
public String toString(Object bean) {
- //todo check bean class
JXPathContext jxcontext = JXPathContext.newContext(bean);
- String result = (String) jxcontext.getValue(expression);
- if (log.isDebugEnabled()) {
- log.debug(expression + " : " + result);
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < nbToken; i++) {
+ String s = data[i];
+ if (jxPath[i]) {
+ s = String.valueOf(jxcontext.getValue(s));
+ }
+ buffer.append(s);
}
- return result;
+ return buffer.toString();
}
}
Modified: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2008-12-01 17:09:43 UTC (rev 1045)
+++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2008-12-01 17:10:17 UTC (rev 1046)
@@ -1,6 +1,7 @@
package jaxx.runtime;
import org.junit.Test;
+import org.junit.Assert;
/** @author chemit */
public class JXPathDecoratorTest {
@@ -35,13 +36,30 @@
@Test
public void testDecorator() throws Exception {
- //fixme : make me work :)
- Decorator<Model> decorator = new JXPathDecorator<Model>(Model.class,"${name} - ${integerValue}");
+ Decorator<Model> decorator;
+ String expected;
+ String result;
Model m = new Model("name", 10);
-// String expected = m.getName() + " - " + m.getIntegervalue();
-// String result = decorator.toString(m);
- //org.junit.Assert.assertEquals(expected, result);
+ decorator = new JXPathDecorator<Model>(Model.class,"${name} - ${integervalue}");
+ expected = m.getName() + " - " + m.getIntegervalue();
+ result = decorator.toString(m);
+ Assert.assertEquals(expected, result);
+
+ decorator = new JXPathDecorator<Model>(Model.class,"${name}${integervalue}");
+ expected = m.getName() + m.getIntegervalue();
+ result = decorator.toString(m);
+ Assert.assertEquals(expected, result);
+
+ decorator = new JXPathDecorator<Model>(Model.class,"before ${name} - ${integervalue} after");
+ expected = "before "+m.getName() + " - " + m.getIntegervalue()+" after";
+ result = decorator.toString(m);
+ Assert.assertEquals(expected, result);
+
+ decorator = new JXPathDecorator<Model>(Model.class,"before${name}-${integervalue}after");
+ expected = "before"+m.getName() + "-" + m.getIntegervalue()+"after";
+ result = decorator.toString(m);
+ Assert.assertEquals(expected, result);
}
}
1
0