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
r1803 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing
by tchemit@users.nuiton.org 24 Mar '10
by tchemit@users.nuiton.org 24 Mar '10
24 Mar '10
Author: tchemit
Date: 2010-03-24 01:38:41 +0100 (Wed, 24 Mar 2010)
New Revision: 1803
Log:
add cleanValidators method + reformat code
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2010-03-23 11:08:43 UTC (rev 1802)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2010-03-24 00:38:41 UTC (rev 1803)
@@ -175,9 +175,9 @@
for (int i = getSize() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getValidator() == validator &&
+ if (error.getValidator().equals(validator) &&
error.getScope() == scope &&
- error.getField() == field &&
+ error.getField().equals(field) &&
messagesToDel.contains(error.getMessage())) {
// remove the message
data.remove(i);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2010-03-23 11:08:43 UTC (rev 1802)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2010-03-24 00:38:41 UTC (rev 1803)
@@ -50,7 +50,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
private static Log log =
- LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+ LogFactory.getLog(SwingValidatorMessageTableModel.class);
public static final String[] columnNames =
{"validator.scope", "validator.field", "validator.message"};
@@ -110,12 +110,16 @@
public void removeMessages(JComponent editor, BeanValidatorScope scope) {
+ if (editor==null) {
+ // no editor, so nothing to do
+ return;
+ }
// do it in reverse mode (only one pass in that way since index
// will stay coherent while removing them)
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getEditor() == editor &&
+ if (editor.equals(error.getEditor()) &&
(scope == null || error.getScope() == scope)) {
// remove the message
data.remove(i);
@@ -152,6 +156,13 @@
}
}
+ public void clearValidators() {
+ for (SwingValidator<?> v : validators) {
+ v.removeBeanValidatorListener(this);
+ }
+ validators.clear();
+ }
+
/**
* Obtain the message for a given row.
*
@@ -378,7 +389,7 @@
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getValidator() == validator &&
+ if (error.getValidator().equals(validator) &&
error.getScope() == scope &&
error.getFieldName().equals(field.getName()) &&
messagesToDel.contains(error.getMessage())) {
@@ -405,7 +416,7 @@
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getValidator() == validator &&
+ if (error.getValidator().equals(validator) &&
error.getScope() == scope &&
error.getFieldName().equals(fieldName) &&
messagesToDel.contains(error.getMessage())) {
@@ -428,7 +439,7 @@
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getEditor() == editor &&
+ if (error.getEditor().equals(editor) &&
(scope == null || error.getScope() == scope) &&
error.getFieldName().equals(fieldName)) {
// remove the message
1
0
23 Mar '10
Author: tchemit
Date: 2010-03-23 12:08:43 +0100 (Tue, 23 Mar 2010)
New Revision: 1802
Log:
Evolution #294: Remove deprecated api from version 2.0
Removed:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
Deleted: trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2010-03-23 11:06:38 UTC (rev 1801)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2010-03-23 11:08:43 UTC (rev 1802)
@@ -1,28 +0,0 @@
-package jaxx.runtime;
-/*
- * *##%
- * 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>.
- * ##%*
- */
-
-/**
- * @deprecated since 2, will be removed in 2.1
- */
-@Deprecated
-public class Util extends JAXXUtil{
-}
1
0
23 Mar '10
Author: tchemit
Date: 2010-03-23 12:06:38 +0100 (Tue, 23 Mar 2010)
New Revision: 1801
Log:
reformat code + removed unsued and commented code
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-23 10:56:00 UTC (rev 1800)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-03-23 11:06:38 UTC (rev 1801)
@@ -78,12 +78,6 @@
try {
return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor,
false);
- /*byte[] data = new byte[descriptor.length()];
- // copy low-order bytes into the array. The high-order bytes should all be zero.
- System.arraycopy(descriptor.getBytes(), 0, data, 0, data.length);
- //descriptor.getBytes(0, descriptor.length(), data, 0);
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
- return (JAXXObjectDescriptor) in.readObject();*/
} catch (IOException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
} catch (ClassNotFoundException e) {
@@ -96,13 +90,6 @@
try {
return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor,
true);
-
- /*byte[] data = new byte[descriptor.length()];
- // copy low-order bytes into the array. The high-order bytes should all be zero.
- System.arraycopy(descriptor.getBytes(), 0, data, 0, data.length);
- //descriptor.getBytes(0, descriptor.length(), data, 0);
- ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data)));
- return (JAXXObjectDescriptor) in.readObject();*/
} catch (IOException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
} catch (ClassNotFoundException e) {
@@ -303,31 +290,9 @@
return listener;
}
-// public static void setComponentWidth(Component component, int width) {
-// component.setSize(width, component.getHeight());
-// if (component instanceof JComponent) {
-// JComponent jcomponent = (JComponent) component;
-// jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height));
-// jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height));
-// if (jcomponent.isDisplayable()) {
-// jcomponent.revalidate();
-// }
-// }
-// }
-
-// public static void setComponentHeight(Component component, int height) {
-// component.setSize(component.getWidth(), height);
-// if (component instanceof JComponent) {
-// JComponent jcomponent = (JComponent) component;
-// jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height));
-// jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height));
-// if (jcomponent.isDisplayable()) {
-// jcomponent.revalidate();
-// }
-// }
-// }
-
- public static boolean assignment(boolean value, String name, JAXXObject src) {
+ public static boolean assignment(boolean value,
+ String name,
+ JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
1
0
r1800 - in trunk/jaxx-runtime/src: main/java/jaxx/runtime/context test/java/jaxx/runtime/context
by tchemit@users.nuiton.org 23 Mar '10
by tchemit@users.nuiton.org 23 Mar '10
23 Mar '10
Author: tchemit
Date: 2010-03-23 11:56:00 +0100 (Tue, 23 Mar 2010)
New Revision: 1800
Log:
Evolution #410: Can listen modifications of a DefaultApplicationContext via the PCS api
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2010-03-22 14:05:21 UTC (rev 1799)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2010-03-23 10:56:00 UTC (rev 1800)
@@ -20,10 +20,16 @@
*/
package jaxx.runtime.context;
-import jaxx.runtime.*;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import java.lang.annotation.*;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -31,87 +37,85 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* The default context to be used for an application.
+ * <p/>
+ * This extends the {@link DefaultJAXXContext} and add a possibility to
+ * auto-instanciate some classes asked via {@link #getContextValue(Class)} and
+ * {@link #getContextValue(Class, String)} methods.
+ * <p/>
+ * To registred a such class, just annotate your class with {@link AutoLoad}.
*
- * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate
- * some classes asked via {@link #getContextValue(java.lang.Class)} and
- * {@link #getContextValue(java.lang.Class, java.lang.String)} methods.
- *
- * To registred a such class, just annotate your class with {@link AutoLoad}.
- *
* @author chemit
+ * @see DefaultJAXXContext
* @since 1.2
- * @see DefaultJAXXContext
*/
public class DefaultApplicationContext extends DefaultJAXXContext {
/**
- * A class annotated @AutoLoad is used by context to auto
- * instanciate the class when required.
- *
+ * A class annotated @AutoLoad is used by context to auto instanciate
+ * the class when required.
+ * <p/>
* Note : A such class always have a public default constructor.
*
- * @author chemit
+ * @author chemit
* @version 1.0, 21/02/09
* @since 1.2
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
- public static @interface AutoLoad {
+ public @interface AutoLoad {
//TODO use this to add a method to init
String initMethod() default "";
}
/**
- * A class annotated @MethodAccess is used by context to obtain the value
- * of an entry via a declared method.
- *
- * Note : A such class must have a method called {@link #methodName()} with
+ * A class annotated @MethodAccess is used by context to obtain the
+ * value of an entry via a declared method.
+ * <p/>
+ * Note : A such class must have a method called {@link #methodName()} with
* a single String parameter.
*
- * @author chemit
+ * @author chemit
* @version 1.0, 21/02/09
* @since 1.2
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
- public static @interface MethodAccess {
+ public @interface MethodAccess {
/**
- * Define a forward to a target class. When the target class
- * will be asked with method {@link JAXXContext#getContextValue(java.lang.Class, java.lang.String)}
+ * Define a forward to a target class. When the target class will be
+ * asked with method {@link JAXXContext#getContextValue(Class, String)}
* it will be delegating to this class.
*
* @return the forwarded class
*/
Class<?> target() default Object.class;
- /**
- * @return the name of the method to access data
- */
+ /** @return the name of the method to access data */
String methodName();
}
+
+ /** Map of forwarded classes (key) to classes (values). */
+ protected Map<Class<?>, Class<?>> forwards;
+
/**
- * Map of forwarded classes (key) to classes (values).
+ * Map of entries to watch associated with the property to fires if a
+ * modification was found.
*/
- protected Map<Class<?>, Class<?>> forwards;
+ protected Map<JAXXContextEntryDef<?>, String> entryListened;
public DefaultApplicationContext() {
- super();
forwards = new HashMap<Class<?>, Class<?>>();
pcs = new PropertyChangeSupport(this);
}
-// public DefaultApplicationContext(JAXXObject ui) {
-// super();
-// }
/** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(DefaultApplicationContext.class);
+ static private final Log log =
+ LogFactory.getLog(DefaultApplicationContext.class);
/** to manage properties modifications */
protected PropertyChangeSupport pcs;
@@ -130,7 +134,8 @@
// always call the forwarder with no name
value = getContextValue(realClass, null);
if (log.isDebugEnabled()) {
- log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")");
+ log.debug("detect forward from " + clazz + " to " + realClass +
+ " (" + value + ")");
}
} else {
@@ -149,10 +154,12 @@
}
if (name != null) {
- throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name);
+ throw new IllegalArgumentException(
+ "an " + AutoLoad.class.getName() + " can not have " +
+ "a named context but was call with this one : " + name);
}
value = newInstance(clazz);
- if (!anno.initMethod().trim().isEmpty()){
+ if (!anno.initMethod().trim().isEmpty()) {
// apply method on class
newAccess(clazz, value, anno.initMethod().trim());
}
@@ -167,14 +174,15 @@
if (access != null) {
if (name == null) {
- if (access.target() != Object.class) {
+ if (!Object.class.equals(access.target())) {
// register forward
Class<?> targetClass = access.target();
if (!forwards.containsKey(targetClass)) {
// register forward
forwards.put(targetClass, clazz);
if (log.isDebugEnabled()) {
- log.debug("register forward from " + targetClass + " to " + clazz);
+ log.debug("register forward from " + targetClass +
+ " to " + clazz);
}
}
}
@@ -187,31 +195,109 @@
}
@Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
+ public <T> void removeContextValue(Class<T> klass, String name) {
Entry<Class<?>, Class<?>> entry;
- if (name == null && forwards.containsValue(klazz)) {
+ if (name == null && forwards.containsValue(klass)) {
// remove forward
- Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator();
+ Iterator<Entry<Class<?>, Class<?>>> itr =
+ forwards.entrySet().iterator();
while (itr.hasNext()) {
entry = itr.next();
- if (entry.getValue().equals(klazz)) {
+ if (entry.getValue().equals(klass)) {
itr.remove();
if (log.isDebugEnabled()) {
- log.debug("removed forward from " + entry.getKey() + " to " + klazz);
+ log.debug("removed forward from " + entry.getKey() +
+ " to " + klass);
}
break;
}
}
}
//FIXME should update forwards state
- super.removeContextValue(klazz, name);
+ JAXXContextEntryDef<?> entryToDel = getEntry(klass, name);
+ Object t = remove0(klass, name);
+ if (log.isDebugEnabled()) {
+ log.debug("removed object = " + t);
+ }
+ if (t != null && entryToDel != null) {
+ // a value was removed
+ // notify listeners
+ fireEntryChanged(entryToDel, t, null);
+ }
+// super.removeContextValue(klass, name);
}
+ @Override
+ public <T> void setContextValue(T o, String name) {
+// super.setContextValue(o, name);
+ if (name == null && PARENT_CONTEXT_ENTRY.accept2(o.getClass(), null)) {
+ setParentContext((JAXXContext) o);
+ return;
+ }
+ JAXXContextEntryDef<?> entry = getKey(name, o.getClass());
+ // first remove entry
+ Object oldValue = remove0(o.getClass(), name);
+ if (oldValue != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("remove value " + oldValue.getClass() + " for " +
+ entry);
+ }
+ }
+ // then can put safely
+ data.put(entry, o);
+ if (log.isDebugEnabled()) {
+ log.debug("[" + name + "] set value for entry " + entry);
+ }
+ // firezs
+ fireEntryChanged(entry.getKlass(), name, oldValue, o);
+ }
+
+ /**
+ * To add a listen modification of the given entry in the context.
+ *
+ * @param entry the entry to listen
+ * @param name the property name to fire if necessary
+ * @param listener the listener to notify if entry has changed
+ * @since 2.0.1
+ */
+ public void addPropertyChangeListener(JAXXContextEntryDef<?> entry,
+ String name,
+ PropertyChangeListener listener) {
+ if (entryListened == null) {
+ entryListened = new HashMap<JAXXContextEntryDef<?>, String>();
+ }
+ entryListened.put(entry, name);
+ if (log.isDebugEnabled()) {
+ log.debug("[" + name + "] for " + entry);
+ }
+ pcs.addPropertyChangeListener(name, listener);
+ }
+
+ /**
+ * To remove a listen modification of the given entry in the context.
+ *
+ * @param entry the entry to listen
+ * @param name the property name to fire if necessary
+ * @param listener the listener to notify if entry has changed
+ * @since 2.0.1
+ */
+ public void removePropertyChangeListener(JAXXContextEntryDef<?> entry,
+ String name,
+ PropertyChangeListener listener) {
+ if (entryListened == null) {
+ entryListened = new HashMap<JAXXContextEntryDef<?>, String>();
+ }
+ entryListened.remove(entry);
+ pcs.removePropertyChangeListener(name, listener);
+ }
+
public void addPropertyChangeListener(PropertyChangeListener listener) {
pcs.addPropertyChangeListener(listener);
}
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
pcs.addPropertyChangeListener(propertyName, listener);
}
@@ -219,7 +305,8 @@
pcs.removePropertyChangeListener(listener);
}
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener) {
pcs.removePropertyChangeListener(propertyName, listener);
}
@@ -227,7 +314,8 @@
return pcs.hasListeners(propertyName);
}
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(
+ String propertyName) {
return pcs.getPropertyChangeListeners(propertyName);
}
@@ -235,8 +323,78 @@
return pcs.getPropertyChangeListeners();
}
- protected Object newInstance(Class<?> clazz) throws IllegalArgumentException {
+ protected void fireEntryChanged(Class<?> klass,
+ String name,
+ Object oldValue,
+ Object newValue) {
+ // a value was removed
+ if (entryListened != null) {
+ // look if the entry was listened
+ if (log.isTraceEnabled()) {
+ log.trace("data size : " + data.size());
+ for (Entry<JAXXContextEntryDef<?>, Object> e : data.entrySet()) {
+ log.trace(e.getKey());
+ }
+ }
+ JAXXContextEntryDef<?> entry2 = getEntry(klass, name);
+ if (log.isDebugEnabled()) {
+ log.debug("[" + name + "] : try to find a changer for " + entry2);
+ }
+ if (entry2 != null) {
+ // entry find directly on this context
+ String propertyName = entryListened.get(entry2);
+ if (log.isTraceEnabled()) {
+ log.trace("registred property name = " + propertyName);
+ }
+ if (propertyName != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("will notify modification on " + entry2);
+ }
+ // fires the removed
+ firePropertyChange(propertyName, oldValue, newValue);
+ }
+ }
+ }
+ }
+
+ protected void fireEntryChanged(JAXXContextEntryDef<?> entryDef,
+ Object oldValue,
+ Object newValue) {
+ // a value was removed
+ if (entryListened != null) {
+ // look if the entry was listened
+
+ if (log.isTraceEnabled()) {
+ log.trace("data size : " + data.size());
+ for (Entry<JAXXContextEntryDef<?>, Object> e : data.entrySet()) {
+ log.trace(e.getKey());
+ }
+ }
+// JAXXContextEntryDef<?> entry2 = getEntry(klass, name);
+// if (log.isDebugEnabled()) {
+// log.debug("[" + name + "] : try to find a changer for " + entry2);
+// }
+ if (entryDef != null) {
+ // entry find directly on this context
+ String propertyName = entryListened.get(entryDef);
+ if (log.isTraceEnabled()) {
+ log.trace("registred property name = " + propertyName);
+ }
+ if (propertyName != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("will notify modification on " + entryDef);
+ }
+ // fires the removed
+ firePropertyChange(propertyName, oldValue, newValue);
+ }
+ }
+ }
+ }
+
+ protected Object newInstance(Class<?> clazz) throws
+ IllegalArgumentException {
+
Object value;
Constructor<?> constructor;
@@ -244,7 +402,8 @@
constructor = clazz.getConstructor();
// auto instanciate the class
if (constructor == null) {
- throw new IllegalArgumentException(clazz + " has no public constructor");
+ throw new IllegalArgumentException(
+ clazz + " has no public constructor");
}
} catch (NoSuchMethodException ex) {
throw new IllegalArgumentException(ex);
@@ -264,7 +423,11 @@
return value;
}
- protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException {
+ protected Object newAccess(
+ Class<?> clazz,
+ Object parent,
+ String methodName,
+ String name) throws IllegalArgumentException {
Object value;
try {
Method m = clazz.getMethod(methodName, String.class);
@@ -281,7 +444,10 @@
}
}
- protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException {
+ protected Object newAccess(
+ Class<?> clazz,
+ Object parent,
+ String methodName) throws IllegalArgumentException {
Object value;
try {
Method m = clazz.getMethod(methodName);
@@ -298,7 +464,9 @@
}
}
- protected void firePropertyChange(String name, Object oldValue, Object newValue) {
+ protected void firePropertyChange(String name,
+ Object oldValue,
+ Object newValue) {
pcs.firePropertyChange(name, oldValue, newValue);
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2010-03-22 14:05:21 UTC (rev 1799)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2010-03-23 10:56:00 UTC (rev 1800)
@@ -158,44 +158,62 @@
}
protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) {
+ //FIXME-TC20100322 : must change this to have a store, we instanciate
+ // a new object each time we wants to deal with the context...
return JAXXUtil.newContextEntryDef(name, klass);
}
@SuppressWarnings({"unchecked"})
- protected <T> T remove0(Class<T> klazz, String name) {
- if (PARENT_CONTEXT_ENTRY.accept(klazz, name)) {
+ protected <T> T remove0(Class<T> klass, String name) {
+ if (PARENT_CONTEXT_ENTRY.accept(klass, name)) {
JAXXContext old = getParentContext();
setParentContext(null);
return (T) old;
}
- JAXXContextEntryDef<?> entry = null;
- for (JAXXContextEntryDef<?> entryDef : data.keySet()) {
- if (entryDef.accept(klazz, name)) {
- entry = entryDef;
- break;
- }
- }
+ JAXXContextEntryDef<?> entry = getEntry(klass, name);
+// JAXXContextEntryDef<?> entry = null;
+// for (JAXXContextEntryDef<?> entryDef : data.keySet()) {
+// if (entryDef.accept(klass, name)) {
+// entry = entryDef;
+// break;
+// }
+// }
if (entry != null) {
return (T) data.remove(entry);
}
- if (JAXXContext.class.equals(klazz)) {
+ if (JAXXContext.class.equals(klass)) {
return null;
}
- // try in parentContext
+
+ // try on parent
JAXXContext parent = getParentContext();
if (parent == null) {
+ // no parent, stop now, can not found entry
return null;
}
if (parent instanceof DefaultJAXXContext) {
- return ((DefaultJAXXContext) parent).remove0(klazz, name);
+ // try now on the parent
+ return ((DefaultJAXXContext) parent).remove0(klass, name);
}
-
+
+ // can not find the entry anywhere, so says that nothing was removed
return null;
}
+ protected JAXXContextEntryDef<?> getEntry(Class<?> klass, String name) {
+ JAXXContextEntryDef<?> entry = null;
+ for (JAXXContextEntryDef<?> entryDef : data.keySet()) {
+ if (entryDef.accept(klass, name)) {
+ entry = entryDef;
+ break;
+ }
+ }
+ return entry;
+ }
+
protected JAXXContext getParentContext() {
return parentContext;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2010-03-22 14:05:21 UTC (rev 1799)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2010-03-23 10:56:00 UTC (rev 1800)
@@ -96,7 +96,6 @@
JAXXContextEntryDef<?> that = (JAXXContextEntryDef<?>) o;
return klass.equals(that.klass) &&
!(name != null ? !name.equals(that.name) : that.name != null);
-
}
@Override
@@ -106,7 +105,7 @@
}
public boolean accept(Class<?> klass, String name) {
- if (klass == Object.class && this.klass != Object.class) {
+ if (Object.class.equals(klass) && !Object.class.equals(this.klass)) {
// try on name only
return this.name != null && name != null && this.name.equals(name);
}
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2010-03-22 14:05:21 UTC (rev 1799)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2010-03-23 10:56:00 UTC (rev 1800)
@@ -20,24 +20,37 @@
*/
package jaxx.runtime.context;
+import jaxx.runtime.JAXXUtil;
import jaxx.runtime.context.DefaultApplicationContext.AutoLoad;
import jaxx.runtime.context.DefaultApplicationContext.MethodAccess;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.*;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Arrays;
+import java.util.List;
+
import static org.junit.Assert.*;
-/**
- *
- * @author tchemit <chemit(a)codelutin.com>
- */
+/** @author tchemit <chemit(a)codelutin.com> */
public class DefaultApplicationContextTest {
+ /** Logger */
+ private static final Log log =
+ LogFactory.getLog(DefaultApplicationContextTest.class);
+
static int helloCount;
+
static int helloGetCount;
+ static final JAXXContextEntryDef<String> STRING_ENTRY =
+ JAXXUtil.newContextEntryDef("myStringEntryKey", String.class);
+
+ static final JAXXContextEntryDef<List<String>> LIST_STRING_ENTRY =
+ JAXXUtil.newListContextEntryDef("myListEntryKey");
+
@AutoLoad
@MethodAccess(methodName = "hello", target = String.class)
public static class Hello {
@@ -51,6 +64,7 @@
return "hello " + name;
}
}
+
DefaultApplicationContext context;
@BeforeClass
@@ -130,4 +144,70 @@
context.getContextValue(Hello.class);
assertEquals(2, helloCount);
}
+
+ static int yoCount;
+
+ @Test
+ public void testEntryListener() {
+
+ PropertyChangeListener listener = new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isInfoEnabled()) {
+ log.info("changed detected on " + evt.getSource());
+ }
+ yoCount++;
+ }
+ };
+ context.addPropertyChangeListener(STRING_ENTRY, "myKey", listener);
+
+ STRING_ENTRY.setContextValue(context, "myValue");
+
+ Assert.assertEquals(1, yoCount);
+
+ STRING_ENTRY.removeContextValue(context);
+
+ Assert.assertEquals(2, yoCount);
+
+ context.removePropertyChangeListener(STRING_ENTRY, "myKey", listener);
+
+ // test that nothing changed now
+
+ STRING_ENTRY.setContextValue(context, "myValue");
+
+ Assert.assertEquals(2, yoCount);
+
+ STRING_ENTRY.removeContextValue(context);
+
+ Assert.assertEquals(2, yoCount);
+
+ // test with a list entry
+
+ context.addPropertyChangeListener(LIST_STRING_ENTRY, "myKey2", listener);
+
+ LIST_STRING_ENTRY.setContextValue(context, Arrays.asList("myValue"));
+
+ Assert.assertEquals(3, yoCount);
+
+ LIST_STRING_ENTRY.removeContextValue(context);
+
+ Assert.assertEquals(4, yoCount);
+
+
+ // test that nothing changed now
+
+ context.removePropertyChangeListener(LIST_STRING_ENTRY, "myKey2", listener);
+
+ LIST_STRING_ENTRY.setContextValue(context, Arrays.asList("myValue2"));
+
+ Assert.assertEquals(4, yoCount);
+
+ LIST_STRING_ENTRY.removeContextValue(context);
+
+ Assert.assertEquals(4, yoCount);
+
+
+ }
+
+
}
1
0
r1799 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation
by sletellier@users.nuiton.org 22 Mar '10
by sletellier@users.nuiton.org 22 Mar '10
22 Mar '10
Author: sletellier
Date: 2010-03-22 15:05:21 +0100 (Mon, 22 Mar 2010)
New Revision: 1799
Log:
Allow to ignore case of rendrer comparator
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java 2010-03-20 17:23:36 UTC (rev 1798)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java 2010-03-22 14:05:21 UTC (rev 1799)
@@ -44,8 +44,8 @@
protected NavigationModel model;
protected List<Comparator> comparators;
+ protected boolean ignoreCase = false;
-
/**
* Used to sort NavigationTreeModel by decorator
*
@@ -57,6 +57,18 @@
}
/**
+ * Used to sort NavigationTreeModel by decorator
+ *
+ * @param model of navigation tree
+ * @param ignoreCase tio ignore renderer case renderer
+ */
+ public NavigationSortedTreeAdapter(NavigationModel model, boolean ignoreCase){
+ this.ignoreCase = ignoreCase;
+ this.model = model;
+ model.addTreeModelListener(this);
+ }
+
+ /**
* Used to sort NavigationTreeModel by comparator
*
* @param model of navigation tree
@@ -134,7 +146,7 @@
List<NavigationTreeNode> children = Collections.list(parent.children());
if (comparators == null || comparators.isEmpty()){
- Collections.sort(children, RENDERER_COMPARATOR);
+ Collections.sort(children, rendererDecorator);
} else {
children = sortWithComparators(children);
}
@@ -230,12 +242,15 @@
return children;
}
- static final Comparator RENDERER_COMPARATOR = new Comparator() {
+ final Comparator rendererDecorator = new Comparator() {
@Override
public int compare(Object o1, Object o2) {
try {
String label1 = ((NavigationTreeNode)o1).getRenderer().toString();
String label2 = ((NavigationTreeNode)o2).getRenderer().toString();
+ if (ignoreCase){
+ return label1.compareToIgnoreCase(label2);
+ }
return label1.compareTo(label2);
} catch (Exception eee) {
return 0;
1
0
r1798 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator
by tchemit@users.nuiton.org 20 Mar '10
by tchemit@users.nuiton.org 20 Mar '10
20 Mar '10
Author: tchemit
Date: 2010-03-20 18:23:36 +0100 (Sat, 20 Mar 2010)
New Revision: 1798
Log:
add validatorsMap + improve BeanValidatorDetector code
Added:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/ValidatorsMap.java
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-19 17:53:26 UTC (rev 1797)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorDetector.java 2010-03-20 17:23:36 UTC (rev 1798)
@@ -299,7 +299,7 @@
public ValidatorFilenameFilter(Class<?> clazz) {
this.clazz = clazz;
- this.prefix = clazz.getSimpleName() + "-";
+ prefix = clazz.getSimpleName() + "-";
}
@Override
Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/ValidatorsMap.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/ValidatorsMap.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/ValidatorsMap.java 2010-03-20 17:23:36 UTC (rev 1798)
@@ -0,0 +1,119 @@
+/*
+ * *##%
+ * ObServe :: Services
+ * Copyright (C) 2008 - 2010 IRD, Codelutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * ##%*
+ */
+
+package jaxx.runtime.validator;
+
+import java.util.*;
+
+/**
+ * Un dictionnaire de validateurs ordonnees par le type de leur bean.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class ValidatorsMap implements Map<Class<?>, BeanValidator<?>> {
+
+ protected final Map<Class<?>, BeanValidator<?>> delegate;
+
+ public ValidatorsMap() {
+ delegate = new HashMap<Class<?>, BeanValidator<?>>();
+ }
+
+ public BeanValidatorScope[] getScopes() {
+ EnumSet<BeanValidatorScope> result =
+ EnumSet.noneOf(BeanValidatorScope.class);
+ for (BeanValidator<?> b : values()) {
+ result.addAll(b.getScopes());
+ }
+ return result.toArray(new BeanValidatorScope[result.size()]);
+ }
+
+// public <X> BeanValidator<X> getValidator(X klass) {
+// BeanValidator<X> beanValidator = (BeanValidator<X>) get(klass.getClass());
+// return beanValidator;
+// }
+
+ public <X> BeanValidator<X> getValidator(Class<X> klass) {
+ BeanValidator<X> beanValidator = (BeanValidator<X>) get(klass);
+ return beanValidator;
+ }
+
+ @Override
+ public int size() {
+ return delegate.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return delegate.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return delegate.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return delegate.containsValue(value);
+ }
+
+ @Override
+ public BeanValidator<?> get(Object key) {
+ return delegate.get(key);
+ }
+
+ @Override
+ public BeanValidator<?> put(Class<?> key, BeanValidator<?> value) {
+ return delegate.put(key, value);
+ }
+
+ @Override
+ public BeanValidator<?> remove(Object key) {
+ return delegate.remove(key);
+ }
+
+ @Override
+ public void putAll(Map<? extends Class<?>, ? extends BeanValidator<?>> m) {
+ delegate.putAll(m);
+ }
+
+ @Override
+ public void clear() {
+ delegate.clear();
+ }
+
+ @Override
+ public Set<Class<?>> keySet() {
+ return delegate.keySet();
+ }
+
+ @Override
+ public Collection<BeanValidator<?>> values() {
+ return delegate.values();
+ }
+
+ @Override
+ public Set<Entry<Class<?>, BeanValidator<?>>> entrySet() {
+ return delegate.entrySet();
+ }
+
+}
Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/ValidatorsMap.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
1
0
r1797 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation
by sletellier@users.nuiton.org 19 Mar '10
by sletellier@users.nuiton.org 19 Mar '10
19 Mar '10
Author: sletellier
Date: 2010-03-19 18:53:26 +0100 (Fri, 19 Mar 2010)
New Revision: 1797
Log:
Creation of adapter to sort navigation tree
Added:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java
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-19 17:32:29 UTC (rev 1796)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationModel.java 2010-03-19 17:53:26 UTC (rev 1797)
@@ -22,6 +22,7 @@
import jaxx.runtime.JAXXContext;
+import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import java.util.regex.Pattern;
@@ -33,7 +34,7 @@
* @author sletellier
* @since 2.0.0
*/
-public interface NavigationModel {
+public interface NavigationModel extends TreeModel {
Object getRoot();
Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java (rev 0)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java 2010-03-19 17:53:26 UTC (rev 1797)
@@ -0,0 +1,245 @@
+/*
+ * *##%
+ * 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import java.util.*;
+
+/**
+ * Adapter to sort NavigationModel
+ * FIXME : Dont work with TreeTable
+ *
+ * @author sletellier
+ * @since 2.0.1
+ */
+public class NavigationSortedTreeAdapter implements TreeModelListener {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationSortedTreeAdapter.class);
+
+ protected NavigationModel model;
+ protected List<Comparator> comparators;
+
+
+ /**
+ * Used to sort NavigationTreeModel by decorator
+ *
+ * @param model of navigation tree
+ */
+ public NavigationSortedTreeAdapter(NavigationModel model){
+ this.model = model;
+ model.addTreeModelListener(this);
+ }
+
+ /**
+ * Used to sort NavigationTreeModel by comparator
+ *
+ * @param model of navigation tree
+ * @param comparator used to sort tree
+ */
+ public NavigationSortedTreeAdapter(NavigationModel model, Comparator comparator){
+ this.model = model;
+ comparators = new ArrayList<Comparator>();
+ comparators.add(comparator);
+ model.addTreeModelListener(this);
+ }
+
+ /**
+ * Used to sort NavigationTreeModel by comparators
+ *
+ * @param model of navigation tree
+ * @param comparators used to sort tree
+ */
+ public NavigationSortedTreeAdapter(NavigationModel model, List<Comparator> comparators){
+ this.model = model;
+ this.comparators = comparators;
+ model.addTreeModelListener(this);
+ }
+
+ /**
+ * Used to sort NavigationTreeModel by comparators
+ *
+ * @param model of navigation tree
+ * @param comparators used to sort tree
+ */
+ public NavigationSortedTreeAdapter(NavigationModel model, Comparator ... comparators){
+ this.model = model;
+ this.comparators = Arrays.asList(comparators);
+ model.addTreeModelListener(this);
+ }
+
+ // TODO : find how optimize this (structure not change every times)
+ @Override
+ public void treeNodesChanged(TreeModelEvent e) {
+ sort(getCurrentNode(e), true);
+ }
+
+ @Override
+ public void treeNodesInserted(TreeModelEvent e) {
+ sort(getCurrentNode(e), true);
+ }
+
+ @Override
+ public void treeNodesRemoved(TreeModelEvent e) {
+ }
+
+ @Override
+ public void treeStructureChanged(TreeModelEvent e) {
+ sort(getCurrentNode(e), true);
+ }
+
+ protected NavigationTreeNode getCurrentNode(TreeModelEvent e){
+ return (NavigationTreeNode) e.getTreePath().getLastPathComponent();
+ }
+
+ // Sort
+ protected void sort() {
+ NavigationTreeNode rootNode = (NavigationTreeNode) model.getRoot();
+ if (rootNode != null && log.isDebugEnabled()){
+ log.debug("Sort from root node : " + rootNode.getBean());
+ }
+ sort(rootNode, true);
+ }
+ protected void sort(NavigationTreeNode parent, boolean structureChanged) {
+
+ if (parent == null){
+ return;
+ }
+
+ List<NavigationTreeNode> children = Collections.list(parent.children());
+
+ if (comparators == null || comparators.isEmpty()){
+ Collections.sort(children, RENDERER_COMPARATOR);
+ } else {
+ children = sortWithComparators(children);
+ }
+
+ if (children == null || children.isEmpty()){
+ return;
+ }
+
+ Iterator<NavigationTreeNode> childrenIterator = children.iterator();
+ if (childrenIterator != null){
+
+ model.removeTreeModelListener(this);
+
+ parent.removeAllChildren();
+ while (childrenIterator.hasNext()) {
+ NavigationTreeNode childNode = childrenIterator.next();
+ if (log.isDebugEnabled()){
+ log.debug("Adding child " + childNode.getBean() + " to parent " + parent.getBean());
+ }
+ parent.add(childNode);
+ }
+
+ if (structureChanged){
+ model.nodeStructureChanged(parent);
+ } else {
+ model.nodeChanged(parent, true);
+ }
+ model.addTreeModelListener(this);
+ }
+ }
+
+ protected List<NavigationTreeNode> sortWithComparators(List<NavigationTreeNode> children) {
+ for (Comparator<?> comparator : comparators){
+ List<NavigationTreeNode> result = sortWithComparator(children, comparator);
+ if (result != null){
+ return result;
+ }
+ }
+ return null;
+ }
+
+ protected <T> List<NavigationTreeNode> sortWithComparator(List<NavigationTreeNode> children,
+ Comparator<T> comparator) {
+ Map<T, NavigationTreeNode> toSort = new HashMap<T, NavigationTreeNode>();
+
+ List<T> beans = new ArrayList<T>();
+
+ // Extract beans
+ for (NavigationTreeNode child : children){
+ Object o = child.getBean();
+ if (o != null){
+ try{
+ T casted = (T) o;
+ beans.add(casted);
+ toSort.put(casted, child);
+ } catch (ClassCastException eee){
+ return null;
+ }
+ }
+ }
+
+ if (beans.isEmpty()){
+ return null;
+ }
+
+ // Sort beans
+ if (log.isDebugEnabled()){
+ log.debug("Sorting : " +
+ beans.get(0).getClass().getName() +
+ " With comparator : " + comparator.getClass().getName());
+ }
+
+ try{
+ Collections.sort(beans, comparator);
+ } catch (Exception eee){
+ if (log.isWarnEnabled()){
+ log.warn("Cant appply comparator : " + comparator.getClass().getName()
+ + " with entity of type : "
+ + (beans.isEmpty() ? " vide " : beans.get(0).getClass().getName()));
+ }
+ return null;
+ }
+
+ // Retrieve sorted nodes
+ children.clear();
+ int cnt = 0;
+ for (T bean : beans){
+ if (log.isDebugEnabled()){
+ log.debug("Retrieve sorted bean : " + ++cnt + " - " + bean);
+ }
+ children.add(toSort.get(bean));
+ }
+ return children;
+ }
+
+ static final Comparator RENDERER_COMPARATOR = new Comparator() {
+ @Override
+ public int compare(Object o1, Object o2) {
+ try {
+ String label1 = ((NavigationTreeNode)o1).getRenderer().toString();
+ String label2 = ((NavigationTreeNode)o2).getRenderer().toString();
+ return label1.compareTo(label2);
+ } catch (Exception eee) {
+ return 0;
+ }
+ }
+ };
+}
1
0
r1796 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer
by tchemit@users.nuiton.org 19 Mar '10
by tchemit@users.nuiton.org 19 Mar '10
19 Mar '10
Author: tchemit
Date: 2010-03-19 18:32:29 +0100 (Fri, 19 Mar 2010)
New Revision: 1796
Log:
reformat code
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2010-03-18 21:42:47 UTC (rev 1795)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2010-03-19 17:32:29 UTC (rev 1796)
@@ -29,10 +29,10 @@
import java.awt.Component;
/**
- * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text :
- * the text is I18nalize.
+ * A simple TableCellRenderer using a delegate TableCellRenderer to render
+ * everything elese thant the text : the text is I18nalize.
*
- * @author chemit
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class I18nTableCellRenderer implements TableCellRenderer {
@@ -45,32 +45,51 @@
/** the delegate cell renderer */
protected TableCellRenderer delegate;
- public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) {
+ public I18nTableCellRenderer(TableCellRenderer delegate,
+ String... keysAndTips) {
this.delegate = delegate;
if (keysAndTips.length == 0) {
- throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)");
+ throw new IllegalArgumentException(
+ "can not have empty keysAndTips parameters (means no " +
+ "column ?)");
}
if (keysAndTips.length % 2 == 1) {
- throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter");
+ throw new IllegalArgumentException(
+ "must have some couple (text,tooltTipText), but had an" +
+ " even number of data in keysAndTips parameter");
}
int size = keysAndTips.length / 2;
- this.keys = new String[size];
- this.tips = new String[size];
+ keys = new String[size];
+ tips = new String[size];
for (int i = 0; i < size; i++) {
- this.keys[i] = keysAndTips[2 * i];
- this.tips[i] = keysAndTips[2 * i + 1];
+ keys[i] = keysAndTips[2 * i];
+ tips[i] = keysAndTips[2 * i + 1];
}
}
@Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasfocus,
+ int row,
+ int column) {
if (column > keys.length) {
- throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
+ throw new IndexOutOfBoundsException(
+ "colum can not be greater than " + keys.length);
}
TableColumn col = table.getColumn(table.getColumnName(column));
int index = col.getModelIndex();
value = _(keys[index]);
- JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
+ JComponent rendererComponent = (JComponent)
+ delegate.getTableCellRendererComponent(
+ table,
+ value,
+ isSelected,
+ hasfocus,
+ row,
+ column
+ );
rendererComponent.setToolTipText(_(tips[index]));
return rendererComponent;
}
1
0
r1795 - in trunk/jaxx-runtime/src: main/java/jaxx/runtime main/java/jaxx/runtime/swing main/java/jaxx/runtime/swing/help main/java/jaxx/runtime/swing/navigation main/java/jaxx/runtime/swing/wizard main/java/jaxx/runtime/validator/field test/java/jaxx/runtime/context test/java/jaxx/runtime/validator test/java/jaxx/runtime/validator/field
by tchemit@users.nuiton.org 18 Mar '10
by tchemit@users.nuiton.org 18 Mar '10
18 Mar '10
Author: tchemit
Date: 2010-03-18 22:42:47 +0100 (Thu, 18 Mar 2010)
New Revision: 1795
Log:
reformat code + improve generics
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java
trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -78,7 +78,7 @@
* <p/>
* Note : Replace previous class jaxx.runtime.swing.Utils in previous versions.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.2
*/
public class SwingUtil extends JAXXUtil {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -49,7 +49,7 @@
* <li>override the method {@link #acceptEvent(MouseEvent, JXLayer)}</li>
* </ul>
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.2
*/
public class BlockingLayerUI extends AbstractLayerUI<JComponent> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -51,7 +51,7 @@
* <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
* </ul>
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class BlockingLayerUI2 extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -35,7 +35,7 @@
* le contenu sera changé automatiquement, ce qui permet une utilisation direct
* dans jaxx sans à avoir à écrire d'écouteur.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
* @see CardLayout2
*/
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -49,7 +49,7 @@
/**
* La classe pour encapsuler l'aide de l'application.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.4
*/
public class JAXXHelpBroker {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -28,7 +28,7 @@
*
* @param <B> type of broker.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
* @see JAXXHelpBroker
*/
Modified: 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-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -39,7 +39,7 @@
* from a node we can not just listen selection model changed, we must control
* it.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.7.2
*/
public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel implements TreeSelectionListener{
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-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -22,67 +22,68 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Un modèle de wizard.
+ * <p/>
+ * <p/>
+ * <b>Note:</b> le type des étapes doit être uné énumération qui implante {@link
+ * WizardStep}.
*
- *
- * <b>Note:</b> le type des étapes doit être uné énumération qui implante
- * {@link WizardStep}.
- *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des étapes.
- *
- * @author tony
+ * @see WizardStep
* @since 1.3
- * @see WizardStep
*/
public class WizardModel<E extends WizardStep> {
public static final String STEPS_PROPERTY_NAME = "steps";
+
public static final String STEP_PROPERTY_NAME = "step";
+
public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
+
public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
+
public static final String VALID_STEP_PROPERTY_NAME = "validStep";
- /**
- * le type d'une etape du model (doit etre une enumeration)
- */
+
+ /** le type d'une etape du model (doit etre une enumeration) */
protected final Class<E> stepClass;
- /**
- * Toutes les étapes à passer
- */
+
+ /** Toutes les étapes à passer */
protected List<E> steps;
+
/** les etapes a exclure */
protected List<E> excludeSteps;
- /**
- * L'étape courante
- */
+
+ /** L'étape courante */
protected E step;
- /**
- * drapeau pour valider l'état de l'étape courante
- */
+
+ /** drapeau pour valider l'état de l'étape courante */
protected boolean validStep;
+
/**
- * drapeau lorsque le modele effectue des operations
- * de transformation de modele mais que les écouteurs
- * ne devraient pas tenir compte des modifications
+ * drapeau lorsque le modele effectue des operations de transformation de
+ * modele mais que les écouteurs ne devraient pas tenir compte des
+ * modifications
*/
protected boolean valueAdjusting;
- /**
- * pour propager les changements dans le modèle vers l'ui
- */
+
+ /** pour propager les changements dans le modèle vers l'ui */
protected PropertyChangeSupport pcs;
public WizardModel(Class<E> stepClass, E... steps) {
if (!Enum.class.isAssignableFrom(stepClass)) {
throw new IllegalArgumentException("stepClass must be an" +
- " Enumeration but was " + stepClass.getName());
+ " Enumeration but was " + stepClass.getName());
}
this.stepClass = stepClass;
- this.pcs = new PropertyChangeSupport(this);
- this.steps = new java.util.ArrayList<E>();
+ pcs = new PropertyChangeSupport(this);
+ this.steps = new ArrayList<E>();
if (steps.length > 0) {
setSteps(steps);
}
@@ -119,7 +120,7 @@
}
if (!steps.contains(e)) {
throw new IllegalStateException("step " + e.toString() +
- " is not in universe of steps (" + steps + ')');
+ " is not in universe of steps (" + steps + ')');
}
setStep(e);
}
@@ -169,7 +170,7 @@
return steps.get(index + 1);
}
- public java.util.List<E> getSteps() {
+ public List<E> getSteps() {
return steps;
}
@@ -179,13 +180,13 @@
/**
* Change l'univers des etapes.
- *
+ * <p/>
* Note: on presume ici que l'étape courante est toujours la meme.
*
* @param steps le nouvel univers des etapes
*/
public void setSteps(E... steps) {
- java.util.List<E> oldValue = this.steps;
+ List<E> oldValue = this.steps;
this.steps = Collections.unmodifiableList(Arrays.asList(steps));
firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
// la propriete nextStep peut avoir changee
@@ -199,6 +200,7 @@
public void setExcludeSteps(List<E> excludeSteps) {
this.excludeSteps = excludeSteps;
}
+
public boolean validate(E s) {
return step != null;
}
@@ -233,11 +235,11 @@
return;
}
boolean validate = validate(step);
- this.validStep = validate;
+ validStep = validate;
// toujours forcer la propagation
firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
}
-
+
protected Class<E> getStepClass() {
return stepClass;
}
@@ -250,7 +252,7 @@
firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
// la propriete previousStep peut avoir changee
firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null,
- getPreviousStep());
+ getPreviousStep());
validate();
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,16 +20,17 @@
*/
package jaxx.runtime.swing.wizard;
-import javax.swing.SwingWorker;
import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.*;
+
/**
- * La classe de base a implanter pour definir l'action d'une operation
- * dans un wizard.
+ * La classe de base a implanter pour definir l'action d'une operation dans un
+ * wizard.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type d'étapes
* @param <M> le type de modèle
* @since 1.3
@@ -37,15 +38,19 @@
public abstract class WizardOperationAction<E extends WizardOperationStep, M extends WizardOperationModel<E>> extends SwingWorker<WizardOperationState, String> {
/** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(WizardOperationAction.class);
+ private static final Log log =
+ LogFactory.getLog(WizardOperationAction.class);
+
E operation;
+
WizardOperationState operationState;
+
Exception error;
public WizardOperationAction(E operation) {
- super();
if (!operation.isOperation()) {
- throw new IllegalArgumentException("the step " + operation + " has no operation defined");
+ throw new IllegalArgumentException(
+ "the step " + operation + " has no operation defined");
}
this.operation = operation;
}
@@ -68,7 +73,8 @@
public abstract void start(JAXXContext context);
- public abstract void beforeAction(JAXXContext context, M model) throws Exception;
+ public abstract void beforeAction(JAXXContext context,
+ M model) throws Exception;
public abstract WizardOperationState doAction(M model) throws Exception;
@@ -86,7 +92,8 @@
@Override
public String toString() {
- return super.toString() + " < operation: " + operation + ", state: " + getState() + " >";
+ return super.toString() + " < operation: " + operation + ", state: " +
+ getState() + " >";
}
@Override
@@ -122,7 +129,7 @@
log.error(e.getMessage(), e);
} finally {
// on enregistre le resultat de l'opération
- this.operationState = result;
+ operationState = result;
}
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,42 +20,45 @@
*/
package jaxx.runtime.swing.wizard;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Date;
-import javax.swing.SwingWorker.StateValue;
import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.SwingWorker.StateValue;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+
/**
* Thread qui réalise les opérations.
+ * <p/>
+ * Pour exécuter une nouvelle opération, on utilise la méthode {@link
+ * #launchOperation(WizardOperationStep)}.
+ * <p/>
+ * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link
+ * #setWaiting(boolean)}
*
- * Pour exécuter une nouvelle opération, on utilise la méthode
- * {@link #launchOperation(WizardOperationStep)}.
- *
- * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
- *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des etapes
* @param <M> le type de modele
* @param <A> le type d'action d'operation
- *
- * @author tony
* @since 1.3
*/
public abstract class WizardOperationActionThread<E extends WizardOperationStep, M extends WizardOperationModel<E>, A extends WizardOperationAction<E, M>> extends Thread implements PropertyChangeListener {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(WizardOperationActionThread.class);
- /**
- * l'état du thread si annulé
- */
+
+ /** l'état du thread si annulé */
private boolean canceled;
+
protected Class<M> modelClass;
+
protected A currentAction;
+
/**
- * un lock pour permettre la suspension et la reprise du thread
- * lors du mode interactif.
+ * un lock pour permettre la suspension et la reprise du thread lors du mode
+ * interactif.
*/
private final Object LOCK = new Object();
@@ -70,11 +73,11 @@
public void cancel() {
log.info("cancel " + this);
- this.canceled = true;
-
+ canceled = true;
+
// on annule le modele
getModel().cancel();
-
+
// on rend la main au thread
setWaiting(false);
}
@@ -179,10 +182,7 @@
}
}
- /**
- * La méthode pour nettoyer le thread, a la fermeture.
- *
- */
+ /** La méthode pour nettoyer le thread, a la fermeture. */
protected void close() {
// par defaut, on ne fait rien
log.trace(this);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,53 +20,47 @@
*/
package jaxx.runtime.swing.wizard;
-import java.util.Arrays;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import javax.swing.SwingWorker.StateValue;
+import java.util.*;
/**
* Un modèle de wizard avec des opérations.
*
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des étapes.
- * @author tony
* @since 1.3
*/
public class WizardOperationModel<E extends WizardOperationStep> extends WizardModel<E> {
public static final String OPERATIONS_PROPERTY_NAME = "operations";
+
public static final String OPERATION_STATE_PROPERTY_NAME = "operationState";
+
public static final String MODEL_STATE_PROPERTY_NAME = "modelState";
+
public static final String WAS_STARTED_PROPERTY_NAME = "wasStarted";
- /**
- * La liste des opérations à effectuer
- */
+ /** La liste des opérations à effectuer */
protected Set<E> operations;
- /**
- * Pour conserver les états des opérations
- */
+
+ /** Pour conserver les états des opérations */
protected Map<E, WizardOperationState> operationStates;
- protected Map<E, WizardOperationAction> operationActions;
- /**
- * L'état générale du modèle
- */
+
+ protected Map<E, WizardOperationAction<E, ? extends WizardOperationModel<E>>> operationActions;
+
+ /** L'état générale du modèle */
protected WizardOperationState modelState;
- /**
- * un drapeau pour savoir siune opération a été lancée
- */
+
+ /** un drapeau pour savoir siune opération a été lancée */
protected boolean wasStarted;
@SuppressWarnings("unchecked")
public <T extends Enum<T>> WizardOperationModel(Class<E> stepClass, E... steps) {
super(stepClass, steps);
- Class<T> k = (Class) stepClass;
- this.operationStates = (Map) new EnumMap(k);
- this.operations = (Set<E>) EnumSet.noneOf(k);
- this.operationActions = (Map) new EnumMap(k);
+ Class<T> k = (Class<T>) stepClass;
+ operationStates = new EnumMap(k);
+ operations = (Set<E>) EnumSet.noneOf(k);
+ operationActions = new EnumMap(k);
}
public Set<E> getOperations() {
@@ -95,11 +89,11 @@
return operationStates.get(operation);
}
- public WizardOperationAction getOperationAction(E operation) {
- WizardOperationAction action = operationActions.get(operation);
+ public WizardOperationAction<E, ? extends WizardOperationModel<E>> getOperationAction(E operation) {
+ WizardOperationAction<E, ? extends WizardOperationModel<E>> action = operationActions.get(operation);
if (action == null) {
try {
- action = operation.getActionClass().newInstance();
+ action = (WizardOperationAction<E, ? extends WizardOperationModel<E>>) operation.getActionClass().newInstance();
operationActions.put(operation, action);
} catch (Exception ex) {
throw new RuntimeException(ex);
@@ -115,7 +109,7 @@
public void setOperationState(E operation, WizardOperationState operationState) {
WizardOperationState oldValue = getOperationState(operation);
- this.operationStates.put(operation, operationState);
+ operationStates.put(operation, operationState);
fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getSteps().indexOf(operation), oldValue, operationState);
updateModelState(operation, operationState);
validate();
@@ -136,9 +130,9 @@
// uniquement si l'onglet precedent est accessible, valide et son etat est a SUCCESSED
E previousStep = steps.get(i - 1);
result[i] = modelState == WizardOperationState.SUCCESSED ||
- (result[i - 1] &&
- validate(previousStep) &&
- (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED));
+ result[i - 1] &&
+ validate(previousStep) &&
+ (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED);
}
}
//System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result));
@@ -165,10 +159,9 @@
}
setModelState(WizardOperationState.CANCELED);
if (getStep() != null && getStep().isOperation()) {
- WizardOperationAction action = getOperationAction(getStep());
+ WizardOperationAction<E, ? extends WizardOperationModel<E>> action = getOperationAction(getStep());
if (action != null) {
if (!action.isCancelled() && !action.isDone() && action.getState() == StateValue.STARTED) {
- System.out.println("cancel action " + action);
// on annule l'action
action.cancel(true);
}
@@ -210,9 +203,9 @@
firePropertyChange(MODEL_STATE_PROPERTY_NAME, null, modelState);
}
- public WizardOperationAction reloadOperation(E operation) {
+ public WizardOperationAction<E, ? extends WizardOperationModel<E>> reloadOperation(E operation) {
operationActions.remove(operation);
- WizardOperationAction newOp = getOperationAction(operation);
+ WizardOperationAction<E, ? extends WizardOperationModel<E>> newOp = getOperationAction(operation);
return newOp;
}
@@ -222,7 +215,7 @@
firePropertyChange(MODEL_STATE_PROPERTY_NAME, oldValue, modelState);
if (!wasStarted) {
if ((oldValue == null || oldValue == WizardOperationState.PENDING) && modelState == WizardOperationState.RUNNING) {
- this.wasStarted = true;
+ wasStarted = true;
firePropertyChange(WAS_STARTED_PROPERTY_NAME, false, true);
}
}
@@ -279,7 +272,7 @@
protected int getOperationIndex(E operation) {
int index = 0;
for (E o : operations) {
- if (operation == o) {
+ if (o.equals(operation)) {
return index;
}
index++;
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -22,31 +22,26 @@
/**
* Pour caractériser l'état d'une opération.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
*/
public enum WizardOperationState {
- /**
- * quand l'opération n'a pas encore été réalisée
- */
+ /** quand l'opération n'a pas encore été réalisée */
PENDING,
- /**
- * quand l'opération est en cours
- */
+
+ /** quand l'opération est en cours */
RUNNING,
- /**
- * quand l'opération est annulé en cours d'exécution
- */
+
+ /** quand l'opération est annulé en cours d'exécution */
CANCELED,
- /**
- * quand une erreur s'est produite pendant l'exécution
- */
+
+ /** quand une erreur s'est produite pendant l'exécution */
FAILED,
- /**
- * quand l'exécution s'est terminée mais requière des corrections
- */
+
+ /** quand l'exécution s'est terminée mais requière des corrections */
NEED_FIX,
- /**
- * quand l'exécution s'est terminée et ne requière pas de correction
- */
+
+ /** quand l'exécution s'est terminée et ne requière pas de correction */
SUCCESSED
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -21,30 +21,25 @@
package jaxx.runtime.swing.wizard;
/**
- *
* Le contrat a implanter pour une etapes dans le modèle de wizard avec
* opérations.
- *
- * @author tony
+ *
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public interface WizardOperationStep extends WizardStep {
- /**
- * @return le label de l'opération
- */
+ /** @return le label de l'opération */
String getOperationLabel();
- /**
- * @return la description de l'opération
- */
+ /** @return la description de l'opération */
String getOperationDescription();
/**
* @return le type de l'action associée à l'étape ou <code>null</code> si
* l'étape n'a pas d'opération associée.
*/
- Class<? extends WizardOperationAction> getActionClass();
+ Class<? extends WizardOperationAction<?, ?>> getActionClass();
/**
* @return <code>true</code> si l'étape a une opération associée,
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -24,8 +24,8 @@
/**
* le contrat d'une étape d'un wizard.
- *
- * @author tony
+ *
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public interface WizardStep extends Serializable {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -23,9 +23,9 @@
/**
* Le contrat d'une ui d'étape.
*
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type d'étape
* @param <M> le type de modèle
- * @author tony
* @since 1.3
*/
public interface WizardStepUI<E extends WizardStep, M extends WizardModel<E>> {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,71 +20,56 @@
*/
package jaxx.runtime.swing.wizard;
-import javax.swing.JTabbedPane;
+import javax.swing.*;
/**
- *
* Contrat a respecter pour une ui de wizard.
- *
+ *
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type d'etape
* @param <M> le type de model
- *
- * @author tony
* @since 1.3
*/
public interface WizardUI<E extends WizardStep, M extends WizardModel<E>> {
- /**
- * @return le modèle de wizard
- */
+ /** @return le modèle de wizard */
M getModel();
- /**
- *
- * @return l'étape courante
- */
+ /** @return l'étape courante */
E getSelectedStep();
- /**
- *
- * @return l'ui de l'étape courante
- */
+ /** @return l'ui de l'étape courante */
WizardStepUI<E, M> getSelectedStepUI();
/**
- *
* @param step l'étape donnée
* @return l'ui de l'étape donnée
*/
WizardStepUI<E, M> getStepUI(E step);
/**
- *
* @param stepIndex la position de l'étape
* @return l'ui de l'étape donée
*/
WizardStepUI<E, M> getStepUI(int stepIndex);
- /**
- * démarre le wizard
- */
+ /** démarre le wizard */
void start();
/**
* //TODO il faudrait supprimer cette méthode
+ *
* @return le conteneur d'ui d'étapes
*/
JTabbedPane getTabs();
- /**
- * Méthode invoqué lorsque la première opération du modèlé a été démarrée.
- */
+ /** Méthode invoqué lorsque la première opération du modèlé a été démarrée. */
void onWasStarted();
-
+
/**
* Méthode invoquée lorsque l'univers des étapes a été modifié dans le
* modèle.
- *
+ *
* @param steps les nouvelles étapes
*/
void onStepsChanged(E[] steps);
@@ -106,9 +91,9 @@
/**
* Méthode invoqué lorsque l'état d'une opération a changé.
*
- * @param step l'étape dont l'état a changé
+ * @param step l'étape dont l'état a changé
* @param newState le nouvel état pour l'étape donné
*/
- void onOperationStateChanged(E step,WizardOperationState newState) ;
+ void onOperationStateChanged(E step, WizardOperationState newState);
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,48 +20,82 @@
*/
package jaxx.runtime.swing.wizard;
-import java.awt.Window;
-import javax.swing.ImageIcon;
import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
import jaxx.runtime.context.JAXXInitialContext;
-import jaxx.runtime.JAXXObject;
import org.apache.commons.beanutils.ConstructorUtils;
+import javax.swing.*;
+import java.awt.*;
+
/**
- *
* Une classe pour lancer une ui de wizard.
*
+ * @author tchemit <chemit(a)codelutin.com>
* @param <E> le type des etapes
* @param <M> le type de modele
* @param <UI> le type d'ui
- * @author tony
* @since 1.3
*/
public abstract class WizardUILancher<E extends WizardStep, M extends WizardModel<E>, UI extends WizardUI<E, M>> {
protected UI ui;
- public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, String title, String tip, ImageIcon icon) {
+ public WizardUILancher(JAXXContext context,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ String title,
+ String tip,
+ ImageIcon icon) {
this(context, uiClass, modelClass, null, title, tip, icon);
}
- public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) {
+ public WizardUILancher(JAXXContext context,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model,
+ String title,
+ String tip,
+ ImageIcon icon) {
try {
- ui = createUI(context, uiClass, modelClass, model, title, tip, icon);
+ ui = createUI(context,
+ uiClass,
+ modelClass,
+ model,
+ title,
+ tip,
+ icon
+ );
} catch (Exception ex) {
- throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ throw new RuntimeException(
+ "could not instanciate launcher for reason " +
+ ex.getMessage(), ex);
}
}
- public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) {
+ public WizardUILancher(JAXXContext context,
+ Window mainUI,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model) {
try {
- ui = createUI(context, mainUI, uiClass, modelClass, model);
+ ui = createUI(context,
+ mainUI,
+ uiClass,
+ modelClass,
+ model
+ );
} catch (Exception ex) {
- throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ throw new RuntimeException(
+ "could not instanciate launcher for reason " +
+ ex.getMessage(), ex);
}
}
- public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass) {
+ public WizardUILancher(JAXXContext context,
+ Window mainUI,
+ Class<UI> uiClass,
+ Class<M> modelClass) {
this(context, mainUI, uiClass, modelClass, null);
}
@@ -102,7 +136,11 @@
}
@SuppressWarnings("unchecked")
- protected UI createUI(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) throws Exception {
+ protected UI createUI(JAXXContext context,
+ Window mainUI,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model) throws Exception {
JAXXInitialContext uiContext = new JAXXInitialContext();
uiContext.add(mainUI == null ? context : mainUI);
// parent context model
@@ -137,12 +175,22 @@
// instanciate ui
- UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{Window.class, JAXXContext.class});
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(
+ uiClass,
+ new Object[]{mainUI, uiContext},
+ new Class[]{Window.class, JAXXContext.class}
+ );
return newUI;
}
@SuppressWarnings("unchecked")
- protected UI createUI(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) throws Exception {
+ protected UI createUI(JAXXContext context,
+ Class<UI> uiClass,
+ Class<M> modelClass,
+ M model,
+ String title,
+ String tip,
+ ImageIcon icon) throws Exception {
JAXXInitialContext uiContext = new JAXXInitialContext();
uiContext.add(context);
// parent context model
@@ -176,7 +224,16 @@
});
// instanciate ui
- UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{uiContext, title, tip, icon}, new Class[]{JAXXContext.class, String.class, String.class, ImageIcon.class});
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(
+ uiClass,
+ new Object[]{uiContext, title, tip, icon},
+ new Class[]{
+ JAXXContext.class,
+ String.class,
+ String.class,
+ ImageIcon.class
+ }
+ );
return newUI;
}
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -20,22 +20,23 @@
*/
package jaxx.runtime.swing.wizard;
-import java.awt.Component;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.*;
+import java.awt.*;
import java.beans.IndexedPropertyChangeEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Array;
import java.util.List;
-import javax.swing.JTabbedPane;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
/**
* Classe de méthodes utiles sur les wizard.
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class WizardUtil {
@@ -139,14 +140,14 @@
/**
* Ajoute un listener sur le modele pour gere la politique d'affichage des
* onglets.
+ * <p/>
+ * Dans cette implantation, les onglets sont ouverts jusqu'a l'etape
+ * courante. Lorsque l'on revient en arrière, les onglets d'etapes
+ * superieurs sont fermes.
*
- * Dans cette implantation, les onglets sont ouverts jusqu'a l'etape courante.
- * Lorsque l'on revient en arrière, les onglets d'etapes superieurs sont
- * fermes.
- *
* @param <E> le type d'un etape de l'assistant
* @param <M> le type du modele de l'assistant
- * @param ui l'ui de l'assitant
+ * @param ui l'ui de l'assitant
* @since 1.7.1
*/
public static <E extends WizardStep, M extends WizardModel<E>> void addTabsDisplayUntilStepListener(final WizardUI<E, M> ui) {
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2010-03-18 21:42:47 UTC (rev 1795)
@@ -1,9 +1,9 @@
<html>
- <body>
- <h1>JAXX - Wizard framework</h1>
-
- This package contains all the classes of the wizard framework.
+<body>
+<h1>JAXX - Wizard framework</h1>
- TODO
- </body>
-</html>
\ No newline at end of file
+This package contains all the classes of the wizard framework.
+
+TODO
+</body>
+</html>
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/FieldExpressionWithParamsValidator.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -33,7 +33,7 @@
* Extends {@link FieldExpressionValidator} to add some extra parameters available
* in the {@link #getExpression()}
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class FieldExpressionWithParamsValidator extends FieldExpressionValidator {
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -31,7 +31,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class DefaultApplicationContextTest {
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -30,7 +30,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class BeanValidatorTest {
@@ -215,4 +215,4 @@
}
}
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -29,7 +29,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
public class XWorkBeanValidatorTest {
@@ -173,4 +173,4 @@
// error was not found
Assert.assertFalse(required);
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java
===================================================================
--- trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java 2010-03-18 21:15:02 UTC (rev 1794)
+++ trunk/jaxx-runtime/src/test/java/jaxx/runtime/validator/field/FieldExpressionBean.java 2010-03-18 21:42:47 UTC (rev 1795)
@@ -25,7 +25,7 @@
/**
*
- * @author tony
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class FieldExpressionBean {
1
0
r1794 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard
by tchemit@users.nuiton.org 18 Mar '10
by tchemit@users.nuiton.org 18 Mar '10
18 Mar '10
Author: tchemit
Date: 2010-03-18 22:15:02 +0100 (Thu, 18 Mar 2010)
New Revision: 1794
Log:
notify ui change model validSetp has changed (to relaod Wizard tab accessible)
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 19:40:22 UTC (rev 1793)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2010-03-18 21:15:02 UTC (rev 1794)
@@ -25,6 +25,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Array;
+import java.util.List;
import javax.swing.JTabbedPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -99,14 +100,26 @@
return;
}
if (WizardModel.STEPS_PROPERTY_NAME.equals(propertyName)) {
- java.util.List<E> steps = (java.util.List<E>) evt.getNewValue();
- ui.onStepsChanged(steps.toArray((E[]) Array.newInstance(ui.getModel().stepClass, steps.size())));
+ List<E> steps = (List<E>) evt.getNewValue();
+ ui.onStepsChanged(
+ steps.toArray((E[]) Array.newInstance(
+ ui.getModel().stepClass, steps.size()))
+ );
return;
}
if (WizardModel.STEP_PROPERTY_NAME.equals(propertyName)) {
ui.onStepChanged((E) evt.getNewValue());
return;
}
+ if (WizardModel.VALID_STEP_PROPERTY_NAME.equals(propertyName)) {
+ Boolean value = (Boolean) evt.getNewValue();
+ if (value == null || !value) {
+ ui.onModelStateChanged(WizardOperationState.NEED_FIX);
+ } else {
+ ui.onModelStateChanged(WizardOperationState.PENDING);
+ }
+ return;
+ }
if (WizardOperationModel.MODEL_STATE_PROPERTY_NAME.equals(propertyName)) {
//TODO should be unicast : only for good stepUI ?
ui.onModelStateChanged((WizardOperationState) evt.getNewValue());
1
0