Author: tchemit Date: 2013-03-21 00:23:30 +0100 (Thu, 21 Mar 2013) New Revision: 662 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/662 Log: refs #1863: [BENTHOS] - Gestion de la saisie du benthos - impact sur service de persistence - debut de reusinage des APi d'ui Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryType.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/TableViewMode.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateMelagAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.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/SampleCategoryType.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDataContext.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/EditCatchesUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.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/SpeciesBatchUI.jaxx 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/SpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-03-20 23:23:30 UTC (rev 662) @@ -488,7 +488,7 @@ //-- Benthos Batch methods --// //------------------------------------------------------------------------// - List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId); + BatchContainer<SpeciesBatch> getRootBenthosBatch(String fishingOperationId); @Transactional(readOnly = false) SpeciesBatch createBenthosBatch(SpeciesBatch bean, String parentBatchId); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-03-20 23:23:30 UTC (rev 662) @@ -575,8 +575,8 @@ //------------------------------------------------------------------------// @Override - public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) { - return batchService.getAllRootBenthosBatch(fishingOperationId); + public BatchContainer<SpeciesBatch> getRootBenthosBatch(String fishingOperationId) { + return batchService.getRootBenthosBatch(fishingOperationId); } @Override Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-03-20 23:23:30 UTC (rev 662) @@ -385,7 +385,7 @@ } @Override - public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) { + public BatchContainer<SpeciesBatch> getRootBenthosBatch(String fishingOperationId) { throw new RuntimeException("method not implemented"); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-03-20 23:23:30 UTC (rev 662) @@ -146,11 +146,12 @@ * <p/> * <strong>Note:</strong> All childs of the batch should be loaded here. * + * * @param fishingOperationId if of the fishing operation to seek * @return the list of root {@link SpeciesBatch} * @since 1.0 */ - List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId); + BatchContainer<SpeciesBatch> getRootBenthosBatch(String fishingOperationId); @Transactional(readOnly = false) SpeciesBatch createBenthosBatch(SpeciesBatch bean, String parentBatchId); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-03-20 23:23:30 UTC (rev 662) @@ -62,7 +62,6 @@ import javax.annotation.Resource; import java.io.Serializable; import java.text.MessageFormat; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -74,7 +73,9 @@ public class BatchPersistenceServiceImpl extends AbstractPersistenceService implements BatchPersistenceService { - /** Logger. */ + /** + * Logger. + */ private static final Log log = LogFactory.getLog(BatchPersistenceServiceImpl.class); @@ -119,13 +120,13 @@ // Vrac SortingBatch vracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID); + "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID); result.setCatchTotalSortedCarousselWeight(vracBatch.getWeight()); result.setCatchTotalSortedTremisWeight(vracBatch.getWeightBeforeSampling()); { // Species SortingBatch speciesBatch = catchBatchDao.getSortingBatch(vracBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); result.setSpeciesTotalSampleSortedWeight(speciesBatch.getWeight()); result.setSpeciesTotalSortedWeight(speciesBatch.getWeightBeforeSampling()); @@ -133,14 +134,14 @@ { // Inert SortingBatch inertBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(), - "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT); + "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_INERT); if (inertBatch != null) { result.setSpeciesTotalInertWeight(inertBatch.getWeight()); } // Alive no itemized SortingBatch livingNotItemizedBatch = catchBatchDao.getSortingBatch(speciesBatch.getChildBatchs(), - "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE); + "referenceTaxonId", enumeration.REFERENCE_TAXON_ID_LIFE); if (livingNotItemizedBatch != null) { result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight()); } @@ -148,7 +149,7 @@ // Benthos SortingBatch benthosBatch = catchBatchDao.getSortingBatch(vracBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); if (benthosBatch != null) { result.setBenthosTotalSampleSortedWeight(benthosBatch.getWeight()); result.setBenthosTotalSortedWeight(benthosBatch.getWeightBeforeSampling()); @@ -159,19 +160,19 @@ // Hors Vrac SortingBatch horsVracBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID); + "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID); if (horsVracBatch != null) { result.setCatchTotalUnsortedWeight(horsVracBatch.getWeight()); { // Species SortingBatch speciesBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); if (speciesBatch != null) { result.setSpeciesTotalUnsortedWeight(speciesBatch.getWeight()); } SortingBatch benthosBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); if (benthosBatch != null) { result.setBenthosTotalUnsortedWeight(benthosBatch.getWeight()); } @@ -182,7 +183,7 @@ // Non trié SortingBatch unsortedBatch = catchBatchDao.getSortingBatch(source.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID); + "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID); if (unsortedBatch != null) { result.setCatchTotalRejectedWeight(unsortedBatch.getWeight()); } @@ -206,8 +207,8 @@ getCurrentSession().flush(); Integer fishingOperationId = Integer.valueOf(bean.getFishingOperation().getId()); int rowUpdated = queryUpdate("updateFishingOperationCatchBatch", - "fishingOperationId", IntegerType.INSTANCE, fishingOperationId, - "catchBatchId", IntegerType.INSTANCE, catchBatch.getId()); + "fishingOperationId", IntegerType.INSTANCE, fishingOperationId, + "catchBatchId", IntegerType.INSTANCE, catchBatch.getId()); if (rowUpdated == 0) { throw new DataIntegrityViolationException("Could not attach catch batch to the given operation : operation was not found."); } @@ -248,12 +249,12 @@ // Vrac / Species SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); // container of speciesBatch is arbitraty put on vrac type (there is // no common ancestor for all species batch). - BatchContainer result = new BatchContainer<SpeciesBatch>(); + BatchContainer<SpeciesBatch> result = new BatchContainer<SpeciesBatch>(); result.setId(String.valueOf(vracSpeciesBatch.getId())); for (Batch batch1 : vracSpeciesBatch.getChildBatchs()) { @@ -261,8 +262,8 @@ // evict some special batches : Life (or Biota) and Inert if (source.getReferenceTaxon() != null - && !enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId()) - && !enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId())) { + && !enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId()) + && !enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId())) { SpeciesBatch target = new SpeciesBatch(); entityToBean(source, target); @@ -272,8 +273,8 @@ // Hors-Vrac / Species SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); if (horsVracSpeciesBatch != null) { for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) { SortingBatch source = (SortingBatch) batch; @@ -487,35 +488,36 @@ //------------------------------------------------------------------------// @Override - public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) { + public BatchContainer<SpeciesBatch> getRootBenthosBatch(String fishingOperationId) { // Load batch tree Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId)); fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId); - List<SpeciesBatch> result = new ArrayList<SpeciesBatch>(); - // Vrac / Benthos SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + + BatchContainer<SpeciesBatch> result = new BatchContainer<SpeciesBatch>(); + result.setId(String.valueOf(vracSpeciesBatch.getId())); for (Batch batch1 : vracSpeciesBatch.getChildBatchs()) { SortingBatch source = (SortingBatch) batch1; // evict some special batches : Life (or Biota) and Inert if (source.getReferenceTaxon() != null - && !enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId()) - && !enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId())) { + && !enumeration.REFERENCE_TAXON_ID_LIFE.equals(source.getReferenceTaxon().getId()) + && !enumeration.REFERENCE_TAXON_ID_INERT.equals(source.getReferenceTaxon().getId())) { SpeciesBatch target = new SpeciesBatch(); entityToBean(source, target); - result.add(target); + result.addChildren(target); } } // Hors-Vrac / Benthos SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); if (horsVracSpeciesBatch != null) { for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) { SortingBatch source = (SortingBatch) batch; @@ -523,10 +525,10 @@ SpeciesBatch target = new SpeciesBatch(); entityToBean(source, target); - result.add(target); + result.addChildren(target); } } - return Collections.unmodifiableList(result); + return result; } @Override @@ -607,8 +609,8 @@ } int rowUpdated = queryUpdate("updateBatchSpecies", - "batchId", IntegerType.INSTANCE, Integer.valueOf(batchId), - "referenceTaxonId", IntegerType.INSTANCE, species.getReferenceTaxonId()); + "batchId", IntegerType.INSTANCE, Integer.valueOf(batchId), + "referenceTaxonId", IntegerType.INSTANCE, species.getReferenceTaxonId()); Preconditions.checkArgument(rowUpdated == 1, "Unable to update operation, to be linked with catch batch."); } @@ -838,8 +840,8 @@ // If parent and root need to be set if (target.getId() == null - || target.getRootBatch() == null - || (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) { + || target.getRootBatch() == null + || (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) { setBatchParents(source, target, parentBatchId, catchBatch); } @@ -863,11 +865,11 @@ // Nothing to do : will be removed later, using notChangedSortingMeasurements } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) { QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target, - enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true); + enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) { QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target, - enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true); + enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } @@ -881,7 +883,7 @@ target.setSamplingRatioText(samplingRatioText); target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight()); QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target, - enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true); + enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } @@ -893,7 +895,7 @@ // Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch) if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) { SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId, - source.getSampleCategoryType(), source.getSampleCategoryValue()); + source.getSampleCategoryType(), source.getSampleCategoryValue()); notChangedSortingMeasurements.remove(sortingMeasurement); } } @@ -969,8 +971,8 @@ Integer qualitativeValueId = convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue()); parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(), - "pmfmId", pmfmId, qualitativeValueId, - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + "pmfmId", pmfmId, qualitativeValueId, + "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); // Parent Batch target.setParentBatch(parentBatch); @@ -1053,8 +1055,8 @@ // If parent and root need to be set if (target.getId() == null - || target.getRootBatch() == null - || (target.getParentBatch() != null && !target.getParentBatch().getId().equals(parentBatch.getId()))) { + || target.getRootBatch() == null + || (target.getParentBatch() != null && !target.getParentBatch().getId().equals(parentBatch.getId()))) { target.setParentBatch(parentBatch); target.setRootBatch(parentBatch.getRootBatch()); @@ -1068,7 +1070,7 @@ // Nothing to do : will be removed later, using notChangedSortingMeasurements } else if (source.getWeight() != null) { QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target, - enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true); + enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } @@ -1078,7 +1080,7 @@ } else if (source.getLengthStepCaracteristic() != null && source.getLengthStep() != null) { Integer pmfmId = Integer.valueOf(source.getLengthStepCaracteristic().getId()); SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId, pmfmId, - source.getLengthStep()); + source.getLengthStep()); notChangedSortingMeasurements.remove(sortingMeasurement); } @@ -1173,7 +1175,7 @@ // Nothing to do : will be removed later, using notChangedQuantificationMeasurements } else if (source.getCatchTotalWeight() != null) { QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target, - enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true); + enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getCatchTotalWeight(), true); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } @@ -1195,9 +1197,9 @@ target.getChildBatchs().add(batch); } beanToEntitySortingBatch(target, target, batch, recorderDepartmentId, - enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, - source.getCatchTotalSortedCarousselWeight(), source.getCatchTotalSortedTremisWeight(), - copyIfNull); + enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, + source.getCatchTotalSortedCarousselWeight(), source.getCatchTotalSortedTremisWeight(), + copyIfNull); batch.setRankOrder((short) 1); // Manage childs : @@ -1217,9 +1219,9 @@ } } beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId, - enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, - source.getSpeciesTotalSampleSortedWeight(), source.getSpeciesTotalSortedWeight(), - copyIfNull); + enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, + source.getSpeciesTotalSampleSortedWeight(), source.getSpeciesTotalSortedWeight(), + copyIfNull); speciesBatch.setRankOrder((short) 1); { @@ -1236,9 +1238,9 @@ } } beanToEntityReferenceTaxonBatch(target, speciesBatch, aliveNotItemizedBatch, recorderDepartmentId, - enumeration.REFERENCE_TAXON_ID_LIFE, - source.getSpeciesTotalLivingNotItemizedWeight(), null, - copyIfNull); + enumeration.REFERENCE_TAXON_ID_LIFE, + source.getSpeciesTotalLivingNotItemizedWeight(), null, + copyIfNull); aliveNotItemizedBatch.setRankOrder((short) 1); // ----------------------------------------------------------------------------- @@ -1250,9 +1252,9 @@ speciesBatch.getChildBatchs().add(inertBatch); } beanToEntityReferenceTaxonBatch(target, speciesBatch, inertBatch, recorderDepartmentId, - enumeration.REFERENCE_TAXON_ID_INERT, - source.getSpeciesTotalInertWeight(), null, - copyIfNull); + enumeration.REFERENCE_TAXON_ID_INERT, + source.getSpeciesTotalInertWeight(), null, + copyIfNull); inertBatch.setRankOrder((short) 2); } @@ -1266,9 +1268,9 @@ batch.getChildBatchs().add(benthosBatch); } beanToEntitySortingBatch(target, batch, benthosBatch, recorderDepartmentId, - enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, - source.getBenthosTotalSampleSortedWeight(), source.getBenthosTotalSortedWeight(), - copyIfNull); + enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, + source.getBenthosTotalSampleSortedWeight(), source.getBenthosTotalSortedWeight(), + copyIfNull); benthosBatch.setRankOrder((short) 2); } @@ -1286,9 +1288,9 @@ target.getChildBatchs().add(batch); } beanToEntitySortingBatch(target, target, batch, recorderDepartmentId, - enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, - source.getCatchTotalUnsortedWeight(), null, - copyIfNull); + enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, + source.getCatchTotalUnsortedWeight(), null, + copyIfNull); batch.setRankOrder((short) 2); // Manage childs : @@ -1309,9 +1311,9 @@ } } beanToEntitySortingBatch(target, batch, speciesBatch, recorderDepartmentId, - enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, - source.getSpeciesTotalUnsortedWeight(), null, - copyIfNull); + enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, + source.getSpeciesTotalUnsortedWeight(), null, + copyIfNull); speciesBatch.setRankOrder((short) 1); } @@ -1325,9 +1327,9 @@ batch.getChildBatchs().add(benthosBatch); } beanToEntitySortingBatch(target, batch, benthosBatch, recorderDepartmentId, - enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, - source.getBenthosTotalUnsortedWeight(), null, - copyIfNull); + enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, + source.getBenthosTotalUnsortedWeight(), null, + copyIfNull); benthosBatch.setRankOrder((short) 2); } @@ -1346,9 +1348,9 @@ target.getChildBatchs().add(unsortedBatch); } beanToEntitySortingBatch(target, target, unsortedBatch, recorderDepartmentId, - enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID, - source.getCatchTotalRejectedWeight(), null, - copyIfNull); + enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_UNSORTED_ID, + source.getCatchTotalRejectedWeight(), null, + copyIfNull); unsortedBatch.setRankOrder((short) 3); } @@ -1452,7 +1454,7 @@ batchReferenceWeight = sampleWeight; } QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target, - enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true); + enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } @@ -1519,7 +1521,7 @@ batchReferenceWeight = sampleWeight; } QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target, - enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true); + enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, batchReferenceWeight, true); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-20 23:23:30 UTC (rev 662) @@ -855,7 +855,7 @@ } protected SpeciesBatch getBenthosBatch(String fishingOperationId, String speciesBatchId) { - return getSpeciesBatch(speciesBatchId, service.getAllRootBenthosBatch(fishingOperationId)); + return getSpeciesBatch(speciesBatchId, service.getRootBenthosBatch(fishingOperationId)); } protected SpeciesBatch getSpeciesBatch(String speciesBatchId, List<SpeciesBatch> speciesBatchs) { Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-03-20 23:23:30 UTC (rev 662) @@ -681,8 +681,8 @@ //------------------------------------------------------------------------// @Override - public List<SpeciesBatch> getAllRootBenthosBatch(String fishingOperationId) { - return driver.getAllRootBenthosBatch(fishingOperationId); + public BatchContainer<SpeciesBatch> getRootBenthosBatch(String fishingOperationId) { + return driver.getRootBenthosBatch(fishingOperationId); } @Override Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties =================================================================== --- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-03-20 23:23:30 UTC (rev 662) @@ -108,7 +108,7 @@ tutti.editProtocol.field.vesselUseFeature.help=editProtocol.html\#fields tutti.editProtocol.help=editProtocol.html tutti.editProtocol.pane.caracteristic.help=editProtocol.html\#fields -tutti.editSpeciesBatch.action.createMelag.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.createSpeciesMelag.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.action.createSpeciesBatch.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.action.removeSpeciesBatch.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.action.removeSpeciesSubBatch.help=editSpeciesBatch.html\#actions Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties =================================================================== --- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-03-20 23:23:30 UTC (rev 662) @@ -108,7 +108,7 @@ tutti.editProtocol.field.vesselUseFeature.help=editProtocol.html\#fields tutti.editProtocol.help=editProtocol.html tutti.editProtocol.pane.caracteristic.help=editProtocol.html\#fields -tutti.editSpeciesBatch.action.createMelag.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.createSpeciesMelag.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.action.createSpeciesBatch.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.action.removeSpeciesBatch.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.action.removeSpeciesSubBatch.help=editSpeciesBatch.html\#actions Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDataContext.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDataContext.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDataContext.java 2013-03-20 23:23:30 UTC (rev 662) @@ -25,8 +25,11 @@ */ import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Program; +import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -40,7 +43,9 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Closeable; +import java.util.Collections; import java.util.List; +import java.util.Map; /** * Data context of ui. @@ -52,7 +57,9 @@ */ public class TuttiDataContext implements Closeable { - /** Logger. */ + /** + * Logger. + */ private static final Log log = LogFactory.getLog(TuttiDataContext.class); protected Program program; @@ -63,10 +70,14 @@ protected List<Caracteristic> caracteristics; + protected List<Caracteristic> lengthStepCaracteristics; + protected List<Person> persons; protected List<Species> species; + protected List<Species> referentSpeciesWithSurveyCode; + protected List<Species> referentSpecies; protected List<Vessel> fishingVessels; @@ -98,7 +109,7 @@ this.uiContext.addPropertyChangeListener(TuttiUIContext.PROPERTY_PROTOCOL_ID, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - protocol = null; + resetProtocol(); resetSpecies(); } }); @@ -156,6 +167,73 @@ return caracteristics; } + public List<Caracteristic> getLengthStepCaracteristics() { + if (lengthStepCaracteristics == null) { + + if (uiContext.isProtocolFilled()) { + + // get loaded protocol + protocol = getProtocol(); + lengthStepCaracteristics = Lists.newArrayListWithCapacity( + protocol.sizeLengthClassesPmfmId()); + + Map<String, Caracteristic> allCaractericsById = + TuttiEntities.splitById(getCaracteristics()); + + if (!protocol.isLengthClassesPmfmIdEmpty()) { + for (String id : protocol.getLengthClassesPmfmId()) { + lengthStepCaracteristics.add(allCaractericsById.get(id)); + } + } + } else { + lengthStepCaracteristics = Lists.newArrayList( + getCaracteristics()); + } + + lengthStepCaracteristics = Collections.unmodifiableList(lengthStepCaracteristics); + } + return lengthStepCaracteristics; + } + + public List<Species> getReferentSpeciesWithSurveyCode() { + if (referentSpeciesWithSurveyCode == null) { + + if (uiContext.isProtocolFilled()) { + + // get loaded protocol + + TuttiProtocol protocol = getProtocol(); + Preconditions.checkNotNull(protocol, + "Could not find protocol in ui context"); + + // fill available species from protocol + + referentSpeciesWithSurveyCode = Lists.newArrayList(); + if (!protocol.isSpeciesEmpty()) { + + // split by taxonId + Map<String, Species> map = TuttiEntities.splitByTaxonId(getReferentSpecies()); + + for (SpeciesProtocol protocolSpecy : protocol.getSpecies()) { + String taxonId = String.valueOf(protocolSpecy.getSpeciesReferenceTaxonId()); + Species species = map.get(taxonId); + species.setSurveyCode(protocolSpecy.getSpeciesSurveyCode()); + referentSpeciesWithSurveyCode.add(species); + } + } + + } else { + + // no protocol, use default values + + referentSpeciesWithSurveyCode = Lists.newArrayList(getReferentSpecies()); + + } + referentSpeciesWithSurveyCode = Collections.unmodifiableList(referentSpeciesWithSurveyCode); + } + return referentSpeciesWithSurveyCode; + } + public List<Species> getSpecies() { if (species == null) { if (log.isInfoEnabled()) { @@ -241,13 +319,18 @@ service = null; program = null; cruise = null; - program = null; + resetProtocol(); resetVessels(); resetGears(); resetPersons(); resetSpecies(); } + public void resetProtocol() { + protocol = null; + lengthStepCaracteristics = null; + } + public void resetGears() { fishingGears = null; scientificGears = null; @@ -265,6 +348,7 @@ public void resetSpecies() { species = null; referentSpecies = null; + referentSpeciesWithSurveyCode = null; } public void resetCaracteristics() { 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-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-20 23:23:30 UTC (rev 662) @@ -27,7 +27,6 @@ import fr.ifremer.tutti.TuttiBusinessException; import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-03-20 23:23:30 UTC (rev 662) @@ -24,11 +24,15 @@ * #L% */ +import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware; @@ -152,6 +156,14 @@ protected final List<Attachment> attachment = Lists.newArrayList(); + /** + * Species already used in some batches. + * + * @since 0.3 + */ + protected final Multimap<CaracteristicQualitativeValue, Species> + speciesUsed = ArrayListMultimap.create(); + public EditCatchesUIModel() { super(CatchBatch.class, fromBeanBinder, toBeanBinder); speciesTotalSortedComputedOrNotWeight.addPropertyChangeListener( @@ -210,6 +222,10 @@ firePropertyChange(PROPERTY_FISHING_OPERATION, oldValue, fishingOperation); } + public Multimap<CaracteristicQualitativeValue, Species> getSpeciesUsed() { + return speciesUsed; + } + public TuttiComputedOrNotData<Float> getCatchTotalComputedOrNotWeight() { return catchTotalComputedOrNotWeight; } Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java (from rev 661, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java 2013-03-20 23:23:30 UTC (rev 662) @@ -0,0 +1,162 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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% + */ + +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +import java.io.Serializable; + +/** + * Represents a sample category value in the species batch table. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SampleCategory<C extends Serializable> implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * Sample category type. + * + * @since 0.3 + */ + protected SampleCategoryType categoryType; + + /** + * Sample category value. + * + * @since 0.3 + */ + protected C categoryValue; + + /** + * Sample category weight. + * + * @since 0.3 + */ + protected Float categoryWeight; + + /** + * Sample computed weight. + * + * @since 1.0 + */ + protected Float computedWeight; + + /** + * Is this sample a subsample ? + * Available only if the category is the finest category of the row + * + * @since 1.0 + */ + protected boolean subSample; + + /** + * Has the row only one frequency ? + * Available only if the category is the finest category of the row + * + * @since 1.0 + */ + protected boolean onlyOneFrequency; + + public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryType categoryType) { + SampleCategory<C> result = new SampleCategory<C>(); + result.setCategoryType(categoryType); + return result; + } + + protected SampleCategory() { + } + + public SampleCategoryType getCategoryType() { + return categoryType; + } + + public void setCategoryType(SampleCategoryType categoryType) { + this.categoryType = categoryType; + } + + public C getCategoryValue() { + return categoryValue; + } + + public void setCategoryValue(C categoryValue) { + this.categoryValue = categoryValue; + } + + public Float getCategoryWeight() { + return categoryWeight; + } + + public void setCategoryWeight(Float categoryWeight) { + this.categoryWeight = categoryWeight; + } + + public Float getComputedWeight() { + return computedWeight; + } + + public void setComputedWeight(Float computedWeight) { + this.computedWeight = computedWeight; + } + + public boolean isSubSample() { + return subSample; + } + + public void setSubSample(boolean subSample) { + this.subSample = subSample; + } + + public boolean hasOnlyOneFrequency() { + return onlyOneFrequency; + } + + public void setOnlyOneFrequency(boolean onlyOneFrequency) { + this.onlyOneFrequency = onlyOneFrequency; + } + + public boolean isValid() { + return categoryValue != null; + } + + public boolean isEmpty() { + return categoryValue == null + && categoryWeight == null + && computedWeight == null; + } + + public boolean isEmptyOrValid() { + return isEmpty() || isValid(); + } + + @Override + public String toString() { + return new ReflectionToStringBuilder(this). + appendSuper(super.toString()). + toString(); + } +} Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-03-20 23:23:30 UTC (rev 662) @@ -0,0 +1,48 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches; + +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 1.2 + */ +public class SampleCategoryColumnIdentifier<R> extends ColumnIdentifier<R> { + + private static final long serialVersionUID = 1L; + + public static <R> SampleCategoryColumnIdentifier<R> newId(String propertyName, + String weightPropertyName, + SampleCategoryType sampleCategoryType, + String headerI18nKey, + String headerTipI18nKey) { + return new SampleCategoryColumnIdentifier<R>(propertyName, + weightPropertyName, + sampleCategoryType, + headerI18nKey, + headerTipI18nKey); + } + + private final SampleCategoryType sampleCategoryType; + + private final String weightPropertyName; + + SampleCategoryColumnIdentifier(String propertyName, + String weightPropertyName, + SampleCategoryType sampleCategoryType, + String headerI18nKey, + String headerTipI18nKey + ) { + super(propertyName, headerI18nKey, headerTipI18nKey); + this.weightPropertyName = weightPropertyName; + this.sampleCategoryType = sampleCategoryType; + } + + public void setWeightValue(R entry, Object value) { + TuttiUIUtil.setProperty(entry, weightPropertyName, value); + } + + public SampleCategoryType getSampleCategoryType() { + return sampleCategoryType; + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java (from rev 661, 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/SampleCategoryComponent.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryComponent.java 2013-03-20 23:23:30 UTC (rev 662) @@ -0,0 +1,271 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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% + */ + +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.swing.editor.NumberEditor; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.AbstractCellEditor; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.io.Serializable; + +/** + * To render and edit a {@link SampleCategory}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SampleCategoryComponent { + + 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) { + return new SampleCategoryEditor<C>(decorator); + } + + /** + * SampleCategory cell editor. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ + public static class SampleCategoryEditor<C extends Serializable> extends AbstractCellEditor + implements TableCellEditor, FocusListener, AncestorListener { + + private static final long serialVersionUID = 1L; + + protected final NumberEditor numberEditor; + + protected final JPanel editor; + + protected final JLabel editorLabel; + + protected final Decorator<C> categoryDecorator; + + public SampleCategoryEditor(Decorator<C> categoryDecorator) { + this.categoryDecorator = categoryDecorator; + numberEditor = new NumberEditor(); + numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT); + numberEditor.getTextField().setBorder(null); + numberEditor.getTextField().addFocusListener(this); + numberEditor.getTextField().addAncestorListener(this); + numberEditor.setModelType(Float.class); + numberEditor.setUseSign(false); + numberEditor.init(); + + editor = new JPanel(new BorderLayout()); + editor.add(BorderLayout.WEST, editorLabel = new JLabel()); + editor.add(BorderLayout.CENTER, numberEditor); + } + + @Override + public Component getTableCellEditorComponent(JTable table, + Object value, + boolean isSelected, + int row, + int column) { + + SampleCategory<C> sampleCategory = (SampleCategory<C>) value; + + C categoryValue = sampleCategory == null ? null : sampleCategory.getCategoryValue(); + Float number = sampleCategory == null ? null : sampleCategory.getCategoryWeight(); + + numberEditor.setModel(number); + + // Check nullity and set the text that will be selected with the current value + if (number == null) { + numberEditor.setModelText(""); + } else { + numberEditor.setModelText(String.valueOf(number)); + } + + String label = sampleCategory == null ? "-" : + categoryDecorator.toString(categoryValue); + + editorLabel.setText(label); + return editor; + } + + @Override + public Float getCellEditorValue() { + return (Float) numberEditor.getModel(); + } + + @Override + public void focusGained(FocusEvent e) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + numberEditor.getTextField().requestFocus(); + numberEditor.getTextField().selectAll(); + } + }); + } + + @Override + public void focusLost(FocusEvent e) { + } + + @Override + public void ancestorAdded(AncestorEvent event) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + numberEditor.getTextField().requestFocus(); + numberEditor.getTextField().selectAll(); + } + }); + } + + @Override + public void ancestorRemoved(AncestorEvent event) { + } + + @Override + public void ancestorMoved(AncestorEvent event) { + } + + @Override + public boolean stopCellEditing() { + boolean result = super.stopCellEditing(); + // Reset previous data to avoid keeping it on other cell edition + if (result) { + resetEditor(); + } + return result; + } + + @Override + public void cancelCellEditing() { + resetEditor(); + super.cancelCellEditing(); + } + + protected void resetEditor() { + numberEditor.setModel(null); + // Use empty string, otherwise there is a NPE in NumberEditorHandler + numberEditor.setModelText(""); + editorLabel.setText("-"); + } + } + + /** + * To render a {@link SampleCategory} in a table cell. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ + public static class SampleCategoryRenderer<C extends Serializable> implements TableCellRenderer { + + protected final TableCellRenderer delegate; + + protected final Decorator<C> categoryDecorator; + + protected final Color computedWeightColor; + + public SampleCategoryRenderer(TableCellRenderer delegate, + Decorator<C> categoryDecorator, + Color computedWeightColor) { + this.delegate = delegate; + this.categoryDecorator = categoryDecorator; + this.computedWeightColor = computedWeightColor; + } + + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { + + SampleCategory<C> sampleCategory = (SampleCategory<C>) value; + + String text = null; + if (sampleCategory != null) { + C categoryValue = sampleCategory.getCategoryValue(); + if (categoryValue != null) { + Float number = sampleCategory.getCategoryWeight(); + Float computedNumber = sampleCategory.getComputedWeight(); + + text = "<html><span style='white-space: nowrap;'>" + categoryDecorator.toString(categoryValue) + " /"; + + if (sampleCategory.isSubSample()) { + text += "/"; + } + text += " "; + + if (number != null) { + text += JAXXUtil.getStringValue(number); + + } else if (computedNumber != null) { + if (sampleCategory.hasOnlyOneFrequency()) { + text += TuttiUIUtil.getWeightStringValue(computedNumber); + + } else { + String color = Integer.toHexString(computedWeightColor.getRGB()).substring(2); + text += "<em style='color: #" + color + "'>" + + TuttiUIUtil.getWeightStringValue(computedNumber) + "</em>"; + } + } else { + text += "-"; + } + + text += "</span></html>"; + } + } + + JComponent result = + (JComponent) delegate.getTableCellRendererComponent(table, + text, + isSelected, + hasFocus, + row, + column); + result.setToolTipText(text); + + return result; + } + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryType.java (from rev 661, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryType.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryType.java 2013-03-20 23:23:30 UTC (rev 662) @@ -0,0 +1,98 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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% + */ + +import com.google.common.collect.Maps; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; +import fr.ifremer.tutti.service.DecoratorService; + +import java.util.EnumMap; + +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +/** + * All sample category types. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public enum SampleCategoryType implements DecoratorService.LabelAware { + sortedUnsorted( + n_("tutti.sampleCategoryType.sortedUnsorted"), + SampleCategoryEnum.sortedUnsorted), + size( + n_("tutti.sampleCategoryType.size"), + SampleCategoryEnum.size), + sex( + n_("tutti.sampleCategoryType.sex"), + SampleCategoryEnum.sex), + maturity( + n_("tutti.sampleCategoryType.maturity"), + SampleCategoryEnum.maturity), + age( + n_("tutti.sampleCategoryType.age"), + SampleCategoryEnum.age); + + private final String i18nKey; + + private final SampleCategoryEnum type; + + private SampleCategoryType(String i18nKey, SampleCategoryEnum type) { + this.i18nKey = i18nKey; + this.type = type; + } + + @Override + public String getLabel() { + return _(i18nKey); + } + + public SampleCategoryEnum getType() { + return type; + } + + public static SampleCategoryType valueOf(SampleCategoryEnum type) { + SampleCategoryType result = enumToType.get(type); + return result; + } + + @Override + public String toString() { + return getLabel(); + } + + public static final EnumMap<SampleCategoryEnum, SampleCategoryType> enumToType; + + static { + enumToType = Maps.newEnumMap(SampleCategoryEnum.class); + enumToType.put(SampleCategoryEnum.sortedUnsorted, sortedUnsorted); + enumToType.put(SampleCategoryEnum.size, size); + enumToType.put(SampleCategoryEnum.sex, sex); + enumToType.put(SampleCategoryEnum.maturity, maturity); + enumToType.put(SampleCategoryEnum.age, age); + + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/TableViewMode.java (from rev 661, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/TableViewMode.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/TableViewMode.java 2013-03-20 23:23:30 UTC (rev 662) @@ -0,0 +1,52 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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% + */ + +/** + * What to show in the species table? + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public enum TableViewMode { + /** + * Show all nodes of sampling. + * + * @since 0.3 + */ + ALL, + /** + * Show only leaves of sampling. + * + * @since 0.3 + */ + LEAF, + /** + * Show onlyroot nodes of sampling. + * + * @since 0.3 + */ + ROOT +} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-03-20 23:23:30 UTC (rev 662) @@ -27,6 +27,10 @@ <import> fr.ifremer.tutti.ui.swing.TuttiUIContext fr.ifremer.tutti.ui.swing.TuttiHelpBroker + + fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode + fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType + fr.ifremer.tutti.ui.swing.util.TuttiUI jaxx.runtime.swing.editor.NumberEditor Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-03-20 23:23:30 UTC (rev 662) @@ -27,6 +27,7 @@ import com.google.common.collect.Lists; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.Attachment; +import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -58,7 +59,7 @@ LogFactory.getLog(BenthosBatchUIHandler.class); public BenthosBatchUIHandler(TuttiUI<?, ?> parentUi, - BenthosBatchUI ui) { + BenthosBatchUI ui) { super(parentUi, ui, BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, BenthosBatchRowModel.PROPERTY_SPECIES, @@ -87,14 +88,15 @@ if (log.isInfoEnabled()) { log.info("Get benthos batch for fishingOperation: " + - bean.getId()); + bean.getId()); } rows = Lists.newArrayList(); if (!TuttiEntities.isNew(bean)) { - List<SpeciesBatch> catches = - persistenceService.getAllRootBenthosBatch(bean.getId()); - for (SpeciesBatch aBatch : catches) { + BatchContainer<SpeciesBatch> catches = + persistenceService.getRootBenthosBatch(bean.getId()); + for (SpeciesBatch aBatch : catches.getChildren() + ) { BenthosBatchRowModel entry = new BenthosBatchRowModel(aBatch); rows.add(entry); @@ -126,16 +128,16 @@ @Override protected void onRowModified(int rowIndex, - BenthosBatchRowModel row, - String propertyName, - Object oldValue, - Object newValue) { + BenthosBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { recomputeRowValidState(row); } @Override protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor, - BenthosBatchRowModel row) { + BenthosBatchRowModel row) { if (row.isValid()) { // there is a valid bean attached to the monitor @@ -319,8 +321,7 @@ } if (log.isInfoEnabled()) { - log.info("Persist new benthos batch with parentId: " + - parentBatchId); + log.info("Persist new benthos batch with parentId: " + parentBatchId); } catchBean = persistenceService.createBenthosBatch(catchBean, parentBatchId); row.setId(catchBean.getId()); Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateMelagAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateMelagAction.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateMelagAction.java 2013-03-20 23:23:30 UTC (rev 662) @@ -1,183 +0,0 @@ - -package fr.ifremer.tutti.ui.swing.content.operation.catches.species; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * 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% - */ - -import com.google.common.collect.Maps; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; -import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; -import jaxx.runtime.SwingUtil; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.JOptionPane; -import java.awt.Frame; -import java.util.Map; - -import static org.nuiton.i18n.I18n._; - -/** - * @author kmorin <kmorin@codelutin.com> - * @since 1.0.2 - */ -public class CreateMelagAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> { - - protected Map<SpeciesBatchRowModel, Float> selectedRows = Maps.newHashMap(); - - protected Float melagWeight = null; - - protected Float sampleMelagWeight = null; - - protected Float sortedWeight = null; - - public CreateMelagAction(SpeciesBatchUIHandler handler) { - super(handler, false); - } - - @Override - protected boolean prepareAction() throws Exception { - boolean result = super.prepareAction(); - - int[] selectedRowIndexes = handler.getTable().getSelectedRows(); - - SpeciesBatchTableModel tableModel = handler.getTableModel(); - - // sum of the weights already entered by the user - Float alreadyKnownWeights = 0f; - sortedWeight = 0f; - - for (int selectedRowIndex : selectedRowIndexes) { - SpeciesBatchRowModel selectedRow = - tableModel.getEntry(selectedRowIndex); - - Float sampleWeight = null; - if (selectedRow.getFinestCategory().getCategoryWeight() != null) { - alreadyKnownWeights += selectedRow.getFinestCategory().getCategoryWeight(); - - } else if (selectedRow.getFinestCategory().getComputedWeight() != null) { - alreadyKnownWeights += selectedRow.getFinestCategory().getComputedWeight(); - - } else if (selectedRow.getWeight() != null) { - sampleWeight = selectedRow.getWeight(); - - } else { - sampleWeight = 0f; - if (selectedRow.getFrequency() != null) { - for (SpeciesFrequencyRowModel frequency : selectedRow.getFrequency()) { - if (frequency.getWeight() == null) { - sampleWeight = 0f; - break; - } - sampleWeight += frequency.getWeight(); - } - } - } - - if (sampleWeight != null) { - if (sampleWeight == 0f) { - JOptionPane.showMessageDialog( - getUI(), - _("tutti.createMelag.error.message", selectedRowIndex + 1), - _("tutti.createMelag.error.title"), - JOptionPane.ERROR_MESSAGE); - - handler.getTable().getSelectionModel().setSelectionInterval(selectedRowIndex, selectedRowIndex); - result = false; - break; - - } else { - sortedWeight += sampleWeight; - } - } - - selectedRows.put(selectedRow, sampleWeight); - } - - if (result) { - melagWeight = openMelagWeightDialog(); - - if (melagWeight != null) { - // substract the weights that the user already entered - // they must not be used to compute the other weights - sampleMelagWeight = melagWeight - alreadyKnownWeights; - } - } - - return result && melagWeight != null; - } - - protected Float openMelagWeightDialog() { - Frame frame = SwingUtil.getParentContainer(getUI(), Frame.class); - - final EnterMelagWeightDialog dialog = new EnterMelagWeightDialog(frame, - getConfig().getShortcutClosePopup()); - SwingUtil.center(frame, dialog); - dialog.pack(); - dialog.setVisible(true); - - Float result = null; - if (dialog.getEditor().getModel() != null) { - result = dialog.getEditor().getModel().floatValue(); - } - return result; - } - - @Override - protected void doAction() throws Exception { - for (SpeciesBatchRowModel batch : selectedRows.keySet()) { - Float sampleWeight = selectedRows.get(batch); - if (sampleWeight != null) { - Float weight = sampleMelagWeight * sampleWeight / sortedWeight; - batch.getFinestCategory().setCategoryWeight(weight); - } - String comment = batch.getComment(); - if (StringUtils.isBlank(comment)) { - comment = ""; - - } else { - comment += "\n"; - } - comment += "issu d'un MELAG de " + melagWeight + "kg"; - batch.setComment(comment); - } - getHandler().saveRows(selectedRows.keySet()); - } - - @Override - protected void releaseAction() { - super.releaseAction(); - //FIXME-TC No release action is not design to refresh ui... -// getHandler().getTable().repaint(); - selectedRows.clear(); - melagWeight = null; - sortedWeight = null; - } - - @Override - public void postSuccessAction() { - super.postSuccessAction(); - getHandler().getTable().repaint(); - - } -} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java (from rev 661, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateMelagAction.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java 2013-03-20 23:23:30 UTC (rev 662) @@ -0,0 +1,183 @@ + +package fr.ifremer.tutti.ui.swing.content.operation.catches.species; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * 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% + */ + +import com.google.common.collect.Maps; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; +import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import jaxx.runtime.SwingUtil; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.JOptionPane; +import java.awt.Frame; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; + +/** + * @author kmorin <kmorin@codelutin.com> + * @since 1.0.2 + */ +public class CreateSpeciesMelagAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> { + + protected Map<SpeciesBatchRowModel, Float> selectedRows = Maps.newHashMap(); + + protected Float melagWeight = null; + + protected Float sampleMelagWeight = null; + + protected Float sortedWeight = null; + + public CreateSpeciesMelagAction(SpeciesBatchUIHandler handler) { + super(handler, false); + } + + @Override + protected boolean prepareAction() throws Exception { + boolean result = super.prepareAction(); + + int[] selectedRowIndexes = handler.getTable().getSelectedRows(); + + SpeciesBatchTableModel tableModel = handler.getTableModel(); + + // sum of the weights already entered by the user + Float alreadyKnownWeights = 0f; + sortedWeight = 0f; + + for (int selectedRowIndex : selectedRowIndexes) { + SpeciesBatchRowModel selectedRow = + tableModel.getEntry(selectedRowIndex); + + Float sampleWeight = null; + if (selectedRow.getFinestCategory().getCategoryWeight() != null) { + alreadyKnownWeights += selectedRow.getFinestCategory().getCategoryWeight(); + + } else if (selectedRow.getFinestCategory().getComputedWeight() != null) { + alreadyKnownWeights += selectedRow.getFinestCategory().getComputedWeight(); + + } else if (selectedRow.getWeight() != null) { + sampleWeight = selectedRow.getWeight(); + + } else { + sampleWeight = 0f; + if (selectedRow.getFrequency() != null) { + for (SpeciesFrequencyRowModel frequency : selectedRow.getFrequency()) { + if (frequency.getWeight() == null) { + sampleWeight = 0f; + break; + } + sampleWeight += frequency.getWeight(); + } + } + } + + if (sampleWeight != null) { + if (sampleWeight == 0f) { + JOptionPane.showMessageDialog( + getUI(), + _("tutti.createMelag.error.message", selectedRowIndex + 1), + _("tutti.createMelag.error.title"), + JOptionPane.ERROR_MESSAGE); + + handler.getTable().getSelectionModel().setSelectionInterval(selectedRowIndex, selectedRowIndex); + result = false; + break; + + } else { + sortedWeight += sampleWeight; + } + } + + selectedRows.put(selectedRow, sampleWeight); + } + + if (result) { + melagWeight = openMelagWeightDialog(); + + if (melagWeight != null) { + // substract the weights that the user already entered + // they must not be used to compute the other weights + sampleMelagWeight = melagWeight - alreadyKnownWeights; + } + } + + return result && melagWeight != null; + } + + protected Float openMelagWeightDialog() { + Frame frame = SwingUtil.getParentContainer(getUI(), Frame.class); + + final EnterMelagWeightDialog dialog = new EnterMelagWeightDialog(frame, + getConfig().getShortcutClosePopup()); + SwingUtil.center(frame, dialog); + dialog.pack(); + dialog.setVisible(true); + + Float result = null; + if (dialog.getEditor().getModel() != null) { + result = dialog.getEditor().getModel().floatValue(); + } + return result; + } + + @Override + protected void doAction() throws Exception { + for (SpeciesBatchRowModel batch : selectedRows.keySet()) { + Float sampleWeight = selectedRows.get(batch); + if (sampleWeight != null) { + Float weight = sampleMelagWeight * sampleWeight / sortedWeight; + batch.getFinestCategory().setCategoryWeight(weight); + } + String comment = batch.getComment(); + if (StringUtils.isBlank(comment)) { + comment = ""; + + } else { + comment += "\n"; + } + comment += "issu d'un MELAG de " + melagWeight + "kg"; + batch.setComment(comment); + } + getHandler().saveRows(selectedRows.keySet()); + } + + @Override + protected void releaseAction() { + super.releaseAction(); + //FIXME-TC No release action is not design to refresh ui... +// getHandler().getTable().repaint(); + selectedRows.clear(); + melagWeight = null; + sortedWeight = null; + } + + @Override + public void postSuccessAction() { + super.postSuccessAction(); + getHandler().getTable().repaint(); + + } +} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-03-20 23:23:30 UTC (rev 662) @@ -59,7 +59,7 @@ SpeciesBatchRowModel row = tableModel.getEntry(table.getSelectedRow()); SpeciesBatchUIModel model = handler.getModel(); - List<Species> speciesList = Lists.newArrayList(model.getAllSpecies()); + List<Species> speciesList = Lists.newArrayList(getDataContext().getReferentSpeciesWithSurveyCode()); speciesList.removeAll( model.getSpeciesUsed().get( row.getSortedUnsortedCategoryValue())); Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-03-20 23:23:30 UTC (rev 662) @@ -1,162 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.species; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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% - */ - -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; - -import java.io.Serializable; - -/** - * Represents a sample category value in the species batch table. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class SampleCategory<C extends Serializable> implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * Sample category type. - * - * @since 0.3 - */ - protected SampleCategoryType categoryType; - - /** - * Sample category value. - * - * @since 0.3 - */ - protected C categoryValue; - - /** - * Sample category weight. - * - * @since 0.3 - */ - protected Float categoryWeight; - - /** - * Sample computed weight. - * - * @since 1.0 - */ - protected Float computedWeight; - - /** - * Is this sample a subsample ? - * Available only if the category is the finest category of the row - * - * @since 1.0 - */ - protected boolean subSample; - - /** - * Has the row only one frequency ? - * Available only if the category is the finest category of the row - * - * @since 1.0 - */ - protected boolean onlyOneFrequency; - - public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryType categoryType) { - SampleCategory<C> result = new SampleCategory<C>(); - result.setCategoryType(categoryType); - return result; - } - - protected SampleCategory() { - } - - public SampleCategoryType getCategoryType() { - return categoryType; - } - - public void setCategoryType(SampleCategoryType categoryType) { - this.categoryType = categoryType; - } - - public C getCategoryValue() { - return categoryValue; - } - - public void setCategoryValue(C categoryValue) { - this.categoryValue = categoryValue; - } - - public Float getCategoryWeight() { - return categoryWeight; - } - - public void setCategoryWeight(Float categoryWeight) { - this.categoryWeight = categoryWeight; - } - - public Float getComputedWeight() { - return computedWeight; - } - - public void setComputedWeight(Float computedWeight) { - this.computedWeight = computedWeight; - } - - public boolean isSubSample() { - return subSample; - } - - public void setSubSample(boolean subSample) { - this.subSample = subSample; - } - - public boolean hasOnlyOneFrequency() { - return onlyOneFrequency; - } - - public void setOnlyOneFrequency(boolean onlyOneFrequency) { - this.onlyOneFrequency = onlyOneFrequency; - } - - public boolean isValid() { - return categoryValue != null; - } - - public boolean isEmpty() { - return categoryValue == null - && categoryWeight == null - && computedWeight == null; - } - - public boolean isEmptyOrValid() { - return isEmpty() || isValid(); - } - - @Override - public String toString() { - return new ReflectionToStringBuilder(this). - appendSuper(super.toString()). - toString(); - } -} Deleted: 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-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-03-20 23:23:30 UTC (rev 662) @@ -1,271 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.species; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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% - */ - -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; -import jaxx.runtime.swing.editor.NumberEditor; -import org.nuiton.util.decorator.Decorator; - -import javax.swing.AbstractCellEditor; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.io.Serializable; -import javax.swing.JComponent; -import jaxx.runtime.JAXXUtil; - -/** - * To render and edit a {@link SampleCategory}. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class SampleCategoryComponent { - - 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) { - return new SampleCategoryEditor<C>(decorator); - } - - /** - * SampleCategory cell editor. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ - public static class SampleCategoryEditor<C extends Serializable> extends AbstractCellEditor - implements TableCellEditor, FocusListener, AncestorListener { - - private static final long serialVersionUID = 1L; - - protected final NumberEditor numberEditor; - - protected final JPanel editor; - - protected final JLabel editorLabel; - - protected final Decorator<C> categoryDecorator; - - public SampleCategoryEditor(Decorator<C> categoryDecorator) { - this.categoryDecorator = categoryDecorator; - numberEditor = new NumberEditor(); - numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT); - numberEditor.getTextField().setBorder(null); - numberEditor.getTextField().addFocusListener(this); - numberEditor.getTextField().addAncestorListener(this); - numberEditor.setModelType(Float.class); - numberEditor.setUseSign(false); - numberEditor.init(); - - editor = new JPanel(new BorderLayout()); - editor.add(BorderLayout.WEST, editorLabel = new JLabel()); - editor.add(BorderLayout.CENTER, numberEditor); - } - - @Override - public Component getTableCellEditorComponent(JTable table, - Object value, - boolean isSelected, - int row, - int column) { - - SampleCategory<C> sampleCategory = (SampleCategory<C>) value; - - C categoryValue = sampleCategory == null ? null : sampleCategory.getCategoryValue(); - Float number = sampleCategory == null ? null : sampleCategory.getCategoryWeight(); - - numberEditor.setModel(number); - - // Check nullity and set the text that will be selected with the current value - if (number == null) { - numberEditor.setModelText(""); - } else { - numberEditor.setModelText(String.valueOf(number)); - } - - String label = sampleCategory == null ? "-" : - categoryDecorator.toString(categoryValue); - - editorLabel.setText(label); - return editor; - } - - @Override - public Float getCellEditorValue() { - return (Float) numberEditor.getModel(); - } - - @Override - public void focusGained(FocusEvent e) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - } - }); - } - - @Override - public void focusLost(FocusEvent e) { - } - - @Override - public void ancestorAdded(AncestorEvent event) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - numberEditor.getTextField().requestFocus(); - numberEditor.getTextField().selectAll(); - } - }); - } - - @Override - public void ancestorRemoved(AncestorEvent event) { - } - - @Override - public void ancestorMoved(AncestorEvent event) { - } - - @Override - public boolean stopCellEditing() { - boolean result = super.stopCellEditing(); - // Reset previous data to avoid keeping it on other cell edition - if (result) { - resetEditor(); - } - return result; - } - - @Override - public void cancelCellEditing() { - resetEditor(); - super.cancelCellEditing(); - } - - protected void resetEditor() { - numberEditor.setModel(null); - // Use empty string, otherwise there is a NPE in NumberEditorHandler - numberEditor.setModelText(""); - editorLabel.setText("-"); - } - } - - /** - * To render a {@link SampleCategory} in a table cell. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ - public static class SampleCategoryRenderer<C extends Serializable> implements TableCellRenderer { - - protected final TableCellRenderer delegate; - - protected final Decorator<C> categoryDecorator; - - protected final Color computedWeightColor; - - public SampleCategoryRenderer(TableCellRenderer delegate, - Decorator<C> categoryDecorator, - Color computedWeightColor) { - this.delegate = delegate; - this.categoryDecorator = categoryDecorator; - this.computedWeightColor = computedWeightColor; - } - - @Override - public Component getTableCellRendererComponent(JTable table, - Object value, - boolean isSelected, - boolean hasFocus, - int row, - int column) { - - SampleCategory<C> sampleCategory = (SampleCategory<C>) value; - - String text = null; - if (sampleCategory != null) { - C categoryValue = sampleCategory.getCategoryValue(); - if (categoryValue != null) { - Float number = sampleCategory.getCategoryWeight(); - Float computedNumber = sampleCategory.getComputedWeight(); - - text = "<html><span style='white-space: nowrap;'>" + categoryDecorator.toString(categoryValue) + " /"; - - if (sampleCategory.isSubSample()) { - text += "/"; - } - text += " "; - - if (number != null) { - text += JAXXUtil.getStringValue(number); - - } else if (computedNumber != null) { - if (sampleCategory.hasOnlyOneFrequency()) { - text += TuttiUIUtil.getWeightStringValue(computedNumber); - - } else { - String color = Integer.toHexString(computedWeightColor.getRGB()).substring(2); - text += "<em style='color: #" + color + "'>" + - TuttiUIUtil.getWeightStringValue(computedNumber) + "</em>"; - } - } else { - text += "-"; - } - - text += "</span></html>"; - } - } - - JComponent result = - (JComponent) delegate.getTableCellRendererComponent(table, - text, - isSelected, - hasFocus, - row, - column); - result.setToolTipText(text); - - return result; - } - } -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-03-20 23:23:30 UTC (rev 662) @@ -1,98 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.species; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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% - */ - -import com.google.common.collect.Maps; -import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; -import fr.ifremer.tutti.service.DecoratorService; - -import java.util.EnumMap; - -import static org.nuiton.i18n.I18n._; -import static org.nuiton.i18n.I18n.n_; - -/** - * All sample category types. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public enum SampleCategoryType implements DecoratorService.LabelAware { - sortedUnsorted( - n_("tutti.sampleCategoryType.sortedUnsorted"), - SampleCategoryEnum.sortedUnsorted), - size( - n_("tutti.sampleCategoryType.size"), - SampleCategoryEnum.size), - sex( - n_("tutti.sampleCategoryType.sex"), - SampleCategoryEnum.sex), - maturity( - n_("tutti.sampleCategoryType.maturity"), - SampleCategoryEnum.maturity), - age( - n_("tutti.sampleCategoryType.age"), - SampleCategoryEnum.age); - - private final String i18nKey; - - private final SampleCategoryEnum type; - - private SampleCategoryType(String i18nKey, SampleCategoryEnum type) { - this.i18nKey = i18nKey; - this.type = type; - } - - @Override - public String getLabel() { - return _(i18nKey); - } - - public SampleCategoryEnum getType() { - return type; - } - - public static SampleCategoryType valueOf(SampleCategoryEnum type) { - SampleCategoryType result = enumToType.get(type); - return result; - } - - @Override - public String toString() { - return getLabel(); - } - - public static final EnumMap<SampleCategoryEnum, SampleCategoryType> enumToType; - - static { - enumToType = Maps.newEnumMap(SampleCategoryEnum.class); - enumToType.put(SampleCategoryEnum.sortedUnsorted, sortedUnsorted); - enumToType.put(SampleCategoryEnum.size, size); - enumToType.put(SampleCategoryEnum.sex, sex); - enumToType.put(SampleCategoryEnum.maturity, maturity); - enumToType.put(SampleCategoryEnum.age, age); - - } -} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-03-20 23:23:30 UTC (rev 662) @@ -30,9 +30,10 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-03-20 23:23:30 UTC (rev 662) @@ -26,7 +26,9 @@ import com.google.common.collect.Sets; import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryColumnIdentifier; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import org.jdesktop.swingx.table.TableColumnModelExt; @@ -43,80 +45,40 @@ private static final long serialVersionUID = 1L; - public static class SampleColumnIdentifier<R> extends ColumnIdentifier<R> { - - private static final long serialVersionUID = 1L; - - public static <R> SampleColumnIdentifier<R> newId(String propertyName, - String weightPropertyName, - SampleCategoryType sampleCategoryType, - String headerI18nKey, - String headerTipI18nKey) { - return new SampleColumnIdentifier<R>(propertyName, - weightPropertyName, - sampleCategoryType, - headerI18nKey, - headerTipI18nKey); - } - - private final SampleCategoryType sampleCategoryType; - - private final String weightPropertyName; - - protected SampleColumnIdentifier(String propertyName, - String weightPropertyName, - SampleCategoryType sampleCategoryType, - String headerI18nKey, - String headerTipI18nKey - ) { - super(propertyName, headerI18nKey, headerTipI18nKey); - this.weightPropertyName = weightPropertyName; - this.sampleCategoryType = sampleCategoryType; - } - - public void setWeightValue(R entry, Object value) { - TuttiUIUtil.setProperty(entry, weightPropertyName, value); - } - - public SampleCategoryType getSampleCategoryType() { - return sampleCategoryType; - } - } - public static final ColumnIdentifier<SpeciesBatchRowModel> SPECIES = ColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_SPECIES, n_("tutti.editSpeciesBatch.table.header.species"), n_("tutti.editSpeciesBatch.table.header.species")); - public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleColumnIdentifier.newId( + public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, SampleCategoryType.sortedUnsorted, n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory"), n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory")); - public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleColumnIdentifier.newId( + public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, SampleCategoryType.size, n_("tutti.editSpeciesBatch.table.header.sizeCategory"), n_("tutti.editSpeciesBatch.table.header.sizeCategory")); - public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleColumnIdentifier.newId( + public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, SampleCategoryType.sex, n_("tutti.editSpeciesBatch.table.header.sexCategory"), n_("tutti.editSpeciesBatch.table.header.sexCategory")); - public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleColumnIdentifier.newId( + public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, SampleCategoryType.maturity, n_("tutti.editSpeciesBatch.table.header.maturityCategory"), n_("tutti.editSpeciesBatch.table.header.maturityCategory")); - public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleColumnIdentifier.newId( + public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY, SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT, SampleCategoryType.age, @@ -195,7 +157,7 @@ SpeciesBatchRowModel entry) { if (sampleCols.contains(propertyName)) { - ((SampleColumnIdentifier<SpeciesBatchRowModel>) propertyName).setWeightValue(entry, aValue); + ((SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) propertyName).setWeightValue(entry, aValue); } else { super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); } @@ -237,7 +199,7 @@ } else if (sampleCols.contains(propertyName)) { - SampleColumnIdentifier<SpeciesBatchRowModel> samplePropertyName = (SampleColumnIdentifier<SpeciesBatchRowModel>) propertyName; + SampleCategoryColumnIdentifier<SpeciesBatchRowModel> samplePropertyName = (SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) propertyName; // can only edit if a category value is setted SpeciesBatchRowModel entry = getEntry(rowIndex); 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-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-03-20 23:23:30 UTC (rev 662) @@ -170,14 +170,14 @@ _help: {"tutti.editSpeciesBatch.action.renameSpeciesBatch.help"}; } -#createMelag { +#createSpeciesMelag { actionIcon: batch-rename; - text: "tutti.editSpeciesBatch.action.createMelag"; - toolTipText: "tutti.editSpeciesBatch.action.createMelag.tip"; - i18nMnemonic: "tutti.editSpeciesBatch.action.createMelag.mnemonic"; - _tuttiAction: {CreateMelagAction.class}; - enabled: {!model.isTableViewModeLeaf() && model.isCreateMelagEnabled()}; - _help: {"tutti.editSpeciesBatch.action.createMelag.help"}; + text: "tutti.editSpeciesBatch.action.createSpeciesMelag"; + toolTipText: "tutti.editSpeciesBatch.action.createSpeciesMelag.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.createSpeciesMelag.mnemonic"; + _tuttiAction: {CreateSpeciesMelagAction.class}; + enabled: {!model.isTableViewModeLeaf() && model.isCreateSpeciesMelagEnabled()}; + _help: {"tutti.editSpeciesBatch.action.createSpeciesMelag.help"}; } #createSpeciesBatchButton { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-03-20 23:23:30 UTC (rev 662) @@ -27,6 +27,9 @@ <import> fr.ifremer.tutti.ui.swing.TuttiHelpBroker + fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode + fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType + fr.ifremer.tutti.ui.swing.util.TuttiUI fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor @@ -83,7 +86,7 @@ <JMenuItem id='removeSpeciesBatchMenu'/> <JMenuItem id='removeSpeciesSubBatchMenu'/> <JMenuItem id='renameSpeciesBatchMenu'/> - <JMenuItem id='createMelag'/> + <JMenuItem id='createSpeciesMelag'/> </JPopupMenu> <Table id='form' fill='both' constraints='BorderLayout.NORTH'> 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-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-20 23:23:30 UTC (rev 662) @@ -34,9 +34,6 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; -import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.DecoratorService; @@ -44,6 +41,10 @@ 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.EditCatchesUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryComponent; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType; +import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI; @@ -61,9 +62,7 @@ import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import jaxx.runtime.JAXXUtil; import jaxx.runtime.SwingUtil; -import jaxx.runtime.context.JAXXContextEntryDef; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; @@ -99,16 +98,12 @@ */ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<SpeciesBatchRowModel, SpeciesBatchUIModel, SpeciesBatchUI> { - /** Logger. */ + /** + * Logger. + */ private static final Log log = LogFactory.getLog(SpeciesBatchUIHandler.class); - public static JAXXContextEntryDef<List<Caracteristic>> FREQUENCY_LENGTH_CONTEXT_ENTRY = - JAXXUtil.newListContextEntryDef("frequencyLength"); - - public static JAXXContextEntryDef<List<Species>> SPECIES_REFERENT_CONTEXT_ENTRY = - JAXXUtil.newListContextEntryDef("speciesReferent"); - public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet( SpeciesBatchRowModel.PROPERTY_SAMPLE_CATEGORY, SpeciesBatchRowModel.PROPERTY_SPECIES, @@ -128,23 +123,23 @@ public SpeciesBatchUIHandler(TuttiUI<?, ?> parentUi, SpeciesBatchUI ui) { super(parentUi, ui, - SpeciesBatchRowModel.PROPERTY_SPECIES, - SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, - SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, - SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, - SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, - SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, - SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, - SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, - SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, - SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY, - SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT, - SpeciesBatchRowModel.PROPERTY_WEIGHT, - SpeciesBatchRowModel.PROPERTY_NUMBER, - SpeciesBatchRowModel.PROPERTY_COMMENT, - SpeciesBatchRowModel.PROPERTY_ATTACHMENT, - SpeciesBatchRowModel.PROPERTY_FREQUENCY, - SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM); + SpeciesBatchRowModel.PROPERTY_SPECIES, + SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, + SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY, + SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_NUMBER, + SpeciesBatchRowModel.PROPERTY_COMMENT, + SpeciesBatchRowModel.PROPERTY_ATTACHMENT, + SpeciesBatchRowModel.PROPERTY_FREQUENCY, + SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM); tableFilters = new EnumMap<TableViewMode, RowFilter<SpeciesBatchTableModel, Integer>>(TableViewMode.class); tableFilters.put(TableViewMode.ALL, new RowFilter<SpeciesBatchTableModel, Integer>() { @@ -202,7 +197,7 @@ if (log.isInfoEnabled()) { log.info("Get species batch for fishingOperation: " + - bean.getId()); + bean.getId()); } rows = Lists.newArrayList(); @@ -232,15 +227,15 @@ Preconditions.checkState( aBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted, "Root species batch must be a sortedUnsorted sample " + - "category but was:" + aBatch.getSampleCategoryType()); + "category but was:" + aBatch.getSampleCategoryType()); SpeciesBatchRowModel rootRow = loadSpeciesBatch(aBatch, null, rows); if (log.isDebugEnabled()) { log.debug("Loaded root batch " + - decorate(rootRow.getSpecies(), DecoratorService.FROM_PROTOCOL) + " - " + - decorate(rootRow.getSortedUnsortedCategoryValue())); + decorate(rootRow.getSpecies(), DecoratorService.FROM_PROTOCOL) + " - " + + decorate(rootRow.getSortedUnsortedCategoryValue())); } } } @@ -314,7 +309,7 @@ showInformationMessage( "[ Captures - Espèces ] " + - "Sauvegarde des modifications de " + row + '.'); + "Sauvegarde des modifications de " + row + '.'); saveRow(row); @@ -404,39 +399,6 @@ SpeciesBatchUIModel model = new SpeciesBatchUIModel(catchesUIModel); model.setTableViewMode(TableViewMode.ALL); ui.setContextValue(model); - - List<Caracteristic> lengthCaracterics; - - TuttiProtocol protocol; - - if (context.isProtocolFilled()) { - - // get loaded protocol - - protocol = getDataContext().getProtocol(); - - lengthCaracterics = Lists.newArrayListWithCapacity( - protocol.sizeLengthClassesPmfmId()); - - Map<String, Caracteristic> allCaractericsById = - TuttiEntities.splitById(getDataContext().getCaracteristics()); - - if (!protocol.isLengthClassesPmfmIdEmpty()) { - for (String id : protocol.getLengthClassesPmfmId()) { - lengthCaracterics.add(allCaractericsById.get(id)); - } - } - - } else { - - // use all caracteristics - lengthCaracterics = Lists.newArrayList( - getDataContext().getCaracteristics()); - } - - // use only the referent here, if the user needs a synonym, he will - // click on the button to select another species - FREQUENCY_LENGTH_CONTEXT_ENTRY.setContextValue(ui, lengthCaracterics); } @Override @@ -451,56 +413,16 @@ Map<Integer, SampleCategoryEnum> categoryEnumMap = SampleCategoryEnum.toIdMapping(); - List<Species> speciesUniverse = getDataContext().getReferentSpecies(); List<SampleCategoryEnum> samplingOrder = Lists.newArrayList(); List<Integer> samplingOrderIds = getConfig().getSamplingOrderIds(); for (Integer id : samplingOrderIds) { samplingOrder.add(categoryEnumMap.get(id)); } - - List<Species> allSpecies; - - boolean protocolFilled = context.isProtocolFilled(); - if (protocolFilled) { - - // get loaded protocol - - TuttiProtocol protocol = getDataContext().getProtocol(); - Preconditions.checkNotNull(protocol, - "Could not find protocol in ui context"); - - // fill available species from protocol - - allSpecies = Lists.newArrayList(); - if (!protocol.isSpeciesEmpty()) { - - // split by taxonId - Map<String, Species> map = TuttiEntities.splitByTaxonId(speciesUniverse); - - for (SpeciesProtocol protocolSpecy : protocol.getSpecies()) { - String taxonId = String.valueOf(protocolSpecy.getSpeciesReferenceTaxonId()); - Species species = map.get(taxonId); - species.setSurveyCode(protocolSpecy.getSpeciesSurveyCode()); - allSpecies.add(species); - } - } - - } else { - - // no protocol, use default values - - allSpecies = Lists.newArrayList(speciesUniverse); - - } - if (log.isInfoEnabled()) { log.info("Will use sampling order: " + samplingOrder); - log.info("Will use " + allSpecies.size() + " species."); } - getModel().setAllSpecies(allSpecies); - JXTable table = getTable(); // can show / hide some columns in model @@ -521,17 +443,17 @@ { // Species column addColumnToModel(columnModel, - null, - newTableCellRender(Species.class, DecoratorService.FROM_PROTOCOL), - SpeciesBatchTableModel.SPECIES); + null, + newTableCellRender(Species.class, DecoratorService.FROM_PROTOCOL), + SpeciesBatchTableModel.SPECIES); } { // SortedUnsortedCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY, - caracteristicDecorator, - defaultRenderer); + SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY, + caracteristicDecorator, + defaultRenderer); } for (SampleCategoryEnum sampleCategoryType : samplingOrder) { @@ -542,9 +464,9 @@ { // SizeCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.SIZE_CATEGORY, - caracteristicDecorator, - defaultRenderer); + SpeciesBatchTableModel.SIZE_CATEGORY, + caracteristicDecorator, + defaultRenderer); } break; case sex: @@ -552,9 +474,9 @@ { // SexCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.SEX_CATEGORY, - caracteristicDecorator, - defaultRenderer); + SpeciesBatchTableModel.SEX_CATEGORY, + caracteristicDecorator, + defaultRenderer); } break; case maturity: @@ -562,9 +484,9 @@ { // MaturityCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.MATURITY_CATEGORY, - caracteristicDecorator, - defaultRenderer); + SpeciesBatchTableModel.MATURITY_CATEGORY, + caracteristicDecorator, + defaultRenderer); } break; @@ -574,9 +496,9 @@ { // AgeCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.AGE_CATEGORY, - getDecorator(Float.class, null), - defaultRenderer); + SpeciesBatchTableModel.AGE_CATEGORY, + getDecorator(Float.class, null), + defaultRenderer); } break; @@ -587,42 +509,42 @@ { // Weight column addColumnToModel(columnModel, - TuttiComputedOrNotDataTableCell.newEditor( - Float.class, false, true, 3, computedDataColor), - TuttiComputedOrNotDataTableCell.newRender( - defaultRenderer, true, 3, computedDataColor), - SpeciesBatchTableModel.WEIGHT); + TuttiComputedOrNotDataTableCell.newEditor( + Float.class, false, true, 3, computedDataColor), + TuttiComputedOrNotDataTableCell.newRender( + defaultRenderer, true, 3, computedDataColor), + SpeciesBatchTableModel.WEIGHT); } { // Number column (from frequencies) addColumnToModel(columnModel, - FrequencyCellComponent.newEditor(ui, computedDataColor), - FrequencyCellComponent.newRender(computedDataColor), - SpeciesBatchTableModel.COMPUTED_NUMBER); + FrequencyCellComponent.newEditor(ui, computedDataColor), + FrequencyCellComponent.newRender(computedDataColor), + SpeciesBatchTableModel.COMPUTED_NUMBER); } { // Comment column addColumnToModel(columnModel, - CommentCellEditor.newEditor(ui), - CommentCellRenderer.newRender(), - SpeciesBatchTableModel.COMMENT); + CommentCellEditor.newEditor(ui), + CommentCellRenderer.newRender(), + SpeciesBatchTableModel.COMMENT); } { // File column addColumnToModel(columnModel, - AttachmentCellEditor.newEditor(ui), - AttachmentCellRenderer.newRender(getDecorator(Attachment.class, null)), - SpeciesBatchTableModel.ATTACHMENT); + AttachmentCellEditor.newEditor(ui), + AttachmentCellRenderer.newRender(getDecorator(Attachment.class, null)), + SpeciesBatchTableModel.ATTACHMENT); } { // Species to confirm column addBooleanColumnToModel(columnModel, - SpeciesBatchTableModel.SPECIES_TO_CONFIRM, - getTable()); + SpeciesBatchTableModel.SPECIES_TO_CONFIRM, + getTable()); } // create table model @@ -753,7 +675,7 @@ int rowIndex = table.getSelectedRow(); Preconditions.checkState(rowIndex != -1, - "Cant split batch if no batch selected"); + "Cant split batch if no batch selected"); SpeciesBatchTableModel tableModel = getTableModel(); @@ -818,10 +740,10 @@ SpeciesBatchRowModel newBatch = tableModel.createNewRow(); loadBatchRow(parentBatch, - newBatch, - sampleCategoryEnum, - row.getCategoryValue(), - row.getWeight()); + newBatch, + sampleCategoryEnum, + row.getCategoryValue(), + row.getWeight()); recomputeRowValidState(newBatch); newBatches.add(newBatch); @@ -909,10 +831,10 @@ if (log.isInfoEnabled()) { log.info("Persist new species batch with parentId: " + - parentBatchId); + parentBatchId); } catchBean = persistenceService.createSpeciesBatch(catchBean, - parentBatchId); + parentBatchId); row.setId(catchBean.getId()); } else { if (log.isInfoEnabled()) { @@ -982,15 +904,15 @@ // can split if selected batch is a leaf enableSplit = row.isBatchLeaf() - && selectedRowCount == 1 - && row.getComputedNumber() == null; + && selectedRowCount == 1 + && row.getComputedNumber() == null; } if (enableRename) { // can rename if selected batch is a parent enableRename = row.isBatchRoot() - && selectedRowCount == 1; + && selectedRowCount == 1; } if (enableRemove) { @@ -1003,7 +925,7 @@ // can remove sub batch if selected batch is not a leaf enableRemoveSub = !row.isBatchLeaf() - && selectedRowCount == 1; + && selectedRowCount == 1; } if (enableCreateMelag) { @@ -1036,11 +958,11 @@ model.setRemoveSpeciesBatchEnabled(enableRemove); model.setRemoveSpeciesSubBatchEnabled(enableRemoveSub); model.setRenameSpeciesBatchEnabled(enableRename); - model.setCreateMelagEnabled(enableCreateMelag); + model.setCreateSpeciesMelagEnabled(enableCreateMelag); } public void collectChildren(SpeciesBatchRowModel row, - Set<SpeciesBatchRowModel> collectedRows) { + Set<SpeciesBatchRowModel> collectedRows) { if (!row.isBatchLeaf()) { @@ -1069,9 +991,10 @@ // the species of the parent is set to the children in loadBatchRow if (parentRow == null && context.isProtocolFilled()) { // get the surveycode from the species list of the model - int i = getModel().getAllSpecies().indexOf(newRow.getSpecies()); + List<Species> speciesList = getDataContext().getReferentSpeciesWithSurveyCode(); + int i = speciesList.indexOf(newRow.getSpecies()); if (i > -1) { - newRow.setSpecies(getModel().getAllSpecies().get(i)); + newRow.setSpecies(speciesList.get(i)); } } @@ -1083,10 +1006,10 @@ "Can't have a batch with no sample category, but was: " + aBatch); loadBatchRow(parentRow, - newRow, - sampleCategoryEnum, - aBatch.getSampleCategoryValue(), - aBatch.getSampleCategoryWeight()); + newRow, + sampleCategoryEnum, + aBatch.getSampleCategoryValue(), + aBatch.getSampleCategoryWeight()); rows.add(newRow); @@ -1156,11 +1079,11 @@ Decorator<C> decorator, TableCellRenderer defaultRenderer) { addColumnToModel(columnModel, - SampleCategoryComponent.newEditor(decorator), - SampleCategoryComponent.newRender(defaultRenderer, - decorator, - getConfig().getColorComputedWeights()), - columnIdentifier); + SampleCategoryComponent.newEditor(decorator), + SampleCategoryComponent.newRender(defaultRenderer, + decorator, + getConfig().getColorComputedWeights()), + columnIdentifier); } public void removeFromSpeciesUsed(SpeciesBatchRowModel row) { @@ -1172,7 +1095,7 @@ } SpeciesBatchUIModel model = getModel(); model.getSpeciesUsed().remove(row.getSortedUnsortedCategoryValue(), - row.getSpecies()); + row.getSpecies()); if (row.isBatchRoot()) { model.setRootNumber(model.getRootNumber() - 1); @@ -1185,12 +1108,12 @@ Preconditions.checkNotNull(row.getSortedUnsortedCategoryValue()); if (log.isDebugEnabled()) { log.debug("Add to speciesUsed: " + - decorate(row.getSortedUnsortedCategoryValue()) + - " - " + decorate(row.getSpecies())); + decorate(row.getSortedUnsortedCategoryValue()) + + " - " + decorate(row.getSpecies())); } SpeciesBatchUIModel model = getModel(); model.getSpeciesUsed().put(row.getSortedUnsortedCategoryValue(), - row.getSpecies()); + row.getSpecies()); model.setRootNumber(model.getRootNumber() + 1); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-03-20 23:23:30 UTC (rev 662) @@ -24,7 +24,6 @@ * #L% */ -import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; @@ -33,6 +32,7 @@ import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode; import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware; @@ -49,8 +49,6 @@ public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode"; - public static final String PROPERTY_ALL_SPECIES = "allSpecies"; - public static final String PROPERTY_CREATE_SPECIES_BATCH_ENABLED = "createSpeciesBatchEnabled"; public static final String PROPERTY_SPLIT_SPECIES_BATCH_ENABLED = "splitSpeciesBatchEnabled"; @@ -61,7 +59,7 @@ public static final String PROPERTY_REMOVE_SPECIES_BATCH_ENABLED = "removeSpeciesBatchEnabled"; - public static final String PROPERTY_CREATE_MELAG_ENABLED = "createMelagEnabled"; + public static final String PROPERTY_CREATE_SPECIES_MELAG_ENABLED = "createMelagEnabled"; public static final String PROPERTY_TABLE_VIEW_MODE_ALL = "tableViewModeAll"; @@ -74,62 +72,54 @@ public static final String PROPERTY_LEAF_NUMBER = "leafNumber"; /** - * All usable species (sets by protocol). + * Can user create a new species batch ? * * @since 0.3 */ - protected List<Species> allSpecies; + protected boolean createSpeciesBatchEnabled; /** - * Species already used in some batches. + * Can user split a selected species batch ? * * @since 0.3 */ - protected final Multimap<CaracteristicQualitativeValue, Species> - speciesUsed = ArrayListMultimap.create(); + protected boolean splitSpeciesBatchEnabled; /** - * What to show in the table. + * Can user remove a selected species batch? * * @since 0.3 */ - protected TableViewMode tableViewMode; + protected boolean removeSpeciesBatchEnabled; /** - * Can user create a new species batch ? + * Can user remove a selected species sub batches? * * @since 0.3 */ - protected boolean createSpeciesBatchEnabled; + protected boolean removeSpeciesSubBatchEnabled; /** - * Can user split a selected species batch ? + * Can user create a melag from the selected species? * * @since 0.3 */ - protected boolean splitSpeciesBatchEnabled; + protected boolean createSpeciesMelagEnabled = true; /** - * Can user remove a selected species batch? + * Can user rename the selected species? * * @since 0.3 */ - protected boolean removeSpeciesBatchEnabled; + protected boolean renameSpeciesBatchEnabled; /** - * Can user remove a selected species sub batches? + * What to show in the table. * * @since 0.3 */ - protected boolean removeSpeciesSubBatchEnabled; + protected TableViewMode tableViewMode; - /** - * Can user create a melag from the selected species? - * - * @since 0.3 - */ - protected boolean createMelagEnabled = true; - /** @since 1.0 */ protected int rootNumber; @@ -138,8 +128,6 @@ protected final List<Attachment> attachment = Lists.newArrayList(); - private boolean renameSpeciesBatchEnabled; - private String rootBatchId; public SpeciesBatchUIModel(EditCatchesUIModel catchesUIModel) { @@ -261,18 +249,8 @@ return TableViewMode.ROOT.equals(tableViewMode); } - public List<Species> getAllSpecies() { - return allSpecies; - } - - public void setAllSpecies(List<Species> allSpecies) { - Object oldValue = getAllSpecies(); - this.allSpecies = allSpecies; - firePropertyChange(PROPERTY_ALL_SPECIES, oldValue, allSpecies); - } - public Multimap<CaracteristicQualitativeValue, Species> getSpeciesUsed() { - return speciesUsed; + return catchesUIModel.getSpeciesUsed(); } public int getRootNumber() { @@ -345,14 +323,14 @@ return renameSpeciesBatchEnabled; } - public boolean isCreateMelagEnabled() { - return createMelagEnabled; + public boolean isCreateSpeciesMelagEnabled() { + return createSpeciesMelagEnabled; } - public void setCreateMelagEnabled(boolean createMelagEnabled) { - Object oldValue = isCreateMelagEnabled(); - this.createMelagEnabled = createMelagEnabled; - firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled); + public void setCreateSpeciesMelagEnabled(boolean createSpeciesMelagEnabled) { + Object oldValue = isCreateSpeciesMelagEnabled(); + this.createSpeciesMelagEnabled = createSpeciesMelagEnabled; + firePropertyChange(PROPERTY_CREATE_SPECIES_MELAG_ENABLED, oldValue, createSpeciesMelagEnabled); } public void setRootBatchId(String rootBatchId) { Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java 2013-03-20 23:23:30 UTC (rev 662) @@ -1,52 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.species; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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% - */ - -/** - * What to show in the species table? - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public enum TableViewMode { - /** - * Show all nodes of sampling. - * - * @since 0.3 - */ - ALL, - /** - * Show only leaves of sampling. - * - * @since 0.3 - */ - LEAF, - /** - * Show onlyroot nodes of sampling. - * - * @since 0.3 - */ - ROOT -} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-03-20 23:23:30 UTC (rev 662) @@ -179,8 +179,7 @@ initUI(ui); List<Caracteristic> lengthStepCaracterics = - SpeciesBatchUIHandler.FREQUENCY_LENGTH_CONTEXT_ENTRY.getContextValue(ui); - Preconditions.checkNotNull(lengthStepCaracterics); + Lists.newArrayList(getDataContext().getLengthStepCaracteristics()); lengthStepCaracteristics = TuttiEntities.splitById(lengthStepCaracterics); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-03-20 23:23:30 UTC (rev 662) @@ -32,7 +32,7 @@ fr.ifremer.tutti.ui.swing.TuttiHelpBroker fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType + fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI fr.ifremer.tutti.ui.swing.util.TuttiUI Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-03-20 23:23:30 UTC (rev 662) @@ -150,9 +150,6 @@ } }); -// SwingValidatorUtil.installUI(ui.getErrorTable(), -// new SwingValidatorMessageTableRenderer()); - listenValidatorValid(ui.getValidator(), getModel()); } @@ -218,7 +215,7 @@ // compute which species can still be used - List<Species> allSpecies = batchModel.getAllSpecies(); + List<Species> allSpecies = getDataContext().getReferentSpeciesWithSurveyCode(); speciesToUse.addAll(allSpecies); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-03-20 23:23:30 UTC (rev 662) @@ -25,8 +25,8 @@ */ import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx 2013-03-20 23:23:30 UTC (rev 662) @@ -27,7 +27,7 @@ <import> fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI - fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType + fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI fr.ifremer.tutti.ui.swing.TuttiHelpBroker Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-20 23:23:30 UTC (rev 662) @@ -31,8 +31,8 @@ import fr.ifremer.tutti.persistence.entities.referential.Species; 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.species.SampleCategory; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.util.Cancelable; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-03-20 23:23:30 UTC (rev 662) @@ -25,7 +25,7 @@ */ import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryType; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-03-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-03-20 23:23:30 UTC (rev 662) @@ -460,12 +460,12 @@ tutti.editProtocol.title.edit.protocol= tutti.editProtocol.warn.clone= tutti.editProtocol.warn.import= -tutti.editSpeciesBatch.action.createMelag= -tutti.editSpeciesBatch.action.createMelag.mnemonic= -tutti.editSpeciesBatch.action.createMelag.tip= tutti.editSpeciesBatch.action.createSpeciesBatch= tutti.editSpeciesBatch.action.createSpeciesBatch.mnemonic= tutti.editSpeciesBatch.action.createSpeciesBatch.tip= +tutti.editSpeciesBatch.action.createSpeciesMelag= +tutti.editSpeciesBatch.action.createSpeciesMelag.mnemonic= +tutti.editSpeciesBatch.action.createSpeciesMelag.tip= tutti.editSpeciesBatch.action.removeSpeciesBatch= tutti.editSpeciesBatch.action.removeSpeciesBatch.mnemonic= tutti.editSpeciesBatch.action.removeSpeciesBatch.tip= 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-19 15:30:18 UTC (rev 661) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-20 23:23:30 UTC (rev 662) @@ -458,12 +458,12 @@ tutti.editProtocol.title.edit.protocol=Éditer un protocol de saisie existant tutti.editProtocol.warn.clone=Le protocole que vous venez de cloner ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer". tutti.editProtocol.warn.import=Le protocole que vous venez d'importer ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer". -tutti.editSpeciesBatch.action.createMelag=Espèces d'un MELAG -tutti.editSpeciesBatch.action.createMelag.mnemonic=C -tutti.editSpeciesBatch.action.createMelag.tip=Calcul des poids des lots appartenant à un MELAG tutti.editSpeciesBatch.action.createSpeciesBatch=Créer un lot pour une espèce tutti.editSpeciesBatch.action.createSpeciesBatch.mnemonic=C tutti.editSpeciesBatch.action.createSpeciesBatch.tip=Créer un nouveau lot pour une espèce +tutti.editSpeciesBatch.action.createSpeciesMelag=Espèces d'un MELAG +tutti.editSpeciesBatch.action.createSpeciesMelag.mnemonic=C +tutti.editSpeciesBatch.action.createSpeciesMelag.tip=Calcul des poids des lots appartenant à un MELAG tutti.editSpeciesBatch.action.removeSpeciesBatch=Supprimer le lot tutti.editSpeciesBatch.action.removeSpeciesBatch.mnemonic=S tutti.editSpeciesBatch.action.removeSpeciesBatch.tip=Supprimer le lot courant (celui de la ligne sélectionnée) et tous ces fils