r2136 - in trunk: jaxx-demo/src/license jaxx-runtime/src/main/java/jaxx/runtime maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin
Author: tchemit Date: 2010-12-01 14:26:17 +0100 (Wed, 01 Dec 2010) New Revision: 2136 Url: http://nuiton.org/repositories/revision/jaxx/2136 Log: Anomalie #1124: Runtime exception when using javax.swing.event.TableColumnModelListener#columnMarginChanged(ChangeEvent) Added: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1124Test.java Modified: trunk/jaxx-demo/src/license/THIRD-PARTY.properties trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java Modified: trunk/jaxx-demo/src/license/THIRD-PARTY.properties =================================================================== --- trunk/jaxx-demo/src/license/THIRD-PARTY.properties 2010-12-01 09:39:38 UTC (rev 2135) +++ trunk/jaxx-demo/src/license/THIRD-PARTY.properties 2010-12-01 13:26:17 UTC (rev 2136) @@ -1,19 +1,19 @@ # Generated by org.nuiton.license.plugin.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : -# - Apache License, Version 2.0 -# - BSD +# - BSD License # - Common Public License Version 1.0 # - Lesser General Public License (LGPL) # - Lesser General Public License (LGPL) v 3.0 +# - Sun Microsystems, Inc. Binary Code License Agreement for the JDK 5.0 # - The Apache Software License, Version 2.0 # - The OpenSymphony Software License 1.1 #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Sun Jun 20 23:37:14 CEST 2010 -commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 -javax.help--javahelp--2.0.02=Sun Microsystems, Inc. Binary Code License Agreement for the JDK 5.0 -opensymphony--ognl--2.6.11=The OpenSymphony Software License 1.1 -org.nuiton.thirdparty--rsyntaxtextarea--1.4.1=Lesser General Public License (LGPL) v 3.0 +#Wed Dec 01 14:20:51 CET 2010 +commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0 +javax.help--javahelp--2.0.02--jar=Sun Microsystems, Inc. Binary Code License Agreement for the JDK 5.0 +opensymphony--ognl--2.6.11--jar=The OpenSymphony Software License 1.1 +org.nuiton.thirdparty--rsyntaxtextarea--1.4.1--jar=Lesser General Public License (LGPL) v 3.0 Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-12-01 09:39:38 UTC (rev 2135) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/JAXXUtil.java 2010-12-01 13:26:17 UTC (rev 2136) @@ -221,8 +221,21 @@ "no method named " + listenerMethodName + " found in class " + listenerClass.getName()); } - Class<?>[] parameterTypes = - listenerMethods.get(0).getParameterTypes(); + // tchemit 2010-12-01 : we must the exact method found, some none javaBeans + // api does use different signature for some of them listener + // 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) { + + // search an exact method, so must use the exact found listener method + parameterTypes = listenerMethod.getParameterTypes(); + } else { + + // keep this horrible code which is not safe at all : + // see previous comment + parameterTypes = listenerMethods.get(0).getParameterTypes(); + } Class<?> methodContainerClass = methodContainer.getClass(); final Method targetMethod = methodContainerClass.getMethod(methodName, parameterTypes); @@ -236,8 +249,8 @@ Method method, Object[] args) { String methodName = method.getName(); - if ((listenerMethodName == null && - listenerMethods.contains(method)) || + if (listenerMethodName == null && + listenerMethods.contains(method) || methodName.equals(listenerMethodName)) { try { targetMethod.setAccessible(true); Added: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1124Test.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1124Test.java (rev 0) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1124Test.java 2010-12-01 13:26:17 UTC (rev 2136) @@ -0,0 +1,75 @@ +package org.nuiton.jaxx.plugin; + +import jaxx.compiler.I18nHelper; +import jaxx.runtime.JAXXUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Test; + +import javax.swing.event.ChangeEvent; +import javax.swing.event.TableColumnModelEvent; +import javax.swing.event.TableColumnModelListener; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +/** + * Fix the bug http://nuiton.org/issues/show/1124 + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2.4 + */ +public class Bug1124Test { + + protected static final Log log = LogFactory.getLog(Bug1124Test.class); + + int i; + @Test + public void testColumnMarginChanged() throws Exception { + + TableColumnModel model = new DefaultTableColumnModel(); + + TableColumnModelListener listener; + + listener = JAXXUtil.getEventListener( + TableColumnModelListener.class, + "columnAdded", + this, + "myColumnAdded" + ); + + Assert.assertNotNull(listener); + + model.addColumnModelListener(listener); + + Assert.assertEquals(0,i); + + model.addColumn(new TableColumn(0)); + + Assert.assertEquals(1,i); + + listener = JAXXUtil.getEventListener( + TableColumnModelListener.class, + "columnMarginChanged", + this, + "myColumnMarginChanged" + ); + Assert.assertNotNull(listener); + + model.addColumnModelListener(listener); + model.setColumnMargin(12); + Assert.assertEquals(2,i); +// listener.columnMarginChanged(new ChangeEvent(this)); + } + + public void myColumnAdded(TableColumnModelEvent evt) { + log.info(evt.getSource()); + i++; + } + + public void myColumnMarginChanged(ChangeEvent evt) { + log.info(evt.getSource()); + i++; + } +} Property changes on: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1124Test.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
participants (1)
-
tchemit@users.nuiton.org