r2273 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean
Author: tchemit Date: 2011-04-30 15:53:41 +0200 (Sat, 30 Apr 2011) New Revision: 2273 Url: http://nuiton.org/repositories/revision/jaxx/2273 Log: Evolution #1493: Use Clonable contract to create new decorators Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java 2011-04-30 13:49:33 UTC (rev 2272) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java 2011-04-30 13:53:41 UTC (rev 2273) @@ -29,6 +29,7 @@ import jaxx.runtime.decorator.JXPathDecorator; import jaxx.runtime.decorator.MultiJXPathDecorator; import jaxx.runtime.swing.JAXXButtonGroup; +import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.autocomplete.AutoCompleteComboBoxEditor; @@ -79,6 +80,8 @@ public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("bean.sort.off"); + public static final Object[] EMPTY_CLASS_ARRAY = new Object[0]; + /** * Encapsule un {@link Decorator} dans un {@link ObjectToStringConverter}. * @@ -238,6 +241,19 @@ String separator; String separatorReplacement; + if (decorator instanceof Cloneable) { + Cloneable cloneable = (Cloneable) decorator; + + try { + Object clone = MethodUtils.invokeExactMethod(cloneable, + "clone", + EMPTY_CLASS_ARRAY + ); + return (MultiJXPathDecorator<O>) clone; + } catch (Exception e) { + throw new IllegalStateException("Could not clone decorator "+decorator, e); } + + } if (decorator instanceof MultiJXPathDecorator<?>) { separator = ((MultiJXPathDecorator<?>) decorator).getSeparator();
participants (1)
-
tchemit@users.nuiton.org