r2615 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean
Author: kmorin Date: 2013-03-12 10:09:46 +0100 (Tue, 12 Mar 2013) New Revision: 2615 Url: http://nuiton.org/projects/jaxx/repository/revisions/2615 Log: fixes #2585 Bug in the BeanFilterableComboBoxHandler when the selected item is a String (not the same type as the bean type) Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanFilterableComboBoxHandler.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanFilterableComboBoxHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanFilterableComboBoxHandler.java 2013-03-12 09:08:07 UTC (rev 2614) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanFilterableComboBoxHandler.java 2013-03-12 09:09:46 UTC (rev 2615) @@ -1,23 +1,23 @@ /* * #%L * JAXX :: Widgets - * * + * * $Id$ * $HeadURL$ * %% * Copyright (C) 2008 - 2010 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% @@ -54,6 +54,7 @@ import javax.swing.ComboBoxEditor; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import jaxx.runtime.JAXXUtil; import jaxx.runtime.swing.model.JaxxFilterableComboBoxModel; /** @@ -197,8 +198,13 @@ // set the selected item to null Object selectedItem = ui.getSelectedItem(); String text = editor.getEditorComponent().getText(); - if (selectedItem == null || - !BeanFilterableComboBoxHandler.this.decorator.toString(selectedItem).equals(text)) { + String selectedItemString; + if (getBeanType().isInstance(selectedItem)) { + selectedItemString = BeanFilterableComboBoxHandler.this.decorator.toString(selectedItem); + } else { + selectedItemString = JAXXUtil.getStringValue(selectedItem); + } + if (selectedItem == null || !selectedItemString.equals(text)) { ui.setSelectedItem(null); } }
participants (1)
-
kmorin@users.nuiton.org