This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 3b08c7232c51e6dfe803b5357c2bca74da63cbbc Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Sep 23 17:32:13 2014 +0200 fixes #5805: [ERGO] dans l'écran de configuration pour le choix des unités de poids : écrire kg et g en minucules --- .../swing/content/config/TuttiConfigUIHandler.java | 58 +++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java index 43344e3..dc01925 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java @@ -24,6 +24,7 @@ package fr.ifremer.tutti.ui.swing.content.config; import fr.ifremer.tutti.TuttiConfiguration; import fr.ifremer.tutti.TuttiConfigurationOption; +import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.action.GoToPreviousScreenAction; import fr.ifremer.tutti.ui.swing.action.ReloadTuttiAction; @@ -34,15 +35,22 @@ import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.config.ConfigUI; import jaxx.runtime.swing.config.ConfigUIHelper; import jaxx.runtime.swing.config.model.MainCallBackFinalizer; +import jaxx.runtime.swing.editor.EnumEditor; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultListCellRenderer; import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; import java.awt.BorderLayout; +import java.awt.Component; -import static org.nuiton.i18n.I18n.t; import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; /** * @author tchemit <chemit@codelutin.com> @@ -187,23 +195,38 @@ public class TuttiConfigUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, // Weight Unit category + WeightUnitTableCellRenderer weightUnitTableCellRenderer = new WeightUnitTableCellRenderer(); + + EnumEditor<WeightUnit> weightUnitEnumEditor = EnumEditor.newEditor(WeightUnit.class); + weightUnitEnumEditor.setRenderer(new WeightUnitListCellRenderer()); + DefaultCellEditor weightUnitTableCellEditor = new DefaultCellEditor(weightUnitEnumEditor); helper.addCategory(n("tutti.config.category.weightUnit"), n("tutti.config.category.weightUnit.description"), CALLBACK_UI) .addOption(TuttiConfigurationOption.WEIGHT_UNIT_SPECIES) .setOptionShortLabel(t("tutti.config.option.weight.unit.species.shortLabel")) + .setOptionRenderer(weightUnitTableCellRenderer) + .setOptionEditor(weightUnitTableCellEditor) .addOption(TuttiConfigurationOption.WEIGHT_UNIT_BENTHOS) .setOptionShortLabel(t("tutti.config.option.weight.unit.benthos.shortLabel")) + .setOptionRenderer(weightUnitTableCellRenderer) + .setOptionEditor(weightUnitTableCellEditor) .addOption(TuttiConfigurationOption.WEIGHT_UNIT_MARINE_LITTER) .setOptionShortLabel(t("tutti.config.option.weight.unit.marineLitter.shortLabel")) + .setOptionRenderer(weightUnitTableCellRenderer) + .setOptionEditor(weightUnitTableCellEditor) .addOption(TuttiConfigurationOption.WEIGHT_UNIT_INDIVIDUAL_OBSERVATION) .setOptionShortLabel(t("tutti.config.option.weight.unit.individualObservation.shortLabel")) + .setOptionRenderer(weightUnitTableCellRenderer) + .setOptionEditor(weightUnitTableCellEditor) .addOption(TuttiConfigurationOption.WEIGHT_UNIT_ACCIDENTAL_CATCH) - .setOptionShortLabel(t("tutti.config.option.weight.unit.accidentalCatch.shortLabel")); + .setOptionShortLabel(t("tutti.config.option.weight.unit.accidentalCatch.shortLabel")) + .setOptionRenderer(weightUnitTableCellRenderer) + .setOptionEditor(weightUnitTableCellEditor); // Technical category @@ -306,4 +329,35 @@ public class TuttiConfigUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, getContext().getMainUI().getHandler().reloadUI(); } + private static class WeightUnitListCellRenderer extends DefaultListCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + if (value != null) { + WeightUnit unit = (WeightUnit) value; + value = unit.getShortLabel(); + } + return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } + } + + private static class WeightUnitTableCellRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + if (value != null) { + + WeightUnit unit = (WeightUnit) value; + value = unit.getShortLabel(); + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } + } + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.