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
r1035 - in lutinjaxx/trunk/jaxx-core/src: main/java/jaxx/runtime/swing/navigation test/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 26 Nov '08
by chemit@users.labs.libre-entreprise.org 26 Nov '08
26 Nov '08
Author: chemit
Date: 2008-11-26 01:06:42 +0000 (Wed, 26 Nov 2008)
New Revision: 1035
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
Log:
improve and refactor navigation model to make findNode more efficent + can now defined the navigation path separator.
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:42:25 UTC (rev 1034)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-26 01:06:42 UTC (rev 1035)
@@ -13,8 +13,7 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Stack;
+import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -30,17 +29,181 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
- private static final long serialVersionUID = 1L;
+ static private final long serialVersionUID = 1L;
- /** la représentation d'un noeud dans le model {@link NavigationTreeModel} */
- public static class NavigationTreeNode extends DefaultMutableTreeNode {
+ /** the separator char used to produce the navigation path of a node. */
+ protected final String navigationPathSeparator;
+ public NavigationTreeModel(TreeNode root, String navigationPathSeparator) {
+ super(root);
+ this.navigationPathSeparator = navigationPathSeparator;
+ }
+
+ @Override
+ public NavigationTreeNode getRoot() {
+ return (NavigationTreeNode) super.getRoot();
+ }
+
+ /**
+ * Search from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the root node, or <code>null</code> if not find.
+ */
+ public NavigationTreeNode findNode(String path) {
+ return findNode(getRoot(), path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ * <p/>
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, String regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, Pattern regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+
+ /**
+ * Search from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
+ return findNode(root, path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes)
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
+ return findNode(root, path, regex == null ? null : Pattern.compile(regex));
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
+ if (regex != null) {
+ Matcher matcher = regex.matcher(path);
+ if (!matcher.matches() || matcher.groupCount() < 1) {
+ log.warn("no matching regex " + regex + " to " + path);
+ return null;
+ }
+ path = matcher.group(1);
+ log.info("matching regex " + regex + " : " + path);
+ }
+ StringTokenizer stk = new StringTokenizer(path, navigationPathSeparator);
+ NavigationTreeNode result = root;
+ // pas the first token (matches the root node)
+ if (root.isRoot() && stk.hasMoreTokens()) {
+ String rootPath = stk.nextToken();
+ if (!rootPath.equals(root.getNavigationPath())) {
+ return null;
+ }
+ }
+ while (stk.hasMoreTokens()) {
+ result = result.getChild(stk.nextToken());
+ }
+ return result;
+ }
+
+
+ /**
+ * Obtain the associated bean value from context corresponding to node from given navigation path.
+ *
+ * @param context the context where to seek value
+ * @param navigationPath the current context path of the node
+ * @return the value associated in context with the given navigation path
+ */
+ public Object getJAXXContextValue(JAXXContext context, String navigationPath) {
+ Object result;
+ NavigationTreeNode node = findNode(navigationPath, (Pattern) null);
+ result = getJAXXContextValue(context, node);
+ return result;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param context the context where to seek value
+ * @param node the current node
+ * @return the value associated in context with the given node.
+ */
+ public Object getJAXXContextValue(JAXXContext context, NavigationTreeNode node) {
+ if (node == null) {
+ return null;
+ //fixme should throw a NPE exception
+ //throw new NullPointerException("node can not be null");
+ }
+ return node.getJAXXContextValue(context);
+ }
+
+ /**
+ * la représentation d'un noeud dans le modele {@link NavigationTreeModel}
+ *
+ * @author chemit
+ */
+ public class NavigationTreeNode extends DefaultMutableTreeNode {
+
private static final long serialVersionUID = 1L;
/** pour representer le context du noeud. */
- protected String context;
+ protected String navigationPath;
- /** the JAXXObject class associated with this node */
+ /** the JAXXObject class associated with this node (can be null) */
protected Class<? extends JAXXObject> jaxxClass;
/** the JAXXAction class associated with this node and will be put in ui context */
@@ -49,13 +212,15 @@
/** the definition of the JAXXContext entry associated to this node, if null will seek in parent */
protected JAXXContextEntryDef jaxxContextEntryDef;
+ /** jxPath to process to obtain real value associated from context with the node (can be null) */
protected String jaxxContextEntryPath;
+ /** renderer of the node */
protected NodeRenderer renderer;
public NavigationTreeNode(Object renderer,
Object jaxxContextEntryDef,
- String context,
+ String navigationPath,
Class<? extends JAXXObject> jaxxClass,
Class<? extends JAXXAction> jaxxActionClass) {
super(renderer);
@@ -64,13 +229,11 @@
((NodeRenderer) renderer).setNode(this);
} else if (renderer instanceof String) {
// nothing special to be done
- } else {
- if (renderer != null) {
- // wrong renderer type
- throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
- }
+ } else if (renderer != null) {
+ // wrong renderer type
+ throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
}
- this.context = context;
+ this.navigationPath = navigationPath;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
@@ -78,18 +241,16 @@
this.jaxxContextEntryDef = ((JAXXContextEntryDef) jaxxContextEntryDef);
} else if (jaxxContextEntryDef instanceof String) {
this.jaxxContextEntryPath = (String) jaxxContextEntryDef;
- } else {
- if (jaxxContextEntryDef != null) {
- // wront context definition type
- throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
- }
+ } else if (jaxxContextEntryDef != null) {
+ // wrong context definition type
+ throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
}
}
public NavigationTreeNode(Object renderer,
JAXXContextEntryDef jaxxContextEntryDef,
String jaxxContextEntryPath,
- String context,
+ String navigationPath,
Class<? extends JAXXObject> jaxxClass,
Class<? extends JAXXAction> jaxxActionClass) {
super(renderer);
@@ -98,25 +259,23 @@
((NodeRenderer) renderer).setNode(this);
} else if (renderer instanceof String) {
// nothing special to be done
- } else {
- if (renderer != null) {
- // wrong renderer type
- throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
- }
+ } else if (renderer != null) {
+ // wrong renderer type
+ throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
}
- this.context = context;
+ this.navigationPath = navigationPath;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
this.jaxxContextEntryDef = jaxxContextEntryDef;
this.jaxxContextEntryPath = jaxxContextEntryPath;
}
- public String getContext() {
- return context;
+ public String getNavigationPath() {
+ return navigationPath;
}
- public void setContext(String context) {
- this.context = context;
+ public void setNavigationPath(String navigationPath) {
+ this.navigationPath = navigationPath;
}
public Class<? extends JAXXObject> getJaxxClass() {
@@ -143,13 +302,21 @@
this.jaxxContextEntryDef = jaxxContextEntryDef;
}
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
/** @return the fully context pathof the node from the root node to this. */
public String getContextPath() {
TreeNode[] path = getPath();
StringBuilder sb = new StringBuilder();
for (TreeNode treeNode : path) {
NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
- sb.append('.').append(myNode.getContext());
+ sb.append(navigationPathSeparator).append(myNode.getNavigationPath());
}
return sb.substring(1);
}
@@ -165,13 +332,13 @@
}
/**
- * @param context the name of the {@link #context} to be matched in the cild of this node.
- * @return the child of this node with given {@link #context} value.
+ * @param navigationPath the name of the {@link #navigationPath} to be matched in the cild of this node.
+ * @return the child of this node with given {@link # navigationPath} value.
*/
- public NavigationTreeNode getChild(String context) {
+ public NavigationTreeNode getChild(String navigationPath) {
for (int i = 0, max = getChildCount(); i < max; i++) {
NavigationTreeNode son = getChildAt(i);
- if (context.equals(son.getContext())) {
+ if (navigationPath.equals(son.getNavigationPath())) {
return son;
}
}
@@ -179,48 +346,16 @@
}
/**
- * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
- * or <code>null</code> if none find..
- */
- protected NavigationTreeNode getFirstAncestorWithDef() {
- if (jaxxContextEntryDef != null) {
- return this;
- }
- return getParent() == null ? null : getParent().getFirstAncestorWithDef();
- }
-
- protected NavigationTreeNode findNode(Stack<String> stack) {
- if (log.isDebugEnabled()) {
- log.debug(context + " : enter with " + stack);
- }
- if (stack.isEmpty()) {
- return this;
- }
- // next context to search
- String currentPath = stack.pop();
- if (getContext().equals(currentPath) && currentPath.startsWith("$")) {
- // this node matchs (only do this for root node)
- return findNode(stack);
- }
- // find the next matching son
- NavigationTreeNode son = getChild(currentPath);
- return son == null ? null : son.findNode(stack);
- }
-
- /**
* Obtain the associated bean value from context corresponding to node
*
* @param context the context to seek
* @return the value associated in context with the given context path
- * @throws InvocationTargetException todo
- * @throws NoSuchMethodException todo
- * @throws IllegalAccessException todo
*/
- public Object getJAXXContextValue(JAXXContext context) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ public Object getJAXXContextValue(JAXXContext context) {
Object result;
if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
- // the node maps directly a value in context, with no jxpath resolving
+ // the node maps directly a value in context, with no jxpath resolving
result = getJaxxContextEntryDef().getContextValue(context);
return result;
}
@@ -234,7 +369,6 @@
}
Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context);
- //Object parentBean = parentNode.getJAXXContextValue(context);
if (parentBean == null) {
// must be an error no bean found
@@ -281,6 +415,17 @@
return result;
}
+ /**
+ * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
+ * or <code>null</code> if none find..
+ */
+ protected NavigationTreeNode getFirstAncestorWithDef() {
+ if (jaxxContextEntryDef != null) {
+ return this;
+ }
+ return getParent() == null ? null : getParent().getFirstAncestorWithDef();
+ }
+
protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
if (parentNode == this) {
// reach the parent limit node, return the expr computed
@@ -337,162 +482,4 @@
}
}
- @Override
- public NavigationTreeNode getRoot() {
- return (NavigationTreeNode) super.getRoot();
- }
-
-
- public NavigationTreeModel(TreeNode root) {
- super(root);
- }
-
- public NavigationTreeModel(TreeNode root, boolean asksAllowsChildren) {
- super(root, asksAllowsChildren);
- }
-
- /**
- * Search from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- * <p/>
- * Example :
- * <p/>
- * <pre>$root.child1.leaf1</pre>
- *
- * @param path the fully path of the searched node.
- * @return the node matching the fully context from the root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(String path) {
- return findNode(getRoot(), path, (Pattern) null);
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- * <p/>
- * <p/>
- * Example :
- * <p/>
- * <pre>$root.child1.leaf1</pre>
- *
- * @param path the fully path of the searched node.
- * @param regex a optional regex to apply to path before searching
- * @return the node matching the fully context from the root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(String path, String regex) {
- return findNode(getRoot(), path, regex);
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- * <p/>
- * Example :
- * <p/>
- * <pre>$root.child1.leaf1</pre>
- *
- * @param path the fully path of the searched node.
- * @param regex a optional regex to apply to path before searching
- * @return the node matching the fully context from the root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(String path, Pattern regex) {
- return findNode(getRoot(), path, regex);
- }
-
-
- /**
- * Search from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- *
- * @param root root node to be used
- * @param path the fully path of the searched node.
- * @return the node matching the fully context from the given root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
- return findNode(root, path, (Pattern) null);
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- *
- * @param root root node to be used
- * @param path the fully path of the searched node.
- * @param regex a previous regex to apply to path : must have a matches
- * @return the node matching the fully context from the given root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
- return findNode(root, path, regex == null ? null : Pattern.compile(regex));
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- *
- * @param root root node to be used
- * @param path the fully path of the searched node.
- * @param regex a previous regex to apply to path : must have a matches
- * @return the node matching the fully context from the given root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
- if (regex != null) {
- Matcher matcher = regex.matcher(path);
- if (!matcher.matches() || matcher.groupCount() < 1) {
- log.warn("no matching regex " + regex + " to " + path);
- return null;
- }
- path = matcher.group(1);
- log.info("matching regex " + regex + " : " + path);
- }
- String[] paths = path.split("\\.");
- Stack<String> stack = new Stack<String>();
- for (int i = paths.length - 1; i > -1; i--) {
- stack.push(paths[i]);
- }
- return root.findNode(stack);
- }
-
-
- /**
- * Obtain the associated bean value from context corresponding to node from given contextPath.
- *
- * @param context the context to seek
- * @param contextPath the current context path of the node
- * @return the value associated in context with the given context path
- * @throws InvocationTargetException todo
- * @throws NoSuchMethodException todo
- * @throws IllegalAccessException todo
- */
- public Object getJAXXContextValue(JAXXContext context, String contextPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
- Object result;
- NavigationTreeNode node = findNode(contextPath, (Pattern) null);
- result = getJAXXContextValue(context, node);
- return result;
- }
-
- /**
- * Obtain the associated bean value from context corresponding to node
- *
- * @param context the context to seek
- * @param node the current node
- * @return the value associated in context with the given context path
- * @throws InvocationTargetException todo
- * @throws NoSuchMethodException todo
- * @throws IllegalAccessException todo
- */
- public Object getJAXXContextValue(JAXXContext context, NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
- //Object result;
- if (node == null) {
- return null;
- }
- return node.getJAXXContextValue(context);
- }
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-25 09:42:25 UTC (rev 1034)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-26 01:06:42 UTC (rev 1035)
@@ -12,7 +12,8 @@
protected NavigationTreeModel model;
- public NavigationTreeModelBuilder() {
+ public NavigationTreeModelBuilder(String navigationSeparator) {
+ model = new NavigationTreeModel(null, navigationSeparator);
}
public NavigationTreeModel getModel() {
@@ -25,7 +26,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(libelle), entryDef, entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -34,7 +35,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(libelle), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -43,7 +44,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(libelle), entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -53,7 +54,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(decorator), entryDef, entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -62,7 +63,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(decorator), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -71,72 +72,27 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(decorator), entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
- public void setRootNode(NavigationTreeNode rootNode) {
- if (model == null) {
- // create model with the root node
- model = new NavigationTreeModel(rootNode);
- } else {
- model.setRoot(rootNode);
- }
- }
-
protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
- if (parentNode != null) {
+ if (parentNode == null) {
+ model.setRoot(node);
+ } else {
parentNode.add(node);
}
+ model.nodeStructureChanged(parentNode);
return node;
}
- public NavigationTreeNode removeChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
- if (parentNode != null) {
+ public NavigationTreeNode removeChildNode(NavigationTreeNode node) {
+ NavigationTreeNode parentNode = node.getParent();
+ /*if (parentNode != null) {
parentNode.remove(node);
- }
- return node;
+ }*/
+ model.removeNodeFromParent(node);
+ return parentNode;
}
- /*
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
- String contextName,
- Class<? extends JAXXObject> uiClass) {
- return build(parentNode, libelle, entryDef, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
- String contextName) {
- return build(parentNode, libelle, entryDef, contextName, null, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String contextName,
- Class<? extends JAXXObject> uiClass) {
- return build(parentNode, libelle, (String) null, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String contextName) {
- return build(parentNode, libelle, (String) null, contextName, null, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator, JAXXContextEntryDef entryDef,
- String contextName, Class<? extends JAXXObject> uiClass) {
- return build(parentNode, decorator, entryDef, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator, JAXXContextEntryDef entryDef,
- String contextName) {
- return build(parentNode, decorator, entryDef, contextName, null, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator,
- String contextName, Class<? extends JAXXObject> uiClass) {
- return build(parentNode, decorator, (String) null, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator,
- String contextName) {
- return build(parentNode, decorator, (String) null, contextName, null, null);
- }*/
-
}
Modified: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2008-11-25 09:42:25 UTC (rev 1034)
+++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2008-11-26 01:06:42 UTC (rev 1035)
@@ -7,7 +7,6 @@
import org.junit.Assert;
import org.junit.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -20,29 +19,29 @@
*/
public class NavigationTreeModelTest {
-
private static final String ROOT_CONTEXT = "$root";
private static final String FAKE = "-fake";
- private static final String DOT = ".";
+ private static final String separator = "/";
+
@Test
public void testFindNode() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
for (int i = 0; i < 4; i++) {
- NavigationTreeNode sonNode = new NavigationTreeNode(null, null, getNodeContext(i), null, null);
- rootNode.insert(sonNode, i);
+ NavigationTreeNode sonNode = builder.build(rootNode, (String) null, (String) null, getNodeContext(i), null, null);
for (int j = 0; j < 4; j++) {
- NavigationTreeNode sonSonNode = new NavigationTreeNode(null, null, getNodeContext(i, j), null, null);
- sonNode.insert(sonSonNode, j);
+ NavigationTreeNode sonSonNode = builder.build(sonNode, (String) null, (String) null, getNodeContext(i, j), null, null);
for (int k = 0; k < 4; k++) {
- sonSonNode.insert(new NavigationTreeNode(null, null, getNodeContext(i, j, k), null, null), k);
+ builder.build(sonSonNode, (String) null, (String) null, getNodeContext(i, j, k), null, null);
}
}
}
- NavigationTreeModel model = new NavigationTreeModel(rootNode);
+ NavigationTreeModel model = builder.getModel();
NavigationTreeNode node;
String contextPath;
@@ -57,28 +56,28 @@
for (int i = 0; i < 4; i++) {
currentNode = getNodeContext(i);
- contextPath = ROOT_CONTEXT + DOT + currentNode;
+ contextPath = ROOT_CONTEXT + separator + currentNode;
node = model.findNode(contextPath);
assertNodeEquals(contextPath, currentNode, 1, node, false);
for (int j = 0; j < 4; j++) {
currentNode = getNodeContext(i, j);
- contextPath = ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + currentNode;
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode;
node = model.findNode(contextPath);
assertNodeEquals(contextPath, currentNode, 2, node, false);
for (int k = 0; k < 4; k++) {
currentNode = getNodeContext(i, j, k);
- contextPath = ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + getNodeContext(i, j) + DOT + currentNode;
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode;
node = model.findNode(contextPath);
assertNodeEquals(contextPath, currentNode, 3, node, false);
}
- node = model.findNode(ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + getNodeContext(i, j) + DOT + currentNode + FAKE);
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode + FAKE);
Assert.assertNull(node);
}
- node = model.findNode(ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + currentNode + FAKE);
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode + FAKE);
Assert.assertNull(node);
}
@@ -128,52 +127,44 @@
@Test
public void testGetJAXXContextValue() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
NavigationTreeNode sonNode;
NavigationTreeNode sonSonNode;
NavigationTreeNode sonSonSonNode;
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
- rootNode.insert(sonNode, 0);
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
+ builder.build(sonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonNode, (String) null, "../integerValue", "integerValue", null, null);
- rootNode.insert(sonNode, 1);
+ sonSonNode = builder.build(sonNode, (String) null, "../sons", "sons", null, null);
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", 0 + "", null, null);
- rootNode.insert(sonNode, 2);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
- sonSonNode = new NavigationTreeNode(null, "../name", "name", null, null);
- sonNode.insert(sonSonNode, 0);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[2]", 1 + "", null, null);
- sonSonNode = new NavigationTreeNode(null, "../integerValue", "integerValue", null, null);
- sonNode.insert(sonSonNode, 1);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
- sonSonNode = new NavigationTreeNode(null, "../sons", "sons", null, null);
- sonNode.insert(sonSonNode, 2);
-
- sonSonSonNode = new NavigationTreeNode(null, "..[1]", 0 + "", null, null);
- sonSonNode.insert(sonSonSonNode, 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
-
- sonSonSonNode = new NavigationTreeNode(null, "..[2]", 1 + "", null, null);
- sonSonNode.insert(sonSonSonNode, 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
-
- sonSonSonNode = new NavigationTreeNode(null, null, 2 + "", null, null);
- //sonSonSonNode = new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, (String) null, 2 + "", null, null);
+ //sonSonSonNode = model.new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
sonSonNode.insert(sonSonSonNode, 2);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/name", "name", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/integerValue", "integerValue", null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/sons", "sons", null, null), 2);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/sons", "sons", null, null);
- NavigationTreeModel model = new NavigationTreeModel(rootNode);
+ NavigationTreeModel model = builder.getModel();
JAXXContext context = new DefaultJAXXContext();
context.setContextValue("the name", "name");
@@ -192,28 +183,28 @@
Assert.assertNull(model.getJAXXContextValue(context, "$root.name" + FAKE));
- testBinding(model, context, "$root.name", context.getContextValue(String.class, "name"));
- testBinding(model, context, "$root.name2", context.getContextValue(String.class, "name2"));
+ testBinding(model, context, "$root/name", context.getContextValue(String.class, "name"));
+ testBinding(model, context, "$root/name2", context.getContextValue(String.class, "name2"));
Model bean = context.getContextValue(Model.class);
- testBinding(model, context, "$root.model", bean);
- testBinding(model, context, "$root.model.name", bean.getName());
- testBinding(model, context, "$root.model.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.model.sons", bean.getSons());
+ testBinding(model, context, "$root/model", bean);
+ testBinding(model, context, "$root/model/name", bean.getName());
+ testBinding(model, context, "$root/model/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/model/sons", bean.getSons());
- testBinding(model, context, "$root.model.sons.0.name", bean.getSons().get(0).getName());
- testBinding(model, context, "$root.model.sons.0.integerValue", bean.getSons().get(0).getIntegerValue());
- testBinding(model, context, "$root.model.sons.0.sons", bean.getSons().get(0).getSons());
+ testBinding(model, context, "$root/model/sons/0/name", bean.getSons().get(0).getName());
+ testBinding(model, context, "$root/model/sons/0/integerValue", bean.getSons().get(0).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/0/sons", bean.getSons().get(0).getSons());
- testBinding(model, context, "$root.model.sons.1.name", bean.getSons().get(1).getName());
- testBinding(model, context, "$root.model.sons.1.integerValue", bean.getSons().get(1).getIntegerValue());
- testBinding(model, context, "$root.model.sons.1.sons", bean.getSons().get(1).getSons());
+ testBinding(model, context, "$root/model/sons/1/name", bean.getSons().get(1).getName());
+ testBinding(model, context, "$root/model/sons/1/integerValue", bean.getSons().get(1).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/1/sons", bean.getSons().get(1).getSons());
- testBinding(model, context, "$root.model.sons.2.name", bean.getSons().get(2).getName());
- testBinding(model, context, "$root.model.sons.2.integerValue", bean.getSons().get(2).getIntegerValue());
- testBinding(model, context, "$root.model.sons.2.sons", bean.getSons().get(2).getSons());
+ testBinding(model, context, "$root/model/sons/2/name", bean.getSons().get(2).getName());
+ testBinding(model, context, "$root/model/sons/2/integerValue", bean.getSons().get(2).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/2/sons", bean.getSons().get(2).getSons());
}
/**
@@ -252,90 +243,93 @@
@Test
public void testGetJAXXContextValueFromList() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
NavigationTreeNode sonNode;
NavigationTreeNode sonSonNode;
NavigationTreeNode sonSonSonNode;
// first son is a list of models
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
- rootNode.insert(sonNode, 0);
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
// first son son is a model
- sonSonNode = new NavigationTreeNode(null, "..[1]", "0", null, null);
- sonNode.insert(sonSonNode, 0);
+ sonSonNode = builder.build(sonNode, (String) null, "..[1]", "0", null, null);
- sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonNode.insert(sonSonSonNode = new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ sonSonNode = builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
- sonSonSonNode.insert(sonSonSonNode = new NavigationTreeNode(null, "..[1]", "0", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", "0", null, null);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
// second son son is a model
- sonSonNode = new NavigationTreeNode(null, "..[2]", "1", null, null);
- sonNode.insert(sonSonNode, 1);
- sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
+ sonSonNode = builder.build(sonNode, (String) null, "..[2]", "1", null, null);
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
// third son son is a model
- sonSonNode = new NavigationTreeNode(null, "..[3]", "2", null, null);
- sonNode.insert(sonSonNode, 2);
- sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
+ sonSonNode = builder.build(sonNode, (String) null, "..[3]", "2", null, null);
- NavigationTreeModel model = new NavigationTreeModel(rootNode);
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
- JAXXContext context = new DefaultJAXXContext();
- List<Model> list = new ArrayList<Model>();
- list.add(new Model("entryOne", 10,
- Arrays.asList(
- new Model("one", 1, Collections.<Model>emptyList()),
- new Model("two", 2, Collections.<Model>emptyList()),
- new Model("three", 3, Collections.<Model>emptyList())
+ NavigationTreeModel model = builder.getModel();
+
+
+ List<Model> list = Arrays.asList(
+ new Model("entryOne", 10,
+ Arrays.asList(
+ new Model("one", 1, Collections.<Model>emptyList()),
+ new Model("two", 2, Collections.<Model>emptyList()),
+ new Model("three", 3, Collections.<Model>emptyList())
+ )
+ ),
+ new Model("entryTwo", 20,
+ Arrays.asList(
+ new Model("2one", 1, Collections.<Model>emptyList()),
+ new Model("2two", 2, Collections.<Model>emptyList()),
+ new Model("2three", 3, Collections.<Model>emptyList())
+ )
+ ),
+ new Model("entryThree", 30,
+ Arrays.asList(
+ new Model("3one", 1, Collections.<Model>emptyList()),
+ new Model("3two", 2, Collections.<Model>emptyList()),
+ new Model("3three", 3, Collections.<Model>emptyList())
+ )
)
- ));
- list.add(new Model("entryTwo", 20,
- Arrays.asList(
- new Model("2one", 1, Collections.<Model>emptyList()),
- new Model("2two", 2, Collections.<Model>emptyList()),
- new Model("2three", 3, Collections.<Model>emptyList())
- )
- ));
- list.add(new Model("entryThree", 30,
- Arrays.asList(
- new Model("3one", 1, Collections.<Model>emptyList()),
- new Model("3two", 2, Collections.<Model>emptyList()),
- new Model("3three", 3, Collections.<Model>emptyList())
- )
- ));
+ );
+ JAXXContext context = new DefaultJAXXContext();
context.setContextValue(list, "models");
Model bean;
- testBinding(model, context, "$root.models", list);
+ testBinding(model, context, "$root/models", list);
bean = list.get(0);
- testBinding(model, context, "$root.models.0", bean);
- testBinding(model, context, "$root.models.0.name", bean.getName());
- testBinding(model, context, "$root.models.0.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.models.0.sons", bean.getSons());
- testBinding(model, context, "$root.models.0.sons.0", bean.getSons().get(0));
- testBinding(model, context, "$root.models.0.sons.0.name", bean.getSons().get(0).getName());
+ testBinding(model, context, "$root/models/0", bean);
+ testBinding(model, context, "$root/models/0/name", bean.getName());
+ testBinding(model, context, "$root/models/0/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/0/sons", bean.getSons());
+ testBinding(model, context, "$root/models/0/sons/0", bean.getSons().get(0));
+ testBinding(model, context, "$root/models/0/sons/0/name", bean.getSons().get(0).getName());
bean = list.get(1);
- testBinding(model, context, "$root.models.1", bean);
- testBinding(model, context, "$root.models.1.name", bean.getName());
- testBinding(model, context, "$root.models.1.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.models.1.sons", bean.getSons());
+ testBinding(model, context, "$root/models/1", bean);
+ testBinding(model, context, "$root/models/1/name", bean.getName());
+ testBinding(model, context, "$root/models/1/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/1/sons", bean.getSons());
bean = list.get(2);
- testBinding(model, context, "$root.models.2", bean);
- testBinding(model, context, "$root.models.2.name", bean.getName());
- testBinding(model, context, "$root.models.2.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.models.2.sons", bean.getSons());
+ testBinding(model, context, "$root/models/2", bean);
+ testBinding(model, context, "$root/models/2/name", bean.getName());
+ testBinding(model, context, "$root/models/2/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/2/sons", bean.getSons());
}
@@ -347,7 +341,7 @@
Assert.assertEquals(expected, value);
}
- protected static String getNodeContext(int... context) {
+ protected String getNodeContext(int... context) {
String result = "";
for (int i : context) {
result += i;
@@ -360,7 +354,7 @@
Assert.assertNotNull(node);
Assert.assertEquals(root, node.isRoot());
Assert.assertEquals(level, node.getLevel());
- Assert.assertEquals(nodeContext, node.getContext());
+ Assert.assertEquals(nodeContext, node.getNavigationPath());
Assert.assertEquals(contextPath, node.getContextPath());
}
1
0
r1034 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 25 Nov '08
by chemit@users.labs.libre-entreprise.org 25 Nov '08
25 Nov '08
Author: chemit
Date: 2008-11-25 09:42:25 +0000 (Tue, 25 Nov 2008)
New Revision: 1034
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
Log:
fix bugs on navigation
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:00:41 UTC (rev 1033)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:42:25 UTC (rev 1034)
@@ -219,7 +219,7 @@
public Object getJAXXContextValue(JAXXContext context) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
Object result;
- if (getJaxxContextEntryDef() != null && jaxxContextEntryPath==null) {
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
// the node maps directly a value in context, with no jxpath resolving
result = getJaxxContextEntryDef().getContextValue(context);
return result;
@@ -242,7 +242,14 @@
return null;
}
- if (this == parentNode && jaxxContextEntryPath == null) {
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+
+ if (this == parentNode) {
// current node is the node matching the context entry value and no jxpath is found
return parentBean;
}
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-11-25 09:00:41 UTC (rev 1033)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-11-25 09:42:25 UTC (rev 1034)
@@ -144,14 +144,16 @@
Object data = getNavigationTreeModel().getJAXXContextValue(context, path);
if (log.isDebugEnabled()) {
- log.debug("find data for contextPath <" + path + "> : " + data.getClass());
+ log.debug("find data for contextPath <" + path + "> : " + (data == null ? null : data.getClass()));
}
+ 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) {
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 09:00:41 UTC (rev 1033)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 09:42:25 UTC (rev 1034)
@@ -25,8 +25,8 @@
return context.getContextValue(NavigationTreeNode.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_NODE);
}
- public static Object getSelectedBean(JAXXContext context) {
- return context.getContextValue(Object.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
+ public static <O> O getSelectedBean(JAXXContext context,Class<O> clazz) {
+ return context.getContextValue(clazz, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
}
public static Object getContextValue(JAXXContext context, String contextKey, String navigationPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
1
0
r1033 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 25 Nov '08
by chemit@users.labs.libre-entreprise.org 25 Nov '08
25 Nov '08
Author: chemit
Date: 2008-11-25 09:00:41 +0000 (Tue, 25 Nov 2008)
New Revision: 1033
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
Log:
out selected bean in context
improve search of bean algorithm (a node can have a JAXXContextEntryDef ad a jxpath)
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -53,7 +53,11 @@
protected NodeRenderer renderer;
- public NavigationTreeNode(Object renderer, Object jaxxContextEntryDef, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass) {
+ public NavigationTreeNode(Object renderer,
+ Object jaxxContextEntryDef,
+ String context,
+ Class<? extends JAXXObject> jaxxClass,
+ Class<? extends JAXXAction> jaxxActionClass) {
super(renderer);
if (renderer instanceof NodeRenderer) {
// the renderer must keep a reference of the node
@@ -82,29 +86,31 @@
}
}
- /*public NavigationTreeNode(String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
+ public NavigationTreeNode(Object renderer,
+ JAXXContextEntryDef jaxxContextEntryDef,
+ String jaxxContextEntryPath,
+ String context,
+ Class<? extends JAXXObject> jaxxClass,
+ Class<? extends JAXXAction> jaxxActionClass) {
+ super(renderer);
+ if (renderer instanceof NodeRenderer) {
+ // the renderer must keep a reference of the node
+ ((NodeRenderer) renderer).setNode(this);
+ } else if (renderer instanceof String) {
+ // nothing special to be done
+ } else {
+ if (renderer != null) {
+ // wrong renderer type
+ throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
+ }
+ }
this.context = context;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
this.jaxxContextEntryDef = jaxxContextEntryDef;
- }*/
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
- /*public NavigationTreeNode(Object userObject, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
- super(userObject);
- this.context = context;
- this.jaxxClass = jaxxClass;
- this.jaxxActionClass = jaxxActionClass;
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- }*/
-
- /*public NavigationTreeNode(Object userObject, boolean allowsChildren, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
- super(userObject, allowsChildren);
- this.context = context;
- this.jaxxClass = jaxxClass;
- this.jaxxActionClass = jaxxActionClass;
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- }*/
-
public String getContext() {
return context;
}
@@ -190,10 +196,10 @@
if (stack.isEmpty()) {
return this;
}
- // nextcontext to search
+ // next context to search
String currentPath = stack.pop();
- if (getContext().equals(currentPath)) {
- // this node matchs
+ if (getContext().equals(currentPath) && currentPath.startsWith("$")) {
+ // this node matchs (only do this for root node)
return findNode(stack);
}
// find the next matching son
@@ -213,8 +219,8 @@
public Object getJAXXContextValue(JAXXContext context) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
Object result;
- if (getJaxxContextEntryDef() != null) {
- // the node maps directly a value in context
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath==null) {
+ // the node maps directly a value in context, with no jxpath resolving
result = getJaxxContextEntryDef().getContextValue(context);
return result;
}
@@ -236,8 +242,8 @@
return null;
}
- if (this == parentNode) {
- // current node is the node matching the context entry value
+ if (this == parentNode && jaxxContextEntryPath == null) {
+ // current node is the node matching the context entry value and no jxpath is found
return parentBean;
}
@@ -257,7 +263,7 @@
}
if (jxpathExpression.startsWith("[")) {
// special case when we want to access a collection
- jxpathExpression = '.'+jxpathExpression;
+ jxpathExpression = '.' + jxpathExpression;
}
log.info("jxpath : " + jxpathExpression);
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -19,15 +19,27 @@
return model;
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef entryDef,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, entryPath, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String entryPath,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
@@ -35,15 +47,27 @@
return addChildNode(parentNode, node);
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, JAXXContextEntryDef entryDef,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef entryDef,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, entryPath, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, String entryPath,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
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-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.navigation;
+import jaxx.runtime.JAXXAction;
import jaxx.runtime.JAXXObject;
-import jaxx.runtime.JAXXAction;
import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -11,7 +11,6 @@
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
import java.awt.Component;
-import java.lang.reflect.InvocationTargetException;
/** A {@link javax.swing.event.TreeSelectionListener} implementation@author chemit */
public abstract class NavigationTreeSelectionAdapter implements TreeSelectionListener {
@@ -23,6 +22,8 @@
static public final String NAVIGATION_SELECTED_NODE = "navigation-selected-node";
+ static public final String NAVIGATION_SELECTED_BEAN = "navigation-selected-bean";
+
/** la classe d'ui par defaut, associé à un noeud de l'arbe */
protected Class<? extends JAXXObject> defaultUIClass;
@@ -86,6 +87,26 @@
*/
protected abstract void goBackToPreviousNode(TreeSelectionEvent event, Exception e);
+ /**
+ * Prepare le nouveau noeud sélectionné.
+ *
+ * @param event l'évènement de selection du noeud
+ * @return le noeud selectionné et preparé
+ */
+ protected NavigationTreeNode prepareNode(TreeSelectionEvent event) {
+ NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+
+ if (node.getJaxxClass() == null) {
+ // no ui is associated with this node, display a empty content
+ node.setJaxxClass(defaultUIClass);
+ }
+
+ if (node.getJaxxActionClass() == null) {
+ node.setJaxxActionClass(defaultUIHandlerClass);
+ }
+ return node;
+ }
+
public void valueChanged(TreeSelectionEvent event) {
if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
// do not treate this if no path changed
@@ -94,21 +115,12 @@
try {
- NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+ NavigationTreeNode node = prepareNode(event);
- if (node.getJaxxClass() == null) {
- // no ui is associated with this node, display a empty content
- node.setJaxxClass(defaultUIClass);
- }
-
- if (node.getJaxxActionClass()==null) {
- node.setJaxxActionClass(defaultUIHandlerClass);
- }
-
String path = node.getContextPath();
- if (log.isDebugEnabled()) {
- log.debug(path);
+ if (log.isTraceEnabled()) {
+ log.trace(path);
}
Component newUI = getNewUI(path);
@@ -119,7 +131,6 @@
return;
}
-
if (!closeUI(event, component)) {
// previous ui was not closed, so reselect the previous node in navigation
goBackToPreviousNode(event, null);
@@ -130,9 +141,19 @@
// now, we are free to open the ui associated with the selected node in navigation
// before all, attach bean in context associated with the selected node in naivgation tree
- attachBeanFromNodeToContext(node);
+ Object data = getNavigationTreeModel().getJAXXContextValue(context, path);
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + path + "> : " + data.getClass());
+ }
+ 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);
@@ -149,13 +170,14 @@
openUI(newUI, node);
} catch (Exception e) {
+ // remove data from context
+
// if any error, go back to previvous node
goBackToPreviousNode(event, e);
}
-
}
- protected void attachBeanFromNodeToContext(NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ /* protected Object attachBeanFromNodeToContext(NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
String path = node.getContextPath();
@@ -171,7 +193,8 @@
context.setContextValue(data);
}
//}
- }
+ return data;
+ }*/
protected void returnToPreviousNode(JTree tree, TreeSelectionEvent event) {
// go back to previous node
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -25,6 +25,10 @@
return context.getContextValue(NavigationTreeNode.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_NODE);
}
+ public static Object getSelectedBean(JAXXContext context) {
+ return context.getContextValue(Object.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
+ }
+
public static Object getContextValue(JAXXContext context, String contextKey, String navigationPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
1
0
r1032 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime
by chemit@users.labs.libre-entreprise.org 25 Nov '08
by chemit@users.labs.libre-entreprise.org 25 Nov '08
25 Nov '08
Author: chemit
Date: 2008-11-25 08:58:41 +0000 (Tue, 25 Nov 2008)
New Revision: 1032
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
Log:
can seek from objet in JAXXContext with Object.class
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2008-11-24 15:35:11 UTC (rev 1031)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2008-11-25 08:58:41 UTC (rev 1032)
@@ -95,8 +95,8 @@
public boolean accept(Class<?> klass, String name) {
if (klass == Object.class && this.klass != Object.class) {
- // block if looking for Object.class
- return false;
+ // try on name only
+ return (this.name != null && name != null && this.name.equals(name));
}
return klass.isAssignableFrom(this.klass) && (this.name == null && name == null
|| (this.name != null && name != null && this.name.equals(name)));
1
0
r1031 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 24 Nov '08
by chemit@users.labs.libre-entreprise.org 24 Nov '08
24 Nov '08
Author: chemit
Date: 2008-11-24 15:35:11 +0000 (Mon, 24 Nov 2008)
New Revision: 1031
Added:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
Log:
introduce a NavigationTreeCellRenderer based on a NodeRenderer
introduce a NAvigationTreeModelBuilder to simplify the build of a model
Added: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java 2008-11-24 15:35:11 UTC (rev 1031)
@@ -0,0 +1,34 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationUtil.NodeRenderer;
+
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import java.awt.Component;
+
+/** @author chemit */
+public class NavigationTreeCellRenderer extends DefaultTreeCellRenderer {
+
+ protected JAXXContext context;
+
+ public NavigationTreeCellRenderer(JAXXContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+ if (value != null && value instanceof NavigationTreeNode && ((NavigationTreeNode) value).getUserObject() instanceof NodeRenderer) {
+
+ // NodeRenderer used as userObject
+ NavigationTreeNode navigationTreeNode = (NavigationTreeNode) value;
+ // could have a cached value (
+ NodeRenderer render = (NodeRenderer) navigationTreeNode.getUserObject();
+
+ value = render.toString(context);
+ }
+
+ return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+}
Added: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-24 15:35:11 UTC (rev 1031)
@@ -0,0 +1,118 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.Decorator;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationUtil.NodeRenderer;
+
+/** @author chemit */
+public class NavigationTreeModelBuilder {
+
+ protected NavigationTreeModel model;
+
+ public NavigationTreeModelBuilder() {
+ }
+
+ public NavigationTreeModel getModel() {
+ return model;
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryPath, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, JAXXContextEntryDef entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryPath, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public void setRootNode(NavigationTreeNode rootNode) {
+ if (model == null) {
+ // create model with the root node
+ model = new NavigationTreeModel(rootNode);
+ } else {
+ model.setRoot(rootNode);
+ }
+ }
+
+ protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
+ if (parentNode != null) {
+ parentNode.add(node);
+ }
+ return node;
+ }
+
+ public NavigationTreeNode removeChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
+ if (parentNode != null) {
+ parentNode.remove(node);
+ }
+ return node;
+ }
+
+ /*
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass) {
+ return build(parentNode, libelle, entryDef, contextName, uiClass, null);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
+ String contextName) {
+ return build(parentNode, libelle, entryDef, contextName, null, null);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String contextName,
+ Class<? extends JAXXObject> uiClass) {
+ return build(parentNode, libelle, (String) null, contextName, uiClass, null);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String contextName) {
+ return build(parentNode, libelle, (String) null, contextName, null, null);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator, JAXXContextEntryDef entryDef,
+ String contextName, Class<? extends JAXXObject> uiClass) {
+ return build(parentNode, decorator, entryDef, contextName, uiClass, null);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator, JAXXContextEntryDef entryDef,
+ String contextName) {
+ return build(parentNode, decorator, entryDef, contextName, null, null);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator,
+ String contextName, Class<? extends JAXXObject> uiClass) {
+ return build(parentNode, decorator, (String) null, contextName, uiClass, null);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator,
+ String contextName) {
+ return build(parentNode, decorator, (String) null, contextName, null, null);
+ }*/
+
+}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-24 15:33:42 UTC (rev 1030)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-24 15:35:11 UTC (rev 1031)
@@ -1,7 +1,9 @@
package jaxx.runtime.swing.navigation;
+import jaxx.runtime.Decorator;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import static org.codelutin.i18n.I18n._;
import java.lang.reflect.InvocationTargetException;
import java.util.regex.Pattern;
@@ -73,5 +75,48 @@
}
return navigationTreeNode;
}
-
+
+ public static class NodeRenderer implements java.io.Serializable {
+
+ protected String libelle;
+
+ protected Decorator decorator;
+
+ protected NavigationTreeNode node;
+
+ private static final long serialVersionUID = -1238962588426200861L;
+
+ public NodeRenderer(String libelle) {
+ this.libelle = libelle;
+ }
+
+ public NodeRenderer(Decorator<?> decorator) {
+ this.decorator = decorator;
+ }
+
+ public String toString(JAXXContext context) {
+ if (libelle != null) {
+ // simple libelle renderer
+ return _(libelle);
+ }
+
+ // with decorator renderer
+ String result;
+
+ try {
+ Object bean = node.getJAXXContextValue(context);
+ result = decorator.toString(bean);
+
+ } catch (Exception e) {
+ result = "";
+ }
+
+ return result;
+ }
+
+ public void setNode(NavigationTreeNode node) {
+ this.node = node;
+ }
+ }
+
}
1
0
r1030 - in lutinjaxx/trunk: . jaxx-core jaxx-core/src/main/java/jaxx/runtime/swing/navigation jaxx-core/src/test/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 24 Nov '08
by chemit@users.labs.libre-entreprise.org 24 Nov '08
24 Nov '08
Author: chemit
Date: 2008-11-24 15:33:42 +0000 (Mon, 24 Nov 2008)
New Revision: 1030
Modified:
lutinjaxx/trunk/jaxx-core/pom.xml
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
lutinjaxx/trunk/pom.xml
Log:
use JXPath to compute bean value in a NavigationTreeModel
Modified: lutinjaxx/trunk/jaxx-core/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-core/pom.xml 2008-11-24 15:33:01 UTC (rev 1029)
+++ lutinjaxx/trunk/jaxx-core/pom.xml 2008-11-24 15:33:42 UTC (rev 1030)
@@ -46,6 +46,11 @@
<artifactId>jxlayer</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-24 15:33:01 UTC (rev 1029)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-24 15:33:42 UTC (rev 1030)
@@ -5,8 +5,8 @@
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
-import org.apache.commons.beanutils.BeanUtilsBean;
-import org.apache.commons.beanutils.PropertyUtilsBean;
+import jaxx.runtime.swing.navigation.NavigationUtil.NodeRenderer;
+import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -14,7 +14,6 @@
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -50,28 +49,61 @@
/** the definition of the JAXXContext entry associated to this node, if null will seek in parent */
protected JAXXContextEntryDef jaxxContextEntryDef;
- public NavigationTreeNode(String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
+ protected String jaxxContextEntryPath;
+
+ protected NodeRenderer renderer;
+
+ public NavigationTreeNode(Object renderer, Object jaxxContextEntryDef, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass) {
+ super(renderer);
+ if (renderer instanceof NodeRenderer) {
+ // the renderer must keep a reference of the node
+ ((NodeRenderer) renderer).setNode(this);
+ } else if (renderer instanceof String) {
+ // nothing special to be done
+ } else {
+ if (renderer != null) {
+ // wrong renderer type
+ throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
+ }
+ }
this.context = context;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
- this.jaxxContextEntryDef = jaxxContextEntryDef;
+
+ if (jaxxContextEntryDef instanceof JAXXContextEntryDef) {
+ this.jaxxContextEntryDef = ((JAXXContextEntryDef) jaxxContextEntryDef);
+ } else if (jaxxContextEntryDef instanceof String) {
+ this.jaxxContextEntryPath = (String) jaxxContextEntryDef;
+ } else {
+ if (jaxxContextEntryDef != null) {
+ // wront context definition type
+ throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
+ }
+ }
}
- public NavigationTreeNode(Object userObject, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
+ /*public NavigationTreeNode(String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
+ this.context = context;
+ this.jaxxClass = jaxxClass;
+ this.jaxxActionClass = jaxxActionClass;
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ }*/
+
+ /*public NavigationTreeNode(Object userObject, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
super(userObject);
this.context = context;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
this.jaxxContextEntryDef = jaxxContextEntryDef;
- }
+ }*/
- public NavigationTreeNode(Object userObject, boolean allowsChildren, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
+ /*public NavigationTreeNode(Object userObject, boolean allowsChildren, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
super(userObject, allowsChildren);
this.context = context;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
this.jaxxContextEntryDef = jaxxContextEntryDef;
- }
+ }*/
public String getContext() {
return context;
@@ -169,6 +201,127 @@
return son == null ? null : son.findNode(stack);
}
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param context the context to seek
+ * @return the value associated in context with the given context path
+ * @throws InvocationTargetException todo
+ * @throws NoSuchMethodException todo
+ * @throws IllegalAccessException todo
+ */
+ public Object getJAXXContextValue(JAXXContext context) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ Object result;
+
+ if (getJaxxContextEntryDef() != null) {
+ // the node maps directly a value in context
+ result = getJaxxContextEntryDef().getContextValue(context);
+ return result;
+ }
+ // find the first ancestor node with a context def
+ NavigationTreeNode parentNode = getFirstAncestorWithDef();
+ if (parentNode == null) {
+ log.warn("could not find a ancestor node with a definition of a context entry from node (" + this + ")");
+ // todo must be an error
+ // no parent found
+ return null;
+ }
+
+ Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context);
+ //Object parentBean = parentNode.getJAXXContextValue(context);
+
+ if (parentBean == null) {
+ // must be an error no bean found
+ log.warn("culd not find a bean attached in context from context entry definition " + parentNode.getJaxxContextEntryDef());
+ return null;
+ }
+
+ if (this == parentNode) {
+ // current node is the node matching the context entry value
+ return parentBean;
+ }
+
+ if (jaxxContextEntryPath == null) {
+ // todo must be an error
+ log.warn("must find a jaxxContextEntryPath on node (" + this + ")");
+ return null;
+ }
+
+ String jxpathExpression = computeJXPath(jaxxContextEntryPath, parentNode);
+
+ if (jxpathExpression == null) {
+ /// todo must be an error
+ log.warn("could not build jxpath from node " + parentNode + " to " + this);
+ // could not retreave the jxpath...
+ return null;
+ }
+ if (jxpathExpression.startsWith("[")) {
+ // special case when we want to access a collection
+ jxpathExpression = '.'+jxpathExpression;
+ }
+ log.info("jxpath : " + jxpathExpression);
+
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+
+ result = jxcontext.getValue(jxpathExpression);
+
+ return result;
+ }
+
+ protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
+ if (parentNode == this) {
+ // reach the parent limit node, return the expr computed
+ return expr;
+ }
+ int firstIndex = expr.indexOf("..");
+ int lastIndex = expr.lastIndexOf("..");
+
+ if (firstIndex == -1) {
+ // this is a error, since current node is not parent limit node,
+ // we must find somewhere a way to go up in nodes
+ throw new IllegalArgumentException(expr + " should contains at least one \"..\"");
+ }
+
+ if (firstIndex != 0) {
+ // this is a error, the ../ must be at the beginning of the expression
+ throw new IllegalArgumentException("\"..\" must be at the beginning but was : " + expr);
+ }
+
+ NavigationTreeNode ancestor = getParent();
+
+ if (firstIndex == lastIndex) {
+ // found only one go up, so must be substitute by the parent node context
+
+ String newExpr = expr.substring(2);
+ //String newExpr = expr.substring(expr.startsWith("../") ? 3 : 2);
+
+ if (getParent().equals(parentNode)) {
+
+ // parent node is the final parent node, so no substitution needed
+ return newExpr;
+ //return parentNode.computeJXPath(newExpr, parentNode);
+ }
+
+ // ancestor must have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath == null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node (" + ancestor + ") must have a jaxxContextEntryPath definition, but was not ");
+ }
+
+ newExpr = ancestor.jaxxContextEntryPath + newExpr;
+
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+
+ // have more than one go up, so the ancestor node can not have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath != null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node can not have a jaxxContextEntryPath definition");
+ }
+
+ // substitute the last ..[/] and delegate to ancestor
+ String newExpr = expr.substring(0, lastIndex - 1) + expr.substring(lastIndex + (expr.charAt(lastIndex + 3) == '/' ? 3 : 2));
+
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
}
@Override
@@ -323,63 +476,10 @@
* @throws IllegalAccessException todo
*/
public Object getJAXXContextValue(JAXXContext context, NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
- Object result;
+ //Object result;
if (node == null) {
return null;
}
- if (node.getJaxxContextEntryDef() != null) {
- // the node maps directly a value in context
- result = node.getJaxxContextEntryDef().getContextValue(context);
- return result;
- }
- // find the first ancestor node with a context def
- NavigationTreeNode parentNode = node.getFirstAncestorWithDef();
- if (parentNode == null) {
- // no parent found
- return null;
- }
-
- Object parentBean = getJAXXContextValue(context, parentNode);
- if (parentBean == null) {
- return null;
- }
- result = parentBean;
- // descend from parentNode to node (says descending into parentBean following node contexts)
- TreeNode[] path = node.getPath();
- PropertyUtilsBean propertyUtils = BeanUtilsBean.getInstance().getPropertyUtils();
-
- int level = parentNode.getLevel() + 1;
-
- if (List.class.isAssignableFrom(parentBean.getClass())) {
- // parent bean is a list, returnindexed node
- NavigationTreeNode sonNode = (NavigationTreeNode) path[level];
- //TODO Finish it...
- int index = parentNode.getIndex(sonNode);
- result = ((List) parentBean).get(index);
- level++;
- }
-
- for (int i = level, length = path.length; i < length; i++) {
- NavigationTreeNode treeNode = (NavigationTreeNode) path[i];
-
- String propertyName = treeNode.getContext();
- Object sonBean = propertyUtils.getProperty(result, propertyName);
- if (sonBean == null) {
- // can be null (for example a leaf list)
- result = null;
- break;
- }
- if (!(List.class.isAssignableFrom(sonBean.getClass())) || treeNode.isLeaf() || i == length - 1) {
- // simple property and last node
- result = sonBean;
- continue;
- }
- // indexed node
- NavigationTreeNode sonNode = (NavigationTreeNode) path[++i];
- int index = treeNode.getIndex(sonNode);
- result = propertyUtils.getIndexedProperty(result, propertyName, index);
- }
- return result;
+ return node.getJAXXContextValue(context);
}
-
}
Modified: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2008-11-24 15:33:01 UTC (rev 1029)
+++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2008-11-24 15:33:42 UTC (rev 1030)
@@ -28,16 +28,16 @@
@Test
public void testFindNode() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(ROOT_CONTEXT, null, null, null);
+ NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
for (int i = 0; i < 4; i++) {
- NavigationTreeNode sonNode = new NavigationTreeNode(getNodeContext(i), null, null, null);
+ NavigationTreeNode sonNode = new NavigationTreeNode(null, null, getNodeContext(i), null, null);
rootNode.insert(sonNode, i);
for (int j = 0; j < 4; j++) {
- NavigationTreeNode sonSonNode = new NavigationTreeNode(getNodeContext(i, j), null, null, null);
+ NavigationTreeNode sonSonNode = new NavigationTreeNode(null, null, getNodeContext(i, j), null, null);
sonNode.insert(sonSonNode, j);
for (int k = 0; k < 4; k++) {
- sonSonNode.insert(new NavigationTreeNode(getNodeContext(i, j, k), null, null, null), k);
+ sonSonNode.insert(new NavigationTreeNode(null, null, getNodeContext(i, j, k), null, null), k);
}
}
}
@@ -128,49 +128,50 @@
@Test
public void testGetJAXXContextValue() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(ROOT_CONTEXT, null, null, null);
+ NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
NavigationTreeNode sonNode;
NavigationTreeNode sonSonNode;
NavigationTreeNode sonSonSonNode;
- sonNode = new NavigationTreeNode("name", null, null, JAXXContextEntryDef.newDef("name", String.class));
+ sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
rootNode.insert(sonNode, 0);
- sonNode = new NavigationTreeNode("name2", null, null, JAXXContextEntryDef.newDef("name2", String.class));
+ sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
rootNode.insert(sonNode, 1);
- sonNode = new NavigationTreeNode("model", null, null, JAXXContextEntryDef.newDef(Model.class));
+ sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
rootNode.insert(sonNode, 2);
- sonSonNode = new NavigationTreeNode("name", null, null, null);
+ sonSonNode = new NavigationTreeNode(null, "../name", "name", null, null);
sonNode.insert(sonSonNode, 0);
- sonSonNode = new NavigationTreeNode("integerValue", null, null, null);
+ sonSonNode = new NavigationTreeNode(null, "../integerValue", "integerValue", null, null);
sonNode.insert(sonSonNode, 1);
- sonSonNode = new NavigationTreeNode("sons", null, null, null);
+ sonSonNode = new NavigationTreeNode(null, "../sons", "sons", null, null);
sonNode.insert(sonSonNode, 2);
- sonSonSonNode = new NavigationTreeNode(0 + "", null, null, null);
+ sonSonSonNode = new NavigationTreeNode(null, "..[1]", 0 + "", null, null);
sonSonNode.insert(sonSonSonNode, 0);
- sonSonSonNode.insert(new NavigationTreeNode("name", null, null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode("integerValue", null, null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode("sons", null, null, null), 2);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
- sonSonSonNode = new NavigationTreeNode(1 + "", null, null, null);
+ sonSonSonNode = new NavigationTreeNode(null, "..[2]", 1 + "", null, null);
sonSonNode.insert(sonSonSonNode, 1);
- sonSonSonNode.insert(new NavigationTreeNode("name", null, null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode("integerValue", null, null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode("sons", null, null, null), 2);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
- sonSonSonNode = new NavigationTreeNode(2 + "", null, null, null);
+ sonSonSonNode = new NavigationTreeNode(null, null, 2 + "", null, null);
+ //sonSonSonNode = new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
sonSonNode.insert(sonSonSonNode, 2);
- sonSonSonNode.insert(new NavigationTreeNode("name", null, null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode("integerValue", null, null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode("sons", null, null, null), 2);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/name", "name", null, null), 0);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/integerValue", "integerValue", null, null), 1);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/sons", "sons", null, null), 2);
NavigationTreeModel model = new NavigationTreeModel(rootNode);
@@ -251,39 +252,39 @@
@Test
public void testGetJAXXContextValueFromList() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(ROOT_CONTEXT, null, null, null);
+ NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
NavigationTreeNode sonNode;
NavigationTreeNode sonSonNode;
NavigationTreeNode sonSonSonNode;
// first son is a list of models
- sonNode = new NavigationTreeNode("models", null, null, JAXXContextEntryDef.newListDef("models"));
+ sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
rootNode.insert(sonNode, 0);
// first son son is a model
- sonSonNode = new NavigationTreeNode("0", null, null, null);
+ sonSonNode = new NavigationTreeNode(null, "..[1]", "0", null, null);
sonNode.insert(sonSonNode, 0);
- sonSonNode.insert(new NavigationTreeNode("name", null, null, null), 0);
- sonSonNode.insert(new NavigationTreeNode("integerValue", null, null, null), 1);
- sonSonNode.insert(sonSonSonNode = new NavigationTreeNode("sons", null, null, null), 2);
+ sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
+ sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
+ sonSonNode.insert(sonSonSonNode = new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
- sonSonSonNode.insert(sonSonSonNode = new NavigationTreeNode("0", null, null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode("name", null, null, null), 0);
+ sonSonSonNode.insert(sonSonSonNode = new NavigationTreeNode(null, "..[1]", "0", null, null), 0);
+ sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
// second son son is a model
- sonSonNode = new NavigationTreeNode("1", null, null, null);
+ sonSonNode = new NavigationTreeNode(null, "..[2]", "1", null, null);
sonNode.insert(sonSonNode, 1);
- sonSonNode.insert(new NavigationTreeNode("name", null, null, null), 0);
- sonSonNode.insert(new NavigationTreeNode("integerValue", null, null, null), 1);
- sonSonNode.insert(new NavigationTreeNode("sons", null, null, null), 2);
+ sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
+ sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
+ sonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
// third son son is a model
- sonSonNode = new NavigationTreeNode("2", null, null, null);
+ sonSonNode = new NavigationTreeNode(null, "..[3]", "2", null, null);
sonNode.insert(sonSonNode, 2);
- sonSonNode.insert(new NavigationTreeNode("name", null, null, null), 0);
- sonSonNode.insert(new NavigationTreeNode("integerValue", null, null, null), 1);
- sonSonNode.insert(new NavigationTreeNode("sons", null, null, null), 2);
+ sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
+ sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
+ sonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
NavigationTreeModel model = new NavigationTreeModel(rootNode);
Modified: lutinjaxx/trunk/pom.xml
===================================================================
--- lutinjaxx/trunk/pom.xml 2008-11-24 15:33:01 UTC (rev 1029)
+++ lutinjaxx/trunk/pom.xml 2008-11-24 15:33:42 UTC (rev 1030)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -186,6 +187,12 @@
<version>3.0.1</version>
</dependency>
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
1
0
r1029 - in lutinjaxx/trunk/jaxx-core/src: main/java/jaxx/runtime test/java/jaxx/runtime
by chemit@users.labs.libre-entreprise.org 24 Nov '08
by chemit@users.labs.libre-entreprise.org 24 Nov '08
24 Nov '08
Author: chemit
Date: 2008-11-24 15:33:01 +0000 (Mon, 24 Nov 2008)
New Revision: 1029
Added:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
Log:
introduce JXPathDecorator but does not works (at the moment...)
Added: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-11-24 15:33:01 UTC (rev 1029)
@@ -0,0 +1,29 @@
+package jaxx.runtime;
+
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** @author chemit */
+public class JXPathDecorator<O> implements Decorator<O> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(JXPathDecorator.class);
+
+ private static final long serialVersionUID = 1L;
+
+ protected String expression;
+
+ public JXPathDecorator(String expression) {
+ this.expression = expression;
+ }
+
+ public String toString(O bean) {
+ JXPathContext jxcontext = JXPathContext.newContext(bean);
+ String result = (String) jxcontext.getValue(expression);
+ if (log.isDebugEnabled()) {
+ log.debug(expression + " : " + result);
+ }
+ return result;
+ }
+}
Added: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java (rev 0)
+++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2008-11-24 15:33:01 UTC (rev 1029)
@@ -0,0 +1,48 @@
+package jaxx.runtime;
+
+import org.junit.Test;
+
+/** @author chemit */
+public class JXPathDecoratorTest {
+
+ public static class Model {
+
+ protected String name;
+
+ protected int integervalue;
+
+ public Model(String name, int integervalue) {
+ this.name = name;
+ this.integervalue = integervalue;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getIntegervalue() {
+ return integervalue;
+ }
+
+ public void setIntegervalue(int integervalue) {
+ this.integervalue = integervalue;
+ }
+ }
+
+ @Test
+ public void testDecorator() throws Exception {
+ //fixme : make me works :)
+
+ //Decorator<Model> decorator = new JXPathDecorator<Model>("./name (./integerValue");
+
+ //Model m = new Model("name", 10);
+ //String expected = m.getName() + " (" + m.getIntegervalue() + ")";
+ //String result = decorator.toString(m);
+
+ //org.junit.Assert.assertEquals(expected, result);
+ }
+}
1
0
r1028 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime
by chemit@users.labs.libre-entreprise.org 24 Nov '08
by chemit@users.labs.libre-entreprise.org 24 Nov '08
24 Nov '08
Author: chemit
Date: 2008-11-24 15:32:37 +0000 (Mon, 24 Nov 2008)
New Revision: 1028
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java
Log:
decorator is serializable
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java 2008-11-21 10:47:28 UTC (rev 1027)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java 2008-11-24 15:32:37 UTC (rev 1028)
@@ -5,7 +5,7 @@
*
* @author chemit
*/
-public interface Decorator<O> {
+public interface Decorator<O> extends java.io.Serializable {
/**
* @param bean the bean to decorate
1
0
r1027 - in lutinjaxx/trunk/jaxx-core/src/main/java/jaxx: compiler runtime/swing
by chemit@users.labs.libre-entreprise.org 21 Nov '08
by chemit@users.labs.libre-entreprise.org 21 Nov '08
21 Nov '08
Author: chemit
Date: 2008-11-21 10:47:28 +0000 (Fri, 21 Nov 2008)
New Revision: 1027
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java
Log:
deplacement des methodes de creation d'icones directement dans Jaxx (jaxx.runtil.swing.Utils)
delegateContext est final et ne doit pas etre instanciee dans les constructeurs (au cas ou on definit un nouveau constructeur)...
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java 2008-11-19 10:24:31 UTC (rev 1026)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java 2008-11-21 10:47:28 UTC (rev 1027)
@@ -85,8 +85,7 @@
staticImports.add("jaxx.runtime.swing.VBox");
staticImports.add("jaxx.runtime.swing.Table");
staticImports.add("static org.codelutin.i18n.I18n._");
- // do not link with jaxx-util here...
- //staticImports.add("static org.codelutin.jaxx.util.UIHelper.createImageIcon");
+ staticImports.add("static jaxx.runtime.swing.Utils.createImageIcon");
}
protected static DefaultObjectHandler firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class));
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-11-19 10:24:31 UTC (rev 1026)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-11-21 10:47:28 UTC (rev 1027)
@@ -20,6 +20,8 @@
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.lang.reflect.Modifier;
+import static java.lang.reflect.Modifier.PROTECTED;
+import static java.lang.reflect.Modifier.FINAL;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -146,7 +148,7 @@
if (getOptions().isAddLogger()) {
javaFile.addImport(org.apache.commons.logging.Log.class);
javaFile.addImport(org.apache.commons.logging.LogFactory.class);
- javaFile.addField(newField(Modifier.PUBLIC + Modifier.STATIC + Modifier.FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)"));
+ javaFile.addField(newField(Modifier.PUBLIC + Modifier.STATIC + FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)"));
}
// JAXXObject
@@ -157,7 +159,7 @@
// JAXXContext
- javaFile.addField(DELEGATE_CONTEXT_FIELD);
+ javaFile.addField(newField(PROTECTED| FINAL, "jaxx.runtime.JAXXContext", "delegateContext","new "+ jaxxContextImplementorClass+ "(this);"));
javaFile.addMethod(SET_CONTEXT_VALUE_METHOD);
javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD);
javaFile.addMethod(GET_CONTEXT_VALUE_METHOD);
@@ -188,8 +190,8 @@
javaFile.addField(PREVIOUS_VALUES_FIELD);
}
- javaFile.addMethod(createConstructor(className, superclassIsJAXXObject, jaxxContextImplementorClass));
- javaFile.addMethod(createConstructorWithInitialContext(className, superclassIsJAXXObject, jaxxContextImplementorClass));
+ javaFile.addMethod(createConstructor(className, superclassIsJAXXObject));
+ javaFile.addMethod(createConstructorWithInitialContext(className, superclassIsJAXXObject));
javaFile.addMethod(createInitializer());
javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD);
@@ -357,7 +359,7 @@
}
}
- protected JavaMethod createConstructor(String className, boolean superclassIsJAXXObject, String jaxxContextImplementorClass) throws CompilerException {
+ protected JavaMethod createConstructor(String className, boolean superclassIsJAXXObject) throws CompilerException {
StringBuffer code = new StringBuffer();
String constructorParams = compiler.getRootObject().getConstructorParams();
if (constructorParams != null) {
@@ -367,16 +369,16 @@
code.append(" super();").append(JAXXCompiler.getLineSeparator());
}
}
- if (!superclassIsJAXXObject) {
+ /*if (!superclassIsJAXXObject) {
code.append("delegateContext = new ").append(jaxxContextImplementorClass).append("(this);");
code.append(JAXXCompiler.getLineSeparator());
- }
+ }*/
code.append("$initialize();");
code.append(JAXXCompiler.getLineSeparator());
return newMethod(Modifier.PUBLIC, null, className, code.toString());
}
- protected JavaMethod createConstructorWithInitialContext(String className, boolean superclassIsJAXXObject, String jaxxContextImplementorClass) throws CompilerException {
+ protected JavaMethod createConstructorWithInitialContext(String className, boolean superclassIsJAXXObject) throws CompilerException {
StringBuffer code = new StringBuffer();
String constructorParams = compiler.getRootObject().getConstructorParams();
if (constructorParams != null) {
@@ -387,8 +389,8 @@
}
}
if (!superclassIsJAXXObject) {
- code.append("delegateContext = new ").append(jaxxContextImplementorClass).append("(this);");
- code.append(JAXXCompiler.getLineSeparator());
+ //code.append("delegateContext = new ").append(jaxxContextImplementorClass).append("(this);");
+ //code.append(JAXXCompiler.getLineSeparator());
code.append("if (parentContext instanceof jaxx.runtime.JAXXInitialContext) {");
code.append(JAXXCompiler.getLineSeparator());
code.append(" ((jaxx.runtime.JAXXInitialContext)parentContext).to(this);");
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java 2008-11-19 10:24:31 UTC (rev 1026)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGeneratorConstants.java 2008-11-21 10:47:28 UTC (rev 1027)
@@ -1,6 +1,5 @@
package jaxx.compiler;
-import static java.lang.reflect.Modifier.FINAL;
import static java.lang.reflect.Modifier.PRIVATE;
import static java.lang.reflect.Modifier.PROTECTED;
import static java.lang.reflect.Modifier.PUBLIC;
@@ -35,7 +34,7 @@
"java.util.Map", "$previousValues", "new java.util.HashMap()"
);
- protected static final JavaField DELEGATE_CONTEXT_FIELD = newField(PROTECTED | FINAL,
+ protected static final JavaField DELEGATE_CONTEXT_FIELD = newField(PROTECTED,
"jaxx.runtime.JAXXContext", "delegateContext"
);
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java 2008-11-19 10:24:31 UTC (rev 1026)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/Utils.java 2008-11-21 10:47:28 UTC (rev 1027)
@@ -4,6 +4,7 @@
*/
package jaxx.runtime.swing;
+import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import javax.swing.text.AbstractDocument;
import javax.swing.text.JTextComponent;
@@ -29,22 +30,25 @@
notifyingListeners.setAccessible(true);
}
- if (notifyingListeners.get(document).equals(Boolean.TRUE))
+ if (notifyingListeners.get(document).equals(Boolean.TRUE)) {
return;
+ }
if (((Integer) numReaders.get(document)).intValue() > 0) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- if (!c.getText().equals(text))
+ if (!c.getText().equals(text)) {
c.setText(text);
+ }
}
});
return;
}
String oldText = c.getText();
- if (oldText == null || !oldText.equals(text))
+ if (oldText == null || !oldText.equals(text)) {
c.setText(text);
+ }
}
catch (NoSuchFieldException e) {
throw new RuntimeException(e);
@@ -57,5 +61,21 @@
}
}
-
+ public static ImageIcon createImageIcon(String path) {
+ java.net.URL imgURL = Utils.class.getResource("/icons/" + path);
+ if (imgURL != null) {
+ return new ImageIcon(imgURL);
+ } else {
+ throw new IllegalArgumentException("could not find icon " + path);
+ }
+ }
+
+ public static ImageIcon createActionIcon(String name) {
+ return createImageIcon("action-" + name + ".png");
+ }
+
+ public static ImageIcon createI18nIcon(String name) {
+ return createImageIcon("i18n/" + name + ".png");
+ }
+
}
1
0
r1026 - in lutinjaxx/trunk: jaxx-core jaxx-core/src/main/java/jaxx/compiler jaxx-swing-action maven-jaxx-plugin
by chemit@users.labs.libre-entreprise.org 19 Nov '08
by chemit@users.labs.libre-entreprise.org 19 Nov '08
19 Nov '08
Author: chemit
Date: 2008-11-19 10:24:31 +0000 (Wed, 19 Nov 2008)
New Revision: 1026
Modified:
lutinjaxx/trunk/jaxx-core/pom.xml
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java
lutinjaxx/trunk/jaxx-swing-action/pom.xml
lutinjaxx/trunk/maven-jaxx-plugin/pom.xml
Log:
suppress dependency from jaxx-util in jaxx-core.
beware, this could break your build... since static org.codelutin.jaxx.util.UIHelper.createImageIcon is no more is JAXXObject.
you can add it in maven plugin via property extraImports...
Modified: lutinjaxx/trunk/jaxx-core/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-core/pom.xml 2008-11-19 00:07:29 UTC (rev 1025)
+++ lutinjaxx/trunk/jaxx-core/pom.xml 2008-11-19 10:24:31 UTC (rev 1026)
@@ -18,17 +18,17 @@
<dependencies>
- <dependency>
+ <!--dependency>
<groupId>org.codelutin</groupId>
<artifactId>jaxx-util</artifactId>
- </dependency>
+ </dependency-->
<!-- pour acceder aux BeansInfos swing via Introspector -->
- <dependency>
+ <!--dependency>
<groupId>com.sun</groupId>
<artifactId>dt</artifactId>
- <!--scope>system</scope-->
- </dependency>
+ <scope>system</scope>
+ </dependency-->
<!-- pour utiliser javaHelp -->
<dependency>
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java 2008-11-19 00:07:29 UTC (rev 1025)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompilerHelper.java 2008-11-19 10:24:31 UTC (rev 1026)
@@ -85,7 +85,8 @@
staticImports.add("jaxx.runtime.swing.VBox");
staticImports.add("jaxx.runtime.swing.Table");
staticImports.add("static org.codelutin.i18n.I18n._");
- staticImports.add("static org.codelutin.jaxx.util.UIHelper.createImageIcon");
+ // do not link with jaxx-util here...
+ //staticImports.add("static org.codelutin.jaxx.util.UIHelper.createImageIcon");
}
protected static DefaultObjectHandler firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class));
Modified: lutinjaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-11-19 00:07:29 UTC (rev 1025)
+++ lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-11-19 10:24:31 UTC (rev 1026)
@@ -21,6 +21,11 @@
<dependency>
<groupId>org.codelutin</groupId>
+ <artifactId>jaxx-util</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
<artifactId>jaxx-core</artifactId>
<scope>compile</scope>
</dependency>
Modified: lutinjaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/pom.xml 2008-11-19 00:07:29 UTC (rev 1025)
+++ lutinjaxx/trunk/maven-jaxx-plugin/pom.xml 2008-11-19 10:24:31 UTC (rev 1026)
@@ -68,6 +68,13 @@
<scope>compile</scope>
</dependency>
+ <!-- pour acceder aux BeansInfos swing via Introspector -->
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>dt</artifactId>
+ <!--scope>system</scope-->
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
1
0