Author: kmorin Date: 2013-03-01 16:55:12 +0100 (Fri, 01 Mar 2013) New Revision: 2584 Url: http://nuiton.org/projects/jaxx/repository/revisions/2584 Log: fixes #2551 NumberCellEditor - the textfield is not emptied when we change to an empty cell Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java 2013-03-01 11:19:52 UTC (rev 2583) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/cell/NumberCellEditor.java 2013-03-01 15:55:12 UTC (rev 2584) @@ -7,16 +7,16 @@ * Copyright (C) 2008 - 2012 CodeLutin * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% @@ -34,6 +34,7 @@ import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.table.TableCellEditor; +import jaxx.runtime.JAXXUtil; import jaxx.runtime.swing.editor.NumberEditor; /** @@ -66,11 +67,7 @@ E number = (E) value; numberEditor.setModel(number); - - // Check nullity and set the text that will be selected with the current value - if (number != null) { - numberEditor.setModelText(String.valueOf(number)); - } + numberEditor.setModelText(JAXXUtil.getStringValue(number)); return numberEditor; } @@ -123,7 +120,11 @@ numberEditor.setModel(null); // Use empty string, otherwise there is a NPE in NumberEditorHandler numberEditor.setModelText(""); + // force binding, I do not know why the textfield text is not emptied + // if we do not force it + numberEditor.applyDataBinding(NumberEditor.BINDING_TEXT_FIELD_TEXT); } return result; } + }