Author: tchemit Date: 2011-04-21 17:12:23 +0200 (Thu, 21 Apr 2011) New Revision: 2262 Url: http://nuiton.org/repositories/revision/jaxx/2262 Log: add method getDataBinding on JAXXObject contract add usefull methods to reload a data binding Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2011-04-19 11:55:35 UTC (rev 2261) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2011-04-21 15:12:23 UTC (rev 2262) @@ -25,6 +25,7 @@ package jaxx.runtime; import java.awt.Container; +import java.beans.PropertyChangeListener; import java.io.Serializable; import java.util.Map; @@ -98,6 +99,16 @@ void removeDataBinding(String id); /** + * Obtain a binding given his id. + * + * @param bindingId the id of the binding + * @return the binding, or {@code null} if not found. + * @since 2.4.2 + * @see JAXXBinding + */ + JAXXBinding getDataBinding(String bindingId); + + /** * All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and * furthermore (for technical reasons) must allow code in outside packages, specifically the JAXX runtime, * to trigger these events. @@ -109,34 +120,34 @@ void firePropertyChange(String name, Object oldValue, Object newValue); /** - * Register a general {@link java.beans.PropertyChangeListener}. + * Register a general {@link PropertyChangeListener}. * * @param listener the listener to register */ - void addPropertyChangeListener(java.beans.PropertyChangeListener listener); + void addPropertyChangeListener(PropertyChangeListener listener); /** - * Register a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. + * Register a {@link PropertyChangeListener}. for the given {@code propertyName}. * * @param property the property name to listen * @param listener the listener to register */ - void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener); + void addPropertyChangeListener(String property, PropertyChangeListener listener); /** - * Unregister a general {@link java.beans.PropertyChangeListener}. + * Unregister a general {@link PropertyChangeListener}. * * @param listener the listener to unregister */ - void removePropertyChangeListener(java.beans.PropertyChangeListener listener); + void removePropertyChangeListener(PropertyChangeListener listener); /** - * Unregister a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. + * Unregister a {@link PropertyChangeListener}. for the given {@code propertyName}. * * @param property the property name to listen * @param listener the listener to unregister */ - void removePropertyChangeListener(String property, java.beans.PropertyChangeListener listener); + void removePropertyChangeListener(String property, PropertyChangeListener listener); /** * Return parent's container corresponding to the Class clazz Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2011-04-19 11:55:35 UTC (rev 2261) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2011-04-21 15:12:23 UTC (rev 2262) @@ -226,7 +226,7 @@ // an exemple is the TableColumnModelListener : http://download.oracle.com/javase/6/docs/api/javax/swing/event/TableColumnMo... // This fix the bug http://nuiton.org/issues/show/1124 Class<?>[] parameterTypes; - if (listenerMethodName!=null) { + if (listenerMethodName != null) { // search an exact method, so must use the exact found listener method parameterTypes = listenerMethod.getParameterTypes(); @@ -250,7 +250,7 @@ Object[] args) { String methodName = method.getName(); if (listenerMethodName == null && - listenerMethods.contains(method) || + listenerMethods.contains(method) || methodName.equals(listenerMethodName)) { try { targetMethod.setAccessible(true); @@ -356,6 +356,8 @@ } } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static boolean assignment(boolean value, String name, JAXXObject src) { @@ -363,41 +365,58 @@ return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated + public static byte assignment(byte value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static short assignment(short value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static int assignment(int value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static long assignment(long value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static float assignment(float value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static double assignment(double value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static char assignment(char value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; } + /** @deprecated since 2.4.2, never use, will not be replaced */ + @Deprecated public static Object assignment(Object value, String name, JAXXObject src) { src.firePropertyChange(name.trim(), null, "dummy value"); return value; @@ -470,6 +489,39 @@ } /** + * To reload a binding, the method will invoke + * <ul> + * <li>{@link JAXXBinding#removeDataBinding()}</li> + * <li>{@link JAXXBinding#applyDataBinding()}</li> + * </ul> + * + * @param binding the binding to reload. + * @since 2.4.2 + */ + public static void reloadBinding(JAXXBinding binding) { + binding.removeDataBinding(); + binding.applyDataBinding(); + } + + /** + * Convinient method to reload a given binding by his id on a JAXX ui. + * + * @param src the ui to treate + * @param bindingId the id of binding to reload. + * @since 2.4.2 + */ + public static void reloadBinding(JAXXObject src, String bindingId) { + JAXXBinding dataBinding = src.getDataBinding(bindingId); + if (dataBinding != null) { + reloadBinding(dataBinding); + } else { + if (log.isWarnEnabled()) { + log.warn("Could not found binding[" + bindingId + "] on ui " + src); + } + } + } + + /** * Convinient method to apply more than one binding on a JAXX ui. * * @param src the ui to treate