Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3898 discussions
r1823 - in trunk: . jaxx-compiler jaxx-demo jaxx-runtime jaxx-swing-action jaxx-widgets maven-jaxx-plugin
by tchemit@users.nuiton.org 31 Mar '10
by tchemit@users.nuiton.org 31 Mar '10
31 Mar '10
Author: tchemit
Date: 2010-03-31 15:20:11 +0200 (Wed, 31 Mar 2010)
New Revision: 1823
Log:
[maven-release-plugin] prepare release jaxx-2.0.1
Modified:
trunk/jaxx-compiler/pom.xml
trunk/jaxx-demo/pom.xml
trunk/jaxx-runtime/pom.xml
trunk/jaxx-swing-action/pom.xml
trunk/jaxx-widgets/pom.xml
trunk/maven-jaxx-plugin/pom.xml
trunk/pom.xml
Modified: trunk/jaxx-compiler/pom.xml
===================================================================
--- trunk/jaxx-compiler/pom.xml 2010-03-31 13:10:29 UTC (rev 1822)
+++ trunk/jaxx-compiler/pom.xml 2010-03-31 13:20:11 UTC (rev 1823)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.1</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2010-03-31 13:10:29 UTC (rev 1822)
+++ trunk/jaxx-demo/pom.xml 2010-03-31 13:20:11 UTC (rev 1823)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.1</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-runtime/pom.xml
===================================================================
--- trunk/jaxx-runtime/pom.xml 2010-03-31 13:10:29 UTC (rev 1822)
+++ trunk/jaxx-runtime/pom.xml 2010-03-31 13:20:11 UTC (rev 1823)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.1</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-swing-action/pom.xml
===================================================================
--- trunk/jaxx-swing-action/pom.xml 2010-03-31 13:10:29 UTC (rev 1822)
+++ trunk/jaxx-swing-action/pom.xml 2010-03-31 13:20:11 UTC (rev 1823)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.1</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2010-03-31 13:10:29 UTC (rev 1822)
+++ trunk/jaxx-widgets/pom.xml 2010-03-31 13:20:11 UTC (rev 1823)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.1</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- trunk/maven-jaxx-plugin/pom.xml 2010-03-31 13:10:29 UTC (rev 1822)
+++ trunk/maven-jaxx-plugin/pom.xml 2010-03-31 13:20:11 UTC (rev 1823)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.1</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-31 13:10:29 UTC (rev 1822)
+++ trunk/pom.xml 2010-03-31 13:20:11 UTC (rev 1823)
@@ -14,7 +14,7 @@
</parent>
<artifactId>jaxx</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.1</version>
<modules>
<module>jaxx-runtime</module>
@@ -414,9 +414,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/jaxx/trunk</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.0.1</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.0.1</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/jaxx/tags/jaxx-2.0.1</url>
</scm>
</project>
1
0
r1822 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation: . tree treetable
by tchemit@users.nuiton.org 31 Mar '10
by tchemit@users.nuiton.org 31 Mar '10
31 Mar '10
Author: tchemit
Date: 2010-03-31 15:10:29 +0200 (Wed, 31 Mar 2010)
New Revision: 1822
Log:
revert rev 1819
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-31 09:22:35 UTC (rev 1821)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-31 13:10:29 UTC (rev 1822)
@@ -21,7 +21,6 @@
package jaxx.runtime.swing.navigation;
import jaxx.runtime.JAXXAction;
-import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.decorator.Decorator;
@@ -56,12 +55,6 @@
/** [optional] default action class */
protected Class<? extends JAXXAction> defaultUIHandlerClass;
- //TODO Doc
- protected Comparator<NavigationNode<?>> rendererComparator;
- //TODO Doc
- protected boolean useRendererComparator;
- //TODO Doc
- protected List<JAXXComparator<?>> comparators;
/**
* if sets to {@code true} will not fires any event (this is a convinient
@@ -78,52 +71,6 @@
this.model = model;
}
- public AbstractNavigationModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationModel<E> model,
- boolean useRendererComparator) {
- this.defaultUIClass = defaultUIClass;
- this.defaultUIHandlerClass = defaultUIHandlerClass;
- this.model = model;
- this.useRendererComparator = useRendererComparator;
- }
-
- public AbstractNavigationModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationModel<E> model,
- JAXXContext context,
- JAXXComparator<?> comparator) {
- this.defaultUIClass = defaultUIClass;
- this.defaultUIHandlerClass = defaultUIHandlerClass;
- this.model = model;
- comparators = new ArrayList<JAXXComparator<?>>();
- comparators.add(comparator);
- }
-
- public AbstractNavigationModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationModel<E> model,
- List<JAXXComparator<?>> comparators) {
- this.defaultUIClass = defaultUIClass;
- this.defaultUIHandlerClass = defaultUIHandlerClass;
- this.model = model;
- this.comparators = comparators;
- }
-
- public AbstractNavigationModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationModel<E> model,
- JAXXComparator<?> ... comparators) {
- this.defaultUIClass = defaultUIClass;
- this.defaultUIHandlerClass = defaultUIHandlerClass;
- this.model = model;
- this.comparators = Arrays.asList(comparators);
- }
-
@Override
public NavigationModel<E> getModel() {
return model;
@@ -321,115 +268,10 @@
if (parentNode == null) {
model.setRoot(node);
} else {
- boolean useExternalComparators =
- comparators != null && !comparators.isEmpty();
- if (!useRendererComparator && !useExternalComparators){
- parentNode.add(node);
- } else {
- Enumeration<? extends E> childEnum = parentNode.children();
-
- List<E> children = Collections.list((Enumeration<E>) childEnum);
-
- if (children.isEmpty()){
- parentNode.add(node);
- } else {
- children.add(node);
-
- if (useExternalComparators){
- children = sortWithComparators(children);
- } else {
- Collections.sort(children, getRendererComparator());
- }
- int i = children.indexOf(node);
-
- if (log.isDebugEnabled()){
- log.debug("Use external comparator : " + useExternalComparators
- + " adding child " + node.getFullPath()
- + " to parent " + parentNode.getFullPath()
- + " at " + i);
- }
-
- parentNode.insert(node, i);
- }
- }
+ parentNode.add(node);
}
model.nodeStructureChanged(parentNode == null ? node : parentNode);
return node;
}
- // Try to find a solution to sort node with comparator
- // This one don't work, i think new nodes dont have bean
- protected List<E> sortWithComparators(List<E> children) {
- for (JAXXComparator<?> comparator : comparators){
- Class<?> beanType = children.get(0).getBean(model.getContext()).getClass();
- if (comparator.getClazz()
- .isAssignableFrom(beanType)){
- List<E> result = sortWithComparator(children, comparator);
- if (result != null){
- return result;
- }
- }
- }
- return children;
- }
-
- protected <T> List<E> sortWithComparator(
- List<E> children,
- JAXXComparator<T> comparator) {
-
- Map<T, E> toSort = new HashMap<T, E>();
-
- List<T> beans = new ArrayList<T>();
-
- // Extract beans
- int cnt = 0;
- for (E child : children){
- Object o = child.getBean(model.getContext());
- T casted = (T) o;
- beans.add(casted);
- toSort.put(casted, child);
- if (log.isDebugEnabled()){
- log.debug("Will sort : " + ++cnt + " - " + (casted == null ? "null" : casted.toString()));
- }
- }
-
- // Sort beans
- Collections.sort(beans, comparator);
-
- // Retrieve sorted nodes
- children.clear();
- cnt = 0;
- for (T bean : beans){
- E retrieveNode = toSort.get(bean);
- if (log.isDebugEnabled()){
- log.debug("Retrieve sorted bean : " +
- ++cnt + " - " + (bean == null ? "null" : bean.toString()));
- }
- children.add(retrieveNode);
- }
- return children;
- }
-
- protected Comparator<NavigationNode<?>> getRendererComparator(){
- if (rendererComparator == null){
- rendererComparator = new Comparator<NavigationNode<?>>() {
-
- @Override
- public int compare(NavigationNode<?> o1, NavigationNode<?> o2) {
- String label1 = o1.getRenderer().toString();
- String label2 = o2.getRenderer().toString();
- if (label1 == null || label2 == null){
- return 0;
- }
- return label1.compareTo(label2);
- }
- };
- }
- return rendererComparator;
- }
- //TODO Doc
- public interface JAXXComparator<T> extends Comparator<T>{
-
- Class<T> getClazz();
- }
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java 2010-03-31 09:22:35 UTC (rev 1821)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java 2010-03-31 13:10:29 UTC (rev 1822)
@@ -26,12 +26,7 @@
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.swing.navigation.AbstractNavigationModelBuilder;
import jaxx.runtime.swing.navigation.NavigationModelBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import java.util.Comparator;
-import java.util.List;
-
/**
* This object is design to build a {@link NavigationTreeModel}.
*
@@ -41,10 +36,6 @@
*/
public class NavigationTreeModelBuilder extends AbstractNavigationModelBuilder<NavigationTreeNode> {
- /** Logger */
- static private final Log log =
- LogFactory.getLog(NavigationTreeModelBuilder.class);
-
public NavigationTreeModelBuilder(
String pathSeparator,
JAXXContext context,
@@ -57,96 +48,12 @@
}
public NavigationTreeModelBuilder(
- String pathSeparator,
- JAXXContext context,
Class<? extends JAXXObject> defaultUIClass,
Class<? extends JAXXAction> defaultUIHandlerClass,
- boolean useRendererComparator) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeModel(pathSeparator, context),
- useRendererComparator
- );
- }
-
- public NavigationTreeModelBuilder(
- String pathSeparator,
- JAXXContext context,
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- JAXXComparator<?> comparator) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeModel(pathSeparator, context),
- comparator
- );
- }
-
- public NavigationTreeModelBuilder(
- String pathSeparator,
- JAXXContext context,
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- List<JAXXComparator<?>> comparators) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeModel(pathSeparator, context),
- comparators
- );
- }
-
- public NavigationTreeModelBuilder(
- String pathSeparator,
- JAXXContext context,
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- JAXXComparator<?> ... comparators) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeModel(pathSeparator, context),
- comparators
- );
- }
-
- public NavigationTreeModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
NavigationTreeModel model) {
super(defaultUIClass, defaultUIHandlerClass, model);
}
- public NavigationTreeModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeModel model,
- boolean useRendererComparator) {
- super(defaultUIClass, defaultUIHandlerClass, model, useRendererComparator);
- }
-
- public NavigationTreeModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeModel model,
- JAXXComparator<?> comparator) {
- super(defaultUIClass, defaultUIHandlerClass, model, comparator);
- }
-
- public NavigationTreeModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeModel model,
- List<JAXXComparator<?>> comparators) {
- super(defaultUIClass, defaultUIHandlerClass, model, comparators);
- }
-
- public NavigationTreeModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeModel model,
- JAXXComparator<?> ... comparators) {
- super(defaultUIClass, defaultUIHandlerClass, model, comparators);
- }
-
@Override
public NavigationTreeNode createNavigationNode(
String pathSeparator,
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java 2010-03-31 09:22:35 UTC (rev 1821)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java 2010-03-31 13:10:29 UTC (rev 1822)
@@ -5,10 +5,8 @@
import jaxx.runtime.JAXXObject;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.swing.navigation.AbstractNavigationModelBuilder;
-import jaxx.runtime.swing.navigation.NavigationModel;
-import jaxx.runtime.swing.navigation.NavigationNode;
-import java.util.*;
+import java.util.List;
public class NavigationTreeTableModelBuilder extends AbstractNavigationModelBuilder<NavigationTreeTableNode> {
@@ -25,100 +23,12 @@
}
public NavigationTreeTableModelBuilder(
- String pathSeparator,
- JAXXContext context,
Class<? extends JAXXObject> defaultUIClass,
Class<? extends JAXXAction> defaultUIHandlerClass,
- List<String> columnsName,
- boolean useRendererComparator) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeTableModel(pathSeparator, context, columnsName),
- useRendererComparator
- );
- }
-
- public NavigationTreeTableModelBuilder(
- String pathSeparator,
- JAXXContext context,
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- List<String> columnsName,
- JAXXComparator<?> comparator) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeTableModel(pathSeparator, context, columnsName),
- comparator
- );
- }
-
- public NavigationTreeTableModelBuilder(
- String pathSeparator,
- JAXXContext context,
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- List<String> columnsName,
- List<JAXXComparator<?>> comparators) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeTableModel(pathSeparator, context, columnsName),
- comparators
- );
- }
-
- public NavigationTreeTableModelBuilder(
- String pathSeparator,
- JAXXContext context,
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- List<String> columnsName,
- JAXXComparator<?> ... comparators) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeTableModel(pathSeparator, context, columnsName),
- comparators
- );
- }
-
- public NavigationTreeTableModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
NavigationTreeTableModel model) {
super(defaultUIClass, defaultUIHandlerClass, model);
}
- public NavigationTreeTableModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeTableModel model,
- boolean useRendererComparator) {
- super(defaultUIClass, defaultUIHandlerClass, model, useRendererComparator);
- }
-
- public NavigationTreeTableModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeTableModel model,
- JAXXComparator<?> comparator) {
- super(defaultUIClass, defaultUIHandlerClass, model, comparator);
- }
-
- public NavigationTreeTableModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeTableModel model,
- List<JAXXComparator<?>> comparators) {
- super(defaultUIClass, defaultUIHandlerClass, model, comparators);
- }
-
- public NavigationTreeTableModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeTableModel model,
- JAXXComparator<?>... comparators) {
- super(defaultUIClass, defaultUIHandlerClass, model, comparators);
- }
-
@Override
public NavigationTreeTableNode createNavigationNode(
String pathSeparator,
1
0
r1821 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation: . tree
by tchemit@users.nuiton.org 31 Mar '10
by tchemit@users.nuiton.org 31 Mar '10
31 Mar '10
Author: tchemit
Date: 2010-03-31 11:22:35 +0200 (Wed, 31 Mar 2010)
New Revision: 1821
Log:
- add adjustingValue state on NavigationMode to not fires any event
- clean generics code on Sort methods (again...)
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java 2010-03-30 21:31:37 UTC (rev 1820)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java 2010-03-31 09:22:35 UTC (rev 1821)
@@ -59,6 +59,11 @@
/** Context to retrieve beans */
private JAXXContext context;
+ /**
+ * if sets to {@code true} will not fires any event (this is a convinient
+ * state when we are building the tree to avoid reload of nodes)
+ */
+ protected boolean adjustingValue;
public AbstractNavigationModel(TreeModel delegate,
String pathSeparator,
@@ -72,6 +77,14 @@
// NavigationModel implementation
//--------------------------------------------------------------------------
+ public boolean isAdjustingValue() {
+ return adjustingValue;
+ }
+
+ public void setAdjustingValue(boolean adjustingValue) {
+ this.adjustingValue = adjustingValue;
+ }
+
@Override
public JAXXContext getContext() {
return context;
@@ -165,6 +178,9 @@
@Override
public final void nodeChanged(E node) {
+ if (adjustingValue) {
+ return;
+ }
nodeChanged(node, false);
if (log.isDebugEnabled()) {
log.debug(node);
@@ -172,6 +188,9 @@
}
protected final void reload(E node) {
+ if (adjustingValue) {
+ return;
+ }
reload(node, false);
}
@@ -179,6 +198,9 @@
if (node == null) {
return;
}
+ if (adjustingValue) {
+ return;
+ }
node.reload(getContext());
if (deep) {
@@ -211,6 +233,9 @@
@Override
public final void valueForPathChanged(TreePath path, Object newValue) {
+ if (adjustingValue) {
+ return;
+ }
getDelegate().valueForPathChanged(path, newValue);
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-30 21:31:37 UTC (rev 1820)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-31 09:22:35 UTC (rev 1821)
@@ -56,13 +56,19 @@
/** [optional] default action class */
protected Class<? extends JAXXAction> defaultUIHandlerClass;
-
- protected Comparator<NavigationNode> rendererComparator;
-
+ //TODO Doc
+ protected Comparator<NavigationNode<?>> rendererComparator;
+ //TODO Doc
protected boolean useRendererComparator;
-
+ //TODO Doc
protected List<JAXXComparator<?>> comparators;
+ /**
+ * if sets to {@code true} will not fires any event (this is a convinient
+ * state when we are building the tree to avoid reload of nodes)
+ */
+ protected boolean adjustingValue;
+
public AbstractNavigationModelBuilder(
Class<? extends JAXXObject> defaultUIClass,
Class<? extends JAXXAction> defaultUIHandlerClass,
@@ -92,7 +98,7 @@
this.defaultUIClass = defaultUIClass;
this.defaultUIHandlerClass = defaultUIHandlerClass;
this.model = model;
- this.comparators = new ArrayList<JAXXComparator<?>>();
+ comparators = new ArrayList<JAXXComparator<?>>();
comparators.add(comparator);
}
@@ -316,7 +322,7 @@
model.setRoot(node);
} else {
boolean useExternalComparators =
- (comparators != null && !comparators.isEmpty());
+ comparators != null && !comparators.isEmpty();
if (!useRendererComparator && !useExternalComparators){
parentNode.add(node);
} else {
@@ -338,8 +344,8 @@
if (log.isDebugEnabled()){
log.debug("Use external comparator : " + useExternalComparators
- + " adding child " + (node.getFullPath())
- + " to parent " + (parentNode.getFullPath())
+ + " adding child " + node.getFullPath()
+ + " to parent " + parentNode.getFullPath()
+ " at " + i);
}
@@ -355,7 +361,7 @@
// This one don't work, i think new nodes dont have bean
protected List<E> sortWithComparators(List<E> children) {
for (JAXXComparator<?> comparator : comparators){
- Class<? extends Object> beanType = children.get(0).getBean(model.getContext()).getClass();
+ Class<?> beanType = children.get(0).getBean(model.getContext()).getClass();
if (comparator.getClazz()
.isAssignableFrom(beanType)){
List<E> result = sortWithComparator(children, comparator);
@@ -404,12 +410,12 @@
return children;
}
- protected Comparator<NavigationNode> getRendererComparator(){
+ protected Comparator<NavigationNode<?>> getRendererComparator(){
if (rendererComparator == null){
- rendererComparator = new Comparator<NavigationNode>() {
+ rendererComparator = new Comparator<NavigationNode<?>>() {
@Override
- public int compare(NavigationNode o1, NavigationNode o2) {
+ public int compare(NavigationNode<?> o1, NavigationNode<?> o2) {
String label1 = o1.getRenderer().toString();
String label2 = o2.getRenderer().toString();
if (label1 == null || label2 == null){
@@ -421,7 +427,7 @@
}
return rendererComparator;
}
-
+ //TODO Doc
public interface JAXXComparator<T> extends Comparator<T>{
Class<T> getClazz();
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java 2010-03-30 21:31:37 UTC (rev 1820)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java 2010-03-31 09:22:35 UTC (rev 1821)
@@ -142,6 +142,20 @@
JAXXContext getContext();
/**
+ * @return {@code true} if no event should be fired
+ */
+ boolean isAdjustingValue();
+
+ /**
+ * Sets the new internal state {@code adjustingValue}.
+ *
+ * If the value is {@code true}, no more event will be fired, otherwise
+ * will not block events firing.
+ *
+ * @param adjustingValue the new value of {@code valueAdjusting} state
+ */
+ void setAdjustingValue(boolean adjustingValue);
+ /**
* Obtain the associated bean value from context corresponding to node from
* given navigation path.
*
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java 2010-03-30 21:31:37 UTC (rev 1820)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java 2010-03-31 09:22:35 UTC (rev 1821)
@@ -71,6 +71,9 @@
@Override
public void nodeStructureChanged(NavigationTreeNode node) {
+ if (isAdjustingValue()) {
+ return;
+ }
NavigationTreeNode n = node;
//TC-20091004 never launch a deep reload
reload(n, true);
@@ -82,7 +85,9 @@
@Override
public void nodeChanged(NavigationTreeNode node, boolean deep) {
-
+ if (isAdjustingValue()) {
+ return;
+ }
NavigationTreeNode n = node;
//TC-20091004 never launch a deep clean, since we do a deep nodeChanged.
reload(n, deep);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java 2010-03-30 21:31:37 UTC (rev 1820)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java 2010-03-31 09:22:35 UTC (rev 1821)
@@ -332,6 +332,12 @@
@Override
public void setBean(Object bean) {
this.bean = bean;
+ //TC-20100331 : we wants to compute render as soon as possible
+ // this is a easy way to not need any reload of the node
+ NavigationNodeRenderer renderer = getRenderer();
+ if (renderer != null) {
+ renderer.reload(bean);
+ }
}
@Override
1
0
Author: tchemit
Date: 2010-03-30 23:31:37 +0200 (Tue, 30 Mar 2010)
New Revision: 1820
Log:
Evolution #428: Using nuiton-i18n 1.2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-30 12:52:36 UTC (rev 1819)
+++ trunk/pom.xml 2010-03-30 21:31:37 UTC (rev 1820)
@@ -363,7 +363,7 @@
<projectId>jaxx</projectId>
<lutinutil.version>1.2</lutinutil.version>
- <i18n.version>1.1</i18n.version>
+ <i18n.version>1.2</i18n.version>
<jxlayer.version>3.0.3</jxlayer.version>
1
0
r1819 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation: . tree treetable
by sletellier@users.nuiton.org 30 Mar '10
by sletellier@users.nuiton.org 30 Mar '10
30 Mar '10
Author: sletellier
Date: 2010-03-30 14:52:36 +0200 (Tue, 30 Mar 2010)
New Revision: 1819
Log:
Try to find an implementation to sort nodes when they are inserted. This method work fine when sort by rederer, but not with owns comparators.
This commit it just to keep a trace : before release, revert or fix it ;)
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-30 12:44:07 UTC (rev 1818)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-30 12:52:36 UTC (rev 1819)
@@ -21,13 +21,14 @@
package jaxx.runtime.swing.navigation;
import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.decorator.Decorator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.Enumeration;
+import java.util.*;
/**
* Interface to create a builder, this object is design to build a {@link
@@ -56,6 +57,12 @@
/** [optional] default action class */
protected Class<? extends JAXXAction> defaultUIHandlerClass;
+ protected Comparator<NavigationNode> rendererComparator;
+
+ protected boolean useRendererComparator;
+
+ protected List<JAXXComparator<?>> comparators;
+
public AbstractNavigationModelBuilder(
Class<? extends JAXXObject> defaultUIClass,
Class<? extends JAXXAction> defaultUIHandlerClass,
@@ -65,6 +72,52 @@
this.model = model;
}
+ public AbstractNavigationModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationModel<E> model,
+ boolean useRendererComparator) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ this.useRendererComparator = useRendererComparator;
+ }
+
+ public AbstractNavigationModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationModel<E> model,
+ JAXXContext context,
+ JAXXComparator<?> comparator) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ this.comparators = new ArrayList<JAXXComparator<?>>();
+ comparators.add(comparator);
+ }
+
+ public AbstractNavigationModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationModel<E> model,
+ List<JAXXComparator<?>> comparators) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ this.comparators = comparators;
+ }
+
+ public AbstractNavigationModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationModel<E> model,
+ JAXXComparator<?> ... comparators) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ this.comparators = Arrays.asList(comparators);
+ }
+
@Override
public NavigationModel<E> getModel() {
return model;
@@ -262,10 +315,115 @@
if (parentNode == null) {
model.setRoot(node);
} else {
- parentNode.add(node);
+ boolean useExternalComparators =
+ (comparators != null && !comparators.isEmpty());
+ if (!useRendererComparator && !useExternalComparators){
+ parentNode.add(node);
+ } else {
+ Enumeration<? extends E> childEnum = parentNode.children();
+
+ List<E> children = Collections.list((Enumeration<E>) childEnum);
+
+ if (children.isEmpty()){
+ parentNode.add(node);
+ } else {
+ children.add(node);
+
+ if (useExternalComparators){
+ children = sortWithComparators(children);
+ } else {
+ Collections.sort(children, getRendererComparator());
+ }
+ int i = children.indexOf(node);
+
+ if (log.isDebugEnabled()){
+ log.debug("Use external comparator : " + useExternalComparators
+ + " adding child " + (node.getFullPath())
+ + " to parent " + (parentNode.getFullPath())
+ + " at " + i);
+ }
+
+ parentNode.insert(node, i);
+ }
+ }
}
model.nodeStructureChanged(parentNode == null ? node : parentNode);
return node;
}
+ // Try to find a solution to sort node with comparator
+ // This one don't work, i think new nodes dont have bean
+ protected List<E> sortWithComparators(List<E> children) {
+ for (JAXXComparator<?> comparator : comparators){
+ Class<? extends Object> beanType = children.get(0).getBean(model.getContext()).getClass();
+ if (comparator.getClazz()
+ .isAssignableFrom(beanType)){
+ List<E> result = sortWithComparator(children, comparator);
+ if (result != null){
+ return result;
+ }
+ }
+ }
+ return children;
+ }
+
+ protected <T> List<E> sortWithComparator(
+ List<E> children,
+ JAXXComparator<T> comparator) {
+
+ Map<T, E> toSort = new HashMap<T, E>();
+
+ List<T> beans = new ArrayList<T>();
+
+ // Extract beans
+ int cnt = 0;
+ for (E child : children){
+ Object o = child.getBean(model.getContext());
+ T casted = (T) o;
+ beans.add(casted);
+ toSort.put(casted, child);
+ if (log.isDebugEnabled()){
+ log.debug("Will sort : " + ++cnt + " - " + (casted == null ? "null" : casted.toString()));
+ }
+ }
+
+ // Sort beans
+ Collections.sort(beans, comparator);
+
+ // Retrieve sorted nodes
+ children.clear();
+ cnt = 0;
+ for (T bean : beans){
+ E retrieveNode = toSort.get(bean);
+ if (log.isDebugEnabled()){
+ log.debug("Retrieve sorted bean : " +
+ ++cnt + " - " + (bean == null ? "null" : bean.toString()));
+ }
+ children.add(retrieveNode);
+ }
+ return children;
+ }
+
+ protected Comparator<NavigationNode> getRendererComparator(){
+ if (rendererComparator == null){
+ rendererComparator = new Comparator<NavigationNode>() {
+
+ @Override
+ public int compare(NavigationNode o1, NavigationNode o2) {
+ String label1 = o1.getRenderer().toString();
+ String label2 = o2.getRenderer().toString();
+ if (label1 == null || label2 == null){
+ return 0;
+ }
+ return label1.compareTo(label2);
+ }
+ };
+ }
+ return rendererComparator;
+ }
+
+ public interface JAXXComparator<T> extends Comparator<T>{
+
+ Class<T> getClazz();
+ }
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java 2010-03-30 12:44:07 UTC (rev 1818)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java 2010-03-30 12:52:36 UTC (rev 1819)
@@ -29,6 +29,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.Comparator;
+import java.util.List;
+
/**
* This object is design to build a {@link NavigationTreeModel}.
*
@@ -54,12 +57,96 @@
}
public NavigationTreeModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
Class<? extends JAXXObject> defaultUIClass,
Class<? extends JAXXAction> defaultUIHandlerClass,
+ boolean useRendererComparator) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeModel(pathSeparator, context),
+ useRendererComparator
+ );
+ }
+
+ public NavigationTreeModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ JAXXComparator<?> comparator) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeModel(pathSeparator, context),
+ comparator
+ );
+ }
+
+ public NavigationTreeModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ List<JAXXComparator<?>> comparators) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeModel(pathSeparator, context),
+ comparators
+ );
+ }
+
+ public NavigationTreeModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ JAXXComparator<?> ... comparators) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeModel(pathSeparator, context),
+ comparators
+ );
+ }
+
+ public NavigationTreeModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
NavigationTreeModel model) {
super(defaultUIClass, defaultUIHandlerClass, model);
}
+ public NavigationTreeModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeModel model,
+ boolean useRendererComparator) {
+ super(defaultUIClass, defaultUIHandlerClass, model, useRendererComparator);
+ }
+
+ public NavigationTreeModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeModel model,
+ JAXXComparator<?> comparator) {
+ super(defaultUIClass, defaultUIHandlerClass, model, comparator);
+ }
+
+ public NavigationTreeModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeModel model,
+ List<JAXXComparator<?>> comparators) {
+ super(defaultUIClass, defaultUIHandlerClass, model, comparators);
+ }
+
+ public NavigationTreeModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeModel model,
+ JAXXComparator<?> ... comparators) {
+ super(defaultUIClass, defaultUIHandlerClass, model, comparators);
+ }
+
@Override
public NavigationTreeNode createNavigationNode(
String pathSeparator,
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java 2010-03-30 12:44:07 UTC (rev 1818)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java 2010-03-30 12:52:36 UTC (rev 1819)
@@ -5,12 +5,13 @@
import jaxx.runtime.JAXXObject;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.swing.navigation.AbstractNavigationModelBuilder;
+import jaxx.runtime.swing.navigation.NavigationModel;
+import jaxx.runtime.swing.navigation.NavigationNode;
-import java.util.List;
+import java.util.*;
public class NavigationTreeTableModelBuilder extends AbstractNavigationModelBuilder<NavigationTreeTableNode> {
-
public NavigationTreeTableModelBuilder(
String pathSeparator,
JAXXContext context,
@@ -24,12 +25,100 @@
}
public NavigationTreeTableModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
Class<? extends JAXXObject> defaultUIClass,
Class<? extends JAXXAction> defaultUIHandlerClass,
+ List<String> columnsName,
+ boolean useRendererComparator) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeTableModel(pathSeparator, context, columnsName),
+ useRendererComparator
+ );
+ }
+
+ public NavigationTreeTableModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ List<String> columnsName,
+ JAXXComparator<?> comparator) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeTableModel(pathSeparator, context, columnsName),
+ comparator
+ );
+ }
+
+ public NavigationTreeTableModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ List<String> columnsName,
+ List<JAXXComparator<?>> comparators) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeTableModel(pathSeparator, context, columnsName),
+ comparators
+ );
+ }
+
+ public NavigationTreeTableModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ List<String> columnsName,
+ JAXXComparator<?> ... comparators) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeTableModel(pathSeparator, context, columnsName),
+ comparators
+ );
+ }
+
+ public NavigationTreeTableModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
NavigationTreeTableModel model) {
super(defaultUIClass, defaultUIHandlerClass, model);
}
+ public NavigationTreeTableModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeTableModel model,
+ boolean useRendererComparator) {
+ super(defaultUIClass, defaultUIHandlerClass, model, useRendererComparator);
+ }
+
+ public NavigationTreeTableModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeTableModel model,
+ JAXXComparator<?> comparator) {
+ super(defaultUIClass, defaultUIHandlerClass, model, comparator);
+ }
+
+ public NavigationTreeTableModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeTableModel model,
+ List<JAXXComparator<?>> comparators) {
+ super(defaultUIClass, defaultUIHandlerClass, model, comparators);
+ }
+
+ public NavigationTreeTableModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeTableModel model,
+ JAXXComparator<?>... comparators) {
+ super(defaultUIClass, defaultUIHandlerClass, model, comparators);
+ }
+
@Override
public NavigationTreeTableNode createNavigationNode(
String pathSeparator,
1
0
r1818 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable
by sletellier@users.nuiton.org 30 Mar '10
by sletellier@users.nuiton.org 30 Mar '10
30 Mar '10
Author: sletellier
Date: 2010-03-30 14:44:07 +0200 (Tue, 30 Mar 2010)
New Revision: 1818
Log:
Fix bug when root node structure change in TreeTable
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java 2010-03-27 20:03:46 UTC (rev 1817)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java 2010-03-30 12:44:07 UTC (rev 1818)
@@ -127,11 +127,17 @@
public void nodeStructureChanged(NavigationTreeTableNode node) {
if (node != null) {
NavigationTreeTableNode parent = node.getParent();
- TreeNode[] treeNodes = getPathToRoot(parent);
- if (treeNodes != null) {
- getModelSupport().fireTreeStructureChanged(new TreePath(treeNodes));
+ if (parent == null || parent.isRoot()){
+ getModelSupport().fireNewRoot();
} else {
- log.error("[Node structure changed] Path to root is null !");
+ TreeNode[] treeNodes = getPathToRoot(parent);
+ if (treeNodes != null) {
+ getModelSupport().fireTreeStructureChanged(new TreePath(treeNodes));
+ }
+ // FIXME : it's append....
+// else {
+// log.error("[Node structure changed] Path to root is null !");
+// }
}
reload(node, true);
} else {
@@ -147,8 +153,10 @@
if (treeNodes != null) {
getModelSupport().fireChildChanged(
new TreePath(treeNodes), parent.getIndex(node), node);
- } else {
- log.error("[Node changed] Path to root is null !");
+ // FIXME : it's append....
+// else {
+// log.error("[Node changed] Path to root is null !");
+// }
}
reload(node, deep);
} else {
1
0
Author: tchemit
Date: 2010-03-27 21:03:46 +0100 (Sat, 27 Mar 2010)
New Revision: 1817
Log:
Utilisation de mavenpom4redmine 2.0.7
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-03-27 16:12:27 UTC (rev 1816)
+++ trunk/pom.xml 2010-03-27 20:03:46 UTC (rev 1817)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>2.0.6</version>
+ <version>2.0.7</version>
</parent>
<artifactId>jaxx</artifactId>
1
0
r1816 - in trunk: jaxx-runtime/src/main/java/jaxx/runtime jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard jaxx-widgets/src/main/java/jaxx/runtime/swing jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model
by tchemit@users.nuiton.org 27 Mar '10
by tchemit@users.nuiton.org 27 Mar '10
27 Mar '10
Author: tchemit
Date: 2010-03-27 17:12:27 +0100 (Sat, 27 Mar 2010)
New Revision: 1816
Log:
Evolution #420: Nettoyer les listeners qui ne servent plus
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -25,8 +25,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.*;
+import java.awt.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeListenerProxy;
+import java.beans.PropertyChangeSupport;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
@@ -34,6 +37,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.*;
+import java.util.List;
public class JAXXUtil {
@@ -290,6 +294,46 @@
return listener;
}
+ /**
+ * Remove all listeners registred in given {@code pcs}.
+ *
+ * @param pcs the pcs to clean
+ */
+ public static void destroy(PropertyChangeSupport pcs) {
+ PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
+ for (PropertyChangeListener l : listeners) {
+ if (log.isInfoEnabled()) {
+ if (l instanceof PropertyChangeListenerProxy) {
+ PropertyChangeListenerProxy ll = (PropertyChangeListenerProxy) l;
+ log.info("remove property change listener " + ll.getPropertyName() + " : " + l);
+ } else {
+ log.info("remove property change listener " + l);
+ }
+ }
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+
+ /**
+ * Remove all listeners registred in given {@code component}.
+ *
+ * @param component the pcs to clean
+ */
+ public static void destroy(Component component) {
+ PropertyChangeListener[] listeners = component.getPropertyChangeListeners();
+ for (PropertyChangeListener l : listeners) {
+ if (log.isInfoEnabled()) {
+ if (l instanceof PropertyChangeListenerProxy) {
+ PropertyChangeListenerProxy ll = (PropertyChangeListenerProxy) l;
+ log.info("remove property change listener " + ll.getPropertyName() + " : " + l);
+ } else {
+ log.info("remove property change listener " + l);
+ }
+ }
+ component.removePropertyChangeListener(l);
+ }
+ }
+
public static boolean assignment(boolean value,
String name,
JAXXObject src) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -20,6 +20,8 @@
*/
package jaxx.runtime.swing.wizard;
+import jaxx.runtime.JAXXUtil;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
@@ -98,6 +100,11 @@
setStep(startStep);
}
+ public void destroy() {
+ // suppression de tous les listeners
+ JAXXUtil.destroy(pcs);
+ }
+
public void gotoNextStep() {
E nextStep = getNextStep();
if (nextStep == null) {
@@ -224,11 +231,15 @@
}
public void removePropertyChangeListeners() {
- for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
- pcs.removePropertyChangeListener(l);
- }
+ JAXXUtil.destroy(pcs);
}
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+ }
+
public void validate() {
if (step == null) {
// pas de validation quand aucune etape n'est sélectionnée
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/AboutPanel.jaxx 2010-03-27 16:12:27 UTC (rev 1816)
@@ -124,6 +124,17 @@
rootPane.setDefaultButton(close);
rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
rootPane.getActionMap().put("close", closeAction);
+ f.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosed(WindowEvent e) {
+ Component ui = (Component) e.getSource();
+ if (log.isInfoEnabled()) {
+ log.info("destroy ui "+ ui);
+ }
+ JAXXUtil.destroy(ui);
+ JAXXUtil.destroy(AboutPanel.this);
+ }
+ });
SwingUtil.center(ui, f);
f.setVisible(true);
}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ErrorDialogUI.jaxx 2010-03-27 16:12:27 UTC (rev 1816)
@@ -42,6 +42,9 @@
instance.setVisible(true);
}
public static void disposeUI() {
+ if (instance != null) {
+ JAXXUtil.destroy(instance);
+ }
instance=null;
}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2010-03-27 16:12:27 UTC (rev 1816)
@@ -3,35 +3,47 @@
<style source='ConfigUI.css'/>
<script><![CDATA[
- import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
+import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
- categories.setModel(new DefaultSingleSelectionModel() {
+categories.setModel(new DefaultSingleSelectionModel() {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- @Override
- public void setSelectedIndex(int index) {
- // check if catgeory can be quit
- boolean canContinue = !isSelected() || ConfigUIBuilder.canQuitCategory(ConfigUI.this);
- if (canContinue) {
- if (log.isDebugEnabled()) {
- log.debug("new index : " + index);
- }
- // was authorized to continue
- super.setSelectedIndex(index);
+ @Override
+ public void setSelectedIndex(int index) {
+ // check if catgeory can be quit
+ boolean canContinue = !isSelected() || ConfigUIBuilder.canQuitCategory(ConfigUI.this);
+ if (canContinue) {
+ if (log.isDebugEnabled()) {
+ log.debug("new index : " + index);
}
+ // was authorized to continue
+ super.setSelectedIndex(index);
}
- });
+ }
+});
- protected void changeCategory(ChangeEvent e) {
- JPanel p = (JPanel) getCategories().getSelectedComponent();
- if (p == null) {
- // pas de selection
- return;
- }
- getModel().setCategory(p.getName());
- getCategories().invalidate();
+public void destroy() {
+ log.info("destroy ui " + getName());
+ JAXXUtil.destroy(this);
+ model.destroy();
+}
+
+@Override
+protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+}
+
+protected void changeCategory(ChangeEvent e) {
+ JPanel p = (JPanel) getCategories().getSelectedComponent();
+ if (p == null) {
+ // pas de selection
+ return;
}
+ getModel().setCategory(p.getName());
+ getCategories().invalidate();
+}
]]>
</script>
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -85,6 +85,8 @@
// just quit, no callBack can be apply here
+ ui.destroy();
+
// close the configu ui
parentWindow.dispose();
return;
@@ -96,6 +98,8 @@
if (forSaved.isEmpty()) {
// just quit, no callBack to call
+ ui.destroy();
+
// close the configu ui
parentWindow.dispose();
return;
@@ -297,159 +301,4 @@
return response;
}
-
- /**
- * // prepare quit action
- Action quitAction = new AbstractAction(quitButton.getText(),
- quitButton.getIcon()) {
-
- private static final long serialVersionUID = 1L;
-
- @Override public void actionPerformed(ActionEvent e) {
- if (!canQuitCategory(ui)) {
- return;
- }
-
- boolean needReloadUI = false;
- boolean needReloadApplication = false;
-
- StringBuilder reloadUIBuffer = new StringBuilder();
-
- StringBuilder reloadApplicationBuffer = new StringBuilder();
-
- if (model.isSaved() && !model.isStandalone()) {
-
-
- StringBuilder buffer = new StringBuilder();
-
- // on doit verifier si des options sauvees necessite
- // un redemarrage de l'application
- for (CategoryModel cat : model) {
- List<OptionModel> savedOptions = cat.getSavedOptions();
- List<OptionModel> needReloadUIOptions = new ArrayList<OptionModel>();
- List<OptionModel> needReloadApplicationOptions = new ArrayList<OptionModel>();
- if (!savedOptions.isEmpty()) {
- Iterator<OptionModel> itr = savedOptions.iterator();
- buffer.append("\n").append(_("config.category.saved", _(cat.getCategory()))).append("\n");
- while (itr.hasNext()) {
- OptionModel option = itr.next();
- buffer.append("\n- ").append(option.getKey());
- if (option.isNeedReloadApplication()) {
- needReloadApplication = true;
- needReloadApplicationOptions.add(option);
- continue;
- }
- if (option.isNeedReloadUI()) {
- needReloadUI = true;
- needReloadUIOptions.add(option);
- continue;
- }
- itr.remove();
-
- }
- if (!savedOptions.isEmpty()) {
-
- if (!needReloadApplicationOptions.isEmpty()) {
- reloadApplicationBuffer.append("\n");
- reloadApplicationBuffer.append(_("config.category.needReloadApplication", _(cat.getCategory())));
- reloadApplicationBuffer.append("\n");
- // second pass to obtain needReloadUI
- for (OptionModel option : needReloadApplicationOptions) {
- reloadApplicationBuffer.append("\n- ").append(option.getKey());
- }
- }
-
- if (!needReloadUIOptions.isEmpty()) {
- reloadUIBuffer.append("\n");
- reloadUIBuffer.append(_("config.category.needReloadUI", _(cat.getCategory())));
- reloadUIBuffer.append("\n");
- // second pass to obtain needReloadUI
- for (OptionModel option : needReloadUIOptions) {
- reloadUIBuffer.append("\n- ").append(option.getKey());
- }
- }
- }
-
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("save options :\n" + buffer.toString());
- }
-
- if (needReloadApplication) {
-
- // reloading application implies reloading ui
- needReloadUI = false;
-
- askUser(ui,
- _("config.title.will.reload.application"),
- _("config.model.needReloadApplication") +
- reloadApplicationBuffer.toString(),
- JOptionPane.INFORMATION_MESSAGE,
- new Object[]{_("config.choice.ok")},
- 0);
- }
-
- if (needReloadUI) {
- askUser(ui,
- _("config.title.will.reload.ui"),
- _("config.model.needReloadUI") +
- reloadUIBuffer.toString(),
- JOptionPane.INFORMATION_MESSAGE,
- new Object[]{_("config.choice.ok")},
- 0);
- }
- }
-
- // close the configu ui
- ui.getParentContainer(Window.class).dispose();
-
- if (needReloadApplication) {
-
- Runnable callback = model.getReloadApplicationCallback();
- if (callback == null) {
- throw new IllegalStateException(
- "No reloadApplicationCallback found in model");
- }
-
- SwingUtilities.invokeLater(callback);
- } else if (needReloadUI) {
-
- Runnable callback = model.getReloadUICallback();
- if (callback == null) {
- throw new IllegalStateException(
- "No reloadUICallback found in model");
- }
- SwingUtilities.invokeLater(callback);
- }
-
-
- }
- };
- String tip = quitButton.getToolTipText();
- quitButton.setAction(quitAction);
- quitButton.setToolTipText(tip);
-
- // build categories tabs
- for (CategoryModel categoryModel : model) {
- String category = categoryModel.getCategory();
- String categoryLabel = _(categoryModel.getCategoryLabel());
- ConfigCategoryUI p = new ConfigCategoryUI(new
- JAXXInitialContext().add(ui).add(categoryModel));
- p.getCategoryLabel().setText(categoryLabel);
- p.setName(category);
- ui.getCategories().addTab(_(category), null, p, categoryLabel);
- }
-
- model.setCategory(defaultCategory);
- int categoryIndex = model.getCategoryIndex(defaultCategory);
- if (log.isDebugEnabled()) {
- log.debug("index of default category (" + defaultCategory + ") : "
- + categoryIndex);
- }
- ui.getCategories().setSelectedIndex(categoryIndex);
- return ui;
- }
- */
}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -20,6 +20,8 @@
*/
package jaxx.runtime.swing.editor.config.model;
+import jaxx.runtime.JAXXUtil;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
@@ -50,10 +52,9 @@
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
protected CategoryModel(String category, String categoryLabel) {
- super();
this.category = category;
this.categoryLabel = categoryLabel;
- this.entries = new ArrayList<OptionModel>();
+ entries = new ArrayList<OptionModel>();
}
protected void addOption(OptionModel option) {
@@ -62,7 +63,6 @@
@Deprecated
public CategoryModel(String category, String categoryLabel, OptionModel[] entries) {
- super();
this.category = category;
this.categoryLabel = categoryLabel;
this.entries = Collections.unmodifiableList(Arrays.asList(entries));
@@ -186,4 +186,14 @@
public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
return pcs.getPropertyChangeListeners();
}
+
+ public void destroy() {
+ JAXXUtil.destroy(pcs);
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+ }
}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigTableModel.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -20,24 +20,26 @@
*/
package jaxx.runtime.swing.editor.config.model;
+import org.nuiton.util.ConverterUtil;
+
+import javax.swing.table.AbstractTableModel;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import javax.swing.table.AbstractTableModel;
-import org.nuiton.util.ConverterUtil;
/**
* le modele du tableau d'options pour une categorie donnee.
- *
+ * <p/>
* Le modele se base sur le modele d'une categorie d'option.
*
* @author tchemit
- *
* @see CategoryModel
*/
public class ConfigTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
+
private static final Class<?>[] columnClass = {String.class, Object.class, String.class};
+
/** le modele d'une categorie */
protected final CategoryModel categoryModel;
@@ -115,7 +117,7 @@
}
OptionModel key = getEntry(row);
Object val;
- if (aValue == null || key.getType() == aValue.getClass()) {
+ if (aValue == null || key.getType().equals(aValue.getClass())) {
val = aValue;
} else {
String valStr = String.valueOf(aValue).trim();
@@ -133,4 +135,17 @@
categoryModel.setValue(key, val);
fireTableRowsUpdated(row, row);
}
+
+
+ public void destroy() {
+ if (categoryModel != null) {
+ categoryModel.destroy();
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+ }
}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -20,16 +20,17 @@
*/
package jaxx.runtime.swing.editor.config.model;
+import jaxx.runtime.JAXXUtil;
import org.apache.commons.beanutils.PropertyUtils;
-import static org.nuiton.i18n.I18n._;
import org.nuiton.util.ApplicationConfig;
-import org.nuiton.util.ApplicationConfig.OptionDef;
import javax.swing.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.*;
+import static org.nuiton.i18n.I18n._;
+
/**
* Le modele de l'ui des preferences.
* <p/>
@@ -72,16 +73,6 @@
* Callbacks manager
*/
protected CallBacksManager callBacksManager;
- /**
- * call back when reload ui is necessary
- */
- @Deprecated
- protected Runnable reloadUICallback;
- /**
- * call back when reload application is necessary
- */
- @Deprecated
- protected Runnable reloadApplicationCallback;
/**
* suport of modification
@@ -90,43 +81,13 @@
public ConfigUIModel(ApplicationConfig config) {
this.config = config;
- this.categories = new LinkedHashMap<String, CategoryModel>();
- this.callBacksManager = new CallBacksManager();
+ categories = new LinkedHashMap<String, CategoryModel>();
+ callBacksManager = new CallBacksManager();
}
/**
* Ajoute une categorie dans le modele.
*
- * @param category l'id de la categorie (la clef de traduction du nom
- * de la categorie)
- * @param categoryLabel la clef de traduction de la description de
- * la categorie
- * @param keys les options de la categorie
- * @deprecated since 2.0.0 prefer use the
- * {@link #addCategory(CategoryModel)}
- */
- @Deprecated
- public void addCategory(String category,
- String categoryLabel,
- OptionDef... keys) {
- if (categories.containsKey(category)) {
- throw new IllegalArgumentException(
- _("config.error.category.already.exists", category));
- }
- OptionModel[] entries = new OptionModel[keys.length];
- int index = 0;
- for (OptionDef d : keys) {
- Object value = config.getOption(d);
- OptionModel e = new OptionModel(d, value);
- entries[index++] = e;
- }
- CategoryModel m = new CategoryModel(category, categoryLabel, entries);
- categories.put(category, m);
- }
-
- /**
- * Ajoute une categorie dans le modele.
- *
* @param category la categorie a ajouter au modèle.
*/
public void addCategory(CategoryModel category) {
@@ -222,16 +183,6 @@
this.standalone = standalone;
}
- @Deprecated
- public Runnable getReloadApplicationCallback() {
- return reloadApplicationCallback;
- }
-
- @Deprecated
- public Runnable getReloadUICallback() {
- return reloadUICallback;
- }
-
public void saveModified() {
// compute transients keys (to never be saved)
List<String> transients = new ArrayList<String>();
@@ -360,15 +311,14 @@
return pcs.getPropertyChangeListeners();
}
- @Deprecated
- protected void setReloadApplicationCallback(
- Runnable reloadApplicationCallback) {
- this.reloadApplicationCallback = reloadApplicationCallback;
+ public void destroy() {
+ JAXXUtil.destroy(pcs);
}
- @Deprecated
- protected void setReloadUICallback(Runnable reloadUICallback) {
- this.reloadUICallback = reloadUICallback;
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
}
protected ApplicationConfig getConfig() {
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -8,7 +8,7 @@
import javax.swing.table.TableCellEditor;
/**
- * A builder of {@link jaxx.runtime.swing.editor.config.model.ConfigUIModel}
+ * A builder of {@link ConfigUIModel}
* Created: 22 déc. 2009
*
* @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
@@ -55,37 +55,6 @@
}
/**
- * Set the {@code reloadApplicationCallback} of the current model.
- *
- * @param callback the call back to set
- * @throws IllegalStateException if there is not a current model
- * @throws NullPointerException if any of parameter is {@code null}
- * @see ConfigUIModel#setReloadApplicationCallback(Runnable)
- */
- @Deprecated
- public void setReloadApplicationCallback(Runnable callback)
- throws IllegalStateException, NullPointerException {
- checkCurrent(model, "model");
- checkNotNull(callback, "setReloadApplicationCallback", "callback");
- model.setReloadApplicationCallback(callback);
- }
-
- /**
- * Set the {@code reloadUICallback} of the current model.
- *
- * @param callback the call back to set
- * @throws IllegalStateException if there is not a current model
- * @throws NullPointerException if any of parameter is {@code null}
- * @see ConfigUIModel#setReloadUICallback(Runnable)
- */
- @Deprecated
- public void setReloadUICallback(Runnable callback) {
- checkCurrent(model, "model");
- checkNotNull(callback, "setReloadUICallback", "callback");
- model.setReloadUICallback(callback);
- }
-
- /**
* Add a new category, and set it as current.
* <p/>
* <b>Note:</b> As side effets, if a previous category, then store it to
@@ -179,7 +148,7 @@
* @param editor the editor to set in the current option.
* @throws IllegalStateException if there is not a current option set.
* @throws NullPointerException if any of parameter is {@code null}
- * @see OptionModel#setEditor(javax.swing.table.TableCellEditor)
+ * @see OptionModel#setEditor(TableCellEditor)
*/
public void setOptionEditor(TableCellEditor editor)
throws IllegalStateException, NullPointerException {
@@ -222,33 +191,6 @@
}
/**
- * Set the needReloadUI flag on the current option.
- *
- * @param needReload new value to set
- * @throws IllegalStateException if there is not a current option set.
- * @see OptionModel#setNeedReloadUI(boolean)
- */
- @Deprecated
- public void setOptionNeedReloadUI(boolean needReload)
- throws IllegalStateException {
- checkCurrent(option, "option");
- option.setNeedReloadUI(needReload);
- }
-
- /**
- * Set the needReloadApplication flag on the current option.
- *
- * @param needReload new value to set
- * @throws IllegalStateException if there is not a current option set.
- * @see OptionModel#setNeedReloadUI(boolean)
- */
- public void setOptionNeedReloadApplication(boolean needReload)
- throws IllegalStateException {
- checkCurrent(option, "option");
- option.setNeedReloadApplication(needReload);
- }
-
- /**
* Flush the model and return it.
* <p/>
* <b>Note:</b> As a side effect, nothing is available in the builder
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -42,18 +42,9 @@
/**
* un drapeau pour savoir si l'option a été sauvée
*/
- protected boolean saved = false;
+ protected boolean saved;
+
/**
- * un drapeau pour savoir si le changement de l'option nécessite un redémarrage de l'ui.
- */
- @Deprecated
- protected boolean needReloadUI = false;
- /**
- * un drapeau pour savoir si le changement de l'option nécessite un redémarrage de l'application.
- */
- @Deprecated
- protected boolean needReloadApplication = false;
- /**
* la valeur non modifié de l'option
*/
protected Object originalValue;
@@ -105,16 +96,6 @@
return def.isFinal();
}
- @Deprecated
- public boolean isNeedReloadUI() {
- return needReloadUI;
- }
-
- @Deprecated
- public boolean isNeedReloadApplication() {
- return needReloadApplication;
- }
-
public Object getOriginalValue() {
return originalValue;
}
@@ -149,7 +130,7 @@
public void initValue(Object originalValue) {
this.originalValue = originalValue;
- this.value = originalValue;
+ value = originalValue;
}
public String getPropertyName() {
@@ -164,16 +145,6 @@
this.editor = editor;
}
- @Deprecated
- protected void setNeedReloadUI(boolean needReloadUI) {
- this.needReloadUI = needReloadUI;
- }
-
- @Deprecated
- protected void setNeedReloadApplication(boolean needReloadApplication) {
- this.needReloadApplication = needReloadApplication;
- }
-
protected void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
Modified: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
===================================================================
--- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java 2010-03-26 18:15:08 UTC (rev 1815)
+++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java 2010-03-27 16:12:27 UTC (rev 1816)
@@ -210,7 +210,6 @@
Assert.assertNotNull(optionModel);
Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
Assert.assertEquals(MyConfig.PROPERTY_LOCALE, optionModel.propertyName);
-// Assert.assertEquals(false, optionModel.needReloadUI);
Assert.assertNull(optionModel.editor);
}
@@ -252,7 +251,6 @@
Assert.assertNotNull(optionModel);
Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
Assert.assertNull(optionModel.propertyName);
-// Assert.assertEquals(false, optionModel.needReloadUI);
Assert.assertEquals(cellEditor, optionModel.editor);
}
1
0
r1815 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable
by tchemit@users.nuiton.org 26 Mar '10
by tchemit@users.nuiton.org 26 Mar '10
26 Mar '10
Author: tchemit
Date: 2010-03-26 19:15:08 +0100 (Fri, 26 Mar 2010)
New Revision: 1815
Log:
add constructor on NavigationTreeTableModel with the superb MyDefaultTreeTableModel TreeTableModel implemantation
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java 2010-03-26 18:05:31 UTC (rev 1814)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java 2010-03-26 18:15:08 UTC (rev 1815)
@@ -59,6 +59,14 @@
protected List<String> columnsName;
+ public NavigationTreeTableModel(MyDefaultTreeTableModel delegate,
+ String pathSeparator,
+ JAXXContext context,
+ List<String> columnsName) {
+ super(delegate, pathSeparator, context);
+ this.columnsName = columnsName;
+ }
+
public NavigationTreeTableModel(String pathSeparator, JAXXContext context, List<String> columnsName) {
super(new MyDefaultTreeTableModel(), pathSeparator, context);
this.columnsName = columnsName;
1
0
Author: tchemit
Date: 2010-03-26 19:05:31 +0100 (Fri, 26 Mar 2010)
New Revision: 1814
Log:
small refactor of navigation api
Added:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContextHelper.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRenderer.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererDecoratorImpl.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererI18nImpl.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/AbstractNavigationHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationMultiTreeHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationOneClicSelectionHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationTreeHandlerWithCardLayout.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeHelper.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableHelper.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableNode.java
Removed:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableNode.java
Modified:
trunk/jaxx-compiler/src/site/rst/NavigationTreeModel.rst
trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationHelper.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNode.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html
trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
trunk/src/site/rst/NavigationModel.rst
Modified: trunk/jaxx-compiler/src/site/rst/NavigationTreeModel.rst
===================================================================
--- trunk/jaxx-compiler/src/site/rst/NavigationTreeModel.rst 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-compiler/src/site/rst/NavigationTreeModel.rst 2010-03-26 18:05:31 UTC (rev 1814)
@@ -15,12 +15,12 @@
Le développement est effectué dans le paquetage *jaxx.runtime.swing.navigation*.
-jaxx.runtime.swing.navigation.NavigationTreeNodeModel
+jaxx.runtime.swing.navigation.tree.NavigationTreeModel
=================================================
Il s'agit du modèle de l'arbre utilisé, c'est une extension d'un *javax.swing.tree.DefaultTreeModel*.
-Les noeuds présents dans ce modèle sont aussi typés en *jaxx.runtime.swing.navigation.NavigationTreeNodeModel.NavigationTreeNode*.
+Les noeuds présents dans ce modèle sont aussi typés en *jaxx.runtime.swing.navigation.tree.NavigationTreeModel.NavigationTreeNode*.
L'idée principale est de pouvoir associé à un noeud précis un chemin depuis la racine, ce que l'on appele *chemin de navigation*.
@@ -30,7 +30,7 @@
Définition d'un noeud
=====================
-Le noeud (*jaxx.runtime.swing.navigation.NavigationTreeNodeModel.NavigationTreeNode*) est une extension d'un *javax.swing.tree.DefaultMutableTreeNode*.
+Le noeud (*jaxx.runtime.swing.navigation.tree.NavigationTreeModel.NavigationTreeNode*) est une extension d'un *javax.swing.tree.DefaultMutableTreeNode*.
Il apporte les nouvelles propriétés suivantes :
Modified: trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java
===================================================================
--- trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -28,7 +28,7 @@
/*@Test
public void testGetClassDescriptor() throws Exception {
- ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.navigation.NavigationTreeNodeModel.NavigationTreeNode");
+ ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.navigation.tree.NavigationTreeModel.NavigationTreeNode");
}*/
@Test
public void testBuiltInClassName() throws ClassNotFoundException, NoSuchMethodException {
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -40,7 +40,13 @@
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.navigation.*;
+import jaxx.runtime.swing.navigation.handler.AbstractNavigationHandler;
+import jaxx.runtime.swing.navigation.handler.NavigationHandler;
+import jaxx.runtime.swing.navigation.handler.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -59,7 +65,7 @@
}
@Override
- public NavigationTreeNodeModel createTreeModel(JAXXContext context) {
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
if (log.isDebugEnabled()) {
log.debug("start creating demo model");
@@ -126,7 +132,7 @@
addDemo(CounterDemo.class).
addDemo(CalculatorDemo.class);
- NavigationTreeNodeModel model = builder.getModel();
+ NavigationTreeModel model = builder.getModel();
if (log.isDebugEnabled()) {
builder.printModel(model.getRoot());
@@ -137,20 +143,20 @@
}
@Override
- public NavigationTreeHandler<NavigationTreeNode> createTreeHandler(JAXXObject context) {
+ public NavigationHandler<NavigationTreeNode> createTreeHandler(JAXXObject context) {
- NavigationTreeHandler<NavigationTreeNode> handler;
+ NavigationHandler<NavigationTreeNode> handler;
handler = new NavigationTreeHandlerWithCardLayout<NavigationTreeNode>(
getPrefix(),
context,
- NavigationTreeHandler.Strategy.PER_UI_TYPE) {
+ NavigationHandler.Strategy.PER_UI_TYPE) {
private static final long serialVersionUID = 1L;
@Override
- protected NavigationTreeNodeModel getNavigationTreeModel() {
- return (NavigationTreeNodeModel) getModel(getContext());
+ public NavigationTreeModel getNavigationTreeModel() {
+ return (NavigationTreeModel) getModel(getContext());
}
@Override
@@ -164,7 +170,7 @@
}
@Override
- protected void treateError(Exception e) {
+ public void treateError(Exception e) {
ErrorDialogUI.showError(e);
}
@@ -174,14 +180,14 @@
}
};
// on ne peut selectionner qu'un seul noeud a la fois
- handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+ handler.setSelectionMode(NavigationHandler.SINGLE_TREE_SELECTION);
// save handler in ui context
setTreeHandler(context, handler);
return handler;
}
- static class TreeModelBuilder extends NavigationTreeNodeModelBuilder {
+ static class TreeModelBuilder extends NavigationTreeModelBuilder {
/** la definition de l'unqiue object a partage */
static private final JAXXContextEntryDef<DemoConfig> def =
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -33,7 +33,7 @@
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
import jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder;
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -27,6 +27,12 @@
import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.swing.navigation.*;
+import jaxx.runtime.swing.navigation.handler.AbstractNavigationHandler;
+import jaxx.runtime.swing.navigation.handler.NavigationHandler;
+import jaxx.runtime.swing.navigation.handler.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,17 +47,6 @@
*/
public class FullNavigationTreeHelper extends NavigationTreeHelper {
-// static {
-// // register decorator one for all
-//
-// DecoratorUtils.register(
-// Movie.class.getSimpleName(),
-// DecoratorUtils.newMultiJXPathDecorator(Movie.class, "${title}$s##${year}$s", "##", " - "));
-//
-// DecoratorUtils.register(
-// People.class.getSimpleName(),
-// DecoratorUtils.newMultiJXPathDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " "));
-// }
/**
* Logger
*/
@@ -95,7 +90,7 @@
}
@Override
- public NavigationTreeNodeModel createTreeModel(JAXXContext context) {
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
if (builder == null) {
builder = new FullNavigationTreeModelBuilder(context);
@@ -103,7 +98,7 @@
builder.createInitialModel();
- NavigationTreeNodeModel model = builder.getModel();
+ NavigationTreeModel model = builder.getModel();
// save tree model in context
setModel(context, model);
@@ -111,23 +106,23 @@
}
@Override
- public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+ public NavigationHandler<NavigationTreeNode> createTreeHandler(JAXXObject context) {
if (log.isDebugEnabled()) {
log.debug("create handler");
}
- NavigationTreeHandler handler;
+ NavigationHandler<NavigationTreeNode> handler;
- handler = new NavigationTreeHandlerWithCardLayout(
+ handler = new NavigationTreeHandlerWithCardLayout<NavigationTreeNode>(
getPrefix(),
context,
- NavigationTreeHandler.Strategy.PER_UI_TYPE) {
+ NavigationHandler.Strategy.PER_UI_TYPE) {
private static final long serialVersionUID = 1L;
@Override
- protected NavigationModel getNavigationTreeModel() {
+ public NavigationModel<NavigationTreeNode> getNavigationTreeModel() {
return getSafeModel(getContext());
}
@@ -142,7 +137,7 @@
}
@Override
- protected void treateError(Exception e) {
+ public void treateError(Exception e) {
ErrorDialogUI.showError(e);
}
@@ -152,7 +147,7 @@
}
};
// on ne peut selectionner qu'un seul noeud a la fois
- handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+ handler.setSelectionMode(NavigationHandler.SINGLE_TREE_SELECTION);
// save handler in ui context
setTreeHandler(context, handler);
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -27,24 +27,22 @@
import jaxx.runtime.JAXXContext;
import jaxx.runtime.decorator.Decorator;
import jaxx.runtime.decorator.DecoratorProvider;
-import jaxx.runtime.swing.navigation.NavigationTreeNodeModelBuilder;
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.nuiton.i18n.I18n._;
import java.util.List;
+import static org.nuiton.i18n.I18n._;
+
/**
- *
* @author chemit
* @since 2.0.0
*/
-public class FullNavigationTreeModelBuilder extends NavigationTreeNodeModelBuilder {
+public class FullNavigationTreeModelBuilder extends NavigationTreeModelBuilder {
- /**
- * Logger
- */
+ /** Logger */
static private final Log log = LogFactory.getLog(FullNavigationTreeModelBuilder.class);
protected FullNavigationTreeModelBuilder(JAXXContext context) {
@@ -55,7 +53,7 @@
//TODO
}
- public void addActor(People people,Movie... movies) {
+ public void addActor(People people, Movie... movies) {
//TODO
}
@@ -122,8 +120,8 @@
// construction du noeud avec les acteurs
NavigationTreeNode actorsNode = build(rootNode, _("actors"),
- FullNavigationTreeHelper.ACTORS,
- "actors", ActorsContentUI.class, null);
+ FullNavigationTreeHelper.ACTORS,
+ "actors", ActorsContentUI.class, null);
for (People p : actors) {
// navigation path = $root/actors/p.id
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2010-03-26 18:05:31 UTC (rev 1814)
@@ -21,7 +21,7 @@
<ContentUI superGenericType='People'>
<script><![CDATA[
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import jaxx.demo.component.jaxx.navigation.*;
@Override
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2010-03-26 18:05:31 UTC (rev 1814)
@@ -23,7 +23,7 @@
<script><![CDATA[
import jaxx.demo.component.jaxx.navigation.*;
import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer;
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
@Override
public void openUI(NavigationTreeNode node) throws Exception {
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx 2010-03-26 18:05:31 UTC (rev 1814)
@@ -25,7 +25,7 @@
<script><![CDATA[
import jaxx.demo.component.jaxx.navigation.*;
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
ContentUIHandler getHandler() {
return getContextValue(ContentUIHandler.class);
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2010-03-26 18:05:31 UTC (rev 1814)
@@ -21,7 +21,7 @@
<ContentUI superGenericType='Movie'>
<script><![CDATA[
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import jaxx.demo.component.jaxx.navigation.*;
@Override
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2010-03-26 18:05:31 UTC (rev 1814)
@@ -23,7 +23,7 @@
<script><![CDATA[
import jaxx.demo.component.jaxx.navigation.*;
import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer;
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
@Override
public void openUI(NavigationTreeNode node) throws Exception {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationHelper.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationHelper.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -22,6 +22,9 @@
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.navigation.handler.NavigationHandler;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTreeTable;
@@ -35,14 +38,14 @@
/**
* Helper object associated to a given navigation tree system.
* <p/>
- * To helper is context safe (base on a {@link NavigationTreeContextHelper}.
+ * To helper is context safe (base on a {@link NavigationContextHelper}.
*
- * @author Letellier
+ * @author letellier <letellier(a)codelutin.com>
* @param <E> type of nodes in model
- * @see NavigationTreeNodeModel
+ * @see NavigationTreeModel
* @since 2.0.1
*/
-public abstract class AbstractNavigationHelper<E extends NavigationNode<E>> extends NavigationTreeContextHelper<E> {
+public abstract class AbstractNavigationHelper<E extends NavigationNode<E>> extends NavigationContextHelper<E> {
/** Logger */
static private final Log log =
@@ -62,7 +65,7 @@
* @param context the context to associate with fresh handler
* @return the new handler
*/
- public abstract NavigationTreeHandler createTreeHandler(JAXXObject context);
+ public abstract NavigationHandler<E> createTreeHandler(JAXXObject context);
public AbstractNavigationHelper(String contextPrefix) {
super(contextPrefix);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModel.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -21,6 +21,7 @@
package jaxx.runtime.swing.navigation;
import jaxx.runtime.JAXXContext;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,38 +42,74 @@
* @since 2.0.1
*/
public abstract class AbstractNavigationModel<E extends NavigationNode<E>> implements NavigationModel<E> {
-//public abstract class AbstractNavigationModel<E extends NavigationNode<E>> extends DefaultTreeModel implements NavigationModel<E> {
-// static private final long serialVersionUID = 1L;
-
/** Logger */
- static private final Log log = LogFactory.getLog(NavigationTreeNodeModel.class);
+ static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
- final TreeModel delegate;
+ /** the delegate model */
+ protected final TreeModel delegate;
/**
- * The path separator used to build the {@link NavigationTreeNode#fullPath}.
+ * The path separator used to build the {@link NavigationNode#getFullPath()}.
*
- * @see NavigationTreeNode#getNodePath()
- * @see NavigationTreeNode#getFullPath()
+ * @see NavigationNode#getNodePath()
+ * @see NavigationNode#getFullPath()
*/
protected final String pathSeparator;
/** Context to retrieve beans */
private JAXXContext context;
- public AbstractNavigationModel(TreeModel delegate, String pathSeparator, JAXXContext context) {
+ public AbstractNavigationModel(TreeModel delegate,
+ String pathSeparator,
+ JAXXContext context) {
this.pathSeparator = pathSeparator;
this.context = context;
this.delegate = delegate;
}
+ //--------------------------------------------------------------------------
+ // NavigationModel implementation
+ //--------------------------------------------------------------------------
+
@Override
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ public TreeModel getDelegate() {
+ return delegate;
+ }
+
+ @Override
+ public final String getPathSeparator() {
+ return pathSeparator;
+ }
+
+ @Override
public final E getRoot() {
return (E) getDelegate().getRoot();
}
@Override
+ public final Object getBean(String navigationPath) {
+ Object result;
+ E node = findNode(navigationPath, (Pattern) null);
+ result = getBean(node);
+ return result;
+ }
+
+ @Override
+ public final Object getBean(E node) {
+ if (node == null) {
+ return null;
+ //fixme should throw a NPE exception
+ //throw new NullPointerException("node can not be null");
+ }
+ return node.getBean(getContext());
+ }
+
+ @Override
public final E findNode(String path) {
return findNode(getRoot(), path, (Pattern) null);
}
@@ -127,38 +164,6 @@
}
@Override
- public JAXXContext getContext() {
- return context;
- }
-
- public TreeModel getDelegate() {
- return delegate;
- }
-
- @Override
- public final String getPathSeparator() {
- return pathSeparator;
- }
-
- @Override
- public final Object getBean(String navigationPath) {
- Object result;
- E node = findNode(navigationPath, (Pattern) null);
- result = getBean(node);
- return result;
- }
-
- @Override
- public final Object getBean(E node) {
- if (node == null) {
- return null;
- //fixme should throw a NPE exception
- //throw new NullPointerException("node can not be null");
- }
- return node.getBean(getContext());
- }
-
- @Override
public final void nodeChanged(E node) {
nodeChanged(node, false);
if (log.isDebugEnabled()) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/AbstractNavigationModelBuilder.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -73,7 +73,7 @@
@Override
public E buildEmptyRoot(JAXXContextEntryDef<?> entryDef,
String contextName) {
- E node = createNavigationTreeNode(
+ E node = createNavigationNode(
model.getPathSeparator(),
contextName,
entryDef,
@@ -91,7 +91,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- E node = createNavigationTreeNode(
+ E node = createNavigationNode(
model.getPathSeparator(),
contextName,
entryDef,
@@ -109,7 +109,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- E node = createNavigationTreeNode(
+ E node = createNavigationNode(
model.getPathSeparator(),
contextName,
entryDef,
@@ -127,7 +127,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- E node = createNavigationTreeNode(
+ E node = createNavigationNode(
model.getPathSeparator(),
contextName,
null,
@@ -146,7 +146,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- E node = createNavigationTreeNode(
+ E node = createNavigationNode(
model.getPathSeparator(),
contextName,
entryDef,
@@ -164,7 +164,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- E node = createNavigationTreeNode(
+ E node = createNavigationNode(
model.getPathSeparator(),
contextName,
entryDef,
@@ -182,7 +182,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- E node = createNavigationTreeNode(
+ E node = createNavigationNode(
model.getPathSeparator(),
contextName,
null,
@@ -212,12 +212,12 @@
@Override
public void addI18nNodeRenderer(E node, String libelle) {
- node.setRenderer(new NavigationTreeNodeRendererI18nImpl(libelle));
+ node.setRenderer(new NavigationNodeRendererI18nImpl(libelle));
}
@Override
public void addDecoratorNodeRenderer(E node, Decorator<?> decorator) {
- node.setRenderer(new NavigationTreeNodeRendererDecoratorImpl(decorator));
+ node.setRenderer(new NavigationNodeRendererDecoratorImpl(decorator));
}
@Override
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContentUI.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -20,6 +20,8 @@
*/
package jaxx.runtime.swing.navigation;
+import jaxx.runtime.swing.navigation.handler.NavigationHandler;
+
import java.awt.*;
/**
@@ -32,21 +34,21 @@
/**
* Init the ui just before been opened by the method {@link
- * NavigationTreeHandler#openUI(Component, NavigationNode)}.
+ * NavigationHandler#openUI(Component, NavigationNode)}.
*
* @param node the selected node associated to the ui
* @throws Exception if any pb while opening the content's ui
- * @see NavigationTreeHandler#openUI(Component, NavigationNode)
+ * @see NavigationHandler#openUI(Component, NavigationNode)
*/
void openUI(E node) throws Exception;
/**
* Clean the ui after been closed by the method {@link
- * NavigationTreeHandler#closeUI(Component)}.
+ * NavigationHandler#closeUI(Component)}.
*
* @param node the selected node associated to the ui
* @throws Exception if any pb when closing the content'sui
- * @see NavigationTreeHandler#closeUI(Component)
+ * @see NavigationHandler#closeUI(Component)
*/
void closeUI(E node) throws Exception;
}
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContextHelper.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContextHelper.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContextHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,253 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.handler.NavigationHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTreeTable;
+
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * To help getting and setting navigation tree objects from a {@link
+ * JAXXContext}.
+ * <p/>
+ * There is seven types of data which can be hold in a context : <ul> <li>tree :
+ * the tree </li> <li>tree-tablr : the jx tree table</li> <li>tree model : the
+ * navigation tree model</li> <li>tree handler : the navigation tree
+ * handler</li> <li>selected path : the navigation path of the selected
+ * node</li> <li>selected node : the selected node</li> <li>selected bean : the
+ * selected bean</li> </ul>
+ * <p/>
+ * To make possible the use of more than one navigation tree system in a same
+ * context, we <b>MUST</b> distinguish the context entries definition. For this
+ * purpose, entries definition are normalized and prefixed by a unique {@link
+ * #prefix}.
+ * <p/>
+ * Here is the keys mapping : <ul> <li>tree : {@code prefix + "-tree"}</li>
+ * <li>tree-table : {@code prefix + "-tree-table"}</li> <li>tree model : {@code
+ * prefix + "-tree-model"}</li> <li>tree handler : {@code prefix +
+ * "-tree-handler"}</li> <li>selected path : {@code prefix +
+ * "-selected-path"}</li> <li>selected node : {@code prefix +
+ * "-selected-node"}</li> <li>selected bean : {@code prefix +
+ * "-selected-bean"}</li> </ul>
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationContextHelper<E extends NavigationNode<E>> {
+
+ /** Logger */
+ static private final Log log = LogFactory.getLog(NavigationContextHelper.class);
+
+ protected final String prefix;
+
+ protected JAXXContextEntryDef<List<String>> selectedPathsContextEntry;
+
+ protected JAXXContextEntryDef<List<Object>> selectedBeansContextEntry;
+
+ protected JAXXContextEntryDef<List<E>> selectedNodesContextEntry;
+
+ protected JAXXContextEntryDef<NavigationModel<E>> modelContextEntry;
+
+ protected JAXXContextEntryDef<NavigationHandler<E>> handlerContextEntry;
+
+ protected JAXXContextEntryDef<JTree> treeContextEntry;
+
+ protected JAXXContextEntryDef<JXTreeTable> treeTableContextEntry;
+
+ public NavigationContextHelper(String prefix) {
+ this.prefix = prefix;
+ treeContextEntry = JAXXUtil.newContextEntryDef(prefix + "-tree", JTree.class);
+ treeTableContextEntry = JAXXUtil.newContextEntryDef(prefix + "-tree-table", JXTreeTable.class);
+ modelContextEntry = (JAXXContextEntryDef) JAXXUtil.newContextEntryDef(prefix + "-model", NavigationModel.class);
+ handlerContextEntry = (JAXXContextEntryDef) JAXXUtil.newContextEntryDef(prefix + "-handler", NavigationHandler.class);
+ selectedBeansContextEntry = JAXXUtil.newListContextEntryDef(prefix + "-selected-beans");
+ selectedNodesContextEntry = JAXXUtil.newListContextEntryDef(prefix + "-selected-nodes");
+ selectedPathsContextEntry = JAXXUtil.newListContextEntryDef(prefix + "-selected-paths");
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public JTree getTree(JAXXContext context) {
+ JTree r = getTreeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public JXTreeTable getTreeTable(JAXXContext context) {
+ JXTreeTable r = getTreeTableContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationModel<E> getModel(JAXXContext context) {
+ NavigationModel<E> r = getModelContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationHandler<E> getTreeHandler(JAXXContext context) {
+ NavigationHandler<E> r =
+ getTreeHandlerContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public String getSelectedPath(JAXXContext context) {
+ String result = getSelectedValue(getSelectedPathContextEntry(), context);
+ return result;
+ }
+
+ public List<String> getSelectedPaths(JAXXContext context) {
+ return getSelectedPathContextEntry().getContextValue(context);
+ }
+
+ public E getSelectedNode(JAXXContext context) {
+ E result = getSelectedValue(getSelectedNodeContextEntry(), context);
+ return result;
+ }
+
+ public List<E> getSelectedNodes(JAXXContext context) {
+ return getSelectedNodeContextEntry().getContextValue(context);
+ }
+
+ public Object getSelectedBean(JAXXContext context) {
+ Object result = getSelectedValue(getSelectedBeanContextEntry(), context);
+ return result;
+ }
+
+ public List<Object> getSelectedBeans(JAXXContext context) {
+ return getSelectedBeanContextEntry().getContextValue(context);
+ }
+
+ public void setModel(JAXXContext context, NavigationModel<E> model) {
+ getModelContextEntry().setContextValue(context, model);
+ }
+
+ public void setTree(JAXXContext context, JTree tree) {
+ getTreeContextEntry().setContextValue(context, tree);
+ }
+
+ public void setTreeTable(JAXXContext context, JXTreeTable treeTable) {
+ getTreeTableContextEntry().setContextValue(context, treeTable);
+ }
+
+ public void setTreeHandler(JAXXContext context,
+ NavigationHandler<E> handler) {
+ getTreeHandlerContextEntry().setContextValue(context, handler);
+ }
+
+ public void setSelectedPath(JAXXContext context, String path) {
+ setSelectedValue(getSelectedPathContextEntry(), context, path);
+ }
+
+ public void setSelectedPaths(JAXXContext context, List<String> paths) {
+ setSelectedValues(getSelectedPathContextEntry(), context, paths);
+ }
+
+ public void setSelectedNode(JAXXContext context, E node) {
+ setSelectedValue(getSelectedNodeContextEntry(), context, node);
+ }
+
+ public void setSelectedNodes(JAXXContext context, List<E> nodes) {
+ setSelectedValues(getSelectedNodeContextEntry(), context, nodes);
+ }
+
+ public void setSelectedBean(JAXXContext context, Object bean) {
+ setSelectedValue(getSelectedBeanContextEntry(), context, bean);
+ }
+
+ public void setSelectedBeans(JAXXContext context, List<Object> beans) {
+ setSelectedValues(getSelectedBeanContextEntry(), context, beans);
+ }
+
+ protected JAXXContextEntryDef<NavigationModel<E>> getModelContextEntry() {
+ return modelContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationHandler<E>>
+ getTreeHandlerContextEntry() {
+ return handlerContextEntry;
+ }
+
+ protected JAXXContextEntryDef<List<Object>> getSelectedBeanContextEntry() {
+ return selectedBeansContextEntry;
+ }
+
+ protected JAXXContextEntryDef<List<E>> getSelectedNodeContextEntry() {
+ return selectedNodesContextEntry;
+ }
+
+ protected JAXXContextEntryDef<List<String>> getSelectedPathContextEntry() {
+ return selectedPathsContextEntry;
+ }
+
+ protected JAXXContextEntryDef<JTree> getTreeContextEntry() {
+ return treeContextEntry;
+ }
+
+ protected JAXXContextEntryDef<JXTreeTable> getTreeTableContextEntry() {
+ return treeTableContextEntry;
+ }
+
+ protected <T> T getSelectedValue(JAXXContextEntryDef<List<T>> entry,
+ JAXXContext context) {
+ List<T> values = entry.getContextValue(context);
+ T result = null;
+ if (values != null && !values.isEmpty()) {
+ if (values.size() > 1) {
+ if (log.isWarnEnabled()) {
+ log.warn("There is " + values.size() +
+ " values selected, will return first one");
+ }
+ }
+ result = values.get(0);
+ }
+ return result;
+ }
+
+ protected <T> void setSelectedValue(JAXXContextEntryDef<List<T>> entry,
+ JAXXContext context,
+ T value) {
+ if (value == null) {
+ entry.removeContextValue(context);
+ } else {
+ List<T> selecteds = new ArrayList<T>();
+ selecteds.add(value);
+ entry.setContextValue(context, selecteds);
+ }
+ }
+
+ protected <T> void setSelectedValues(JAXXContextEntryDef<List<T>> entry,
+ JAXXContext context,
+ List<T> values) {
+ if (values == null || values.isEmpty()) {
+ entry.removeContextValue(context);
+ } else {
+ entry.setContextValue(context, values);
+ }
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationContextHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -21,6 +21,7 @@
package jaxx.runtime.swing.navigation;
import jaxx.runtime.JAXXContext;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreePath;
@@ -29,13 +30,12 @@
/**
* Interface to create model of the tree used for a navigation tree.
* <p/>
- * Il est composé de {@link NavigationTreeNode}
+ * Il est composé de {@link NavigationNode}
*
* @author sletellier
* @since 2.0.0
*/
-public interface NavigationModel<E extends NavigationNode<E>> {
-//public interface NavigationModel<E extends NavigationNode<E>> extends TreeModel {
+public interface NavigationModel<E extends NavigationNode<E>> {
E getRoot();
@@ -54,8 +54,8 @@
* <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.
+ * @return the node matching the fully context from the root node, or
+ * <code>null</code> if not find.
*/
E findNode(String path);
@@ -113,14 +113,14 @@
* 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#path} valued
- * separated by {@link #getPathSeparator()}.
+ * (concatenation of nodes) {@link NavigationTreeNode#path} valued separated
+ * by {@link #getPathSeparator()}.
*
* @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.
+ * @return the node matching the fully context from the given root node, or
+ * <code>null</code> if not found.
*/
E findNode(E root, String path, String regex);
@@ -134,16 +134,16 @@
* @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.
+ * @return the node matching the fully context from the given root node, or
+ * <code>null</code> if not found.
*/
E findNode(E root, String path, Pattern regex);
JAXXContext getContext();
/**
- * Obtain the associated bean value from context corresponding to node
- * from given navigation path.
+ * Obtain the associated bean value from context corresponding to node from
+ * given navigation path.
*
* @param navigationPath the current context path of the node
* @return the value associated in context with the given navigation path
@@ -165,69 +165,64 @@
void nodeChanged(E node, boolean deep);
String getPathSeparator();
-
+
/**
- * Returns the child of <code>parent</code> at index <code>index</code>
- * in the parent's
- * child array. <code>parent</code> must be a node previously obtained
- * from this data source. This should not return <code>null</code>
- * if <code>index</code>
- * is a valid index for <code>parent</code> (that is <code>index >= 0 &&
- * index < getChildCount(parent</code>)).
+ * Returns the child of <code>parent</code> at index <code>index</code> in
+ * the parent's child array. <code>parent</code> must be a node previously
+ * obtained from this data source. This should not return <code>null</code>
+ * if <code>index</code> is a valid index for <code>parent</code> (that is
+ * <code>index >= 0 && index < getChildCount(parent</code>)).
*
- * @param parent a node in the tree, obtained from this data source
- * @return the child of <code>parent</code> at index <code>index</code>
+ * @param parent a node in the tree, obtained from this data source
+ * @param index index of the node
+ * @return the child of <code>parent</code> at index <code>index</code>
*/
Object getChild(Object parent, int index);
-
/**
- * Returns the number of children of <code>parent</code>.
- * Returns 0 if the node
- * is a leaf or if it has no children. <code>parent</code> must be a node
- * previously obtained from this data source.
+ * Returns the number of children of <code>parent</code>. Returns 0 if the
+ * node is a leaf or if it has no children. <code>parent</code> must be a
+ * node previously obtained from this data source.
*
- * @param parent a node in the tree, obtained from this data source
- * @return the number of children of the node <code>parent</code>
+ * @param parent a node in the tree, obtained from this data source
+ * @return the number of children of the node <code>parent</code>
*/
int getChildCount(Object parent);
-
/**
- * Returns <code>true</code> if <code>node</code> is a leaf.
- * It is possible for this method to return <code>false</code>
- * even if <code>node</code> has no children.
- * A directory in a filesystem, for example,
- * may contain no files; the node representing
- * the directory is not a leaf, but it also has no children.
+ * Returns <code>true</code> if <code>node</code> is a leaf. It is possible
+ * for this method to return <code>false</code> even if <code>node</code>
+ * has no children. A directory in a filesystem, for example, may contain no
+ * files; the node representing the directory is not a leaf, but it also has
+ * no children.
*
- * @param node a node in the tree, obtained from this data source
- * @return true if <code>node</code> is a leaf
+ * @param node a node in the tree, obtained from this data source
+ * @return true if <code>node</code> is a leaf
*/
boolean isLeaf(Object node);
/**
- * Messaged when the user has altered the value for the item identified
- * by <code>path</code> to <code>newValue</code>.
- * If <code>newValue</code> signifies a truly new value
- * the model should post a <code>treeNodesChanged</code> event.
- *
- * @param path path to the node that the user has altered
- * @param newValue the new value from the TreeCellEditor
- */
+ * Messaged when the user has altered the value for the item identified by
+ * <code>path</code> to <code>newValue</code>. If <code>newValue</code>
+ * signifies a truly new value the model should post a
+ * <code>treeNodesChanged</code> event.
+ *
+ * @param path path to the node that the user has altered
+ * @param newValue the new value from the TreeCellEditor
+ */
void valueForPathChanged(TreePath path, Object newValue);
/**
- * Returns the index of child in parent. If either <code>parent</code>
- * or <code>child</code> is <code>null</code>, returns -1.
- * If either <code>parent</code> or <code>child</code> don't
- * belong to this tree model, returns -1.
+ * Returns the index of child in parent. If either <code>parent</code> or
+ * <code>child</code> is <code>null</code>, returns -1. If either
+ * <code>parent</code> or <code>child</code> don't belong to this tree
+ * model, returns -1.
*
* @param parent a node in the tree, obtained from this data source
- * @param child the node we are interested in
+ * @param child the node we are interested in
* @return the index of the child in the parent, or -1 if either
- * <code>child</code> or <code>parent</code> are <code>null</code>
- * or don't belong to this tree model
+ * <code>child</code> or <code>parent</code> are <code>null</code>
+ * or don't belong to this tree model
*/
int getIndexOfChild(Object parent, Object child);
@@ -236,21 +231,19 @@
//
/**
- * Adds a listener for the <code>TreeModelEvent</code>
- * posted after the tree changes.
+ * Adds a listener for the {@code TreeModelEvent} posted after the tree
+ * changes.
*
- * @param l the listener to add
- * @see #removeTreeModelListener
+ * @param l the listener to add
+ * @see #removeTreeModelListener
*/
void addTreeModelListener(TreeModelListener l);
/**
- * Removes a listener previously added with
- * <code>addTreeModelListener</code>.
+ * Removes a listener previously added with {@code addTreeModelListener}.
*
- * @see #addTreeModelListener
- * @param l the listener to remove
+ * @param l the listener to remove
+ * @see #addTreeModelListener
*/
void removeTreeModelListener(TreeModelListener l);
-
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModelBuilder.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -26,7 +26,7 @@
import jaxx.runtime.decorator.Decorator;
/**
- * Interface to create a builder, this object is design to build a {@link
+ * Contract to create a builder, this object is design to build a {@link
* NavigationModel}.
*
* @author sletellier
@@ -38,7 +38,7 @@
// To create your own instance of NavigationTreeTableNode
- E createNavigationTreeNode(
+ E createNavigationNode(
String pathSeparator,
String contextName,
JAXXContextEntryDef<?> jaxxContextEntryDef,
@@ -92,10 +92,11 @@
E removeChildNode(E node);
+ void moveNode(E parentNode, E node, int position);
+
void addI18nNodeRenderer(E node, String libelle);
- void addDecoratorNodeRenderer(E node,
- Decorator<?> decorator);
+ void addDecoratorNodeRenderer(E node, Decorator<?> decorator);
void addNodeJaxxClasses(
E node,
@@ -103,6 +104,4 @@
Class<? extends JAXXAction> uIHandlerClass);
void printModel(E node);
-
- void moveNode(E parentNode, E node, int position);
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiContentUI.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -21,6 +21,8 @@
package jaxx.runtime.swing.navigation;
+import jaxx.runtime.swing.navigation.handler.NavigationMultiTreeHandler;
+
import java.awt.*;
import java.util.List;
@@ -38,16 +40,17 @@
*
* @param nodes the selected node associated to the ui
* @throws Exception if any pb while opening the content's ui
+ * @see NavigationMultiTreeHandler#openUI(Component, List)
*/
void openUI(List<E> nodes) throws Exception;
/**
* Clean the ui after been closed by the method {@link
- * NavigationTreeHandler#closeUI(Component)}.
+ * NavigationMultiTreeHandler#closeUI(Component)}.
*
* @param nodes the selected node associated to the ui
* @throws Exception if any pb when closing the content'sui
- * @see NavigationTreeHandler#closeUI(Component)
+ * @see NavigationMultiTreeHandler#closeUI(Component)
*/
void closeUI(List<E> nodes) throws Exception;
}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,187 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.tree.TreePath;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The handler of a navigation tree.
- * <p/>
- * This is also the selection model to use, since we must check before moving
- * from nodes we can not just listen selection model changed, we must control
- * it.
- * <p/>
- * This one is used to enable multi selection
- *
- * @author sletellier
- * @since 2.0.1
- */
-public abstract class NavigationMultiTreeHandler<E extends NavigationNode<E>> extends NavigationTreeHandler<E> {
-
- /** Logger */
- static private final Log log =
- LogFactory.getLog(NavigationMultiTreeHandler.class);
-
-
- public NavigationMultiTreeHandler(String contextPrefix,
- JAXXObject context,
- Strategy strategy) {
- super(contextPrefix, context, strategy);
-
- // Enable multi selection
- setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
- }
-
- @Override
- public void valueChanged(TreeSelectionEvent event) {
- TreePath[] paths = event.getPaths();
-
- // TODO : verifier que la selection n'est pas la même
- List<E> nodes = new ArrayList<E>();
- if (paths == null) {
- selectNodeUI(new ArrayList<E>());
- return;
- }
- for (TreePath path : paths) {
- E node = (E) path.getLastPathComponent();
- nodes.add(node);
- if (log.isDebugEnabled()) {
- log.debug("Adding path : " + path);
- log.debug("As node : " + node.getFullPath());
- }
- }
- selectNodeUI(nodes);
- }
-
- /**
- * Ouvre l'ui associée aux noeuds sélectionnés dans l'arbre de navigation.
- *
- * @param newUI l'ui associé au noeud sélectionné à ouvrir
- * @param nodes les node de l'ui a ouvrir
- * @throws Exception if any
- */
- protected abstract void openUI(Component newUI,
- List<E> nodes)
- throws Exception;
-
- /**
- * Instancie une nouvelle ui associé à des noeuds de l'arbre de navigation
- *
- * @param nodes les noeuds associés à l'ui à créer
- * @return la nouvelle ui associée au noeud
- * @throws Exception if any
- */
- protected abstract Component createUI(List<E> nodes)
- throws Exception;
-
- /**
- * @param nodes les noeuds associés à l'ui à retrouver
- * @return l'ui associés au nouveau noeud sélectionné
- */
- protected abstract Component getUI(List<E> nodes);
-
- protected void selectNodeUI(List<E> nodes) {
- log.info("select nodes " + nodes);
-
- try {
-// List<String> paths = new ArrayList<String>();
- List<Object> beans = new ArrayList<Object>();
- for (E node : nodes) {
-
- String path = node.getFullPath();
-// paths.add(path);
-
- if (log.isTraceEnabled()) {
- log.trace(path);
- }
- // now, we are free to open the ui associated with the selected
- // node in navigation
-
- // get the bean associated with the node
- beans.add(getNavigationTreeModel().getBean(path));
- }
-
- Component newUI = getUI(nodes);
-
- // save it in context (must be done before init ui)
- JAXXContext ctxt = getContext();
- NavigationTreeContextHelper<E> helper = getContextHelper();
-
- // remove previous selected bean
- //TODO-TC-20091004 should have an automatic clean context method
- //TODO-TC-20091004 while
- helper.setSelectedBean(ctxt, null);
-
-// if (beans != null) {
- helper.setSelectedBeans(ctxt, beans);
-// }
-
- if (newUI == null) {
-
- // a new ui instance is required
- newUI = createUI(nodes);
- }
-
- // save in context current node context path
- helper.setSelectedPaths(ctxt, getPaths(nodes));
-
- // save in context current node
- helper.setSelectedNodes(ctxt, nodes);
-
- // save in context current ui
-// helper.setSelectedUI(ctxt, newUI);
-
- // really open the ui associated with the selected node
- // init ui before to be visible
- if (newUI instanceof NavigationMultiContentUI<?>) {
- ((NavigationMultiContentUI<E>) newUI).openUI(nodes);
- }
-
- // set ui in content
- openUI(newUI, nodes);
-
- } catch (Exception e) {
- // remove data from context
-
- // if any error, go back to previvous node
- treateError(e);
- }
- }
-
- protected List<String> getPaths(List<E> nodes) {
- List<String> result = new ArrayList<String>();
- for (E node : nodes) {
- result.add(node.getFullPath());
- }
- return result;
- }
-
-}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNode.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNode.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNode.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -8,36 +8,29 @@
import java.io.Serializable;
import java.util.Enumeration;
+/**
+ * Contract of a navigation node.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @param <E> type of the node
+ * @since 2.0.1
+ */
public interface NavigationNode<E extends NavigationNode<E>> extends Cloneable, Serializable {
-// public interface NavigationNode<E extends NavigationNode<E>> extends Cloneable, MutableTreeNode, Serializable {
- NavigationTreeNodeRenderer getRenderer();
- void setRenderer(NavigationTreeNodeRenderer renderer);
+ NavigationNodeRenderer getRenderer();
String getPathSeparator();
String getNodePath();
- void setNodePath(String navigationPath);
-
Class<? extends JAXXObject> getUIClass();
- void setUIClass(Class<? extends JAXXObject> uIClass);
-
- void setInternalClass(Class<?> internalClass);
-
Class<? extends JAXXAction> getUIHandlerClass();
- void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass);
-
JAXXContextEntryDef<?> getJaxxContextEntryDef();
- void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef);
-
String getJaxxContextEntryPath();
- void setJaxxContextEntryPath(String jaxxContextEntryPath);
-
Class<?> getInternalClass();
String getFullPath();
@@ -50,24 +43,8 @@
Object getBean();
- void setBean(Object bean);
-
- void reload(JAXXContext context);
-
Object getBean(JAXXContext context);
- void insert(E child, int index);
-
- void remove(int index);
-
- void remove(E node);
-
- void setUserObject(Object object);
-
- void removeFromParent();
-
- void setParent(E newParent);
-
int getChildCount();
int getIndex(E node);
@@ -82,10 +59,40 @@
Object getUserObject();
- void add(E node);
+ E[] getPathToRoot(E aNode, int depth);
- E[] getPathToRoot(E aNode, int depth) ;
-
E[] getPath();
+ void setRenderer(NavigationNodeRenderer renderer);
+
+ void setNodePath(String navigationPath);
+
+ void setUIClass(Class<? extends JAXXObject> uIClass);
+
+ void setInternalClass(Class<?> internalClass);
+
+ void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass);
+
+ void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef);
+
+ void setJaxxContextEntryPath(String jaxxContextEntryPath);
+
+ void setParent(E newParent);
+
+ void setBean(Object bean);
+
+ void setUserObject(Object object);
+
+ void reload(JAXXContext context);
+
+ void add(E node);
+
+ void insert(E child, int index);
+
+ void remove(int index);
+
+ void remove(E node);
+
+ void removeFromParent();
+
}
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRenderer.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRenderer.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRenderer.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,62 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.tree.TreeCellRenderer;
+import java.io.Serializable;
+
+/**
+ * Text Renderer of a {@link NavigationNode}.
+ * <p/>
+ * This object will be placed as the {@link NavigationNode#getUserObject()} of
+ * nodes.
+ * <p/>
+ * <p/>
+ * In that way, we can use the {@link #toString()} value to render the node
+ * without writing any {@link TreeCellRenderer}.
+ * <p/>
+ * To rebuild the renderer text of a node use the method {@link #reload(Object)}
+ * with the {@code bean} provides by the model for the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear
+ * soon...
+ */
+public interface NavigationNodeRenderer extends Serializable {
+
+ /** @return the render value of the node */
+ @Override
+ String toString();
+
+ /**
+ * Can override the node internal class for display purpose.
+ *
+ * @return the type of data to be displayed.
+ */
+ Class<?> getInternalClass();
+
+ /**
+ * Reload the render value from the {@code bean} of node.
+ *
+ * @param bean the bean associated to the node to render
+ */
+ void reload(Object bean);
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererDecoratorImpl.java (from rev 1809, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererDecoratorImpl.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererDecoratorImpl.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,72 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.decorator.Decorator;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
+
+/**
+ * Decorator Renderer of a {@link NavigationTreeNode}.
+ * <p/>
+ * Apply a {@link Decorator} to the {@code bean} associated to the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear
+ * soon...
+ */
+public class NavigationNodeRendererDecoratorImpl implements NavigationNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+
+ /** Decorator */
+ protected final Decorator<?> decorator;
+
+ /** internal class of representing data */
+ protected final Class<?> internalClass;
+
+ /** last renderered value */
+ protected String text;
+
+ public NavigationNodeRendererDecoratorImpl(Decorator<?> decorator) {
+ internalClass = decorator.getInternalClass();
+ this.decorator = decorator;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object bean) {
+ try {
+ text = decorator.toString(bean);
+
+ } catch (Exception e) {
+ text = "";
+ }
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererDecoratorImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererI18nImpl.java (from rev 1809, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererI18nImpl.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererI18nImpl.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,68 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * I18n label Renderer of a {@link NavigationTreeNode}.
+ * <p/>
+ * Just apply a i18n translation on the given {@link #libelle}.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear
+ * soon...
+ */
+public class NavigationNodeRendererI18nImpl implements NavigationNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+
+ /** Static i18n label to render */
+ protected final String libelle;
+
+ /** internal class of representing data */
+ protected final Class<?> internalClass;
+
+ /** last renderered value */
+ protected String text;
+
+ public NavigationNodeRendererI18nImpl(String libelle) {
+ this.libelle = libelle;
+ internalClass = String.class;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object data) {
+ text = _(libelle);
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationNodeRendererI18nImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,66 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXObject;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.tree.TreePath;
-import java.util.Arrays;
-
-/**
- * The handler of a navigation tree.
- * <p/>
- * This is also the selection model to use, since we must check before moving
- * from nodes we can not just listen selection model changed, we must control
- * it.
- * <p/>
- * This one is used to enable one clic multi selection
- *
- * @author sletellier
- * @since 2.0.1
- */
-public abstract class NavigationOneClicSelectionHandler<E extends NavigationNode<E>> extends NavigationMultiTreeHandler<E> {
-
- /** Logger */
- static private final Log log =
- LogFactory.getLog(NavigationOneClicSelectionHandler.class);
-
-
- public NavigationOneClicSelectionHandler(String contextPrefix,
- JAXXObject context,
- Strategy strategy) {
- super(contextPrefix, context, strategy);
- }
-
- @Override
- public void setSelectionPath(TreePath path) {
- TreePath[] treePaths = getSelectionPaths();
- if (treePaths == null || !Arrays.asList(treePaths).contains(path)) {
- addSelectionPath(path);
- } else {
- removeSelectionPath(path);
- }
- }
-
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,253 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTreeTable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.JTree;
-
-/**
- * To help getting and setting navigation tree objects from a {@link JAXXContext}.
- * <p/>
- * There is seven types of data which can be hold in a context :
- * <ul>
- * <li>tree : the tree </li>
- * <li>tree-tablr : the jx tree table</li>
- * <li>tree model : the navigation tree model</li>
- * <li>tree handler : the navigation tree handler</li>
- * <li>selected path : the navigation path of the selected node</li>
- * <li>selected node : the selected node</li>
- * <li>selected bean : the selected bean</li>
- * </ul>
- * <p/>
- * To make possible the use of more than one navigation tree system in a same
- * context, we <b>MUST</b> distinguish the context entries definition. For this
- * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}.
- * <p/>
- * Here is the keys mapping :
- * <ul>
- * <li>tree : {@code prefix + "-tree"}</li>
- * <li>tree-table : {@code prefix + "-tree-table"}</li>
- * <li>tree model : {@code prefix + "-tree-model"}</li>
- * <li>tree handler : {@code prefix + "-tree-handler"}</li>
- * <li>selected path : {@code prefix + "-selected-path"}</li>
- * <li>selected node : {@code prefix + "-selected-node"}</li>
- * <li>selected bean : {@code prefix + "-selected-bean"}</li>
- * </ul>
- *
- * @author chemit
- * @since 1.7.2
- */
-public class NavigationTreeContextHelper <E extends NavigationNode<E>> {
-
- /**
- * Logger
- */
- static private final Log log = LogFactory.getLog(NavigationTreeContextHelper.class);
-
- protected final String prefix;
- protected JAXXContextEntryDef<List<String>> selectedPathsContextEntry;
- protected JAXXContextEntryDef<List<Object>> selectedBeansContextEntry;
- protected JAXXContextEntryDef<List<E>> selectedNodesContextEntry;
- protected JAXXContextEntryDef<NavigationModel<E>> modelContextEntry;
- protected JAXXContextEntryDef<NavigationTreeHandler> handlerContextEntry;
- protected JAXXContextEntryDef<JTree> treeContextEntry;
- protected JAXXContextEntryDef<JXTreeTable> treeTableContextEntry;
-
- public NavigationTreeContextHelper(String prefix) {
- this.prefix = prefix;
- treeContextEntry = JAXXUtil.newContextEntryDef(prefix + "-tree", JTree.class);
- treeTableContextEntry = JAXXUtil.newContextEntryDef(prefix + "-tree-table", JXTreeTable.class);
- modelContextEntry = (JAXXContextEntryDef)JAXXUtil.newContextEntryDef(prefix + "-model", NavigationModel.class);
- handlerContextEntry = JAXXUtil.newContextEntryDef(prefix + "-handler", NavigationTreeHandler.class);
- selectedBeansContextEntry = JAXXUtil.newListContextEntryDef(prefix + "-selected-beans");
- selectedNodesContextEntry = JAXXUtil.newListContextEntryDef(prefix + "-selected-nodes");
- selectedPathsContextEntry = JAXXUtil.newListContextEntryDef(prefix + "-selected-paths");
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public JTree getTree(JAXXContext context) {
- JTree r = getTreeContextEntry().getContextValue(context);
- return r;
- }
-
- public JXTreeTable getTreeTable(JAXXContext context) {
- JXTreeTable r = getTreeTableContextEntry().getContextValue(context);
- return r;
- }
-
- public NavigationModel<E> getModel(JAXXContext context) {
- NavigationModel<E> r = getModelContextEntry().getContextValue(context);
- return r;
- }
-
- public NavigationTreeHandler getTreeHandler(JAXXContext context) {
- NavigationTreeHandler r =
- getTreeHandlerContextEntry().getContextValue(context);
- return r;
- }
-
- public String getSelectedPath(JAXXContext context) {
- String result = getSelectedValue(getSelectedPathContextEntry(),context);
- return result;
- }
-
- public List<String> getSelectedPaths(JAXXContext context) {
- return getSelectedPathContextEntry().getContextValue(context);
- }
-
- public E getSelectedNode(JAXXContext context) {
- E result = getSelectedValue(getSelectedNodeContextEntry(),context);
- return result;
- }
-
- public List<E> getSelectedNodes(JAXXContext context) {
- return getSelectedNodeContextEntry().getContextValue(context);
- }
-
- public Object getSelectedBean(JAXXContext context) {
- Object result = getSelectedValue(getSelectedBeanContextEntry(),context);
- return result;
- }
-
- public List<Object> getSelectedBeans(JAXXContext context) {
- return getSelectedBeanContextEntry().getContextValue(context);
- }
-
- public void setModel(JAXXContext context, NavigationModel<E> model) {
- getModelContextEntry().setContextValue(context, model);
- }
-
- public void setTree(JAXXContext context, JTree tree) {
- getTreeContextEntry().setContextValue(context, tree);
- }
-
- public void setTreeTable(JAXXContext context, JXTreeTable treeTable) {
- getTreeTableContextEntry().setContextValue(context, treeTable);
- }
-
- public void setTreeHandler(JAXXContext context,
- NavigationTreeHandler handler) {
- getTreeHandlerContextEntry().setContextValue(context, handler);
- }
-
- public void setSelectedPath(JAXXContext context, String path) {
- setSelectedValue(getSelectedPathContextEntry(), context, path);
- }
-
- public void setSelectedPaths(JAXXContext context, List<String> paths) {
- setSelectedValues(getSelectedPathContextEntry(), context, paths);
- }
-
- public void setSelectedNode(JAXXContext context, E node) {
- setSelectedValue(getSelectedNodeContextEntry(), context, node);
- }
-
- public void setSelectedNodes(JAXXContext context, List<E> nodes) {
- setSelectedValues(getSelectedNodeContextEntry(), context, nodes);
- }
-
- public void setSelectedBean(JAXXContext context, Object bean) {
- setSelectedValue(getSelectedBeanContextEntry(), context, bean);
- }
-
- public void setSelectedBeans(JAXXContext context, List<Object> beans) {
- setSelectedValues(getSelectedBeanContextEntry(), context, beans);
- }
-
- protected JAXXContextEntryDef<NavigationModel<E>> getModelContextEntry() {
- return modelContextEntry;
- }
-
- protected JAXXContextEntryDef<NavigationTreeHandler>
- getTreeHandlerContextEntry() {
- return handlerContextEntry;
- }
-
- protected JAXXContextEntryDef<List<Object>> getSelectedBeanContextEntry() {
- return selectedBeansContextEntry;
- }
-
- protected JAXXContextEntryDef<List<E>> getSelectedNodeContextEntry() {
- return selectedNodesContextEntry;
- }
-
- protected JAXXContextEntryDef<List<String>> getSelectedPathContextEntry() {
- return selectedPathsContextEntry;
- }
-
- protected JAXXContextEntryDef<JTree> getTreeContextEntry() {
- return treeContextEntry;
- }
-
- protected JAXXContextEntryDef<JXTreeTable> getTreeTableContextEntry() {
- return treeTableContextEntry;
- }
-
- protected <T> T getSelectedValue(JAXXContextEntryDef<List<T>> entry,
- JAXXContext context) {
- List<T> values = entry.getContextValue(context);
- T result = null;
- if (values != null && !values.isEmpty()) {
- if (values.size() > 1) {
- if (log.isWarnEnabled()) {
- log.warn("There is " + values.size() +
- " values selected, will return first one");
- }
- }
- result = values.get(0);
- }
- return result;
- }
-
- protected <T> void setSelectedValue(JAXXContextEntryDef<List<T>> entry,
- JAXXContext context,
- T value) {
- if (value == null) {
- entry.removeContextValue(context);
- } else {
- List<T> selecteds = new ArrayList<T>();
- selecteds.add(value);
- entry.setContextValue(context, selecteds);
- }
- }
-
- protected <T> void setSelectedValues(JAXXContextEntryDef<List<T>> entry,
- JAXXContext context,
- List<T> values) {
- if (values == null || values.isEmpty()) {
- entry.removeContextValue(context);
- } else {
- entry.setContextValue(context, values);
- }
- }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,342 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXAction;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.context.JAXXInitialContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultTreeSelectionModel;
-import javax.swing.tree.TreePath;
-import java.awt.*;
-import java.util.Arrays;
-
-/**
- * The handler of a navigation tree.
- * <p/>
- * This is also the selection model to use, since we must check before moving
- * from a node we can not just listen selection model changed, we must control
- * it.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.7.2
- */
-public abstract class NavigationTreeHandler<E extends NavigationNode<E>> extends DefaultTreeSelectionModel implements TreeSelectionListener {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger */
- static private final Log log = LogFactory.getLog(NavigationTreeHandler.class);
-
- /**
- * Strategy of instanciation of ui.
- * <p/>
- * For a given {@code node}, the method {@link #getId(NavigationNode)}
- * returns the id of ui to use.
- */
- public enum Strategy {
-
- /** instanciate a ui for a node */
- PER_NODE {
-
- @Override
- public String getId(NavigationNode<?> node) {
- return node.getFullPath();
- }
- },
- /**
- * instanciate only one a ui for a type,nodes will share the
- * instanciation
- */
- PER_UI_TYPE {
-
- @Override
- public String getId(NavigationNode<?> node) {
- return node.getUIClass().getName();
- }
- };
-
- public abstract String getId(NavigationNode<?> node);
- }
-
- /** UI which contains navigation tree */
- protected JAXXContext context;
-
- /** UI Instanciation strategy */
- protected Strategy strategy;
-
- /**
- * JAXXContext access helper.
- *
- * @since 1.7.2
- */
- protected NavigationTreeContextHelper<E> contextHelper;
-
- protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
- contextHelper = new NavigationTreeContextHelper<E>(contextPrefix);
- this.context = context;
- this.strategy = strategy;
- addTreeSelectionListener(this);
- }
-
- @Override
- public void valueChanged(TreeSelectionEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("Value changed for path : " + event.getPath());
- log.debug("Old lead selection path : " + event.getOldLeadSelectionPath());
- }
- if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
- // do not treate this if no path changed
- return;
- }
- E node = (E) event.getPath().getLastPathComponent();
- selectNodeUI(node);
- }
-
- /** @return le modèle de navigation associé */
- protected abstract NavigationModel<?> getNavigationTreeModel();
-
- /**
- * @return le composent actuellement visible associé au noeud courant ou au
- * noeud précédent lors d'un changement de noeud.
- */
- protected abstract Component getCurrentUI();
-
- /**
- * @param node le noeud associé à l'ui à retrouver
- * @return l'ui associé au novueau noeud sélectionné
- */
- protected abstract Component getUI(E node);
-
- /**
- * @param component le composent actuellement visible
- * @return <code>true</code> si le composent a bien été fermé,
- * <code>false</code> sinon
- * @throws Exception if any
- */
- protected abstract boolean closeUI(Component component) throws Exception;
-
- /**
- * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation
- *
- * @param node le noeud associé à l'ui à créer
- * @return la nouvelle ui associée au noeud
- * @throws Exception if any
- */
- protected abstract Component createUI(E node) throws Exception;
-
- /**
- * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation.
- *
- * @param newUI l'ui associé au noeud sélectionné à ouvrir
- * @param node le node de l'ui a ouvrir
- * @throws Exception if any
- */
- protected abstract void openUI(Component newUI, E node) throws Exception;
-
- /**
- * Traitement des exceptions.
- *
- * @param e l'erreur recontrée (ou null si pas d"erreur)
- */
- protected abstract void treateError(Exception e);
-
- public JAXXContext getContext() {
- return context;
- }
-
- public NavigationTreeContextHelper<E> getContextHelper() {
- return contextHelper;
- }
-
- @Override
- public void setSelectionPath(TreePath path) {
- if (path.equals(getSelectionPath())) {
- // stay on same node, can skip
- if (log.isDebugEnabled()) {
- log.debug("skip stay on path " + path);
- }
- return;
- }
- Component component = getCurrentUI();
-
- try {
- if (!closeUI(component)) {
- if (log.isDebugEnabled()) {
- log.debug("changing node canceled!");
- }
- // can not changed current node
- return;
- }
- if (component instanceof NavigationContentUI<?>) {
- ((NavigationContentUI<E>) component).closeUI((E) path.getLastPathComponent());
- }
- } catch (Exception ex) {
- treateError(ex);
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("will select path " + path);
- }
- // ok can safely select the new path
- super.setSelectionPath(path);
- }
-
- @Override
- public void setSelectionPaths(TreePath[] paths) {
- //FIXME-TC20100315 this can not work...
- // can't test like this paths as Array...
- if (Arrays.equals(paths, getSelectionPaths())) {
- // stay on same node, can skip
- if (log.isDebugEnabled()) {
- log.debug("skip stay on path " + Arrays.toString(paths));
- }
- return;
- }
- Component component = getCurrentUI();
-
- try {
- if (!closeUI(component)) {
- if (log.isDebugEnabled()) {
- log.debug("changing node canceled!");
- }
- // can not changed current node
- return;
- }
- if (component instanceof NavigationMultiContentUI<?>) {
- if (paths.length == 1) {
- NavigationTreeContextHelper<E> helper = getContextHelper();
- ((NavigationMultiContentUI<E>) component).closeUI(helper.getSelectedNodes(getContext()));
- }
- }
- } catch (Exception ex) {
- treateError(ex);
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("will select " + paths.length + " paths");
- }
- // ok can safely select the new path
- super.setSelectionPaths(paths);
- }
-
- protected void selectNodeUI(E node) {
-
- try {
-
- String path = node.getFullPath();
-
- if (log.isTraceEnabled()) {
- log.trace(path);
- }
-
- Component newUI = getUI(node);
-
- // now, we are free to open the ui associated with the selected node in navigation
-
- // get the bean associated with the node
- Object data = getNavigationTreeModel().getBean(path);
-
- // save it in context (must be done before init ui)
- addSelectedBeanInContext(node, data);
-
- if (newUI == null) {
-
- // a new ui instance is required
- newUI = createUI(node);
- }
-
- JAXXContext ctxt = getContext();
- NavigationTreeContextHelper<E> helper = getContextHelper();
-
- // save in context current node context path
- helper.setSelectedPath(ctxt, node.getFullPath());
-
- // save in context current node
- helper.setSelectedNode(ctxt, node);
-
- // save in context current ui
-// helper.setSelectedUI(ctxt, newUI);
-
- // really open the ui associated with the selected node
- // init ui before to be visible
- if (newUI instanceof NavigationContentUI<?>) {
- ((NavigationContentUI<E>) newUI).openUI(node);
- }
-
- // set ui in content
- openUI(newUI, node);
-
- } catch (Exception e) {
- // remove data from context
-
- // if any error, go back to previvous node
- treateError(e);
- }
- }
-
- /**
- * Prepare le context a utiliser pour initialiser une nouvelle ui.
- *
- * @param node le noeud associé à l'ui à créer
- * @return le context à utiliser pour instancier l'ui
- * @throws Exception if any
- */
- protected JAXXContext createUIContext(E node) throws Exception {
-
- if (node.getUIHandlerClass() == null) {
- if (log.isWarnEnabled()) {
- log.warn("no action associated with ui " + node.getUIClass());
- }
- // no action associated, just
- return getContext();
- }
-
- JAXXAction action = node.getUIHandlerClass().newInstance();
-
- // init context with
- JAXXInitialContext uiContext = action.init(getContext());
- return uiContext;
- }
-
- protected void addSelectedBeanInContext(E node, Object data) {
-
- if (log.isDebugEnabled()) {
- log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass()));
- }
- JAXXContext ctxt = getContext();
- NavigationTreeContextHelper<E> helper = getContextHelper();
-
- // remove previous selected bean
- //TODO-TC-20091004 should have an automatic clean context method while
- helper.setSelectedBean(ctxt, null);
-
- if (data != null) {
-
- helper.setSelectedBean(ctxt, data);
- }
- }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,131 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.swing.CardLayout2;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.*;
-import java.awt.*;
-import java.lang.reflect.Constructor;
-
-/**
- * Simple {@link NavigationTreeHandler} implementation with a {@link
- * CardLayout2} to manage components to associated with tree's nodes.
- * <p/>
- * For each node, the ui associated has a constraints in a cardlayout which is
- * the node context path.
- * <p/>
- * A single container managed by the cardlayout is used to display the
- * components associated with tree's nodes.
- *
- * @author chemit
- */
-public abstract class NavigationTreeHandlerWithCardLayout<E extends NavigationNode<E>> extends NavigationTreeHandler<E> {
-
- /** Logger */
- static private final Log log = LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class);
-
- /**
- * All components associated with a tree's node is displayed in a single
- * container.
- *
- * @return the containter of components
- */
- protected abstract JPanel getContentContainer();
-
- /**
- * the cardlayout managing components associated with tree node. The
- * constraints of each component is the node contextPath.
- *
- * @return the layout used to display components associated with tree's
- * nodes.
- */
- protected abstract CardLayout2 getContentLayout();
-
- public NavigationTreeHandlerWithCardLayout(String contextPrefix,
- JAXXObject context,
- Strategy strategy) {
- super(contextPrefix, context, strategy);
- if (getContentContainer() == null) {
- throw new IllegalArgumentException(
- "could not have a null 'contentContainer' in ui " + context);
- }
- if (getContentLayout() == null) {
- throw new IllegalArgumentException(
- "could not have a null 'contentLayout' in ui " + context);
- }
- }
-
- @Override
- protected Component getCurrentUI() {
- CardLayout2 layout = getContentLayout();
- JPanel container = getContentContainer();
- return layout.getVisibleComponent(container);
- }
-
- @Override
- protected Component getUI(E node) {
- CardLayout2 layout = getContentLayout();
- JPanel container = getContentContainer();
- String constraints = strategy.getId(node);
- return layout.contains(constraints) ?
- layout.getComponent(container, constraints) : null;
- }
-
- @Override
- protected void openUI(Component newUI, E node) throws
- Exception {
-
- CardLayout2 layout = getContentLayout();
- JPanel container = getContentContainer();
- // switch layout
- String constraints = strategy.getId(node);
- layout.show(container, constraints);
- }
-
- @Override
- protected boolean closeUI(Component component) throws Exception {
- // by default, we says that component was succesfull closed
- return true;
- }
-
- @Override
- protected Component createUI(E node) throws Exception {
-
- JAXXContext uiContext = createUIContext(node);
-
- Constructor<? extends JAXXObject> constructor =
- node.getUIClass().getConstructor(JAXXContext.class);
- JAXXObject newUI = constructor.newInstance(uiContext);
-
- if (log.isDebugEnabled()) {
- log.debug("instanciate new ui " + newUI);
- }
- String constraints = strategy.getId(node);
- getContentContainer().add((Component) newUI, constraints);
- return (Component) newUI;
- }
-}
-
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,37 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-/**
- * Helper object associated to a given navigation tree system.
- *
- * To helper is context safe (base on a {@link NavigationTreeContextHelper}.
- *
- * @author chemit
- * @since 1.7.2
- * @see NavigationTreeNodeModel
- */
-public abstract class NavigationTreeHelper extends AbstractNavigationHelper<NavigationTreeNode> {
-
- protected NavigationTreeHelper(String contextPrefix) {
- super(contextPrefix);
- }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,551 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXAction;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.jxpath.JXPathContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeNode;
-import java.util.Enumeration;
-
-/**
- * Node of the {@link NavigationTreeNodeModel}.
- * <p/>
- * Each node is associated with : <ul> <li> a {@code bean} coming from a {@link
- * JAXXContext} </li> <li> a {@code uiClass} to build the associated ui </li>
- * </ul>
- * <p/>
- * To retrieve the bean from the context, there is a huge logic in the method
- * {@link #getBean(JAXXContext)}.
- * <p/>
- * In few words, if the {@link #jaxxContextEntryDef} is defined, it means that
- * the object is taken from the {@code context}.
- * <p/>
- * Otherwise, find the first ancestor with an context entry and retrieve from
- * here the bean.
- * <p/>
- * Then go down to the initial node by applying the jxpath expressions {@link
- * #jaxxContextEntryPath} of each node on road back.
- * <p/>
- * <p/>
- * To identify easly a node, each node has a {@link #path} and a {@link
- * #fullPath} (full path from root node).
- * <p/>
- * <p/>
- * To display the node we use a {@link NavigationTreeNodeRenderer} which is in
- * fact the {@link #userObject}, the object can be synch with the bean via the
- * {@link NavigationTreeNodeRenderer#reload(Object)} method.
- *
- * @author chemit
- * @see NavigationTreeNodeModel
- * @see NavigationTreeNodeRenderer
- * @since 1.7.2
- */
-public class NavigationTreeNode extends DefaultMutableTreeNode implements NavigationNode<NavigationTreeNode> {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger */
- static private final Log log = LogFactory.getLog(NavigationTreeNode.class);
-
- /**
- * The path separator used to build the {@link #fullPath}.
- *
- * @see #path
- * @see #fullPath
- */
- protected final String pathSeparator;
-
- /**
- * The node path.
- * <p/>
- * Used to build the {@link #fullPath} which gives a unique identifier of
- * the node.
- *
- * @see #pathSeparator
- * @see #fullPath
- */
- protected String path;
-
- /**
- * The full path for the node from the rood node.
- * <p/>
- * This path is build by appending nodes {@link #path} from the root node to
- * this node, between each path we introduce the {@link #pathSeparator}.
- * <p/>
- * Exemple :
- * <pre>
- * root
- * $root
- * `-- child1
- * `-- child2
- * </pre>
- * will given {@code $root/child1/child2}.
- *
- * @see #pathSeparator
- * @see #path
- */
- protected String fullPath;
-
- /**
- * The UI class associated with the node.
- * <p/>
- * This class can be {@code null}, in that case, the {@link
- * NavigationTreeNodeModelBuilder#defaultUIClass} will be used while building
- * the model.
- */
- protected Class<? extends JAXXObject> uIClass;
-
- /**
- * The UI handler class associated with the node.
- * <p/>
- * This class can be {@code null}, in that case, the {@link
- * NavigationTreeNodeModelBuilder#defaultUIHandlerClass} will be used while
- * building the model.
- */
- protected Class<? extends JAXXAction> uIHandlerClass;
-
- /**
- * The context entry definition to retrieve the bean.
- * <p/>
- * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
- * node.
- */
- protected JAXXContextEntryDef<?> jaxxContextEntryDef;
-
- /**
- * The jxPath to process to obtain real {@code bean} from the data retrieve
- * in the context.
- * <p/>
- * <b>Note:</b> If not set -no jxpath will be apply on the bean from
- * context.
- */
- protected String jaxxContextEntryPath;
-
- /**
- * The bean associated with the node ( the value can be obtain via the
- * method {@link #getBean(JAXXContext)} or directly set via method {@link
- * #setBean(Object)}.
- * <p/>
- * cache of bean associated with bean to improve performance
- */
- protected transient Object bean;
-
- /**
- * The type of the related bean associated with the node.
- * <p/>
- * Note: This type is here to override the NodeRenderer internalClass, since
- * we could need to override this data.
- * <p/>
- * If this property is let to null, then we will use the NodeRenderer one
- */
- protected Class<?> internalClass;
-
- public NavigationTreeNode(String pathSeparator,
- String navigationPath,
- Object jaxxContextEntryDef) {
- this.pathSeparator = pathSeparator;
- path = navigationPath;
- if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
- this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef);
- } else if (jaxxContextEntryDef instanceof String) {
- jaxxContextEntryPath = (String) 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(String pathSeparator,
- String navigationPath,
- JAXXContextEntryDef<?> jaxxContextEntryDef,
- String jaxxContextEntryPath) {
- this.pathSeparator = pathSeparator;
- path = navigationPath;
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- this.jaxxContextEntryPath = jaxxContextEntryPath;
- }
-
- /** @return the text node renderer (store in {@link #userObject} property. */
- @Override
- public NavigationTreeNodeRenderer getRenderer() {
- NavigationTreeNodeRenderer render = null;
- Object o = getUserObject();
- if (o != null && o instanceof NavigationTreeNodeRenderer) {
- render = (NavigationTreeNodeRenderer) o;
- }
- return render;
- }
-
- @Override
- public void setRenderer(NavigationTreeNodeRenderer renderer) {
- // clear all cache
- bean = null;
- setUserObject(renderer);
- }
-
- @Override
- public String getPathSeparator() {
- return pathSeparator;
- }
-
- @Override
- public String getNodePath() {
- return path;
- }
-
- @Override
- public void setNodePath(String navigationPath) {
- path = navigationPath;
- }
-
- @Override
- public Class<? extends JAXXObject> getUIClass() {
- return uIClass;
- }
-
- @Override
- public void setUIClass(Class<? extends JAXXObject> uIClass) {
- this.uIClass = uIClass;
- }
-
- @Override
- public void setInternalClass(Class<?> internalClass) {
- this.internalClass = internalClass;
- }
-
- @Override
- public Class<? extends JAXXAction> getUIHandlerClass() {
- return uIHandlerClass;
- }
-
- @Override
- public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
- this.uIHandlerClass = uIHandlerClass;
- }
-
- @Override
- public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
- return jaxxContextEntryDef;
- }
-
- @Override
- public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- }
-
- @Override
- public String getJaxxContextEntryPath() {
- return jaxxContextEntryPath;
- }
-
- @Override
- public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
- this.jaxxContextEntryPath = jaxxContextEntryPath;
- }
-
- @Override
- public Class<?> getInternalClass() {
- if (internalClass == null && getRenderer() != null) {
- return getRenderer().getInternalClass();
- }
- return internalClass;
- }
-
- /** @return the fully context path of the node from the root node to this. */
- @Override
- public String getFullPath() {
- if (fullPath == null) {
- StringBuilder sb = new StringBuilder();
- for (TreeNode treeNode : getPath()) {
- NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
- sb.append(pathSeparator).append(myNode.getNodePath());
- }
- fullPath = sb.substring(1);
- }
- return fullPath;
- }
-
- @Override
- public NavigationTreeNode getChildAt(int index) {
- return (NavigationTreeNode) super.getChildAt(index);
- }
-
- @Override
- public NavigationTreeNode getParent() {
- return (NavigationTreeNode) super.getParent();
- }
-
- /**
- * @param path the name of the {@link #path} to be matched in the child of
- * this node.
- * @return the child of this node with given {@link #path} value.
- */
- @Override
- public NavigationTreeNode getChild(String path) {
- Enumeration<? extends NavigationTreeNode> childs = children();
- while (childs.hasMoreElements()) {
- NavigationTreeNode son = childs.nextElement();
- if (path.equals(son.getNodePath())) {
- return son;
- }
- }
- return null;
- }
-
- @Override
- public Object getBean() {
- return bean;
- }
-
- @Override
- public void setBean(Object bean) {
- this.bean = bean;
- }
-
- @Override
- public void reload(JAXXContext context) {
-
- // clear bean cache
- bean = null;
-
- // clear context navigation cache
- fullPath = null;
-
- NavigationTreeNodeRenderer renderer = getRenderer();
- if (renderer == null) {
- // this can't be !
- throw new NullPointerException(
- "could not find the renderer for node " + this);
- }
-
- String s = getFullPath();
- Object b = null;
- try {
- b = getBean(context);
- } finally {
- if (log.isInfoEnabled()) {
- log.info("bean for path [" + s + "] = " + bean);
- }
- }
-
- renderer.reload(b);
- }
-
- /**
- * 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
- */
- @Override
- public Object getBean(JAXXContext context) {
- if (bean != null) {
- // use cached bean
- return bean;
- }
- Object result;
- if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
- // the node maps directly a value in context, with no jxpath resolving
- result = getJaxxContextEntryDef().getContextValue(context);
- // save in cache
- setBean(result);
- 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);
- if (parentBean == null) {
- // must be an error no bean found
- log.warn("could not find a bean attached in context from context" +
- " entry definition " + parentNode.getJaxxContextEntryDef());
- return null;
- }
- if (parentNode.jaxxContextEntryPath != null) {
- // apply the jxpath on parentBean
- JXPathContext jxcontext = JXPathContext.newContext(parentBean);
- parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
- }
- // save in cache
- parentNode.setBean(parentBean);
- if (parentNode.equals(this)) {
- // current node is the node matching the context entry value and
- // no jxpath is found
- 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;
- }
- if (log.isDebugEnabled()) {
- log.debug("jxpath : " + jxpathExpression);
- }
- JXPathContext jxcontext = JXPathContext.newContext(parentBean);
- result = jxcontext.getValue(jxpathExpression);
- // save in cache
- setBean(result);
- return result;
- }
-
- @Override
- public void insert(NavigationTreeNode child, int index) {
- super.insert(child, index);
- }
-
- @Override
- public void remove(NavigationTreeNode node) {
- super.remove(node);
- }
-
- @Override
- public void setParent(NavigationTreeNode newParent) {
- super.setParent(newParent);
- }
-
- @Override
- public int getIndex(NavigationTreeNode node) {
- return super.getIndex(node);
- }
-
- @Override
- public Enumeration<? extends NavigationTreeNode> children() {
- return super.children();
- }
-
- /**
- * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
- * or <code>null</code> if none find..
- */
- protected NavigationTreeNode getFirstAncestorWithDef() {
- if (jaxxContextEntryDef != null) {
- // find a node with a direct link with the context
- return this;
- }
- // the node is not linked to context
- // seek in his parent
- NavigationTreeNode ancestor = getParent();
- return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
- }
-
- protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
- if (equals(parentNode)) {
- // 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;
- }
- // 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
- public void add(NavigationTreeNode node) {
- super.add(node);
- }
-
-
- @Override
- public NavigationTreeNode[] getPath() {
- TreeNode[] treeNodes = super.getPath();
- NavigationTreeNode[] result = new NavigationTreeNode[treeNodes.length];
- System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
- return result;
- }
-
- @Override
- public NavigationTreeNode[] getPathToRoot(NavigationTreeNode aNode, int depth) {
- TreeNode[] treeNodes = super.getPathToRoot(aNode, depth);
- NavigationTreeNode[] result = new NavigationTreeNode[treeNodes.length];
- System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
- return result;
- }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModel.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModel.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,99 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreeNode;
-
-/**
- * Model of the tree used for a navigation tree.
- * <p/>
- * Il est composé de {@link NavigationTreeNode}
- *
- * @author chemit
- * @since 1.7.2
- */
-public class NavigationTreeNodeModel extends AbstractNavigationModel<NavigationTreeNode> implements TreeModel {
-
- /** Logger */
- private static final Log log =
- LogFactory.getLog(NavigationTreeNodeModel.class);
-
-// private static final long serialVersionUID = 1L;
-
- public NavigationTreeNodeModel(String pathSeparator, JAXXContext context) {
- super(new DefaultTreeModel(null), pathSeparator, context);
- }
-//
-// @Override
-// public NavigationTreeNode getRoot() {
-// return (NavigationTreeNode) delegate.getRoot();
-// }
-
- @Override
- public void setRoot(NavigationTreeNode root) {
- getDelegate().setRoot(root);
- }
-
- public DefaultTreeModel getDelegate() {
- return (DefaultTreeModel) delegate;
- }
-
- @Override
- public NavigationTreeNode[] getPathToRoot(NavigationTreeNode aNode) {
- TreeNode[] treeNodes = getDelegate().getPathToRoot(aNode);
- NavigationTreeNode[] result = new NavigationTreeNode[treeNodes.length];
- System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
- return result;
- }
-
- @Override
- public void removeNodeFromParent(NavigationTreeNode node) {
- getDelegate().removeNodeFromParent(node);
- }
-
- @Override
- public void nodeStructureChanged(NavigationTreeNode node) {
- NavigationTreeNode n = node;
- //TC-20091004 never launch a deep reload
- reload(n, true);
- getDelegate().nodeStructureChanged(node);
- if (log.isDebugEnabled()) {
- log.debug(node);
- }
- }
-
- @Override
- public void nodeChanged(NavigationTreeNode node, boolean deep) {
-
- NavigationTreeNode n = node;
- //TC-20091004 never launch a deep clean, since we do a deep nodeChanged.
- reload(n, deep);
- getDelegate().nodeChanged(node);
- }
-
-
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModelBuilder.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModelBuilder.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,90 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXAction;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This object is design to build a {@link NavigationTreeNodeModel}.
- *
- * @author chemit
- * @see NavigationModelBuilder
- * @since 17.2
- */
-public class NavigationTreeNodeModelBuilder extends AbstractNavigationModelBuilder<NavigationTreeNode> {
-
- /** Logger */
- static private final Log log =
- LogFactory.getLog(NavigationTreeNodeModelBuilder.class);
-
- public NavigationTreeNodeModelBuilder(
- String pathSeparator,
- JAXXContext context,
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass) {
- this(defaultUIClass,
- defaultUIHandlerClass,
- new NavigationTreeNodeModel(pathSeparator, context)
- );
- }
-
- @Override
- public NavigationTreeNodeModel getModel() {
- return (NavigationTreeNodeModel) super.getModel();
- }
-
- public NavigationTreeNodeModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationTreeNodeModel model) {
- super(defaultUIClass, defaultUIHandlerClass, model);
- }
-
- @Override
- public NavigationTreeNode createNavigationTreeNode(
- String pathSeparator,
- String contextName,
- JAXXContextEntryDef<?> jaxxContextEntryDef,
- String jaxxContextEntryPath) {
- return new NavigationTreeNode(
- pathSeparator,
- contextName,
- jaxxContextEntryDef,
- jaxxContextEntryPath
- );
- }
-
-// // TODO : to remove
-// /**
-// * @deprecated please use NavigationModel for return type
-// * @return the tree model
-// */
-// @Override
-// @Deprecated
-// public NavigationTreeNodeModel getModel() {
-// return (NavigationTreeNodeModel)super.getModel();
-// }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,65 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import javax.swing.tree.TreeCellRenderer;
-import java.io.Serializable;
-
-/**
- * Text Renderer of a {@link NavigationNode}.
- * <p/>
- * This object will be placed as the {@link NavigationTreeNode#getUserObject()} of
- * nodes.
- * <p/>
- *
- * In that way, we can use the {@link #toString()} value to render the node
- * without writing any {@link TreeCellRenderer}.
- * <p/>
- * To rebuild the renderer text of a node use the method {@link #reload(Object)}
- * with the {@code bean} provides by the model for the node.
- *
- * @author chemit
- * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
- */
-public interface NavigationTreeNodeRenderer extends Serializable {
-
- /**
- *
- * @return the render value of the node
- */
- @Override
- String toString();
-
- /**
- *
- * Can override the the node internal class for display purpose.
- *
- * @return the type of data to be displayed.
- */
- Class<?> getInternalClass();
-
- /**
- * Reload the render value from the {@code bean} of node.
- *
- * @param bean the bean associated to the node to render
- */
- void reload(Object bean);
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,71 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.decorator.Decorator;
-
-/**
- * Decorator Renderer of a {@link NavigationTreeNode}.
- * <p/>
- * Apply a {@link Decorator} to the {@code bean} associated to the node.
- *
- * @author chemit
- * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear
- * soon...
- */
-public class NavigationTreeNodeRendererDecoratorImpl implements NavigationTreeNodeRenderer {
-
- private static final long serialVersionUID = -1L;
-
- /** Decorator */
- protected final Decorator<?> decorator;
-
- /** internal class of representing data */
- protected final Class<?> internalClass;
-
- /** last renderered value */
- protected String text;
-
- public NavigationTreeNodeRendererDecoratorImpl(Decorator<?> decorator) {
- internalClass = decorator.getInternalClass();
- this.decorator = decorator;
- }
-
- @Override
- public String toString() {
- return text;
- }
-
- @Override
- public void reload(Object bean) {
- try {
- text = decorator.toString(bean);
-
- } catch (Exception e) {
- text = "";
- }
- }
-
- @Override
- public Class<?> getInternalClass() {
- return internalClass;
- }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,68 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * I18n label Renderer of a {@link NavigationTreeNode}.
- *
- * Just apply a i18n translation on the given {@link #libelle}.
- *
- * @author chemit
- * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
- */
-public class NavigationTreeNodeRendererI18nImpl implements NavigationTreeNodeRenderer {
-
- private static final long serialVersionUID = -1L;
- /**
- * Static i18n label to render
- */
- protected final String libelle;
- /**
- * internal class of representing data
- */
- protected final Class<?> internalClass;
- /**
- * last renderered value
- */
- protected String text;
-
- public NavigationTreeNodeRendererI18nImpl(String libelle) {
- this.libelle = libelle;
- internalClass = String.class;
- }
-
- @Override
- public String toString() {
- return text;
- }
-
- @Override
- public void reload(Object data) {
- text = _(libelle);
- }
-
- @Override
- public Class<?> getInternalClass() {
- return internalClass;
- }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModel.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModel.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,328 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.tree.TreeModelSupport;
-import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
-import org.jdesktop.swingx.treetable.TreeTableModel;
-
-import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreePath;
-import java.util.List;
-
-/**
- * Model of the tree table used for a navigation tree table.
- * <p/>
- * Il est composé de {@link NavigationTreeNode}
- * <p/>
- * FIXME : Essayer d'enlever les copier coller {@link NavigationTreeNodeModel}
- *
- * @author sletellier
- * @since 2.0.0
- */
-public class NavigationTreeTableModel extends AbstractNavigationModel<NavigationTreeTableNode> implements TreeTableModel {
-
-// static private final long serialVersionUID = 1L;
-
- /** Logger */
- static private final Log log =
- LogFactory.getLog(NavigationTreeTableModel.class);
-
- public static class MyDefaultTreeTableModel extends DefaultTreeTableModel {
-
- public TreeModelSupport getModelSupport() {
- return modelSupport;
- }
- }
-
-// /**
-// * The path separator used to build the {@link NavigationTreeNode#fullPath}.
-// *
-// * @see NavigationTreeNode#getNodePath()
-// * @see NavigationTreeNode#getFullPath()
-// */
-// protected final String pathSeparator;
-//
-// /** Context to retrieve beans */
-// private JAXXContext context;
-
- protected List<String> columnsName;
-
- public NavigationTreeTableModel(String pathSeparator, JAXXContext context, List<String> columnsName) {
- super(new MyDefaultTreeTableModel(), pathSeparator, context);
-// this.pathSeparator = pathSeparator;
-// this.context = context;
- this.columnsName = columnsName;
- }
-
-
- public MyDefaultTreeTableModel getDelegate() {
- return (MyDefaultTreeTableModel) delegate;
- }
-
-// @Override
-// public NavigationTreeTableNode getRoot() {
-// return (NavigationTreeTableNode) getDelegate().getRoot();
-// }
-
- @Override
- public NavigationTreeTableNode[] getPathToRoot(NavigationTreeTableNode aNode) {
- if (aNode == null) {
- return null;
- }
- TreeNode[] treeNodes = getDelegate().getPathToRoot(aNode);
- NavigationTreeTableNode[] result = new NavigationTreeTableNode[treeNodes.length];
- System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
- return result;
-
- }
-
- @Override
- public void setRoot(NavigationTreeTableNode root) {
- getDelegate().setRoot(root);
-// this.root = root;
- getModelSupport().fireNewRoot();
- }
-
- /**
- * Message this to remove node from its parent. This will message
- * nodesWereRemoved to create the appropriate event. This is the preferred
- * way to remove a node as it handles the event creation for you.
- */
- @Override
- public void removeNodeFromParent(NavigationTreeTableNode node) {
- NavigationTreeTableNode parent = node.getParent();
-
- if (parent == null) {
- throw new IllegalArgumentException("node does not have a parent.");
- }
-
- int index = parent.getIndex(node);
- node.removeFromParent();
- getModelSupport().fireChildRemoved(new TreePath(getPathToRoot(parent)),
- index, node);
- }
-
-// @Override
-// public NavigationTreeTableNode findNode(String path) {
-// return findNode(getRoot(), path, (Pattern) null);
-// }
-//
-// @Override
-// public NavigationTreeTableNode findNode(String path, String regex) {
-// return findNode(getRoot(), path, regex);
-// }
-//
-// @Override
-// public NavigationTreeTableNode findNode(String path, Pattern regex) {
-// return findNode(getRoot(), path, regex);
-// }
-//
-// @Override
-// public NavigationTreeTableNode findNode(NavigationTreeTableNode root,
-// String path) {
-// return findNode(root, path, (Pattern) null);
-// }
-//
-// @Override
-// public NavigationTreeTableNode findNode(NavigationTreeTableNode root,
-// String path,
-// String regex) {
-// return findNode(root, path, regex == null ?
-// null : Pattern.compile(regex));
-// }
-//
-// @Override
-// public NavigationTreeTableNode findNode(NavigationTreeTableNode 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);
-// if (log.isDebugEnabled()) {
-// log.debug("matching regex " + regex + " : " + path);
-// }
-// }
-// StringTokenizer stk = new StringTokenizer(path, pathSeparator);
-// NavigationTreeTableNode result = root;
-// // pas the first token (matches the root node)
-// if (root.isRoot() && stk.hasMoreTokens()) {
-// String rootPath = stk.nextToken();
-// if (!rootPath.equals(root.getNodePath())) {
-// return null;
-// }
-// }
-// while (stk.hasMoreTokens()) {
-// result = result.getChild(stk.nextToken());
-// }
-// return result;
-// }
-//
-// @Override
-// public JAXXContext getContext() {
-// return context;
-// }
-//
-// @Override
-// public Object getBean(String navigationPath) {
-// Object result;
-// NavigationTreeTableNode node = findNode(navigationPath, (Pattern) null);
-// result = getBean(node);
-// return result;
-// }
-//
-// @Override
-// public Object getBean(NavigationTreeTableNode node) {
-// if (node == null) {
-// return null;
-// //fixme should throw a NPE exception
-// //throw new NullPointerException("node can not be null");
-// }
-// return node.getBean(getContext());
-// }
-
-
- /**
- * Accessor to tree model support.
- *
- * @return tree model support
- */
- protected TreeModelSupport getModelSupport() {
- return getDelegate().getModelSupport();
- }
-
-// @Override
-// public void nodeChanged(NavigationTreeTableNode node) {
-// if (node != null) {
-// NavigationTreeTableNode parent = node.getParent();
-// NavigationTreeTableNode[] treeNodes = getPathToRoot(parent);
-// if (treeNodes != null) {
-// getModelSupport().fireChildChanged(
-// new TreePath(treeNodes), parent.getIndex(node), node);
-// } else {
-// log.error("[Node changed] Path to root is null !");
-// }
-// reload((NavigationTreeTableNode) node, true);
-// } else {
-// log.error("Node is null !");
-// }
-// }
-
- @Override
- public void nodeStructureChanged(NavigationTreeTableNode node) {
- if (node != null) {
- NavigationTreeTableNode parent = node.getParent();
- TreeNode[] treeNodes = getPathToRoot(parent);
- if (treeNodes != null) {
- getModelSupport().fireTreeStructureChanged(new TreePath(treeNodes));
- } else {
- log.error("[Node structure changed] Path to root is null !");
- }
- reload(node, true);
- } else {
- log.error("Node is null !");
- }
- }
-
- @Override
- public void nodeChanged(NavigationTreeTableNode node, boolean deep) {
- if (node != null) {
- NavigationTreeTableNode parent = node.getParent();
- TreeNode[] treeNodes = getPathToRoot(parent);
- if (treeNodes != null) {
- getModelSupport().fireChildChanged(
- new TreePath(treeNodes), parent.getIndex(node), node);
- } else {
- log.error("[Node changed] Path to root is null !");
- }
- reload(node, deep);
- } else {
- log.error("Node is null !");
- }
- }
-//
-// @Override
-// public String getPathSeparator() {
-// return pathSeparator;
-// }
-
- @Override
- public Class<?> getColumnClass(int i) {
- return getDelegate().getColumnClass(i);
- }
-
- @Override
- public int getColumnCount() {
- return columnsName.size();
- }
-
- @Override
- public String getColumnName(int column) {
- return columnsName.get(column);
- }
-
- @Override
- public int getHierarchicalColumn() {
- return getDelegate().getHierarchicalColumn();
- }
-
- @Override
- public Object getValueAt(Object o, int i) {
- return getDelegate().getValueAt(o, i);
- }
-
- @Override
- public boolean isCellEditable(Object o, int i) {
- return getDelegate().isCellEditable(o, i);
- }
-
- @Override
- public void setValueAt(Object o, Object o1, int i) {
- getDelegate().setValueAt(o, o1, i);
- }
-//
-// protected void reload(NavigationTreeTableNode node) {
-// reload(node, false);
-// }
-//
-// protected void reload(NavigationTreeTableNode node, boolean deep) {
-// if (node == null) {
-// return;
-// }
-// node.reload(getContext());
-//
-// if (deep) {
-// Enumeration<?> childs = node.children();
-// while (childs.hasMoreElements()) {
-// NavigationTreeTableNode o = (NavigationTreeTableNode) childs.nextElement();
-// reload(o, true);
-// }
-// }
-// }
-
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModelBuilder.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModelBuilder.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModelBuilder.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,29 +0,0 @@
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXAction;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.context.JAXXContextEntryDef;
-
-public class NavigationTreeTableModelBuilder extends AbstractNavigationModelBuilder<NavigationTreeTableNode> {
-
- public NavigationTreeTableModelBuilder(
- Class<? extends JAXXObject> defaultUIClass,
- Class<? extends JAXXAction> defaultUIHandlerClass,
- NavigationModel<NavigationTreeTableNode> model) {
- super(defaultUIClass, defaultUIHandlerClass, model);
- }
-
- @Override
- public NavigationTreeTableNode createNavigationTreeNode(
- String pathSeparator,
- String contextName,
- JAXXContextEntryDef<?> jaxxContextEntryDef,
- String jaxxContextEntryPath) {
- return new NavigationTreeTableNode(
- pathSeparator,
- contextName,
- jaxxContextEntryDef,
- jaxxContextEntryPath
- );
- }
-}
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableNode.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableNode.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableNode.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,568 +0,0 @@
-/*
- * *##%
- * JAXX Runtime
- * Copyright (C) 2008 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.JAXXAction;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.jxpath.JXPathContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
-
-import javax.swing.tree.TreeNode;
-import java.util.Enumeration;
-
-/**
- * Node of the {@link NavigationTreeTableModel}.
- *
- * @author sletellier
- * @see NavigationTreeNode
- * @since 2.0.0
- */
-public class NavigationTreeTableNode extends DefaultMutableTreeTableNode implements NavigationNode<NavigationTreeTableNode> {
-//public abstract class NavigationTreeTableNode extends NavigationTreeNode implements TreeTableNode, NavigationNode<NavigationTreeTableNode> {
-
- private static final long serialVersionUID = -1L;
-
- /** Logger */
- private static final Log log =
- LogFactory.getLog(NavigationTreeTableNode.class);
-
- /**
- * The path separator used to build the {@link #fullPath}.
- *
- * @see #path
- * @see #fullPath
- */
- protected final String pathSeparator;
-
- /**
- * The node path.
- * <p/>
- * Used to build the {@link #fullPath} which gives a unique identifier of
- * the node.
- *
- * @see #pathSeparator
- * @see #fullPath
- */
- protected String path;
-
- /**
- * The full path for the node from the rood node.
- * <p/>
- * This path is build by appending nodes {@link #path} from the root node to
- * this node, between each path we introduce the {@link #pathSeparator}.
- * <p/>
- * Exemple :
- * <pre>
- * root
- * $root
- * `-- child1
- * `-- child2
- * </pre>
- * will given {@code $root/child1/child2}.
- *
- * @see #pathSeparator
- * @see #path
- */
- protected String fullPath;
-
- /**
- * The UI class associated with the node.
- * <p/>
- * This class can be {@code null}, in that case, the {@link
- * NavigationTreeNodeModelBuilder#defaultUIClass} will be used while building
- * the model.
- */
- protected Class<? extends JAXXObject> uIClass;
-
- /**
- * The UI handler class associated with the node.
- * <p/>
- * This class can be {@code null}, in that case, the {@link
- * NavigationTreeNodeModelBuilder#defaultUIHandlerClass} will be used while
- * building the model.
- */
- protected Class<? extends JAXXAction> uIHandlerClass;
-
- /**
- * The context entry definition to retrieve the bean.
- * <p/>
- * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
- * node.
- */
- protected JAXXContextEntryDef<?> jaxxContextEntryDef;
-
- /**
- * The jxPath to process to obtain real {@code bean} from the data retrieve
- * in the context.
- * <p/>
- * <b>Note:</b> If not set -no jxpath will be apply on the bean from
- * context.
- */
- protected String jaxxContextEntryPath;
-
- /**
- * The bean associated with the node ( the value can be obtain via the
- * method {@link #getBean(JAXXContext)} or directly set via method {@link
- * #setBean(Object)}.
- * <p/>
- * cache of bean associated with bean to improve performance
- */
- protected transient Object bean;
-
- /**
- * The type of the related bean associated with the node.
- * <p/>
- * Note: This type is here to override the NodeRenderer internalClass, since
- * we could need to override this data.
- * <p/>
- * If this property is let to null, then we will use the NodeRenderer one
- */
- protected Class<?> internalClass;
-
-// public NavigationTreeTableNode(String pathSeparator,
-// String navigationPath,
-// Object jaxxContextEntryDef) {
-// super(pathSeparator, navigationPath, jaxxContextEntryDef);
-// }
-//
-// public NavigationTreeTableNode(String pathSeparator,
-// String navigationPath,
-// JAXXContextEntryDef<?> jaxxContextEntryDef,
-// String jaxxContextEntryPath) {
-// super(pathSeparator,
-// navigationPath,
-// jaxxContextEntryDef,
-// jaxxContextEntryPath
-// );
-// }
-
- public NavigationTreeTableNode(String pathSeparator,
- String navigationPath,
- Object jaxxContextEntryDef) {
- this.pathSeparator = pathSeparator;
- path = navigationPath;
- if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
- this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef);
- } else if (jaxxContextEntryDef instanceof String) {
- jaxxContextEntryPath = (String) 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 NavigationTreeTableNode(String pathSeparator,
- String navigationPath,
- JAXXContextEntryDef<?> jaxxContextEntryDef,
- String jaxxContextEntryPath) {
- this.pathSeparator = pathSeparator;
- path = navigationPath;
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- this.jaxxContextEntryPath = jaxxContextEntryPath;
- }
-
- /** @return the text node renderer (store in {@link #userObject} property. */
- @Override
- public NavigationTreeNodeRenderer getRenderer() {
- NavigationTreeNodeRenderer render = null;
- Object o = getUserObject();
- if (o != null && o instanceof NavigationTreeNodeRenderer) {
- render = (NavigationTreeNodeRenderer) o;
- }
- return render;
- }
-
- @Override
- public void setRenderer(NavigationTreeNodeRenderer renderer) {
- // clear all cache
- bean = null;
- setUserObject(renderer);
- }
-
- @Override
- public String getPathSeparator() {
- return pathSeparator;
- }
-
- @Override
- public String getNodePath() {
- return path;
- }
-
- @Override
- public void setNodePath(String navigationPath) {
- path = navigationPath;
- }
-
- @Override
- public Class<? extends JAXXObject> getUIClass() {
- return uIClass;
- }
-
- @Override
- public void setUIClass(Class<? extends JAXXObject> uIClass) {
- this.uIClass = uIClass;
- }
-
- @Override
- public void setInternalClass(Class<?> internalClass) {
- this.internalClass = internalClass;
- }
-
- @Override
- public Class<? extends JAXXAction> getUIHandlerClass() {
- return uIHandlerClass;
- }
-
- @Override
- public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
- this.uIHandlerClass = uIHandlerClass;
- }
-
- @Override
- public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
- return jaxxContextEntryDef;
- }
-
- @Override
- public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- }
-
- @Override
- public String getJaxxContextEntryPath() {
- return jaxxContextEntryPath;
- }
-
- @Override
- public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
- this.jaxxContextEntryPath = jaxxContextEntryPath;
- }
-
- @Override
- public Class<?> getInternalClass() {
- if (internalClass == null && getRenderer() != null) {
- return getRenderer().getInternalClass();
- }
- return internalClass;
- }
-
- /** @return the fully context path of the node from the root node to this. */
- @Override
- public String getFullPath() {
- if (fullPath == null) {
- StringBuilder sb = new StringBuilder();
- for (TreeNode treeNode : getPath()) {
- NavigationTreeTableNode myNode = (NavigationTreeTableNode) treeNode;
- sb.append(pathSeparator).append(myNode.getNodePath());
- }
- fullPath = sb.substring(1);
- }
- return fullPath;
- }
-
- /**
- * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
- * or <code>null</code> if none find..
- */
- protected NavigationTreeTableNode getFirstAncestorWithDef() {
- if (jaxxContextEntryDef != null) {
- // find a node with a direct link with the context
- return this;
- }
- // the node is not linked to context
- // seek in his parent
- NavigationTreeTableNode ancestor = getParent();
- return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
- }
-
- protected String computeJXPath(String expr, NavigationTreeTableNode parentNode) {
- if (equals(parentNode)) {
- // 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);
- }
- NavigationTreeTableNode 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;
- }
- // 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
- public Object getBean() {
- return bean;
- }
-
- @Override
- public void setBean(Object bean) {
- this.bean = bean;
- }
-
- @Override
- public void reload(JAXXContext context) {
-
- // clear bean cache
- bean = null;
-
- // clear context navigation cache
- fullPath = null;
-
- NavigationTreeNodeRenderer renderer = getRenderer();
- if (renderer == null) {
- // this can't be !
- throw new NullPointerException(
- "could not find the renderer for node " + this);
- }
-
- String s = getFullPath();
- Object b = null;
- try {
- b = getBean(context);
- } finally {
- if (log.isInfoEnabled()) {
- log.info("bean for path [" + s + "] = " + bean);
- }
- }
-
- renderer.reload(b);
- }
-
- /**
- * 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
- */
- @Override
- public Object getBean(JAXXContext context) {
- if (bean != null) {
- // use cached bean
- return bean;
- }
- Object result;
- if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
- // the node maps directly a value in context, with no jxpath resolving
- result = getJaxxContextEntryDef().getContextValue(context);
- // save in cache
- setBean(result);
- return result;
- }
- // find the first ancestor node with a context def
- NavigationTreeTableNode 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);
- if (parentBean == null) {
- // must be an error no bean found
- log.warn("could not find a bean attached in context from context" +
- " entry definition " + parentNode.getJaxxContextEntryDef());
- return null;
- }
- if (parentNode.jaxxContextEntryPath != null) {
- // apply the jxpath on parentBean
- JXPathContext jxcontext = JXPathContext.newContext(parentBean);
- parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
- }
- // save in cache
- parentNode.setBean(parentBean);
- if (parentNode.equals(this)) {
- // current node is the node matching the context entry value and
- // no jxpath is found
- 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;
- }
- if (log.isDebugEnabled()) {
- log.debug("jxpath : " + jxpathExpression);
- }
- JXPathContext jxcontext = JXPathContext.newContext(parentBean);
- result = jxcontext.getValue(jxpathExpression);
- // save in cache
- setBean(result);
- return result;
- }
-
-
- @Override
- public NavigationTreeTableNode getChildAt(int index) {
- return (NavigationTreeTableNode) super.getChildAt(index);
- }
-
- @Override
- public NavigationTreeTableNode getParent() {
- return (NavigationTreeTableNode) super.getParent();
- }
-
- @Override
- public NavigationTreeTableNode getChild(String path) {
- Enumeration<?> childs = children();
- while (childs.hasMoreElements()) {
- NavigationTreeTableNode son =
- (NavigationTreeTableNode) childs.nextElement();
- if (path.equals(son.getNodePath())) {
- return son;
- }
- }
- return null;
- }
-
- @Override
- public Enumeration<? extends NavigationTreeTableNode> children() {
- return (Enumeration<? extends NavigationTreeTableNode>) super.children();
- }
-
- @Override
- public void insert(NavigationTreeTableNode child, int index) {
- super.insert(child, index);
- }
-
- @Override
- public void remove(NavigationTreeTableNode node) {
- super.remove(node);
- }
-
- @Override
- public void setParent(NavigationTreeTableNode newParent) {
- super.setParent(newParent);
- }
-
- @Override
- public int getIndex(NavigationTreeTableNode node) {
- return super.getIndex(node);
- }
-
- @Override
- public void add(NavigationTreeTableNode node) {
- super.add(node);
- }
-
- @Override
- public NavigationTreeTableNode[] getPath() {
- return getPathToRoot(this, 0);
- }
-
- @Override
- public NavigationTreeTableNode[] getPathToRoot(NavigationTreeTableNode aNode, int depth) {
- NavigationTreeTableNode[] retNodes;
-
- /* Check for null, in case someone passed in a null node, or
- they passed in an element that isn't rooted at root. */
- if (aNode == null) {
- if (depth == 0) {
- return null;
- } else {
- retNodes = new NavigationTreeTableNode[depth];
- }
- } else {
- depth++;
- retNodes = getPathToRoot(aNode.getParent(), depth);
- retNodes[retNodes.length - depth] = aNode;
- }
- return retNodes;
- }
-
- @Override
- public boolean isRoot() {
- return getParent() == null;
- }
-
- //
-// @Override
-// public abstract Object getValueAt(int column);
-//
-// @Override
-// public abstract int getColumnCount();
-//
-// @Override
-// public abstract boolean isEditable(int column);
-//
-// @Override
-// public abstract void setValueAt(Object aValue, int column);
-}
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/AbstractNavigationHandler.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/AbstractNavigationHandler.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/AbstractNavigationHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,273 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.handler;
+
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.navigation.NavigationContentUI;
+import jaxx.runtime.swing.navigation.NavigationContextHelper;
+import jaxx.runtime.swing.navigation.NavigationMultiContentUI;
+import jaxx.runtime.swing.navigation.NavigationNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.util.Arrays;
+
+/**
+ * The handler of a navigation tree.
+ * <p/>
+ * This is also the selection model to use, since we must check before moving
+ * from a node we can not just listen selection model changed, we must control
+ * it.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.7.2
+ */
+public abstract class AbstractNavigationHandler<E extends NavigationNode<E>> extends DefaultTreeSelectionModel implements NavigationHandler<E> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger */
+ static private final Log log =
+ LogFactory.getLog(AbstractNavigationHandler.class);
+
+ /** UI which contains navigation tree */
+ protected JAXXContext context;
+
+ /** UI Instanciation strategy */
+ protected Strategy strategy;
+
+ /**
+ * JAXXContext access helper.
+ *
+ * @since 1.7.2
+ */
+ protected NavigationContextHelper<E> contextHelper;
+
+ protected AbstractNavigationHandler(String contextPrefix,
+ JAXXObject context,
+ Strategy strategy) {
+ contextHelper = new NavigationContextHelper<E>(contextPrefix);
+ this.context = context;
+ this.strategy = strategy;
+ addTreeSelectionListener(this);
+ }
+
+ @Override
+ public void valueChanged(TreeSelectionEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("Value changed for path : " + event.getPath());
+ log.debug("Old lead selection path : " +
+ event.getOldLeadSelectionPath());
+ }
+ if (event.getOldLeadSelectionPath() != null &&
+ event.getOldLeadSelectionPath().equals(event.getPath())) {
+ // do not treate this if no path changed
+ return;
+ }
+ E node = (E) event.getPath().getLastPathComponent();
+ selectNodeUI(node);
+ }
+
+ @Override
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ @Override
+ public NavigationContextHelper<E> getContextHelper() {
+ return contextHelper;
+ }
+
+ @Override
+ public void setSelectionPath(TreePath path) {
+ if (path.equals(getSelectionPath())) {
+ // stay on same node, can skip
+ if (log.isDebugEnabled()) {
+ log.debug("skip stay on path " + path);
+ }
+ return;
+ }
+ Component component = getCurrentUI();
+
+ try {
+ if (!closeUI(component)) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing node canceled!");
+ }
+ // can not changed current node
+ return;
+ }
+ if (component instanceof NavigationContentUI<?>) {
+ ((NavigationContentUI<E>) component).closeUI((E) path.getLastPathComponent());
+ }
+ } catch (Exception ex) {
+ treateError(ex);
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will select path " + path);
+ }
+ // ok can safely select the new path
+ super.setSelectionPath(path);
+ }
+
+ @Override
+ public void setSelectionPaths(TreePath[] paths) {
+ //FIXME-TC20100315 this can not work...
+ // can't test like this paths as Array...
+ if (Arrays.equals(paths, getSelectionPaths())) {
+ // stay on same node, can skip
+ if (log.isDebugEnabled()) {
+ log.debug("skip stay on path " + Arrays.toString(paths));
+ }
+ return;
+ }
+ Component component = getCurrentUI();
+
+ try {
+ if (!closeUI(component)) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing node canceled!");
+ }
+ // can not changed current node
+ return;
+ }
+ if (component instanceof NavigationMultiContentUI<?>) {
+ if (paths.length == 1) {
+ NavigationContextHelper<E> helper = getContextHelper();
+ ((NavigationMultiContentUI<E>) component).closeUI(helper.getSelectedNodes(getContext()));
+ }
+ }
+ } catch (Exception ex) {
+ treateError(ex);
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will select " + paths.length + " paths");
+ }
+ // ok can safely select the new path
+ super.setSelectionPaths(paths);
+ }
+
+ protected void selectNodeUI(E node) {
+
+ try {
+
+ String path = node.getFullPath();
+
+ if (log.isTraceEnabled()) {
+ log.trace(path);
+ }
+
+ Component newUI = getUI(node);
+
+ // now, we are free to open the ui associated with the selected node in navigation
+
+ // get the bean associated with the node
+ Object data = getNavigationTreeModel().getBean(path);
+
+ // save it in context (must be done before init ui)
+ addSelectedBeanInContext(node, data);
+
+ if (newUI == null) {
+
+ // a new ui instance is required
+ newUI = createUI(node);
+ }
+
+ JAXXContext ctxt = getContext();
+ NavigationContextHelper<E> helper = getContextHelper();
+
+ // save in context current node context path
+ helper.setSelectedPath(ctxt, node.getFullPath());
+
+ // save in context current node
+ helper.setSelectedNode(ctxt, node);
+
+ // save in context current ui
+// helper.setSelectedUI(ctxt, newUI);
+
+ // really open the ui associated with the selected node
+ // init ui before to be visible
+ if (newUI instanceof NavigationContentUI<?>) {
+ ((NavigationContentUI<E>) newUI).openUI(node);
+ }
+
+ // set ui in content
+ openUI(newUI, node);
+
+ } catch (Exception e) {
+ // remove data from context
+
+ // if any error, go back to previvous node
+ treateError(e);
+ }
+ }
+
+ /**
+ * Prepare le context a utiliser pour initialiser une nouvelle ui.
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return le context à utiliser pour instancier l'ui
+ * @throws Exception if any
+ */
+ protected JAXXContext createUIContext(E node) throws Exception {
+
+ if (node.getUIHandlerClass() == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("no action associated with ui " + node.getUIClass());
+ }
+ // no action associated, just
+ return getContext();
+ }
+
+ JAXXAction action = node.getUIHandlerClass().newInstance();
+
+ // init context with
+ JAXXInitialContext uiContext = action.init(getContext());
+ return uiContext;
+ }
+
+ protected void addSelectedBeanInContext(E node, Object data) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass()));
+ }
+ JAXXContext ctxt = getContext();
+ NavigationContextHelper<E> helper = getContextHelper();
+
+ // remove previous selected bean
+ //TODO-TC-20091004 should have an automatic clean context method while
+ helper.setSelectedBean(ctxt, null);
+
+ if (data != null) {
+
+ helper.setSelectedBean(ctxt, data);
+ }
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/AbstractNavigationHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationHandler.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationHandler.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,109 @@
+package jaxx.runtime.swing.navigation.handler;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.swing.navigation.NavigationContextHelper;
+import jaxx.runtime.swing.navigation.NavigationModel;
+import jaxx.runtime.swing.navigation.NavigationNode;
+
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+import java.awt.*;
+import java.io.Serializable;
+
+public interface NavigationHandler<E extends NavigationNode<E>> extends Cloneable, Serializable, TreeSelectionModel, TreeSelectionListener {
+
+ /**
+ * Strategy of instanciation of ui.
+ * <p/>
+ * For a given {@code node}, the method {@link #getId(NavigationNode)}
+ * returns the id of ui to use.
+ */
+ enum Strategy {
+
+ /** instanciate a ui for a node */
+ PER_NODE {
+
+ @Override
+ public String getId(NavigationNode<?> node) {
+ return node.getFullPath();
+ }
+ },
+ /**
+ * instanciate only one a ui for a type,nodes will share the
+ * instanciation
+ */
+ PER_UI_TYPE {
+
+ @Override
+ public String getId(NavigationNode<?> node) {
+ return node.getUIClass().getName();
+ }
+ };
+
+ public abstract String getId(NavigationNode<?> node);
+ }
+
+ JAXXContext getContext();
+
+ /** @return le modèle de navigation associé */
+ NavigationModel<E> getNavigationTreeModel();
+
+ /**
+ * @return le composent actuellement visible associé au noeud courant ou au
+ * noeud précédent lors d'un changement de noeud.
+ */
+ Component getCurrentUI();
+
+ /**
+ * @param node le noeud associé à l'ui à retrouver
+ * @return l'ui associé au novueau noeud sélectionné
+ */
+ Component getUI(E node);
+
+ /**
+ * @param component le composent actuellement visible
+ * @return <code>true</code> si le composent a bien été fermé,
+ * <code>false</code> sinon
+ * @throws Exception if any
+ */
+ boolean closeUI(Component component) throws Exception;
+
+ /**
+ * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return la nouvelle ui associée au noeud
+ * @throws Exception if any
+ */
+ Component createUI(E node) throws Exception;
+
+ /**
+ * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation.
+ *
+ * @param newUI l'ui associé au noeud sélectionné à ouvrir
+ * @param node le node de l'ui a ouvrir
+ * @throws Exception if any
+ */
+ void openUI(Component newUI, E node) throws Exception;
+
+ /**
+ * Traitement des exceptions.
+ *
+ * @param e l'erreur recontrée (ou null si pas d"erreur)
+ */
+ void treateError(Exception e);
+
+
+ @Override
+ void valueChanged(TreeSelectionEvent event);
+
+ NavigationContextHelper<E> getContextHelper();
+
+ @Override
+ void setSelectionPath(TreePath path);
+
+ @Override
+ void setSelectionPaths(TreePath[] paths);
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationMultiTreeHandler.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationMultiTreeHandler.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationMultiTreeHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,189 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+
+package jaxx.runtime.swing.navigation.handler;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.navigation.NavigationContextHelper;
+import jaxx.runtime.swing.navigation.NavigationMultiContentUI;
+import jaxx.runtime.swing.navigation.NavigationNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The handler of a navigation tree.
+ * <p/>
+ * This is also the selection model to use, since we must check before moving
+ * from nodes we can not just listen selection model changed, we must control
+ * it.
+ * <p/>
+ * This one is used to enable multi selection
+ *
+ * @author sletellier
+ * @since 2.0.1
+ */
+public abstract class NavigationMultiTreeHandler<E extends NavigationNode<E>> extends AbstractNavigationHandler<E> {
+
+ /** Logger */
+ static private final Log log =
+ LogFactory.getLog(NavigationMultiTreeHandler.class);
+
+
+ public NavigationMultiTreeHandler(String contextPrefix,
+ JAXXObject context,
+ Strategy strategy) {
+ super(contextPrefix, context, strategy);
+
+ // Enable multi selection
+ setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
+ }
+
+ @Override
+ public void valueChanged(TreeSelectionEvent event) {
+ TreePath[] paths = event.getPaths();
+
+ // TODO : verifier que la selection n'est pas la même
+ List<E> nodes = new ArrayList<E>();
+ if (paths == null) {
+ selectNodeUI(new ArrayList<E>());
+ return;
+ }
+ for (TreePath path : paths) {
+ E node = (E) path.getLastPathComponent();
+ nodes.add(node);
+ if (log.isDebugEnabled()) {
+ log.debug("Adding path : " + path);
+ log.debug("As node : " + node.getFullPath());
+ }
+ }
+ selectNodeUI(nodes);
+ }
+
+ /**
+ * Ouvre l'ui associée aux noeuds sélectionnés dans l'arbre de navigation.
+ *
+ * @param newUI l'ui associé au noeud sélectionné à ouvrir
+ * @param nodes les node de l'ui a ouvrir
+ * @throws Exception if any
+ */
+ protected abstract void openUI(Component newUI, List<E> nodes)
+ throws Exception;
+
+ /**
+ * Instancie une nouvelle ui associé à des noeuds de l'arbre de navigation
+ *
+ * @param nodes les noeuds associés à l'ui à créer
+ * @return la nouvelle ui associée au noeud
+ * @throws Exception if any
+ */
+ protected abstract Component createUI(List<E> nodes)
+ throws Exception;
+
+ /**
+ * @param nodes les noeuds associés à l'ui à retrouver
+ * @return l'ui associés au nouveau noeud sélectionné
+ */
+ protected abstract Component getUI(List<E> nodes);
+
+ protected void selectNodeUI(List<E> nodes) {
+ log.info("select nodes " + nodes);
+
+ try {
+// List<String> paths = new ArrayList<String>();
+ List<Object> beans = new ArrayList<Object>();
+ for (E node : nodes) {
+
+ String path = node.getFullPath();
+// paths.add(path);
+
+ if (log.isTraceEnabled()) {
+ log.trace(path);
+ }
+ // now, we are free to open the ui associated with the selected
+ // node in navigation
+
+ // get the bean associated with the node
+ beans.add(getNavigationTreeModel().getBean(path));
+ }
+
+ Component newUI = getUI(nodes);
+
+ // save it in context (must be done before init ui)
+ JAXXContext ctxt = getContext();
+ NavigationContextHelper<E> helper = getContextHelper();
+
+ // remove previous selected bean
+ //TODO-TC-20091004 should have an automatic clean context method
+ //TODO-TC-20091004 while
+ helper.setSelectedBean(ctxt, null);
+
+// if (beans != null) {
+ helper.setSelectedBeans(ctxt, beans);
+// }
+
+ if (newUI == null) {
+
+ // a new ui instance is required
+ newUI = createUI(nodes);
+ }
+
+ // save in context current node context path
+ helper.setSelectedPaths(ctxt, getPaths(nodes));
+
+ // save in context current node
+ helper.setSelectedNodes(ctxt, nodes);
+
+ // save in context current ui
+// helper.setSelectedUI(ctxt, newUI);
+
+ // really open the ui associated with the selected node
+ // init ui before to be visible
+ if (newUI instanceof NavigationMultiContentUI<?>) {
+ ((NavigationMultiContentUI<E>) newUI).openUI(nodes);
+ }
+
+ // set ui in content
+ openUI(newUI, nodes);
+
+ } catch (Exception e) {
+ // remove data from context
+
+ // if any error, go back to previvous node
+ treateError(e);
+ }
+ }
+
+ protected List<String> getPaths(List<E> nodes) {
+ List<String> result = new ArrayList<String>();
+ for (E node : nodes) {
+ result.add(node.getFullPath());
+ }
+ return result;
+ }
+
+}
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationOneClicSelectionHandler.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationOneClicSelectionHandler.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationOneClicSelectionHandler.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,67 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+
+package jaxx.runtime.swing.navigation.handler;
+
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.navigation.NavigationNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.TreePath;
+import java.util.Arrays;
+
+/**
+ * The handler of a navigation tree.
+ * <p/>
+ * This is also the selection model to use, since we must check before moving
+ * from nodes we can not just listen selection model changed, we must control
+ * it.
+ * <p/>
+ * This one is used to enable one clic multi selection
+ *
+ * @author sletellier
+ * @since 2.0.1
+ */
+public abstract class NavigationOneClicSelectionHandler<E extends NavigationNode<E>> extends NavigationMultiTreeHandler<E> {
+
+ /** Logger */
+ static private final Log log =
+ LogFactory.getLog(NavigationOneClicSelectionHandler.class);
+
+
+ public NavigationOneClicSelectionHandler(String contextPrefix,
+ JAXXObject context,
+ Strategy strategy) {
+ super(contextPrefix, context, strategy);
+ }
+
+ @Override
+ public void setSelectionPath(TreePath path) {
+ TreePath[] treePaths = getSelectionPaths();
+ if (treePaths == null || !Arrays.asList(treePaths).contains(path)) {
+ addSelectionPath(path);
+ } else {
+ removeSelectionPath(path);
+ }
+ }
+
+}
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationTreeHandlerWithCardLayout.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationTreeHandlerWithCardLayout.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationTreeHandlerWithCardLayout.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,132 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.handler;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.navigation.NavigationNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.*;
+import java.awt.*;
+import java.lang.reflect.Constructor;
+
+/**
+ * Simple {@link AbstractNavigationHandler} implementation with a {@link
+ * CardLayout2} to manage components to associated with tree's nodes.
+ * <p/>
+ * For each node, the ui associated has a constraints in a cardlayout which is
+ * the node context path.
+ * <p/>
+ * A single container managed by the cardlayout is used to display the
+ * components associated with tree's nodes.
+ *
+ * @author chemit
+ */
+public abstract class NavigationTreeHandlerWithCardLayout<E extends NavigationNode<E>> extends AbstractNavigationHandler<E> {
+
+ /** Logger */
+ static private final Log log =
+ LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class);
+
+ /**
+ * All components associated with a tree's node is displayed in a single
+ * container.
+ *
+ * @return the containter of components
+ */
+ protected abstract JPanel getContentContainer();
+
+ /**
+ * the cardlayout managing components associated with tree node. The
+ * constraints of each component is the node contextPath.
+ *
+ * @return the layout used to display components associated with tree's
+ * nodes.
+ */
+ protected abstract CardLayout2 getContentLayout();
+
+ public NavigationTreeHandlerWithCardLayout(String contextPrefix,
+ JAXXObject context,
+ Strategy strategy) {
+ super(contextPrefix, context, strategy);
+ if (getContentContainer() == null) {
+ throw new IllegalArgumentException(
+ "could not have a null 'contentContainer' in ui " + context);
+ }
+ if (getContentLayout() == null) {
+ throw new IllegalArgumentException(
+ "could not have a null 'contentLayout' in ui " + context);
+ }
+ }
+
+ @Override
+ public Component getCurrentUI() {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ return layout.getVisibleComponent(container);
+ }
+
+ @Override
+ public Component getUI(E node) {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ String constraints = strategy.getId(node);
+ return layout.contains(constraints) ?
+ layout.getComponent(container, constraints) : null;
+ }
+
+ @Override
+ public void openUI(Component newUI, E node) throws Exception {
+
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ // switch layout
+ String constraints = strategy.getId(node);
+ layout.show(container, constraints);
+ }
+
+ @Override
+ public boolean closeUI(Component component) throws Exception {
+ // by default, we says that component was succesfull closed
+ return true;
+ }
+
+ @Override
+ public Component createUI(E node) throws Exception {
+
+ JAXXContext uiContext = createUIContext(node);
+
+ Constructor<? extends JAXXObject> constructor =
+ node.getUIClass().getConstructor(JAXXContext.class);
+ JAXXObject newUI = constructor.newInstance(uiContext);
+
+ if (log.isDebugEnabled()) {
+ log.debug("instanciate new ui " + newUI);
+ }
+ String constraints = strategy.getId(node);
+ getContentContainer().add((Component) newUI, constraints);
+ return (Component) newUI;
+ }
+}
+
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/handler/NavigationTreeHandlerWithCardLayout.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html 2010-03-26 18:05:31 UTC (rev 1814)
@@ -1,12 +1,12 @@
<html>
- <body>
- <h1>JAXX - tree utilities</h1>
+<body>
+<h1>JAXX - tree utilities</h1>
- This package contains all the classes of the navigation tree framework.
+This package contains all the classes of the navigation tree framework.
- <p>
- Replace the previous framework from package
- <code>jaxx.runtime.swing.navigation</code>
- </p>
- </body>
-</html>
\ No newline at end of file
+<p>
+ Replace the previous framework from package
+ <code>jaxx.runtime.swing.navigation</code>
+</p>
+</body>
+</html>
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeHelper.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeHelper.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,40 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.tree;
+
+import jaxx.runtime.swing.navigation.AbstractNavigationHelper;
+import jaxx.runtime.swing.navigation.NavigationContextHelper;
+
+/**
+ * Helper object associated to a given navigation tree system.
+ * <p/>
+ * To helper is context safe (base on a {@link NavigationContextHelper}.
+ *
+ * @author chemit
+ * @see NavigationTreeModel
+ * @since 1.7.2
+ */
+public abstract class NavigationTreeHelper extends AbstractNavigationHelper<NavigationTreeNode> {
+
+ protected NavigationTreeHelper(String contextPrefix) {
+ super(contextPrefix);
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java (from rev 1813, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModel.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,93 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.tree;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.swing.navigation.AbstractNavigationModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreeNode;
+
+/**
+ * Model of the tree used for a navigation tree.
+ * <p/>
+ * Il est composé de {@link NavigationTreeNode}
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeModel extends AbstractNavigationModel<NavigationTreeNode> implements TreeModel {
+
+ /** Logger */
+ private static final Log log =
+ LogFactory.getLog(NavigationTreeModel.class);
+
+ public NavigationTreeModel(String pathSeparator, JAXXContext context) {
+ super(new DefaultTreeModel(null), pathSeparator, context);
+ }
+
+ @Override
+ public void setRoot(NavigationTreeNode root) {
+ getDelegate().setRoot(root);
+ }
+
+ public DefaultTreeModel getDelegate() {
+ return (DefaultTreeModel) super.getDelegate();
+ }
+
+ @Override
+ public NavigationTreeNode[] getPathToRoot(NavigationTreeNode aNode) {
+ TreeNode[] treeNodes = getDelegate().getPathToRoot(aNode);
+ NavigationTreeNode[] result = new NavigationTreeNode[treeNodes.length];
+ System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
+ return result;
+ }
+
+ @Override
+ public void removeNodeFromParent(NavigationTreeNode node) {
+ getDelegate().removeNodeFromParent(node);
+ }
+
+ @Override
+ public void nodeStructureChanged(NavigationTreeNode node) {
+ NavigationTreeNode n = node;
+ //TC-20091004 never launch a deep reload
+ reload(n, true);
+ getDelegate().nodeStructureChanged(node);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ @Override
+ public void nodeChanged(NavigationTreeNode node, boolean deep) {
+
+ NavigationTreeNode n = node;
+ //TC-20091004 never launch a deep clean, since we do a deep nodeChanged.
+ reload(n, deep);
+ getDelegate().nodeChanged(node);
+ }
+
+
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeModelBuilder.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,81 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.tree;
+
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.AbstractNavigationModelBuilder;
+import jaxx.runtime.swing.navigation.NavigationModelBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This object is design to build a {@link NavigationTreeModel}.
+ *
+ * @author chemit
+ * @see NavigationModelBuilder
+ * @since 17.2
+ */
+public class NavigationTreeModelBuilder extends AbstractNavigationModelBuilder<NavigationTreeNode> {
+
+ /** Logger */
+ static private final Log log =
+ LogFactory.getLog(NavigationTreeModelBuilder.class);
+
+ public NavigationTreeModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeModel(pathSeparator, context)
+ );
+ }
+
+ public NavigationTreeModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeModel model) {
+ super(defaultUIClass, defaultUIHandlerClass, model);
+ }
+
+ @Override
+ public NavigationTreeNode createNavigationNode(
+ String pathSeparator,
+ String contextName,
+ JAXXContextEntryDef<?> jaxxContextEntryDef,
+ String jaxxContextEntryPath) {
+ return new NavigationTreeNode(
+ pathSeparator,
+ contextName,
+ jaxxContextEntryDef,
+ jaxxContextEntryPath
+ );
+ }
+
+ @Override
+ public NavigationTreeModel getModel() {
+ return (NavigationTreeModel) super.getModel();
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,556 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.tree;
+
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.NavigationNode;
+import jaxx.runtime.swing.navigation.NavigationNodeRenderer;
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+import java.util.Enumeration;
+
+/**
+ * Node of the {@link NavigationTreeModel}.
+ * <p/>
+ * Each node is associated with : <ul> <li> a {@code bean} coming from a {@link
+ * JAXXContext} </li> <li> a {@code uiClass} to build the associated ui </li>
+ * </ul>
+ * <p/>
+ * To retrieve the bean from the context, there is a huge logic in the method
+ * {@link #getBean(JAXXContext)}.
+ * <p/>
+ * In few words, if the {@link #jaxxContextEntryDef} is defined, it means that
+ * the object is taken from the {@code context}.
+ * <p/>
+ * Otherwise, find the first ancestor with an context entry and retrieve from
+ * here the bean.
+ * <p/>
+ * Then go down to the initial node by applying the jxpath expressions {@link
+ * #jaxxContextEntryPath} of each node on road back.
+ * <p/>
+ * <p/>
+ * To identify easly a node, each node has a {@link #path} and a {@link
+ * #fullPath} (full path from root node).
+ * <p/>
+ * <p/>
+ * To display the node we use a {@link NavigationNodeRenderer}
+ * which is in fact the {@link #userObject}, the object can be synch with the
+ * bean via the {@link NavigationNodeRenderer#reload(Object)}
+ * method.
+ *
+ * @author chemit
+ * @see NavigationTreeModel
+ * @see NavigationNodeRenderer
+ * @since 1.7.2
+ */
+public class NavigationTreeNode extends DefaultMutableTreeNode implements NavigationNode<NavigationTreeNode> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger */
+ static private final Log log = LogFactory.getLog(NavigationTreeNode.class);
+
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see #path
+ * @see #fullPath
+ */
+ protected final String pathSeparator;
+
+ /**
+ * The node path.
+ * <p/>
+ * Used to build the {@link #fullPath} which gives a unique identifier of
+ * the node.
+ *
+ * @see #pathSeparator
+ * @see #fullPath
+ */
+ protected String path;
+
+ /**
+ * The full path for the node from the rood node.
+ * <p/>
+ * This path is build by appending nodes {@link #path} from the root node to
+ * this node, between each path we introduce the {@link #pathSeparator}.
+ * <p/>
+ * Exemple :
+ * <pre>
+ * root
+ * $root
+ * `-- child1
+ * `-- child2
+ * </pre>
+ * will given {@code $root/child1/child2}.
+ *
+ * @see #pathSeparator
+ * @see #path
+ */
+ protected String fullPath;
+
+ /**
+ * The UI class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the {@link
+ * NavigationTreeModelBuilder#defaultUIClass} will be used while building
+ * the model.
+ */
+ protected Class<? extends JAXXObject> uIClass;
+
+ /**
+ * The UI handler class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the {@link
+ * NavigationTreeModelBuilder#defaultUIHandlerClass} will be used while
+ * building the model.
+ */
+ protected Class<? extends JAXXAction> uIHandlerClass;
+
+ /**
+ * The context entry definition to retrieve the bean.
+ * <p/>
+ * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
+ * node.
+ */
+ protected JAXXContextEntryDef<?> jaxxContextEntryDef;
+
+ /**
+ * The jxPath to process to obtain real {@code bean} from the data retrieve
+ * in the context.
+ * <p/>
+ * <b>Note:</b> If not set -no jxpath will be apply on the bean from
+ * context.
+ */
+ protected String jaxxContextEntryPath;
+
+ /**
+ * The bean associated with the node ( the value can be obtain via the
+ * method {@link #getBean(JAXXContext)} or directly set via method {@link
+ * #setBean(Object)}.
+ * <p/>
+ * cache of bean associated with bean to improve performance
+ */
+ protected transient Object bean;
+
+ /**
+ * The type of the related bean associated with the node.
+ * <p/>
+ * Note: This type is here to override the NodeRenderer internalClass, since
+ * we could need to override this data.
+ * <p/>
+ * If this property is let to null, then we will use the NodeRenderer one
+ */
+ protected Class<?> internalClass;
+
+ public NavigationTreeNode(String pathSeparator,
+ String navigationPath,
+ Object jaxxContextEntryDef) {
+ this.pathSeparator = pathSeparator;
+ path = navigationPath;
+ if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
+ this.jaxxContextEntryDef =
+ (JAXXContextEntryDef<?>) jaxxContextEntryDef;
+ } else if (jaxxContextEntryDef instanceof String) {
+ jaxxContextEntryPath = (String) 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(String pathSeparator,
+ String navigationPath,
+ JAXXContextEntryDef<?> jaxxContextEntryDef,
+ String jaxxContextEntryPath) {
+ this.pathSeparator = pathSeparator;
+ path = navigationPath;
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ /** @return the text node renderer (store in {@link #userObject} property. */
+ @Override
+ public NavigationNodeRenderer getRenderer() {
+ NavigationNodeRenderer render = null;
+ Object o = getUserObject();
+ if (o != null && o instanceof NavigationNodeRenderer) {
+ render = (NavigationNodeRenderer) o;
+ }
+ return render;
+ }
+
+ @Override
+ public void setRenderer(NavigationNodeRenderer renderer) {
+ // clear all cache
+ bean = null;
+ setUserObject(renderer);
+ }
+
+ @Override
+ public String getPathSeparator() {
+ return pathSeparator;
+ }
+
+ @Override
+ public String getNodePath() {
+ return path;
+ }
+
+ @Override
+ public void setNodePath(String navigationPath) {
+ path = navigationPath;
+ }
+
+ @Override
+ public Class<? extends JAXXObject> getUIClass() {
+ return uIClass;
+ }
+
+ @Override
+ public void setUIClass(Class<? extends JAXXObject> uIClass) {
+ this.uIClass = uIClass;
+ }
+
+ @Override
+ public void setInternalClass(Class<?> internalClass) {
+ this.internalClass = internalClass;
+ }
+
+ @Override
+ public Class<? extends JAXXAction> getUIHandlerClass() {
+ return uIHandlerClass;
+ }
+
+ @Override
+ public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
+ this.uIHandlerClass = uIHandlerClass;
+ }
+
+ @Override
+ public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
+ return jaxxContextEntryDef;
+ }
+
+ @Override
+ public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ }
+
+ @Override
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ @Override
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ if (internalClass == null && getRenderer() != null) {
+ return getRenderer().getInternalClass();
+ }
+ return internalClass;
+ }
+
+ /** @return the fully context path of the node from the root node to this. */
+ @Override
+ public String getFullPath() {
+ if (fullPath == null) {
+ StringBuilder sb = new StringBuilder();
+ for (TreeNode treeNode : getPath()) {
+ NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
+ sb.append(pathSeparator).append(myNode.getNodePath());
+ }
+ fullPath = sb.substring(1);
+ }
+ return fullPath;
+ }
+
+ @Override
+ public NavigationTreeNode getChildAt(int index) {
+ return (NavigationTreeNode) super.getChildAt(index);
+ }
+
+ @Override
+ public NavigationTreeNode getParent() {
+ return (NavigationTreeNode) super.getParent();
+ }
+
+ /**
+ * @param path the name of the {@link #path} to be matched in the child of
+ * this node.
+ * @return the child of this node with given {@link #path} value.
+ */
+ @Override
+ public NavigationTreeNode getChild(String path) {
+ Enumeration<? extends NavigationTreeNode> childs = children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode son = childs.nextElement();
+ if (path.equals(son.getNodePath())) {
+ return son;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object getBean() {
+ return bean;
+ }
+
+ @Override
+ public void setBean(Object bean) {
+ this.bean = bean;
+ }
+
+ @Override
+ public void reload(JAXXContext context) {
+
+ // clear bean cache
+ bean = null;
+
+ // clear context navigation cache
+ fullPath = null;
+
+ NavigationNodeRenderer renderer = getRenderer();
+ if (renderer == null) {
+ // this can't be !
+ throw new NullPointerException(
+ "could not find the renderer for node " + this);
+ }
+
+ String s = getFullPath();
+ Object b = null;
+ try {
+ b = getBean(context);
+ } finally {
+ if (log.isInfoEnabled()) {
+ log.info("bean for path [" + s + "] = " + bean);
+ }
+ }
+
+ renderer.reload(b);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ public Object getBean(JAXXContext context) {
+ if (bean != null) {
+ // use cached bean
+ return bean;
+ }
+ Object result;
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
+ // the node maps directly a value in context, with no jxpath resolving
+ result = getJaxxContextEntryDef().getContextValue(context);
+ // save in cache
+ setBean(result);
+ 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);
+ if (parentBean == null) {
+ // must be an error no bean found
+ log.warn("could not find a bean attached in context from context" +
+ " entry definition " + parentNode.getJaxxContextEntryDef());
+ return null;
+ }
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+ // save in cache
+ parentNode.setBean(parentBean);
+ if (parentNode.equals(this)) {
+ // current node is the node matching the context entry value and
+ // no jxpath is found
+ 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;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("jxpath : " + jxpathExpression);
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ result = jxcontext.getValue(jxpathExpression);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+
+ @Override
+ public void insert(NavigationTreeNode child, int index) {
+ super.insert(child, index);
+ }
+
+ @Override
+ public void remove(NavigationTreeNode node) {
+ super.remove(node);
+ }
+
+ @Override
+ public void setParent(NavigationTreeNode newParent) {
+ super.setParent(newParent);
+ }
+
+ @Override
+ public int getIndex(NavigationTreeNode node) {
+ return super.getIndex(node);
+ }
+
+ @Override
+ public Enumeration<? extends NavigationTreeNode> children() {
+ return super.children();
+ }
+
+ @Override
+ public void add(NavigationTreeNode node) {
+ super.add(node);
+ }
+
+ @Override
+ public NavigationTreeNode[] getPath() {
+ TreeNode[] treeNodes = super.getPath();
+ NavigationTreeNode[] result = new NavigationTreeNode[treeNodes.length];
+ System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
+ return result;
+ }
+
+ @Override
+ public NavigationTreeNode[] getPathToRoot(NavigationTreeNode aNode, int depth) {
+ TreeNode[] treeNodes = super.getPathToRoot(aNode, depth);
+ NavigationTreeNode[] result = new NavigationTreeNode[treeNodes.length];
+ System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
+ 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) {
+ // find a node with a direct link with the context
+ return this;
+ }
+ // the node is not linked to context
+ // seek in his parent
+ NavigationTreeNode ancestor = getParent();
+ return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
+ }
+
+ protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
+ if (equals(parentNode)) {
+ // 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;
+ }
+ // 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);
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/tree/NavigationTreeNode.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableHelper.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableHelper.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableHelper.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,41 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.treetable;
+
+import jaxx.runtime.swing.navigation.AbstractNavigationHelper;
+import jaxx.runtime.swing.navigation.NavigationContextHelper;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModel;
+
+/**
+ * Helper object associated to a given navigation tree table system.
+ * <p/>
+ * To helper is context safe (base on a {@link NavigationContextHelper}.
+ *
+ * @author chemit
+ * @see NavigationTreeModel
+ * @since 1.7.2
+ */
+public abstract class NavigationTreeTableHelper extends AbstractNavigationHelper<NavigationTreeTableNode> {
+
+ protected NavigationTreeTableHelper(String contextPrefix) {
+ super(contextPrefix);
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java (from rev 1813, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModel.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModel.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,186 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.treetable;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.swing.navigation.AbstractNavigationModel;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.tree.TreeModelSupport;
+import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
+import org.jdesktop.swingx.treetable.TreeTableModel;
+
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
+import java.util.List;
+
+/**
+ * Model of the tree table used for a navigation tree table.
+ * <p/>
+ * Il est composé de {@link NavigationTreeNode}
+ * <p/>
+ * FIXME : Essayer d'enlever les copier coller {@link NavigationTreeModel}
+ *
+ * @author sletellier
+ * @since 2.0.0
+ */
+public class NavigationTreeTableModel extends AbstractNavigationModel<NavigationTreeTableNode> implements TreeTableModel {
+
+ /** Logger */
+ static private final Log log =
+ LogFactory.getLog(NavigationTreeTableModel.class);
+
+ public static class MyDefaultTreeTableModel extends DefaultTreeTableModel {
+
+ public TreeModelSupport getModelSupport() {
+ return modelSupport;
+ }
+ }
+
+ protected List<String> columnsName;
+
+ public NavigationTreeTableModel(String pathSeparator, JAXXContext context, List<String> columnsName) {
+ super(new MyDefaultTreeTableModel(), pathSeparator, context);
+ this.columnsName = columnsName;
+ }
+
+
+ public MyDefaultTreeTableModel getDelegate() {
+ return (MyDefaultTreeTableModel) delegate;
+ }
+
+ @Override
+ public NavigationTreeTableNode[] getPathToRoot(NavigationTreeTableNode aNode) {
+ if (aNode == null) {
+ return null;
+ }
+ TreeNode[] treeNodes = getDelegate().getPathToRoot(aNode);
+ NavigationTreeTableNode[] result = new NavigationTreeTableNode[treeNodes.length];
+ System.arraycopy(treeNodes, 0, result, 0, treeNodes.length);
+ return result;
+
+ }
+
+ @Override
+ public void setRoot(NavigationTreeTableNode root) {
+ getDelegate().setRoot(root);
+ getModelSupport().fireNewRoot();
+ }
+
+ /**
+ * Message this to remove node from its parent. This will message
+ * nodesWereRemoved to create the appropriate event. This is the preferred
+ * way to remove a node as it handles the event creation for you.
+ */
+ @Override
+ public void removeNodeFromParent(NavigationTreeTableNode node) {
+ NavigationTreeTableNode parent = node.getParent();
+
+ if (parent == null) {
+ throw new IllegalArgumentException("node does not have a parent.");
+ }
+
+ int index = parent.getIndex(node);
+ node.removeFromParent();
+ getModelSupport().fireChildRemoved(new TreePath(getPathToRoot(parent)),
+ index, node);
+ }
+
+ /**
+ * Accessor to tree model support.
+ *
+ * @return tree model support
+ */
+ protected TreeModelSupport getModelSupport() {
+ return getDelegate().getModelSupport();
+ }
+
+ @Override
+ public void nodeStructureChanged(NavigationTreeTableNode node) {
+ if (node != null) {
+ NavigationTreeTableNode parent = node.getParent();
+ TreeNode[] treeNodes = getPathToRoot(parent);
+ if (treeNodes != null) {
+ getModelSupport().fireTreeStructureChanged(new TreePath(treeNodes));
+ } else {
+ log.error("[Node structure changed] Path to root is null !");
+ }
+ reload(node, true);
+ } else {
+ log.error("Node is null !");
+ }
+ }
+
+ @Override
+ public void nodeChanged(NavigationTreeTableNode node, boolean deep) {
+ if (node != null) {
+ NavigationTreeTableNode parent = node.getParent();
+ TreeNode[] treeNodes = getPathToRoot(parent);
+ if (treeNodes != null) {
+ getModelSupport().fireChildChanged(
+ new TreePath(treeNodes), parent.getIndex(node), node);
+ } else {
+ log.error("[Node changed] Path to root is null !");
+ }
+ reload(node, deep);
+ } else {
+ log.error("Node is null !");
+ }
+ }
+
+ @Override
+ public Class<?> getColumnClass(int i) {
+ return getDelegate().getColumnClass(i);
+ }
+
+ @Override
+ public int getColumnCount() {
+ return columnsName.size();
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ return columnsName.get(column);
+ }
+
+ @Override
+ public int getHierarchicalColumn() {
+ return getDelegate().getHierarchicalColumn();
+ }
+
+ @Override
+ public Object getValueAt(Object o, int i) {
+ return getDelegate().getValueAt(o, i);
+ }
+
+ @Override
+ public boolean isCellEditable(Object o, int i) {
+ return getDelegate().isCellEditable(o, i);
+ }
+
+ @Override
+ public void setValueAt(Object o, Object o1, int i) {
+ getDelegate().setValueAt(o, o1, i);
+ }
+
+}
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java (from rev 1812, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableModelBuilder.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,51 @@
+package jaxx.runtime.swing.navigation.treetable;
+
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.AbstractNavigationModelBuilder;
+
+import java.util.List;
+
+public class NavigationTreeTableModelBuilder extends AbstractNavigationModelBuilder<NavigationTreeTableNode> {
+
+
+ public NavigationTreeTableModelBuilder(
+ String pathSeparator,
+ JAXXContext context,
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ List<String> columnsName) {
+ this(defaultUIClass,
+ defaultUIHandlerClass,
+ new NavigationTreeTableModel(pathSeparator, context, columnsName)
+ );
+ }
+
+ public NavigationTreeTableModelBuilder(
+ Class<? extends JAXXObject> defaultUIClass,
+ Class<? extends JAXXAction> defaultUIHandlerClass,
+ NavigationTreeTableModel model) {
+ super(defaultUIClass, defaultUIHandlerClass, model);
+ }
+
+ @Override
+ public NavigationTreeTableNode createNavigationNode(
+ String pathSeparator,
+ String contextName,
+ JAXXContextEntryDef<?> jaxxContextEntryDef,
+ String jaxxContextEntryPath) {
+ return new NavigationTreeTableNode(
+ pathSeparator,
+ contextName,
+ jaxxContextEntryDef,
+ jaxxContextEntryPath
+ );
+ }
+
+ @Override
+ public NavigationTreeTableModel getModel() {
+ return (NavigationTreeTableModel) super.getModel();
+ }
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableNode.java (from rev 1810, trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeTableNode.java)
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableNode.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/treetable/NavigationTreeTableNode.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -0,0 +1,552 @@
+/*
+ * *##%
+ * JAXX Runtime
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.navigation.treetable;
+
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.NavigationNode;
+import jaxx.runtime.swing.navigation.NavigationNodeRenderer;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
+
+import javax.swing.tree.TreeNode;
+import java.util.Enumeration;
+
+/**
+ * Node of the {@link NavigationTreeTableModel}.
+ *
+ * @author sletellier
+ * @see NavigationTreeNode
+ * @since 2.0.0
+ */
+public class NavigationTreeTableNode extends DefaultMutableTreeTableNode implements NavigationNode<NavigationTreeTableNode> {
+
+ private static final long serialVersionUID = -1L;
+
+ /** Logger */
+ private static final Log log =
+ LogFactory.getLog(NavigationTreeTableNode.class);
+
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see #path
+ * @see #fullPath
+ */
+ protected final String pathSeparator;
+
+ /**
+ * The node path.
+ * <p/>
+ * Used to build the {@link #fullPath} which gives a unique identifier of
+ * the node.
+ *
+ * @see #pathSeparator
+ * @see #fullPath
+ */
+ protected String path;
+
+ /**
+ * The full path for the node from the rood node.
+ * <p/>
+ * This path is build by appending nodes {@link #path} from the root node to
+ * this node, between each path we introduce the {@link #pathSeparator}.
+ * <p/>
+ * Exemple :
+ * <pre>
+ * root
+ * $root
+ * `-- child1
+ * `-- child2
+ * </pre>
+ * will given {@code $root/child1/child2}.
+ *
+ * @see #pathSeparator
+ * @see #path
+ */
+ protected String fullPath;
+
+ /**
+ * The UI class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the {@link
+ * NavigationTreeModelBuilder#defaultUIClass} will be used while building
+ * the model.
+ */
+ protected Class<? extends JAXXObject> uIClass;
+
+ /**
+ * The UI handler class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the {@link
+ * NavigationTreeModelBuilder#defaultUIHandlerClass} will be used while
+ * building the model.
+ */
+ protected Class<? extends JAXXAction> uIHandlerClass;
+
+ /**
+ * The context entry definition to retrieve the bean.
+ * <p/>
+ * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
+ * node.
+ */
+ protected JAXXContextEntryDef<?> jaxxContextEntryDef;
+
+ /**
+ * The jxPath to process to obtain real {@code bean} from the data retrieve
+ * in the context.
+ * <p/>
+ * <b>Note:</b> If not set -no jxpath will be apply on the bean from
+ * context.
+ */
+ protected String jaxxContextEntryPath;
+
+ /**
+ * The bean associated with the node ( the value can be obtain via the
+ * method {@link #getBean(JAXXContext)} or directly set via method {@link
+ * #setBean(Object)}.
+ * <p/>
+ * cache of bean associated with bean to improve performance
+ */
+ protected transient Object bean;
+
+ /**
+ * The type of the related bean associated with the node.
+ * <p/>
+ * Note: This type is here to override the NodeRenderer internalClass, since
+ * we could need to override this data.
+ * <p/>
+ * If this property is let to null, then we will use the NodeRenderer one
+ */
+ protected Class<?> internalClass;
+
+ public NavigationTreeTableNode(String pathSeparator,
+ String navigationPath,
+ Object jaxxContextEntryDef) {
+ this.pathSeparator = pathSeparator;
+ path = navigationPath;
+ if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
+ this.jaxxContextEntryDef =
+ (JAXXContextEntryDef<?>) jaxxContextEntryDef;
+ } else if (jaxxContextEntryDef instanceof String) {
+ jaxxContextEntryPath = (String) 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 NavigationTreeTableNode(String pathSeparator,
+ String navigationPath,
+ JAXXContextEntryDef<?> jaxxContextEntryDef,
+ String jaxxContextEntryPath) {
+ this.pathSeparator = pathSeparator;
+ path = navigationPath;
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ /** @return the text node renderer (store in {@link #userObject} property. */
+ @Override
+ public NavigationNodeRenderer getRenderer() {
+ NavigationNodeRenderer render = null;
+ Object o = getUserObject();
+ if (o != null && o instanceof NavigationNodeRenderer) {
+ render = (NavigationNodeRenderer) o;
+ }
+ return render;
+ }
+
+ @Override
+ public void setRenderer(NavigationNodeRenderer renderer) {
+ // clear all cache
+ bean = null;
+ setUserObject(renderer);
+ }
+
+ @Override
+ public String getPathSeparator() {
+ return pathSeparator;
+ }
+
+ @Override
+ public String getNodePath() {
+ return path;
+ }
+
+ @Override
+ public void setNodePath(String navigationPath) {
+ path = navigationPath;
+ }
+
+ @Override
+ public Class<? extends JAXXObject> getUIClass() {
+ return uIClass;
+ }
+
+ @Override
+ public void setUIClass(Class<? extends JAXXObject> uIClass) {
+ this.uIClass = uIClass;
+ }
+
+ @Override
+ public void setInternalClass(Class<?> internalClass) {
+ this.internalClass = internalClass;
+ }
+
+ @Override
+ public Class<? extends JAXXAction> getUIHandlerClass() {
+ return uIHandlerClass;
+ }
+
+ @Override
+ public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
+ this.uIHandlerClass = uIHandlerClass;
+ }
+
+ @Override
+ public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
+ return jaxxContextEntryDef;
+ }
+
+ @Override
+ public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ }
+
+ @Override
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ @Override
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ if (internalClass == null && getRenderer() != null) {
+ return getRenderer().getInternalClass();
+ }
+ return internalClass;
+ }
+
+ /** @return the fully context path of the node from the root node to this. */
+ @Override
+ public String getFullPath() {
+ if (fullPath == null) {
+ StringBuilder sb = new StringBuilder();
+ for (TreeNode treeNode : getPath()) {
+ NavigationTreeTableNode myNode =
+ (NavigationTreeTableNode) treeNode;
+ sb.append(pathSeparator).append(myNode.getNodePath());
+ }
+ fullPath = sb.substring(1);
+ }
+ return fullPath;
+ }
+
+ /**
+ * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
+ * or <code>null</code> if none find..
+ */
+ protected NavigationTreeTableNode getFirstAncestorWithDef() {
+ if (jaxxContextEntryDef != null) {
+ // find a node with a direct link with the context
+ return this;
+ }
+ // the node is not linked to context
+ // seek in his parent
+ NavigationTreeTableNode ancestor = getParent();
+ return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
+ }
+
+ protected String computeJXPath(String expr,
+ NavigationTreeTableNode parentNode) {
+ if (equals(parentNode)) {
+ // 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);
+ }
+ NavigationTreeTableNode 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;
+ }
+ // 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
+ public Object getBean() {
+ return bean;
+ }
+
+ @Override
+ public void setBean(Object bean) {
+ this.bean = bean;
+ }
+
+ @Override
+ public void reload(JAXXContext context) {
+
+ // clear bean cache
+ bean = null;
+
+ // clear context navigation cache
+ fullPath = null;
+
+ NavigationNodeRenderer renderer = getRenderer();
+ if (renderer == null) {
+ // this can't be !
+ throw new NullPointerException(
+ "could not find the renderer for node " + this);
+ }
+
+ String s = getFullPath();
+ Object b = null;
+ try {
+ b = getBean(context);
+ } finally {
+ if (log.isInfoEnabled()) {
+ log.info("bean for path [" + s + "] = " + bean);
+ }
+ }
+ renderer.reload(b);
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ public Object getBean(JAXXContext context) {
+ if (bean != null) {
+ // use cached bean
+ return bean;
+ }
+ Object result;
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
+ // the node maps directly a value in context, with no jxpath
+ // resolving
+ result = getJaxxContextEntryDef().getContextValue(context);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+ // find the first ancestor node with a context def
+ NavigationTreeTableNode 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);
+ if (parentBean == null) {
+ // must be an error no bean found
+ log.warn("could not find a bean attached in context from context" +
+ " entry definition " + parentNode.getJaxxContextEntryDef());
+ return null;
+ }
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+ // save in cache
+ parentNode.setBean(parentBean);
+ if (parentNode.equals(this)) {
+ // current node is the node matching the context entry value and
+ // no jxpath is found
+ 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;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("jxpath : " + jxpathExpression);
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ result = jxcontext.getValue(jxpathExpression);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+
+
+ @Override
+ public NavigationTreeTableNode getChildAt(int index) {
+ return (NavigationTreeTableNode) super.getChildAt(index);
+ }
+
+ @Override
+ public NavigationTreeTableNode getParent() {
+ return (NavigationTreeTableNode) super.getParent();
+ }
+
+ @Override
+ public NavigationTreeTableNode getChild(String path) {
+ Enumeration<?> childs = children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeTableNode son =
+ (NavigationTreeTableNode) childs.nextElement();
+ if (path.equals(son.getNodePath())) {
+ return son;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Enumeration<? extends NavigationTreeTableNode> children() {
+ return (Enumeration<? extends NavigationTreeTableNode>) super.children();
+ }
+
+ @Override
+ public void insert(NavigationTreeTableNode child, int index) {
+ super.insert(child, index);
+ }
+
+ @Override
+ public void remove(NavigationTreeTableNode node) {
+ super.remove(node);
+ }
+
+ @Override
+ public void setParent(NavigationTreeTableNode newParent) {
+ super.setParent(newParent);
+ }
+
+ @Override
+ public int getIndex(NavigationTreeTableNode node) {
+ return super.getIndex(node);
+ }
+
+ @Override
+ public void add(NavigationTreeTableNode node) {
+ super.add(node);
+ }
+
+ @Override
+ public NavigationTreeTableNode[] getPath() {
+ return getPathToRoot(this, 0);
+ }
+
+ @Override
+ public NavigationTreeTableNode[] getPathToRoot(
+ NavigationTreeTableNode aNode, int depth) {
+ NavigationTreeTableNode[] retNodes;
+
+ /* Check for null, in case someone passed in a null node, or
+ they passed in an element that isn't rooted at root. */
+ if (aNode == null) {
+ if (depth == 0) {
+ return null;
+ } else {
+ retNodes = new NavigationTreeTableNode[depth];
+ }
+ } else {
+ depth++;
+ retNodes = getPathToRoot(aNode.getParent(), depth);
+ retNodes[retNodes.length - depth] = aNode;
+ }
+ return retNodes;
+ }
+
+ @Override
+ public boolean isRoot() {
+ return getParent() == null;
+ }
+
+}
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2010-03-26 18:05:31 UTC (rev 1814)
@@ -23,6 +23,9 @@
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.context.DefaultJAXXContext;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.tree.NavigationTreeNode;
import org.junit.Assert;
import org.junit.Test;
@@ -46,7 +49,7 @@
@Test
public void testFindNode() throws Exception {
- NavigationTreeNodeModelBuilder builder = new NavigationTreeNodeModelBuilder(separator, new DefaultJAXXContext(), null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, new DefaultJAXXContext(), null, null);
NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
@@ -104,7 +107,7 @@
}
/**
- * Test the {@link NavigationTreeNodeModel#getBean(String)}} with an entry point
+ * Test the {@link NavigationTreeModel#getBean(String)}} with an entry point
* as a bean.
* <p/>
* Tree is like this
@@ -158,7 +161,7 @@
new Model("two", 2, Collections.<Model>emptyList()),
new Model("three", 3, Collections.<Model>emptyList()))));
- NavigationTreeNodeModelBuilder builder = new NavigationTreeNodeModelBuilder(separator, context, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null);
NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
@@ -224,7 +227,7 @@
}
/**
- * Test the {@link NavigationTreeNodeModel#getBean(String)} with an entry point
+ * Test the {@link NavigationTreeModel#getBean(String)} with an entry point
* as a list.
* <p/>
* Tree is like this
@@ -279,7 +282,7 @@
context.setContextValue(list, "models");
- NavigationTreeNodeModelBuilder builder = new NavigationTreeNodeModelBuilder(separator, context, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null);
NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
Modified: trunk/src/site/rst/NavigationModel.rst
===================================================================
--- trunk/src/site/rst/NavigationModel.rst 2010-03-26 14:57:07 UTC (rev 1813)
+++ trunk/src/site/rst/NavigationModel.rst 2010-03-26 18:05:31 UTC (rev 1814)
@@ -22,7 +22,7 @@
Contrat representant le model de l'arbre de navigation.
Les noeuds présents dans se modèle sont aussi typés en
-*jaxx.runtime.swing.navigation.NavigationTreeNodeModel.NavigationTreeNode*.
+*jaxx.runtime.swing.navigation.tree.NavigationTreeModel.NavigationTreeNode*.
L'idée principale est de pouvoir associer à un noeud précis un chemin depuis
la racine, ce que l'on appele *chemin de navigation*.
@@ -33,25 +33,25 @@
Tout les models suivants implémantent cette interface.
-jaxx.runtime.swing.navigation.NavigationTreeNodeModel
+jaxx.runtime.swing.navigation.tree.NavigationTreeModel
=================================================
Il s'agit du modèle de l'arbre utilisé, c'est une extension d'un
*javax.swing.tree.DefaultTreeModel*.
-jaxx.runtime.swing.navigation.NavigationTreeTableModel
+jaxx.runtime.swing.navigation.treetable.NavigationTreeTableModel
======================================================
Il s'agit du modèle de l'arbre tableau (*org.jdesktop.swingx.JXTreeTable*),
c'est une extension d'un *org.jdesktop.swingx.treetable.DefaultTreeTableModel*.
Les noeuds présents dans se modèle sont typés en
-*jaxx.runtime.swing.navigation.NavigationTreeNodeModel.NavigationTreeTableNode* qui
-étend *jaxx.runtime.swing.navigation.NavigationTreeNodeModel.NavigationTreeNode*.
+*jaxx.runtime.swing.navigation.tree.NavigationTreeModel.NavigationTreeTableNode* qui
+étend *jaxx.runtime.swing.navigation.tree.NavigationTreeModel.NavigationTreeNode*.
NavigationTreeTableNode est abstaite, l'instance doit donc être crée en
implementant la méthode createNavigationTreeTableNode
-du builder (*jaxx.runtime.swing.navigation.NavigationTreeTableModelBuilder*).
+du builder (*jaxx.runtime.swing.navigation.treetable.NavigationTreeTableModelBuilder*).
Les builders
============
@@ -64,23 +64,23 @@
Tous les builders implémentent cette interface.
-jaxx.runtime.swing.navigation.NavigationTreeNodeModelBuilder
+jaxx.runtime.swing.navigation.tree.NavigationTreeModelBuilder
--------------------------------------------------------
Classe utilitaire pour construire le model (ici un
-*jaxx.runtime.swing.navigation.NavigationTreeNodeModel*) et décorer un arbre.
+*jaxx.runtime.swing.navigation.tree.NavigationTreeModel*) et décorer un arbre.
-jaxx.runtime.swing.navigation.NavigationTreeTableModelBuilder
+jaxx.runtime.swing.navigation.treetable.NavigationTreeTableModelBuilder
-------------------------------------------------------------
Classe utilitaire pour construire le model (ici un
-*jaxx.runtime.swing.navigation.NavigationTreeTableModel*) et décorer un arbre
+*jaxx.runtime.swing.navigation.treetable.NavigationTreeTableModel*) et décorer un arbre
tableau.
Les Handlers
============
-jaxx.runtime.swing.navigation.NavigationTreeHandler
+jaxx.runtime.swing.navigation.handler.AbstractNavigationHandler
---------------------------------------------------
Cette classe est une implémentation d'un model de sélection pour les arbres
@@ -90,31 +90,31 @@
(*Strategy.PER_NODE*) soit on associe une ui par type de noeud
(*Strategy.PER_UI_TYPE*).
-jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout
+jaxx.runtime.swing.navigation.handler.NavigationTreeHandlerWithCardLayout
-----------------------------------------------------------------
-Extension de *jaxx.runtime.swing.navigation.NavigationTreeHandler* pour
+Extension de *jaxx.runtime.swing.navigation.handler.AbstractNavigationHandler* pour
l'utilisation de CardLayout (*jaxx.runtime.swing.CardLayout2*).
-jaxx.runtime.swing.navigation.NavigationMultiTreeHandler
+jaxx.runtime.swing.navigation.handler.NavigationMultiTreeHandler
--------------------------------------------------------
TODO ajouter la strategie de la multiselection
-Extension de *jaxx.runtime.swing.navigation.NavigationTreeHandler* pour
+Extension de *jaxx.runtime.swing.navigation.handler.AbstractNavigationHandler* pour
ajouter la possibilité d'utiliser la multisélection.
-jaxx.runtime.swing.navigation.NavigationOneClicSelectionHandler
+jaxx.runtime.swing.navigation.handler.NavigationOneClicSelectionHandler
---------------------------------------------------------------
-Extension de *jaxx.runtime.swing.navigation.NavigationMultiTreeHandler* pour
+Extension de *jaxx.runtime.swing.navigation.handler.NavigationMultiTreeHandler* pour
activer le simple clic lors de la multi-selection.
Définition d'un noeud
=====================
Le noeud
-(*jaxx.runtime.swing.navigation.NavigationTreeNodeModel.NavigationTreeNode*) est
+(*jaxx.runtime.swing.navigation.tree.NavigationTreeModel.NavigationTreeNode*) est
une extension d'un *javax.swing.tree.DefaultMutableTreeNode*.
Il apporte les nouvelles propriétés suivantes :
1
0