Author: kmorin Date: 2013-03-05 13:11:44 +0100 (Tue, 05 Mar 2013) New Revision: 536 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/536 Log: - fixes #2005 [CAPTURE] Especes - poids total vrac observ?\195?\169 peu diff?\195?\169rent du poids calcul?\195?\169 - add computed data color in config Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -188,6 +188,10 @@ return applicationConfig.getOptionAsFile(TuttiApplicationConfigOption.UI_CONFIG_FILE.getKey()); } + public Float getDifferenceRateBetweenSortedAndTotalWeights() { + return applicationConfig.getOptionAsFloat(TuttiApplicationConfigOption.TOTAL_SORTED_WEIGHTS_DIFFERENCE_RATE.getKey()); + } + public boolean isAutoPopupNumberEditor() { return applicationConfig.getOptionAsBoolean(TuttiApplicationConfigOption.AUTO_POPUP_NUMBER_EDITOR.getKey()); } @@ -232,6 +236,10 @@ return applicationConfig.getOptionAsColor(TuttiApplicationConfigOption.COLOR_ROW_TO_CONFIRM.getKey()); } + public Color getColorComputedWeights() { + return applicationConfig.getOptionAsColor(TuttiApplicationConfigOption.COLOR_COMPUTED_WEIGHTS.getKey()); + } + public KeyStroke getShortcutClosePopup() { return applicationConfig.getOptionAsKeyStroke(TuttiApplicationConfigOption.SHORTCUT_CLOSE_POPUP.getKey()); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfigOption.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -79,6 +79,13 @@ File.class ), + TOTAL_SORTED_WEIGHTS_DIFFERENCE_RATE( + "tutti.weights.rate.difference.totalAndSorted", + n_("tutti.weights.rate.difference.totalAndSorted.description"), + "1.0", + Float.class + ), + PROGRAM_ID( "tutti.programId", n_("tutti.option.programId.description"), @@ -142,6 +149,13 @@ Color.class ), + COLOR_COMPUTED_WEIGHTS( + "tutti.ui.color.computedWeights", + n_("tutti.option.ui.color.computedWeights.description"), + Color.BLUE.toString(), + Color.class + ), + SHORTCUT_CLOSE_POPUP( "tutti.ui.shortcut.closePopup", n_("tutti.option.ui.shortcut.closePopup.description"), Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -99,7 +99,8 @@ CALLBACK_APPLICATION) .addOption(TuttiServiceConfigOption.DATA_DIRECTORY) .addOption(TuttiServiceConfigOption.SITE_URL) - .addOption(TuttiApplicationConfigOption.UI_CONFIG_FILE); + .addOption(TuttiApplicationConfigOption.UI_CONFIG_FILE) + .addOption(TuttiApplicationConfigOption.TOTAL_SORTED_WEIGHTS_DIFFERENCE_RATE); // UI @@ -110,6 +111,7 @@ .addOption(TuttiApplicationConfigOption.COLOR_ROW_READ_ONLY) .addOption(TuttiApplicationConfigOption.COLOR_CELL_WITH_VALUE) .addOption(TuttiApplicationConfigOption.COLOR_ROW_TO_CONFIRM) + .addOption(TuttiApplicationConfigOption.COLOR_COMPUTED_WEIGHTS) .addOption(TuttiApplicationConfigOption.DATE_FORMAT) .addOption(TuttiApplicationConfigOption.COORDINATE_EDITOR_TYPE); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-05 12:11:44 UTC (rev 536) @@ -31,6 +31,7 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -51,10 +52,6 @@ protected String errorMessage; - protected String errorTitle; - - protected Component errorComponent; - public ComputeWeightsAction(EditCatchesUIHandler handler) { super(handler, "generate", @@ -68,47 +65,46 @@ EditCatchesUIModel model = getModel(); computeSpeciesBatches(); - Float speciesTotalSortedWeight = model.getSpeciesTotalSortedComputedWeight(); - Float speciesTotalUnsortedWeight = model.getSpeciesTotalUnsortedComputedWeight(); - EditCatchesUI ui = getUI(); + if (errorMessage == null) { + Float speciesTotalSortedWeight = model.getSpeciesTotalSortedComputedWeight(); + Float speciesTotalUnsortedWeight = model.getSpeciesTotalUnsortedComputedWeight(); - model.setCatchTotalSortedComputedWeight(speciesTotalSortedWeight); - model.setCatchTotalUnsortedComputedWeight(speciesTotalUnsortedWeight); + EditCatchesUI ui = getUI(); - Float totalWeight = model.getCatchTotalWeight(); - Float rejectedWeight = model.getCatchTotalRejectedWeight(); + model.setCatchTotalSortedComputedWeight(speciesTotalSortedWeight); + model.setCatchTotalUnsortedComputedWeight(speciesTotalUnsortedWeight); - if (rejectedWeight == null && totalWeight != null) { - if (!totalWeight.equals(speciesTotalUnsortedWeight - + speciesTotalSortedWeight)) { - errorMessage = _("tutti.action.computeWeights.error.incoherentTotal"); - errorTitle = _("tutti.action.computeWeights.error.incoherentTotal.title"); - errorComponent = ui.getCatchTotalWeightField(); + Float totalWeight = model.getCatchTotalWeight(); + Float rejectedWeight = model.getCatchTotalRejectedWeight(); - } else { + if (rejectedWeight == null && totalWeight != null) { + if (!totalWeight.equals(speciesTotalUnsortedWeight + + speciesTotalSortedWeight)) { + errorMessage = _("tutti.action.computeWeights.error.incoherentTotal"); - model.setCatchTotalRejectedComputedWeight(totalWeight - - speciesTotalUnsortedWeight - - speciesTotalSortedWeight); - } + } else { - } else if (totalWeight == null) { - if (rejectedWeight == null) { - rejectedWeight = 0f; - model.setCatchTotalRejectedComputedWeight(0f); - } - model.setCatchTotalComputedWeight(speciesTotalUnsortedWeight - + speciesTotalSortedWeight - + rejectedWeight); + model.setCatchTotalRejectedComputedWeight(totalWeight + - speciesTotalUnsortedWeight + - speciesTotalSortedWeight); + } - } else if (rejectedWeight != null - && !totalWeight.equals(speciesTotalUnsortedWeight - + speciesTotalSortedWeight - + rejectedWeight)) { - errorMessage = _("tutti.action.computeWeights.error.incoherentTotal"); - errorTitle = _("tutti.action.computeWeights.error.incoherentTotal.title"); - errorComponent = ui.getCatchTotalWeightField(); + } else if (totalWeight == null) { + if (rejectedWeight == null) { + rejectedWeight = 0f; + model.setCatchTotalRejectedComputedWeight(0f); + } + model.setCatchTotalComputedWeight(speciesTotalUnsortedWeight + + speciesTotalSortedWeight + + rejectedWeight); + + } else if (rejectedWeight != null + && !totalWeight.equals(speciesTotalUnsortedWeight + + speciesTotalSortedWeight + + rejectedWeight)) { + errorMessage = _("tutti.action.computeWeights.error.incoherentTotal"); + } } } @@ -128,17 +124,13 @@ EditCatchesUI ui = getUI(); List<SpeciesBatchRowModel> roots = getUI().getSpeciesTabContent().getModel().getRows(); - for (SpeciesBatchRowModel row : roots) { + for (int i = 0 ; i < roots.size() ; i++) { + SpeciesBatchRowModel row = roots.get(i); if (row.isBatchRoot()) { Float weight = computeSpeciesBatch(row); if (weight == null) { - JOptionPane.showMessageDialog( - speciesUI, - _("tutti.dialog.catches.species.computeWeight.error.message"), - _("tutti.dialog.catches.species.computeWeight.error.title"), - JOptionPane.ERROR_MESSAGE); - totalSortedWeight = null; - totalUnsortedWeight = null; + errorMessage = _("tutti.action.computeWeights.error.noWeight"); + AbstractSelectTableAction.doSelectCell(speciesUI.getTable(), i, 1); break; } if (persistenceService.isSortedQualitativeValue(row.getSortedUnsortedCategory().getCategoryValue())) { @@ -149,45 +141,57 @@ } } - Number inertWeight = model.getSpeciesTotalInertWeight(); - if (inertWeight != null) { - totalSortedWeight += inertWeight.floatValue(); - } else { - model.setSpeciesTotalInertWeight(0f); - } + if (errorMessage == null) { + Number inertWeight = model.getSpeciesTotalInertWeight(); + if (inertWeight != null) { + totalSortedWeight += inertWeight.floatValue(); + } else { + model.setSpeciesTotalInertWeight(0f); + } - Number livingNotItemizedWeight = model.getSpeciesTotalLivingNotItemizedWeight(); - if (livingNotItemizedWeight != null) { - totalSortedWeight += livingNotItemizedWeight.floatValue(); - } else { - model.setSpeciesTotalLivingNotItemizedWeight(0f); - } + Number livingNotItemizedWeight = model.getSpeciesTotalLivingNotItemizedWeight(); + if (livingNotItemizedWeight != null) { + totalSortedWeight += livingNotItemizedWeight.floatValue(); + } else { + model.setSpeciesTotalLivingNotItemizedWeight(0f); + } - model.setSpeciesTotalSampleSortedComputedWeight(totalSortedWeight); + model.setSpeciesTotalSampleSortedComputedWeight(totalSortedWeight); - Float speciesTotalSortedWeight = model.getSpeciesTotalSortedWeight(); - if (speciesTotalSortedWeight == null) { - speciesTotalSortedWeight = totalSortedWeight; - model.setSpeciesTotalSortedComputedWeight(totalSortedWeight); + Float speciesTotalSortedWeight = model.getSpeciesTotalSortedWeight(); + Float rate = getConfig().getDifferenceRateBetweenSortedAndTotalWeights(); + if (speciesTotalSortedWeight == null) { + speciesTotalSortedWeight = totalSortedWeight; + model.setSpeciesTotalSortedComputedWeight(totalSortedWeight); - } else if (speciesTotalSortedWeight < totalSortedWeight) { - errorMessage = _("tutti.action.computeWeights.error.incoherentSpeciesTotalSorted"); - errorTitle = _("tutti.action.computeWeights.error.incoherentSpeciesTotalSorted.title"); - errorComponent = ui.getSpeciesTotalSortedWeightField(); + } else if (speciesTotalSortedWeight < totalSortedWeight) { + errorMessage = _("tutti.action.computeWeights.error.incoherentSpeciesTotalSorted"); - } else if (speciesTotalSortedWeight < 1.05 * totalSortedWeight) { - // TODO Si le "Poids total VRAC" est saisi est que sa valeur - // est supérieure de moins de x% (x en configuration) - // du "Poids total Vrac trié", demander confirmation que - // le "Poids total VRAC" est bien une valeur observée - // sinon la remplacer par le "Poids total Vrac trié" - } + } else if (speciesTotalSortedWeight < (1 + rate / 100) * totalSortedWeight) { + // Si le "Poids total VRAC" est saisi est que sa valeur + // est supérieure de moins de x% (x en configuration) + // du "Poids total Vrac trié", demander confirmation que + // le "Poids total VRAC" est bien une valeur observée + // sinon la remplacer par le "Poids total Vrac trié" + int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(), + _("tutti.action.computeWeights.replaceTotalSortedWeight.message", rate), + _("tutti.action.computeWeights.replaceTotalSortedWeight.title"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); - model.setSpeciesTotalUnsortedComputedWeight(totalUnsortedWeight); + if (answer == JOptionPane.NO_OPTION) { + model.setSpeciesTotalSortedWeight(null); + speciesTotalSortedWeight = totalSortedWeight; + model.setSpeciesTotalSortedComputedWeight(totalSortedWeight); + } + } - Float totalWeight = totalUnsortedWeight + speciesTotalSortedWeight; - model.setSpeciesTotalComputedWeight(totalWeight); + model.setSpeciesTotalUnsortedComputedWeight(totalUnsortedWeight); + Float totalWeight = totalUnsortedWeight + speciesTotalSortedWeight; + model.setSpeciesTotalComputedWeight(totalWeight); + } + speciesUI.getTable().repaint(); } @@ -221,8 +225,6 @@ } else if (categoryWeight < sum) { errorMessage = _("tutti.action.computeWeights.error.incoherentParentCategoryWeight"); - errorTitle = _("tutti.action.computeWeights.error.incoherentParentCategoryWeight.title"); - errorComponent = null; } else { boolean subSample = categoryWeight > sum; @@ -258,8 +260,6 @@ if (categoryWeight == null && rowWeight != null) { errorMessage = _("tutti.action.computeWeights.error.incoherentRowWeightCategory"); - errorTitle = _("tutti.action.computeWeights.error.incoherentRowWeightCategory.title"); - errorComponent = null; } else if (categoryWeight == null && frequencyWeight != null) { // if the category weight is null and the frequencies have a weight, @@ -274,16 +274,12 @@ // weight, then set the weight of the sample if (categoryWeight != null && frequencyWeight > categoryWeight) { errorMessage = _("tutti.action.computeWeights.error.incoherentCategoryWeight"); - errorTitle = _("tutti.action.computeWeights.error.incoherentCategoryWeight.title"); - errorComponent = null; } else if (rowWeight == null) { row.setComputedWeight(frequencyWeight); } else if (!rowWeight.equals(frequencyWeight)) { errorMessage = _("tutti.action.computeWeights.error.incoherentRowWeightFrequency"); - errorTitle = _("tutti.action.computeWeights.error.incoherentRowWeightFrequency.title"); - errorComponent = null; } result = categoryWeight; @@ -302,17 +298,11 @@ @Override protected void releaseAction() { if (errorMessage != null) { - JOptionPane.showMessageDialog( - getUI(), - errorMessage, - errorTitle, - JOptionPane.ERROR_MESSAGE); + error = new Exception(errorMessage); + } else { + super.releaseAction(); } - if (errorComponent != null) { - errorComponent.requestFocus(); - } errorMessage = null; - errorComponent = null; } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-05 12:11:44 UTC (rev 536) @@ -8,15 +8,15 @@ * %% * 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 + * 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 + * + * 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% @@ -38,6 +38,7 @@ useFloat: true; numberPattern: {DECIMAL3_PATTERN}; decimalNumber: 3; + computedDataColor: {handler.getConfig().getColorComputedWeights()}; } #catchTable { @@ -136,7 +137,7 @@ #speciesTotalSortedWeightField { text: {getStringValue(model.getSpeciesTotalSortedWeight() != null ? - String.format("%.3f", model.getSpeciesTotalSortedWeight()) : + String.format("%.3f", model.getSpeciesTotalSortedWeight()) : model.getSpeciesTotalSortedComputedWeight() != null ? String.format("%.3f", model.getSpeciesTotalSortedComputedWeight()) : null)}; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -117,11 +117,8 @@ // remove all rows from the model getModel().getRows().removeAll(rowToRemove); - // refresh table from parent batch row index to the end - tableModel.fireTableDataChanged(); + if (!getModel().getRows().isEmpty()) { - if (tableModel.getRowCount() > 0) { - // select first row AbstractSelectTableAction.doSelectCell(table, 0, 0); } else { @@ -129,6 +126,9 @@ table.clearSelection(); } + // refresh table from parent batch row index to the end + tableModel.fireTableDataChanged(); + if (table.isEditing()) { // but no edit it Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -52,8 +52,11 @@ */ public class SampleCategoryComponent { - public static <C extends Serializable> TableCellRenderer newRender(TableCellRenderer renderer, Decorator<C> decorator) { - return new SampleCategoryRenderer<C>(renderer, decorator); + public static <C extends Serializable> TableCellRenderer newRender( + TableCellRenderer renderer, + Decorator<C> decorator, + Color computedDataColor) { + return new SampleCategoryRenderer<C>(renderer, decorator, computedDataColor); } public static <C extends Serializable> TableCellEditor newEditor(Decorator<C> decorator) { @@ -196,10 +199,14 @@ protected final Decorator<C> categoryDecorator; + protected final Color computedWeightColor; + public SampleCategoryRenderer(TableCellRenderer delegate, - Decorator<C> categoryDecorator) { + Decorator<C> categoryDecorator, + Color computedWeightColor) { this.delegate = delegate; this.categoryDecorator = categoryDecorator; + this.computedWeightColor = computedWeightColor; } @Override @@ -236,8 +243,8 @@ text += String.format("%.3f", computedNumber); } else { - String blue = Integer.toHexString(Color.BLUE.getRGB()).substring(2); - text += "<em style='color: #" + blue + "'>" + + String color = Integer.toHexString(computedWeightColor.getRGB()).substring(2); + text += "<em style='color: #" + color + "'>" + String.format("%.3f", computedNumber) + "</em>"; } } else { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-03-05 12:11:44 UTC (rev 536) @@ -8,15 +8,15 @@ * %% * 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 + * 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 + * + * 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% @@ -38,6 +38,7 @@ useFloat: true; numberPattern: {DECIMAL3_PATTERN}; decimalNumber: 3; + computedDataColor: {handler.getConfig().getColorComputedWeights()}; } #speciesTotalWeightLabel { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-05 12:11:44 UTC (rev 536) @@ -550,6 +550,8 @@ Decorator<CaracteristicQualitativeValue> caracteristicDecorator = getDecorator(CaracteristicQualitativeValue.class, null); + Color computedDataColor = getConfig().getColorComputedWeights(); + { // Species column addColumnToModel(columnModel, @@ -602,17 +604,17 @@ addColumnToModel(columnModel, TuttiComputedOrNotDataTableCell.newEditor( - Float.class, false, true, 3), + Float.class, false, true, 3, computedDataColor), TuttiComputedOrNotDataTableCell.newRender( - defaultRenderer, true, 3), + defaultRenderer, true, 3, computedDataColor), SpeciesBatchTableModel.WEIGHT); } { // Number column (from frequencies) addColumnToModel(columnModel, - FrequencyCellComponent.newEditor(ui), - FrequencyCellComponent.newRender(), + FrequencyCellComponent.newEditor(ui, computedDataColor), + FrequencyCellComponent.newRender(computedDataColor), SpeciesBatchTableModel.COMPUTED_NUMBER); } @@ -1152,7 +1154,9 @@ TableCellRenderer defaultRenderer) { addColumnToModel(columnModel, SampleCategoryComponent.newEditor(decorator), - SampleCategoryComponent.newRender(defaultRenderer, decorator), + SampleCategoryComponent.newRender(defaultRenderer, + decorator, + getConfig().getColorComputedWeights()), columnIdentifier); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -64,13 +64,16 @@ public static final String ROW_INDEX = "rowIndex"; + protected Color computedDataColor; + /** Logger. */ private static final Log log = LogFactory.getLog(FrequencyCellComponent.class); - public FrequencyCellComponent() { + public FrequencyCellComponent(Color computedDataColor) { setHorizontalAlignment(CENTER); setIcon(SwingUtil.createActionIcon("show-frequency")); + this.computedDataColor = computedDataColor; } public void setComputedOrNotText(TuttiComputedOrNotData<Integer> data) { @@ -83,7 +86,7 @@ && data.getComputedData() != null && data.getComputedData() != 0) { - String blue = Integer.toHexString(Color.BLUE.getRGB()).substring(2); + String blue = Integer.toHexString(computedDataColor.getRGB()).substring(2); text = "<html><em style='color: #" + blue + "'>" + data.getComputedData() + "</em></html>"; } else { @@ -92,12 +95,12 @@ setText(text); } - public static TableCellRenderer newRender() { - return new FrequencyCellRenderer(); + public static TableCellRenderer newRender(Color computedDataColor) { + return new FrequencyCellRenderer(computedDataColor); } - public static TableCellEditor newEditor(SpeciesBatchUI ui) { - return new FrequencyCellEditor(ui); + public static TableCellEditor newEditor(SpeciesBatchUI ui, Color computedDataColor) { + return new FrequencyCellEditor(ui, computedDataColor); } public static class FrequencyCellEditor extends AbstractCellEditor implements TableCellEditor { @@ -120,9 +123,9 @@ protected Integer columnIndex; - public FrequencyCellEditor(SpeciesBatchUI ui) { + public FrequencyCellEditor(SpeciesBatchUI ui, Color computedDataColor) { this.ui = ui; - component = new FrequencyCellComponent(); + component = new FrequencyCellComponent(computedDataColor); component.setBorder(new LineBorder(Color.BLACK)); component.addKeyListener(new KeyAdapter() { @Override @@ -274,8 +277,8 @@ protected final FrequencyCellComponent component; - public FrequencyCellRenderer() { - component = new FrequencyCellComponent(); + public FrequencyCellRenderer(Color computedDataColor) { + component = new FrequencyCellComponent(computedDataColor); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -337,7 +337,7 @@ jTextField.setFont(font); jTextField.setEditable(!computed); jTextField.setEnabled(!computed); - jTextField.setDisabledTextColor(Color.BLUE); + jTextField.setDisabledTextColor(getConfig().getColorComputedWeights()); } } else if (component instanceof AbstractButton) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-03-05 12:11:44 UTC (rev 536) @@ -8,15 +8,15 @@ %% 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 + 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 + + 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% @@ -25,12 +25,15 @@ <import> fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData + java.awt.Color </import> <String id='property' javaBean='TuttiComputedOrNotData.PROPERTY_DATA'/> <TuttiComputedOrNotData id='bean' genericType='?' javaBean='null'/> + <Color id='computedDataColor' javaBean='null'/> + <!-- ui handler --> <TuttiComputedOrNotDataEditorHandler id='handler' constructorParams='this'/> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-03-05 12:11:44 UTC (rev 536) @@ -11,15 +11,15 @@ * %% * 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 + * 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 + * + * 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% @@ -64,7 +64,7 @@ TuttiComputedOrNotData bean = (TuttiComputedOrNotData) editor.getBean(); if (bean != null) { - bean.addPropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l); + bean.addPropertyChangeListener(l); } editor.addPropertyChangeListener(TuttiComputedOrNotDataEditor.PROPERTY_BEAN, new PropertyChangeListener() { @@ -72,12 +72,12 @@ TuttiComputedOrNotData bean = (TuttiComputedOrNotData) evt.getOldValue(); if (bean != null) { - bean.removePropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l); + bean.removePropertyChangeListener(l); } bean = (TuttiComputedOrNotData) evt.getNewValue(); if (bean != null) { - bean.addPropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l); + bean.addPropertyChangeListener(l); } } }); @@ -116,7 +116,7 @@ if (bean != null && editor.getModel() == null) { JTextField tf = editor.getTextField(); tf.setFont(TuttiUI.TEXTFIELD_COMPUTED_FONT); - tf.setForeground(Color.BLUE); + tf.setForeground(((TuttiComputedOrNotDataEditor) editor).getComputedDataColor()); String modelText; Number computedData = bean.getComputedData(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-03-05 12:11:44 UTC (rev 536) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -54,20 +54,24 @@ public static TableCellRenderer newRender(TableCellRenderer renderer, boolean useFloat, - Integer decimalNumber) { + Integer decimalNumber, + Color computedDataColor) { return new TuttiComputedOrNotDataTableCellRenderer(renderer, useFloat, - decimalNumber); + decimalNumber, + computedDataColor); } public static TableCellEditor newEditor(Class type, boolean useSign, boolean useFloat, - Integer decimalNumber) { + Integer decimalNumber, + Color computedDataColor) { return new TuttiComputedOrNotDataTableCellEditor(type, useSign, - useFloat, decimalNumber); + useFloat, decimalNumber, + computedDataColor); } public static class TuttiComputedOrNotDataTableCellEditor @@ -84,9 +88,11 @@ public TuttiComputedOrNotDataTableCellEditor(Class type, boolean useSign, boolean useFloat, - Integer decimalNumber) { + Integer decimalNumber, + Color computedDataColor) { numberEditor = new TuttiComputedOrNotDataEditor(); + numberEditor.setComputedDataColor(computedDataColor); numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT); numberEditor.getTextField().addFocusListener(this); numberEditor.getTextField().addAncestorListener(this); @@ -178,16 +184,20 @@ protected Integer decimalNumber; + protected Color computedDataColor; + protected boolean useFloat; public TuttiComputedOrNotDataTableCellRenderer( TableCellRenderer delegate, boolean useFloat, - Integer decimalNumber) { + Integer decimalNumber, + Color computedDataColor) { this.delegate = delegate; this.useFloat = useFloat; this.decimalNumber = decimalNumber; + this.computedDataColor = computedDataColor; } public Component getTableCellRendererComponent(JTable table, @@ -204,7 +214,7 @@ if (dataValue == null) { dataValue = data.getComputedData(); font = TuttiUI.TEXTFIELD_COMPUTED_FONT; - foreground = Color.BLUE; + foreground = computedDataColor; } else { font = TuttiUI.TEXTFIELD_NORMAL_FONT; Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-05 11:36:05 UTC (rev 535) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-05 12:11:44 UTC (rev 536) @@ -44,6 +44,9 @@ tutti.action.computeWeights.error.incoherentSpeciesTotalSorted.title=Incohérence tutti.action.computeWeights.error.incoherentTotal=Le poids total de la capture ne correspond pas à la somme des poids totaux Vrac, Hors Vrac et non triés tutti.action.computeWeights.error.incoherentTotal.title=Incohérence +tutti.action.computeWeights.error.noWeight=Un lot n'a pas de poids +tutti.action.computeWeights.replaceTotalSortedWeight.message=Le Poids total VRAC saisi est supérieur de moins de %s%% au Poids total Vrac trié.%nEst-ce bien une valeur observée ? Si non, la valeur sera remplacée par le poids calculé. +tutti.action.computeWeights.replaceTotalSortedWeight.title=Poids total VRAC peu différent du Poids total Vrac trié tutti.action.computeWeights.tip=Elever les poids tutti.action.configuration=Configuration tutti.action.configuration.tip=Configurer Tutti @@ -391,6 +394,7 @@ tutti.option.protocolId.description=Identifiant du dernier protocole utilisé tutti.option.ui.autoPopupNumberEditor.description=Toujours afficher le pavé numérique lors de l'édition d'un nombre tutti.option.ui.color.cellWithValue.description=Couleur d'une cellule avec des données +tutti.option.ui.color.computedWeights.description=Couleur des données calculées tutti.option.ui.color.rowInvalid.description=Ligne invalide tutti.option.ui.color.rowReadOnly.description=Cellule non éditable tutti.option.ui.color.rowToConfirm.description=Ligne à confirmer @@ -577,3 +581,4 @@ tutti.validator.warning.longitude.minute.outOfBounds=La minute de la latitude doit être comprise entre 0 et 60 tutti.validator.warning.longitude.outOfBounds=La Latitude doit être comprise entre -180.0 et 180.0 tutti.validator.warning.longitude.second.outOfBounds=La seconde de la longitude doit être comprise entre 0 et 60 +tutti.weights.rate.difference.totalAndSorted.description=Pourcentage de différence entre les Poids totaux VRAC triés et les poids totaux VRAC en dessous duquel on demande confirmation sur la saisie.