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 cd91569f09a824900bae3d19ddbe9b5a2332ca06 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Dec 31 21:32:19 2014 +0100 ajout du comportement pour l'ecran espece --- .../frequency/SpeciesFrequencyTableModel.java | 67 ++++++++++++++++------ .../species/frequency/SpeciesFrequencyUI.css | 4 +- .../frequency/SpeciesFrequencyUIHandler.java | 19 +++++- .../species/frequency/SpeciesFrequencyUIModel.java | 20 +++++++ 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java index 0ac5ae6..6efd894 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java @@ -24,6 +24,7 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; import com.google.common.collect.Maps; import fr.ifremer.tutti.type.WeightUnit; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel; import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; import org.nuiton.jaxx.application.swing.table.ColumnIdentifier; import org.jdesktop.swingx.table.TableColumnModelExt; @@ -72,6 +73,7 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp protected final WeightUnit weightUnit; protected final PropertyChangeListener rowPropertyChangeListener; + protected final PropertyChangeListener onLengthStepChangedListener; public SpeciesFrequencyTableModel(WeightUnit weightUnit, TableColumnModelExt columnModel, @@ -82,10 +84,54 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp this.uiModel = uiModel; this.rowCache = Maps.newTreeMap(); this.rowPropertyChangeListener = rowPropertyChangeListener; + this.onLengthStepChangedListener = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Float oldValue = (Float) evt.getOldValue(); + if (oldValue != null) { + rowCache.remove(oldValue); + } + SpeciesFrequencyRowModel row = (SpeciesFrequencyRowModel) evt.getSource(); + Float lengthStep = row.getLengthStep(); + if (lengthStep != null) { + rowCache.put(lengthStep, row); + } + } + }; setNoneEditableCols(); } @Override + protected void onRowAdded(int rowIndex, SpeciesFrequencyRowModel newValue) { + recomputeCanEditLengthStep(); + } + + public void recomputeCanEditLengthStep() { + + boolean result = true; + + for (SpeciesFrequencyRowModel row : rows) { + + if (row.isEmpty()) { + // la ligne est vide + continue; + } + if (row.getLengthStep() == null || row.getNumber() == null) { + // la ligne n'est pas complete + continue; + } + + // une ligne non vide et complete a ete trouvee + // on ne peut plus editer + result = false; + + } + + uiModel.setCanEditLengthStep(result); + + } + + @Override public SpeciesFrequencyRowModel createNewRow() { Float defaultStep = null; @@ -99,23 +145,8 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp lengthStep + uiModel.getStep()); } } - SpeciesFrequencyRowModel result = - new SpeciesFrequencyRowModel(weightUnit); - result.addPropertyChangeListener(SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP, - new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - Float oldValue = (Float) evt.getOldValue(); - if (oldValue != null) { - rowCache.remove(oldValue); - } - SpeciesFrequencyRowModel row = (SpeciesFrequencyRowModel) evt.getSource(); - Float lengthStep = row.getLengthStep(); - if (lengthStep != null) { - rowCache.put(lengthStep, row); - } - } - }); + SpeciesFrequencyRowModel result = new SpeciesFrequencyRowModel(weightUnit); + result.addPropertyChangeListener(SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP,onLengthStepChangedListener); result.addPropertyChangeListener(rowPropertyChangeListener); @@ -151,5 +182,7 @@ public class SpeciesFrequencyTableModel extends AbstractApplicationTableModel<Sp rowCache.put(lengthStep, row); } } + + recomputeCanEditLengthStep(); } } \ No newline at end of file diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css index 395a20e..ab2f490 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css @@ -56,7 +56,7 @@ ComputableDataEditor { useFloat: true; numberPattern: {DECIMAL1_PATTERN}; bean: {model}; - enabled: {!model.isSimpleCountingMode()}; + enabled: {!model.isSimpleCountingMode() && model.isCanEditLengthStep()}; _selectOnFocus: true; _validatorLabel: {t("tutti.editSpeciesFrequencies.field.step")}; _help: {"tutti.editSpeciesFrequencies.field.step.help"}; @@ -104,7 +104,7 @@ ComputableDataEditor { #lengthStepCaracteristicComboBox { property: lengthStepCaracteristic; selectedItem: {model.getLengthStepCaracteristic()}; - enabled: {!model.isSimpleCountingMode()}; + enabled: {!model.isSimpleCountingMode() && model.isCanEditLengthStep()}; _validatorLabel: {t("tutti.editSpeciesFrequencies.field.lengthStepCaracteristic")}; _help: {"tutti.editSpeciesFrequencies.field.lengthStepCaracteristic.help"}; } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index 9c4516e..7de2882 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -38,6 +38,7 @@ import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.FrequencyConfigurationMode; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyCellComponent.FrequencyCellEditor; @@ -226,6 +227,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci model.updateRowWithWeight(row); boolean lengthStepModified = SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP.equals(propertyName); + boolean numberModified = BenthosFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName); if (lengthStepModified) { Float lengthStepToDec = (Float) oldValue; @@ -264,6 +266,12 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } model.updateEmptyRow(row); + + if (lengthStepModified || numberModified) { + + getTableModel().recomputeCanEditLengthStep(); + } + } @Override @@ -922,10 +930,17 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci SpeciesFrequencyRowModel speciesFrequencyRowModel = tableModel.getRowCache().get(logRow.getLengthStep()); if (speciesFrequencyRowModel != null) { Integer number = speciesFrequencyRowModel.getNumber(); - if (number != null && number > 0) { - speciesFrequencyRowModel.setNumber(number - 1); + if (number != null) { + + if (number > 1) { + speciesFrequencyRowModel.setNumber(number - 1); + } else { + speciesFrequencyRowModel.setNumber(null); + } + tableModel.fireTableDataChanged(); } + tableModel.recomputeCanEditLengthStep(); } SpeciesFrequencyLogsTableModel logsTableModel = (SpeciesFrequencyLogsTableModel) getUI().getLogsTable().getModel(); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java index 85b71a7..8d9b11d 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java @@ -83,6 +83,8 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa public static final String PROPERTY_NEXT_EDITABLE_ROW_INDEX = "nextEditableRowIndex"; + public static final String PROPERTY_CAN_EDIT_LENGTH_STEP = "canEditLengthStep"; + /** * Fill mode. * @@ -183,6 +185,14 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa */ protected Map<Integer, MutableInt> nbOfRowsByLengthStep = new HashMap<Integer, MutableInt>(); + /** + * Can edit length step? (only if no row is filled). + * see https://forge.codelutin.com/issues/5694 + * + * @since 3.11 + */ + protected boolean canEditLengthStep = true; + public SpeciesFrequencyUIModel(WeightUnit weightUnit, SampleCategoryModel sampleCategoryModel) { super(SpeciesBatchRowModel.class, null, null); @@ -278,6 +288,16 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa firePropertyChange(PROPERTY_SIMPLE_COUNT, oldValue, simpleCount); } + public boolean isCanEditLengthStep() { + return canEditLengthStep; + } + + public void setCanEditLengthStep(boolean canEditLengthStep) { + Object oldValue = isCanEditLengthStep(); + this.canEditLengthStep = canEditLengthStep; + firePropertyChange(PROPERTY_CAN_EDIT_LENGTH_STEP, oldValue, canEditLengthStep); + } + public Integer getNextEditableRowIndex() { return nextEditableRowIndex; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.