Author: sletellier Date: 2012-06-27 12:14:52 +0200 (Wed, 27 Jun 2012) New Revision: 2341 Url: http://nuiton.org/repositories/revision/jaxx/2341 Log: Dont force using bean to init Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2012-06-25 17:06:30 UTC (rev 2340) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2012-06-27 10:14:52 UTC (rev 2341) @@ -25,16 +25,6 @@ package jaxx.runtime.swing.editor; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComponent; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; -import javax.swing.text.BadLocationException; import java.awt.Dimension; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -47,6 +37,15 @@ import java.math.BigInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.swing.JComponent; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.text.BadLocationException; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import static jaxx.runtime.swing.editor.NumberEditor.PROPERTY_MODEL; import static jaxx.runtime.swing.editor.NumberEditor.PROPERTY_POPUP_VISIBLE; @@ -88,9 +87,9 @@ /** initialise l'ui et les listeners d'évènements. */ public void init() { try { - if (editor.getBean() == null) { - throw new NullPointerException("can not have a null bean in ui " + editor); - } +// if (editor.getBean() == null) { +// throw new NullPointerException("can not have a null bean in ui " + editor); +// } editor.addPropertyChangeListener(NumberEditor.PROPERTY_NUMBER_PATTERN, new PropertyChangeListener() { @@ -157,11 +156,11 @@ if (StringUtils.isNotEmpty(editor.getNumberPattern())) { numberPattern = Pattern.compile(editor.getNumberPattern()); } - + // Determine si c'est un float - Class<?> type = getGetter().getReturnType(); - if (editor.getModelType() != null) { - type = editor.getModelType(); + Class<?> type = editor.getModelType(); + if (editor.getModelType() == null) { + type = getGetter().getReturnType(); } modelType = type; if (log.isDebugEnabled()) { @@ -277,6 +276,9 @@ Number newValue = null; + // allow using ',' char + s = s.replaceAll(",", "."); + if (s.trim().isEmpty()) { // le champ est vide donc c'est la valeur null a reaffecter s = null;