This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See http://git.nuiton.org/jaxx.git commit 407c4cad7d8ca69941f670eb2984ad8cb8fac5b2 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Nov 30 12:25:04 2014 +0100 move numbercell editor to widgets-number module --- .../jaxx/widgets/editor/cell/NumberCellEditor.java | 139 --------------------- 1 file changed, 139 deletions(-) diff --git a/jaxx-widgets/src/main/java/org/nuiton/jaxx/widgets/editor/cell/NumberCellEditor.java b/jaxx-widgets/src/main/java/org/nuiton/jaxx/widgets/editor/cell/NumberCellEditor.java deleted file mode 100644 index 97866c3..0000000 --- a/jaxx-widgets/src/main/java/org/nuiton/jaxx/widgets/editor/cell/NumberCellEditor.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.nuiton.jaxx.widgets.editor.cell; - -/* - * #%L - * JAXX :: Widgets - * %% - * Copyright (C) 2008 - 2014 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 - * 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 - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import jaxx.runtime.swing.editor.NumberEditor; -import org.nuiton.jaxx.widgets.editor.number.NumberEditor2; -import org.nuiton.jaxx.widgets.editor.number.NumberEditor2Model; - -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; -import javax.swing.table.TableCellEditor; -import java.awt.Component; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; - -/** - * Created on 11/23/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.17 - */ -public class NumberCellEditor<E extends Number> extends AbstractCellEditor - implements TableCellEditor, FocusListener, AncestorListener { - - private static final long serialVersionUID = 1L; - - protected final NumberEditor2 numberEditor; - - /** constructor */ - public NumberCellEditor(Class<E> type, boolean useSign) { - numberEditor = new NumberEditor2(); - numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT); - numberEditor.getTextField().setBorder(null); - numberEditor.getTextField().addFocusListener(this); - numberEditor.getTextField().addAncestorListener(this); - - numberEditor.setNumberType(type); - numberEditor.setUseSign(useSign); - numberEditor.init(); - - } - - @Override - public Component getTableCellEditorComponent(JTable table, - Object value, - boolean isSelected, - int row, - int column) { - - E number = (E) value; - numberEditor.setNumberValue(number); -// numberEditor.setModelText(JAXXUtil.getStringValue(number)); - return numberEditor; - } - - public NumberEditor2 getNumberEditor() { - return numberEditor; - } - - @Override - public E getCellEditorValue() { - NumberEditor2Model model = numberEditor.getModel(); - return (E) model.getNumberValue(); - } - - @Override - public void focusGained(FocusEvent e) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - } - }); - } - - @Override - public void focusLost(FocusEvent e) { - // commenting the next line fixes http://www.nuiton.org/issues/3517 and http://www.nuiton.org/issues/3518 -// cancelCellEditing(); - } - - @Override - public void ancestorAdded(AncestorEvent event) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - } - }); - } - - @Override - public void ancestorRemoved(AncestorEvent event) { - } - - @Override - public void ancestorMoved(AncestorEvent event) { - } - - @Override - public boolean stopCellEditing() { - boolean result = super.stopCellEditing(); - // Reset previous data to avoid keeping it on other cell edition - if (result) { - numberEditor.setNumberValue(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; - } - -} -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.