This is an automated email from the git hooks/post-receive script. New commit to branch feature/8153 in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 8748f3906dad4c65a91522bcd24cc85dd3d6b8d0 Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Mar 31 18:04:18 2016 +0200 Fix merge --- .../frequency/SpeciesFrequencyUIHandler.java | 316 +-------------------- 1 file changed, 5 insertions(+), 311 deletions(-) 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 4d5f545..f1a0cb6 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 @@ -50,7 +50,6 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchTableModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.SamplingCodeCellEditor; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.SamplingCodeCellRenderer; -import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.SamplingCodeCellEditor; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.EditSpeciesBatchPanelUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesOrBenthosBatchUISupport; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; @@ -724,7 +723,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci CopyIndividualObservationMode oldCopyMode = (CopyIndividualObservationMode) evt.getOldValue(); CopyIndividualObservationMode newCopyMode = (CopyIndividualObservationMode) evt.getNewValue(); - if (newCopyMode ==null) { + if (newCopyMode == null) { return; } @@ -843,7 +842,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci context.removeVetoableChangeListener(TuttiUIContext.PROPERTY_SCREEN, changeScreenListener); } -public void editBatch(FrequencyCellEditor editor, Optional<String> optionalTitle) { + public void editBatch(FrequencyCellEditor editor, Optional<String> optionalTitle) { SpeciesBatchRowModel speciesBatch = editor.getEditRow(); Objects.requireNonNull(speciesBatch, "Impossible d'éditer un lot non renseigné"); @@ -948,311 +947,6 @@ public void editBatch(FrequencyCellEditor editor, Optional<String> optionalTitle } - public void editBatchOld(FrequencyCellEditor editor, Optional<String> optionalTitle) { - - SpeciesBatchRowModel speciesBatch = editor.getEditRow(); - Objects.requireNonNull(speciesBatch, "Impossible d'éditer un lot non renseigné"); - - // on enlève la colonne spécifique à l'espèce précédente - if (maturityColumnId.isPresent()) { - TableColumnExt maturityColumn = ui.getObsTable().getColumnExt(maturityColumnId.get()); - ui.getObsTable().removeColumn(maturityColumn); - maturityColumnId = Optional.empty(); - } - - if (optionalTitle.isPresent()) { - - String title = optionalTitle.get(); - frequenciesHistogramPopup.setTitle(title + t("tutti.editSpeciesFrequencies.title")); - averageWeightsHistogramPopup.setTitle(title + weightUnit.decorateLabel(t("tutti.editSpeciesFrequencies.field.graphAverageWeight"))); - - } - - SpeciesFrequencyUIModel model = getModel(); - - model.setInitBatchEdition(true); - - try { - - FrequencyConfigurationMode mode = FrequencyConfigurationMode.FREQUENCIES; - FrequencyConfigurationMode frequenciesMode = FrequencyConfigurationMode.AUTO_GEN; - - model.setNextEditableRowIndex(editor.getNextEditableRowIndex()); - model.setTotalNumber(null); - model.setTotalComputedWeight(null); - model.setTotalWeight(null); - model.setSimpleCount(null); - model.setMinStep(null); - model.setMaxStep(null); - model.setRtp(null); - model.setCopyRtpWeights(false); - model.setAddIndividualObservationOnRafale(false); - - frequencyEditor = editor; - - Caracteristic lengthStepCaracteristic = null; - CopyIndividualObservationMode copyIndividualObservationMode = null; - - List<SpeciesFrequencyRowModel> rows = new ArrayList<>(); - List<IndividualObservationBatchRowModel> obsRows = new ArrayList<>(); - - Species species = speciesBatch.getSpecies(); - IndividualObservationBatchTableModel obsTableModel = getObsTableModel(); - obsTableModel.setSpecies(species); - SamplingCodePrefix samplingCodePrefix = new SamplingCodePrefix(getConfig().getSamplingCodePrefix(), - decorate(species, DecoratorService.WITH_SURVEY_CODE_NO_NAME)); - obsTableModel.setSamplingCodePrefix(samplingCodePrefix); - - model.setTotalWeight(speciesBatch.getWeight()); - - Optional<String> speciesMaturityPmfmId = Optional.empty(); - - // set rtps - TuttiProtocol protocol = getDataContext().getProtocol(); - if (protocol != null) { - - Integer referenceTaxonId = species.getReferenceTaxonId(); - Optional<SpeciesProtocol> optSpeciesProtocol = - protocol.getSpecies().stream() - .filter(sp -> sp.getSpeciesReferenceTaxonId().equals(referenceTaxonId)) - .findFirst(); - - if (optSpeciesProtocol.isPresent()) { - SpeciesProtocol speciesProtocol = optSpeciesProtocol.get(); - Rtp rtp; - CaracteristicQualitativeValue sampleCategoryValue = (CaracteristicQualitativeValue) speciesBatch.getSampleCategoryValue(sexCaracteristic.getIdAsInt()); - - if (sampleCategoryValue != null) { - - if (Sexs.isMale(sampleCategoryValue)) { - rtp = speciesProtocol.getRtpMale(); - } else if (Sexs.isFemale(sampleCategoryValue)) { - rtp = speciesProtocol.getRtpFemale(); - } else { - rtp = speciesProtocol.getRtpUndefined(); - } - - } else { - rtp = speciesProtocol.getRtpUndefined(); - } - model.setRtp(rtp); - - speciesMaturityPmfmId = Optional.ofNullable(speciesProtocol.getMaturityPmfmId()); - } - } - - List<SpeciesFrequencyRowModel> frequency = speciesBatch.getFrequency(); - List<IndividualObservationBatchRowModel> individualObservations = speciesBatch.getIndividualObservation(); - - // - // try to load existing frequency - // - - if (CollectionUtils.isNotEmpty(frequency)) { - - SpeciesFrequencyTableModel tableModel = getTableModel(); - - for (SpeciesFrequencyRowModel rowModel : frequency) { - - SpeciesFrequencyRowModel newRow = tableModel.createNewRow(false, false); - newRow.copy(rowModel); - rows.add(newRow); - - } - - // use first frequency row length step caracteristics - - SpeciesFrequencyRowModel rowModel = frequency.get(0); - lengthStepCaracteristic = rowModel.getLengthStepCaracteristic(); - - if (log.isInfoEnabled()) { - log.info("Use existing lengthStep caracteristic / step " + decorate(lengthStepCaracteristic)); - } - } - - // Add maturity column if necessary - - Optional<Caracteristic> maturityCaracteristic = speciesMaturityPmfmId.map(maturityCaracteristics::get); - - setMaturityCaracteristic(maturityCaracteristic); - - // - // try to load existing individual observations - // - - if (CollectionUtils.isNotEmpty(individualObservations)) { - - IndividualObservationBatchTableModel tableModel = getObsTableModel(); - tableModel.setRows(new ArrayList<>()); - - int rankOrder = 1; - for (IndividualObservationBatchRowModel rowModel : individualObservations) { - - CopyIndividualObservationMode incomingCopyIndividualObservationMode = rowModel.getCopyIndividualObservationMode(); - Objects.requireNonNull(incomingCopyIndividualObservationMode, "Mode de recopie non trouvé sur l'observation individuelle: " + rowModel.getId()); - if (copyIndividualObservationMode == null) { - copyIndividualObservationMode = incomingCopyIndividualObservationMode; - } else { - if (copyIndividualObservationMode != incomingCopyIndividualObservationMode) { - throw new IllegalStateException("Plusieurs modes de recopie trouvés sur les observations individuelles du lot, ce qui est impossible"); - } - } - IndividualObservationBatchRowModel newRow = tableModel.createNewRow(); - newRow.copy(rowModel); - newRow.setRankOrder(rankOrder++); - newRow.addPropertyChangeListener(obsChangedListener); - newRow.setValid(true); - - if (maturityCaracteristic.isPresent()) { - - Caracteristic caracteristicKey = maturityCaracteristic.get(); - Serializable caracteristicValue = newRow.getCaracteristics().remove(caracteristicKey); - newRow.getDefaultCaracteristics().putIfAbsent(caracteristicKey, caracteristicValue); - } - - obsRows.add(newRow); - - } - - // use first individual observation row length step caracteristics - - if (lengthStepCaracteristic == null) { - IndividualObservationBatchRowModel rowModel = individualObservations.get(0); - lengthStepCaracteristic = rowModel.getLengthStepCaracteristic(); - - if (log.isInfoEnabled()) { - log.info("Use existing lengthStep caracteristic / step " + decorate(lengthStepCaracteristic)); - } - } - - } else { - - // par défaut pas de mode de recopie - copyIndividualObservationMode = CopyIndividualObservationMode.NOTHING; - - } - - if (log.isDebugEnabled()) { - log.debug("copy individual observation mode : " + copyIndividualObservationMode); - } - - SpeciesBatchRowModel previousSiblingRow = frequencyEditor.getPreviousSiblingRow(); - - if (lengthStepCaracteristic == null && previousSiblingRow != null) { - - // try to get it from his previous brother row - List<SpeciesFrequencyRowModel> previousFrequency = previousSiblingRow.getFrequency(); - - if (CollectionUtils.isNotEmpty(previousFrequency)) { - - // use the first frequency length step caracteristic / step - SpeciesFrequencyRowModel rowModel = previousFrequency.get(0); - lengthStepCaracteristic = rowModel.getLengthStepCaracteristic(); - if (log.isInfoEnabled()) { - log.info("Use previous sibling existing lengthStep caracteristic / step " + decorate(lengthStepCaracteristic)); - } - } - } - - if (lengthStepCaracteristic == null) { - - String lengthStepPmfmId = taxonCache.getLengthStepPmfmId(species); - - if (lengthStepPmfmId != null) { - - lengthStepCaracteristic = lengthStepCaracteristics.get(lengthStepPmfmId); - - if (log.isInfoEnabled()) { - log.info("Use existing from protocol lengthStep caracteristic / step " + decorate(lengthStepCaracteristic)); - } - - } - } - - if (lengthStepCaracteristic == null) { - String speciesLengthStepPmfmId = taxonCache.getLengthStepPmfmId(species); - if (speciesLengthStepPmfmId == null) { - mode = FrequencyConfigurationMode.SIMPLE_COUNTING; - } - } - - if (log.isInfoEnabled()) { - log.info("FrequencyConfigurationMode: " + mode); - } - - if (log.isDebugEnabled()) { - log.debug("Will edit batch row: " + speciesBatch + " with " + rows.size() + " frequency"); - } - - Integer number = speciesBatch.getNumber(); - if (number != null && rows.isEmpty()) { - mode = FrequencyConfigurationMode.SIMPLE_COUNTING; - model.setSimpleCount(number); - } - - // make sure configuration mode will be rebound - model.setConfigurationMode(null); - model.setConfigurationMode(mode); - - model.setFrequenciesConfigurationMode(null); - model.setFrequenciesConfigurationMode(frequenciesMode); - - // connect model to validator - ui.getValidator().setBean(model); - - // always sort row by their length - // see http://forge.codelutin.com/issues/2482 - Collections.sort(rows); - - model.setLengthStepCaracteristic(lengthStepCaracteristic); - model.setRows(rows); - - CaracteristicMap sampleCategoryValues = new CaracteristicMap(); - Iterator<SampleCategory<?>> iterator = speciesBatch.iterator(); - iterator.forEachRemaining(sampleCategory -> { - Caracteristic caracteristic = sampleCategory.getCategoryDef().getCaracteristic(); - sampleCategoryValues.put(caracteristic, sampleCategory.getCategoryValue()); - }); - - obsTableModel.setDefaultCaracteristicValues(sampleCategoryValues); - - model.setIndividualObservationRows(obsRows); - obsTableModel.setRows(obsRows); - model.recomputeIndividualObservationRowsValidateState(); - - // keep batch (will be used to push back editing entry) - model.setBatch(speciesBatch); - - // let's change the copy mode (mark it in init mode to avoid user change confirmation and some recompuations) - model.setCopyIndividualObservationMode(null); - model.setCopyIndividualObservationMode(copyIndividualObservationMode); - - model.computeRowWeightWithRtp(); - - model.recomputeIndividualObservationRowsValidateState(); - model.recomputeRowsValidateState(); - - if (getContext().isIchtyometerConnected()) { - - // let's listen the ichtyometer - listenItchtyometer(); - - } - - individualObservationUICache.init(ui, frequencyEditor.getEditRow(), getDataContext().getFishingOperation()); - - model.setModify(false); - - getContext().addVetoableChangeListener(TuttiUIContext.PROPERTY_SCREEN, changeScreenListener); - - } finally { - model.setInitBatchEdition(false); - //FIXME Voir si c'est nécessaire ? - model.setModify(false); - } - - } - public boolean askCancelEditBeforeLeaving() { // Ask confirmation to quit screen String htmlMessage = String.format(AbstractApplicationUIHandler.CONFIRMATION_FORMAT, @@ -2009,12 +1703,12 @@ public void editBatch(FrequencyCellEditor editor, Optional<String> optionalTitle super.beforeOpenPopup(modelRowIndex, modelColumnIndex); boolean sampleCodeMenusEnabled = modelRowIndex >= 1 && ui.getObsTable().getSelectedRowCount() == 1 - && getObsTableModel().getRows().get(ui.getObsTable().getSelectedRow()).withSamplingCode(); + && getObsTableModel().getRows().get(ui.getObsTable().getSelectedRow()).withSamplingCode(); ui.getEditSampleCodeMenu().setEnabled(sampleCodeMenusEnabled); ui.getDeleteSampleCodeMenu().setEnabled(sampleCodeMenusEnabled); } - + public void loadFrequenciesAndObservations(List<SpeciesFrequencyRowModel> frequency, List<IndividualObservationBatchRowModel> individualObservations) { SpeciesFrequencyUIModel model = getModel(); SpeciesBatchRowModel speciesBatch = model.getBatch(); @@ -2042,7 +1736,7 @@ public void editBatch(FrequencyCellEditor editor, Optional<String> optionalTitle IndividualObservationBatchTableModel obsTableModel = getObsTableModel(); obsTableModel.setSpecies(species); - SamplingCodePrefix samplingCodePrefix = new SamplingCodePrefix(getConfig().getSamplingCodePrefix(), decorate(species, DecoratorService.WITH_SURVEY_CODE_NO_NAME)); + SamplingCodePrefix samplingCodePrefix = new SamplingCodePrefix(getConfig().getSamplingCodePrefix(), decorate(species, DecoratorService.WITH_SURVEY_CODE_NO_NAME)); obsTableModel.setSamplingCodePrefix(samplingCodePrefix); model.setTotalWeight(speciesBatch.getWeight()); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.