This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jmexico. See http://git.codelutin.com/jmexico.git commit 95453fe5598f6fb1dc2a719f9fb800bee9c0a498 Author: Eric Chatellier <chatellier@codelutin.com> Date: Thu Jan 7 17:24:32 2016 +0100 fixes #7873: display factor description in tooltip --- .../editor/FactorNameCellRenderer.java | 60 +++++++++++++++++++++ .../editor/InputDesignEditorHandler.java | 5 +- .../editor/MexicoDecoratorProvider.java | 61 ---------------------- 3 files changed, 61 insertions(+), 65 deletions(-) diff --git a/jmexico-editor/src/main/java/fr/reseaumexico/editor/FactorNameCellRenderer.java b/jmexico-editor/src/main/java/fr/reseaumexico/editor/FactorNameCellRenderer.java new file mode 100644 index 0000000..7eddfc5 --- /dev/null +++ b/jmexico-editor/src/main/java/fr/reseaumexico/editor/FactorNameCellRenderer.java @@ -0,0 +1,60 @@ +/* + * #%L + * JMexico :: Swing Editor + * %% + * Copyright (C) 2016 Réseau Mexico, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.reseaumexico.editor; + +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; + +import org.apache.commons.lang3.StringUtils; + +import fr.reseaumexico.model.Factor; + +/** + * Factor cell renderer for editor table. + * + * Handle factor name and fctor description as tooltip. + * + * @author Eric Chatellier + */ +public class FactorNameCellRenderer extends DefaultTableCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 8036762402104794846L; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) { + + Factor factor = (Factor)value; + + String factorTxt = factor.getName(); + if (StringUtils.isEmpty(factorTxt)) { + // fallback on id + factorTxt = factor.getId(); + } + + setToolTipText(factor.getDescription()); + + return this; + } +} diff --git a/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java b/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java index 88c209e..cdb2b94 100644 --- a/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java +++ b/jmexico-editor/src/main/java/fr/reseaumexico/editor/InputDesignEditorHandler.java @@ -90,10 +90,7 @@ public class InputDesignEditorHandler { JXTable table = ui.getInputDesignTable(); // table renderer - table.setDefaultRenderer( - Factor.class, - new DecoratorProviderTableCellRenderer( - new MexicoDecoratorProvider())); + table.setDefaultRenderer(Factor.class, new FactorNameCellRenderer()); table.setDefaultRenderer(Object.class, new FactorValueCellRenderer(ui)); // cell editor diff --git a/jmexico-editor/src/main/java/fr/reseaumexico/editor/MexicoDecoratorProvider.java b/jmexico-editor/src/main/java/fr/reseaumexico/editor/MexicoDecoratorProvider.java deleted file mode 100644 index 6522861..0000000 --- a/jmexico-editor/src/main/java/fr/reseaumexico/editor/MexicoDecoratorProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * #%L - * JMexico :: Swing Editor - * %% - * Copyright (C) 2011 - 2015 Réseau Mexico, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.reseaumexico.editor; - -import fr.reseaumexico.model.Factor; -import org.apache.commons.lang3.StringUtils; -import org.nuiton.util.decorator.Decorator; -import org.nuiton.util.decorator.DecoratorProvider; - -/** - * @author sletellier - letellier@codelutin.com - * @author tchemit - chemit@codelutin.com - * @since 0.1 - */ -public class MexicoDecoratorProvider extends DecoratorProvider { - - @Override - protected void loadDecorators() { - registerDecorator(new Decorator<Factor>(Factor.class) { - - private static final long serialVersionUID = 1L; - - @Override - public String toString(Object bean) { - String result = null; - if (bean != null) { - Factor f = (Factor) bean; - if (StringUtils.isNotEmpty(f.getName())) { - - // use name - result = f.getName(); - } else { - - // fallback on id - result = f.getId(); - } - } - return result; - } - }); - } -} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.