r2675 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor
Author: kmorin Date: 2013-05-27 14:49:26 +0200 (Mon, 27 May 2013) New Revision: 2675 Url: http://nuiton.org/projects/jaxx/repository/revisions/2675 Log: fixes #2706 [NumberEditor] When the new model does not match the pattern, the last text set is not correct 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 2013-05-26 06:50:51 UTC (rev 2674) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2013-05-27 12:49:26 UTC (rev 2675) @@ -476,14 +476,31 @@ } protected void setModel(Number oldValue, Number newValue) { - if (editor.getBean() == null) { - return; - } if (log.isDebugEnabled()) { log.debug(editor.getProperty() + " on " + editor.getBean().getClass() + " :: " + oldValue + " to " + newValue); } + String strValue; + if (newValue == null) { + strValue = ""; + } else { + strValue = newValue + ""; + if (editor.isUseFloat()) { + Float n = Float.parseFloat(strValue); + if ((float) n.intValue() == n) { + strValue = n.intValue() + ""; + } + } + } + + lastValidText = strValue; + editor.setModelText(strValue); + + if (editor.getBean() == null) { + return; + } + try { Method mutator = getMutator(); if (newValue == null && !getAcceptNull()) { @@ -509,21 +526,7 @@ // mutator.invoke(editor.getBean(), newValue); // } mutator.invoke(editor.getBean(), newValue); - String strValue; - if (newValue == null) { - strValue = ""; - } else { - strValue = newValue + ""; - if (editor.isUseFloat()) { - Float n = Float.parseFloat(strValue); - if ((float) n.intValue() == n) { - strValue = n.intValue() + ""; - } - } - } - - lastValidText = strValue; - editor.setModelText(strValue); + } catch (Exception e) { throw new RuntimeException(e); }
participants (1)
-
kmorin@users.nuiton.org