r666 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti tutti-persistence/src/main/java/fr/ifremer/tutti/persistence tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence/src/main/resources/i18n tutti-persistence/src/main/xmi tutti-service/src/main/java/fr/ifremer/tutti/service tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri tutti-ui-swing tutti-ui-swing/src/main
Author: tchemit Date: 2013-03-23 19:20:58 +0100 (Sat, 23 Mar 2013) New Revision: 666 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/666 Log: refs #1863: [BENTHOS] - Gestion de la saisie du benthos Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/LabelAware.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchRootRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIModel.java trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml Removed: 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/species/EnterMelagWeightDialog.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRootRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/AddSpeciesAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 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/CreateSpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml 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/entities/data/SampleCategoryEnum.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Directions.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRow.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java trunk/tutti-ui-swing/pom.xml 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/content/operation/EditFishingOperationAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.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/ImportPupitriAction.java 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/benthos/BenthosBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 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/benthos/BenthosBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.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/SpeciesFrequencyCellComponent.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/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/CaracteristicRow.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 trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/BeanValidatorDetectorTest.java Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/LabelAware.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/LabelAware.java (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/LabelAware.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,38 @@ +package fr.ifremer.tutti; + +/* + * #%L + * Tutti :: Persistence + * $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 java.io.Serializable; + +/** + * A contract to decorate some objects + * (not known at this level but with a label property to display them). + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public interface LabelAware extends Serializable { + String getLabel(); +} Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/LabelAware.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-03-23 18:20:58 UTC (rev 666) @@ -37,7 +37,6 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; 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.Country; import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -229,8 +228,6 @@ ObjectType getObjectType(String objectTypeCode); - boolean isSortedQualitativeValue(CaracteristicQualitativeValue value); - /** * Import given temporary species. * 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-03-23 18:20:58 UTC (rev 666) @@ -41,7 +41,6 @@ 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.Country; import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -321,11 +320,6 @@ } @Override - public boolean isSortedQualitativeValue(CaracteristicQualitativeValue value) { - return referentialService.isSortedQualitativeValue(value); - } - - @Override public Person getPerson(Integer personId) { return referentialService.getPerson(personId); } 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-03-23 18:20:58 UTC (rev 666) @@ -37,7 +37,6 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; 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.Country; import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -200,11 +199,6 @@ } @Override - public boolean isSortedQualitativeValue(CaracteristicQualitativeValue value) { - throw new RuntimeException("method not implemented"); - } - - @Override public List<Species> importTemporarySpecies(List<Species> species) { throw new RuntimeException("method not implemented"); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryEnum.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryEnum.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategoryEnum.java 2013-03-23 18:20:58 UTC (rev 666) @@ -27,38 +27,49 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Maps; +import fr.ifremer.tutti.LabelAware; import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile; import java.util.Map; -public enum SampleCategoryEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer> { +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; - sortedUnsorted("PMFM_ID_SORTED_UNSORTED"), - size("PMFM_ID_SIZE_CATEGORY"), - sex("PMFM_ID_SEX"), - maturity("PMFM_ID_MATURITY"), - age("PMFM_ID_AGE"); +public enum SampleCategoryEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer>, LabelAware { + sortedUnsorted("PMFM_ID_SORTED_UNSORTED", + n_("tutti.sampleCategoryType.sortedUnsorted")), + size("PMFM_ID_SIZE_CATEGORY", n_("tutti.sampleCategoryType.size")), + sex("PMFM_ID_SEX", n_("tutti.sampleCategoryType.sex")), + maturity("PMFM_ID_MATURITY", n_("tutti.sampleCategoryType.maturity")), + age("PMFM_ID_AGE", n_("tutti.sampleCategoryType.age")); + private final String fieldName; + private final String i18nKey; + private Integer fieldValue; private boolean init; - SampleCategoryEnum(String fieldName) { + SampleCategoryEnum(String fieldName, String i18nKey) { this.fieldName = fieldName; + this.i18nKey = i18nKey; } @Override + public String getLabel() { + return _(i18nKey); + } + + @Override public String getFieldName() { return fieldName; } @Override public Integer getFieldValue() { - Preconditions.checkState( - isInit(), - "Enumeration " + getClass() + " was not init!"); + Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!"); return fieldValue; } Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,71 @@ +package fr.ifremer.tutti.persistence.entities.data; + +import com.google.common.base.Preconditions; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile; + +/** + * Represents the sorted - unsorted pmfm. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2 + */ +public enum SortedUnsortedEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer> { + + SORTED("QUALITATIVE_VRAC_ID"), + UNSORTED("QUALITATIVE_HORS_VRAC_ID"); + + private final String fieldName; + + private Integer fieldValue; + + private boolean init; + + SortedUnsortedEnum(String fieldName) { + this.fieldName = fieldName; + } + + @Override + public String getFieldName() { + return fieldName; + } + + @Override + public Integer getFieldValue() { + Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!"); + return fieldValue; + } + + @Override + public void setFieldValue(Object fieldValue) { + this.fieldValue = (Integer) fieldValue; + } + + @Override + public boolean isInit() { + return init; + } + + @Override + public void setInit(boolean init) { + this.init = init; + } + + public boolean matchValue(CaracteristicQualitativeValue value) { + return fieldValue.equals(Integer.valueOf(value.getId())); + } + + public CaracteristicQualitativeValue getValue(Caracteristic c) { + Preconditions.checkNotNull(c); + Preconditions.checkState(!c.isQualitativeValueEmpty()); + CaracteristicQualitativeValue result = null; + for (CaracteristicQualitativeValue value : c.getQualitativeValue()) { + if (matchValue(value)) { + result = value; + break; + } + } + return result; + } +} Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-03-23 18:20:58 UTC (rev 666) @@ -73,9 +73,7 @@ public class BatchPersistenceServiceImpl extends AbstractPersistenceService implements BatchPersistenceService { - /** - * Logger. - */ + /** Logger. */ private static final Log log = LogFactory.getLog(BatchPersistenceServiceImpl.class); @@ -120,13 +118,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()); @@ -134,14 +132,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()); } @@ -149,7 +147,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()); @@ -160,19 +158,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()); } @@ -183,7 +181,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()); } @@ -207,8 +205,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."); } @@ -249,8 +247,8 @@ // 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). @@ -262,8 +260,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); @@ -273,8 +271,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; @@ -306,7 +304,7 @@ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId); SortingBatch batch = SortingBatch.Factory.newInstance(); - beanToEntity(bean, batch, parentBatchId, catchBatch, true); + speciesBatchToEntity(bean, batch, parentBatchId, catchBatch); batch = catchBatchDao.createSortingBatch(batch, catchBatch); bean.setId(String.valueOf(batch.getId())); @@ -332,7 +330,7 @@ if (bean.getParentBatch() != null) { parentBatchId = bean.getParentBatch().getId(); } - beanToEntity(bean, batch, parentBatchId, catchBatch, true); + speciesBatchToEntity(bean, batch, parentBatchId, catchBatch); catchBatchDao.updateSortingBatch(batch, catchBatch); getCurrentSession().flush(); @@ -495,8 +493,8 @@ // 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())); @@ -505,8 +503,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); @@ -516,8 +514,8 @@ // 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; @@ -548,7 +546,7 @@ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId); SortingBatch batch = SortingBatch.Factory.newInstance(); - beanToEntity(bean, batch, parentBatchId, catchBatch, true); + benthosBatchToEntity(bean, batch, parentBatchId, catchBatch); batch = catchBatchDao.createSortingBatch(batch, catchBatch); bean.setId(String.valueOf(batch.getId())); @@ -574,7 +572,7 @@ if (bean.getParentBatch() != null) { parentBatchId = bean.getParentBatch().getId(); } - beanToEntity(bean, batch, parentBatchId, catchBatch, true); + benthosBatchToEntity(bean, batch, parentBatchId, catchBatch); catchBatchDao.updateSortingBatch(batch, catchBatch); getCurrentSession().flush(); @@ -609,8 +607,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."); } @@ -817,11 +815,26 @@ } } - protected void beanToEntity(SpeciesBatch source, - SortingBatch target, - String parentBatchId, - fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch, - boolean copyIfNull) { + protected void speciesBatchToEntity(SpeciesBatch source, + SortingBatch target, + String parentBatchId, + fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) { + sortingBatchToEntity(source, target, parentBatchId, catchBatch, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + } + + protected void benthosBatchToEntity(SpeciesBatch source, + SortingBatch target, + String parentBatchId, + fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) { + sortingBatchToEntity(source, target, parentBatchId, catchBatch, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + } + + protected void sortingBatchToEntity(SpeciesBatch source, + SortingBatch target, + String parentBatchId, + fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch, + Integer batchPmfm) { + Preconditions.checkNotNull(source.getFishingOperation()); Preconditions.checkNotNull(source.getFishingOperation().getId()); @@ -840,9 +853,9 @@ // If parent and root need to be set if (target.getId() == null - || target.getRootBatch() == null - || (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) { - setBatchParents(source, target, parentBatchId, catchBatch); + || target.getRootBatch() == null + || (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) { + setBatchParents(source, target, parentBatchId, catchBatch, batchPmfm); } // RankOrder (initialize once, at creation) @@ -861,20 +874,20 @@ target.setSubgroupCount(1f); // Weight or SampleCategoryWeight - if (copyIfNull && source.getWeight() == null && source.getSampleCategoryWeight() == null) { + if (source.getWeight() == null && source.getSampleCategoryWeight() == null) { // 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); } // Sampling Ratio - if (copyIfNull && (source.getSampleCategoryWeight() == null || source.getWeight() == null)) { + if (source.getSampleCategoryWeight() == null || source.getWeight() == null) { target.setSamplingRatio(null); target.setSamplingRatioText(null); } else if (source.getSampleCategoryWeight() != null && source.getWeight() != null) { @@ -883,32 +896,32 @@ 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); } // Sorting measurement - if (copyIfNull && (source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null)) { + if (source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null) { // Nothing to do : will be removed later, using notChangedSortingMeasurements } else if (source.getSampleCategoryType() != null && source.getSampleCategoryValue() != null) { Integer pmfmId = sampleCategory2PmfmId(source.getSampleCategoryType()); // 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); } } // Individual count - if (copyIfNull && source.getNumber() == null) { + if (source.getNumber() == null) { target.setIndividualCount(null); } else if (source.getNumber() != null) { target.setIndividualCount(source.getNumber()); } // Species - if (copyIfNull && (source.getSpecies() == null || parentBatchId != null)) { + if (source.getSpecies() == null || parentBatchId != null) { target.setReferenceTaxon(null); } else if (source.getSpecies() != null && parentBatchId == null) { ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, source.getSpecies().getReferenceTaxonId()); @@ -923,7 +936,7 @@ } // Comments - if (copyIfNull && source.getComment() == null) { + if (source.getComment() == null) { target.setComments(null); } else if (source.getComment() != null) { target.setComments(source.getComment()); @@ -945,8 +958,11 @@ } } - protected void setBatchParents(SpeciesBatch source, SortingBatch target, String parentBatchIdStr, - fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) { + protected void setBatchParents(SpeciesBatch source, + SortingBatch target, + String parentBatchIdStr, + fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch, + Integer batchPmfmId) { Preconditions.checkNotNull(target); Preconditions.checkNotNull(source.getFishingOperation()); @@ -971,8 +987,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, batchPmfmId); // Parent Batch target.setParentBatch(parentBatch); @@ -1055,8 +1071,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()); @@ -1070,7 +1086,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); } @@ -1080,7 +1096,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); } @@ -1175,7 +1191,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); } @@ -1197,9 +1213,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 : @@ -1219,9 +1235,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); { @@ -1238,9 +1254,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); // ----------------------------------------------------------------------------- @@ -1252,9 +1268,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); } @@ -1268,9 +1284,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); } @@ -1288,9 +1304,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 : @@ -1311,9 +1327,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); } @@ -1327,9 +1343,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); } @@ -1348,9 +1364,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); } @@ -1454,7 +1470,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); } @@ -1521,7 +1537,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/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-03-23 18:20:58 UTC (rev 666) @@ -28,7 +28,6 @@ import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Country; import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -217,8 +216,6 @@ @Cacheable(value = "objectTypeByCode", key = "#objectTypeCode") ObjectType getObjectType(String objectTypeCode); - boolean isSortedQualitativeValue(CaracteristicQualitativeValue value); - /** * Import given temporary species. * Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-03-23 18:20:58 UTC (rev 666) @@ -371,12 +371,6 @@ } @Override - public boolean isSortedQualitativeValue(CaracteristicQualitativeValue value) { - return value != null && - enumeration.QUALITATIVE_VRAC_ID.toString().equals(value.getId()); - } - - @Override public List<Species> getAllSpecies() { TaxonRefTaxVO[] sources = taxonNameDao.getAllTaxonNames(true); @@ -519,7 +513,7 @@ break; } } - result.setQualitativeValue(qualitativeValue); + result.setQualitativeValue(Collections.unmodifiableList(qualitativeValue)); return result; } @@ -833,7 +827,7 @@ query.setString("statusValidCode", enumeration.STATUS_VALID_CODE); query.setString("statusTemporaryCode", enumeration.STATUS_TEMPORARY_CODE); - Iterator result = query.iterate(); + Iterator<Object[]> result = query.iterate(); return result; } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-03-23 18:20:58 UTC (rev 666) @@ -29,6 +29,7 @@ import com.google.common.collect.Sets; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; +import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum; import org.springframework.beans.factory.annotation.Value; import org.springframework.util.ReflectionUtils; @@ -269,6 +270,7 @@ } // init enums + initEnum(SortedUnsortedEnum.class, annotatedFieldValues); initEnum(AttachementObjectTypeEnum.class, annotatedFieldValues); initEnum(SampleCategoryEnum.class, annotatedFieldValues); Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties =================================================================== --- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-03-23 18:20:58 UTC (rev 666) @@ -25,3 +25,8 @@ tutti.persistence.batch.validation.vracSpeciesInertNotFound= tutti.persistence.batch.validation.vracSpeciesLifeNotFound= tutti.persistence.batch.validation.vracSpeciesNotFound= +tutti.sampleCategoryType.age= +tutti.sampleCategoryType.maturity= +tutti.sampleCategoryType.sex= +tutti.sampleCategoryType.size= +tutti.sampleCategoryType.sortedUnsorted= Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties =================================================================== --- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-03-23 18:20:58 UTC (rev 666) @@ -15,7 +15,6 @@ tutti.config.option.persistence.jdbc.username.description=Login de l'utilisateur pour se connecter à la base de données tutti.config.persistence=Configuration de la persistence de Tutti tutti.persistence.batch.validation.horsVracBenthosNotFound=Lot 'Hors Vrac > Benthos' non trouvé ou configuré avec d'autres critères de classement. -tutti.persistence.batch.validation.horsVracNotFound=Lot 'Hors Vrac' non trouvé, ou configuré avec d'autres critères de classement. tutti.persistence.batch.validation.horsVracSpeciesNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement. tutti.persistence.batch.validation.onlySpeciesBatchStructure=Lot 'Espèces' (données historiques CGFS) détecté. tutti.persistence.batch.validation.unsortedNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement. @@ -26,3 +25,8 @@ tutti.persistence.batch.validation.vracSpeciesInertNotFound=Lot 'Vrac > Espèces > Inerte' non trouvé, ou configuré avec d'autres critères de classement. tutti.persistence.batch.validation.vracSpeciesLifeNotFound=Lot 'Vrac > Espèces > Biota' non trouvé, ou configuré avec d'autres critères de classement. tutti.persistence.batch.validation.vracSpeciesNotFound=Lot 'Vrac > Espèces' non trouvé, ou configuré avec d'autres critères de classement. +tutti.sampleCategoryType.age=Age +tutti.sampleCategoryType.maturity=Maturité +tutti.sampleCategoryType.sex=Sexe +tutti.sampleCategoryType.size=Class Tri. +tutti.sampleCategoryType.sortedUnsorted=V/HV Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo =================================================================== (Binary files differ) Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-03-23 18:20:58 UTC (rev 666) @@ -24,6 +24,7 @@ * #L% */ +import fr.ifremer.tutti.LabelAware; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -42,8 +43,6 @@ import org.nuiton.util.decorator.Decorator; import org.nuiton.util.decorator.DecoratorProvider; -import java.io.Serializable; - import static org.nuiton.i18n.I18n._; import static org.nuiton.i18n.I18n.n_; @@ -55,19 +54,10 @@ */ public class DecoratorService extends AbstractTuttiService { - /** - * A contract to decorate some objects - * (not known at this level but with a label property to display them). - * - * @since 0.3 - */ - public interface LabelAware extends Serializable { - String getLabel(); - } - public static final String CARACTERISTIC_WITH_UNIT = "withUnit"; - public static final String CARACTERISTIC_PARAMETER_ONLY= "parameterOnly"; + public static final String CARACTERISTIC_PARAMETER_ONLY = "parameterOnly"; + public static final String FROM_PROTOCOL = "fromProtocol"; public static final String BY_NAME = "byName"; @@ -110,7 +100,7 @@ registerTuttiDecorator(Person.class, "${firstName}$s#${lastName}$s#${department}$s", SEPARATOR, " "); registerTuttiDecorator(FishingOperationLocation.class, "${label}$s#${name}$s", SEPARATOR, " - "); registerTuttiDecorator(Caracteristic.class, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s", SEPARATOR, " - "); - registerTuttiDecorator(Caracteristic.class,CARACTERISTIC_PARAMETER_ONLY, "${parameterName}$s", SEPARATOR, " - "); + registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_PARAMETER_ONLY, "${parameterName}$s", SEPARATOR, " - "); // registerMultiJXPathDecorator(Caracteristic.class, CARACTERISTIC_WITH_UNIT, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s (${unit}$s)", SEPARATOR, " - "); registerTuttiDecorator(CaracteristicQualitativeValue.class, "${name}$s", SEPARATOR, " - "); registerTuttiDecorator(SpeciesProtocol.class, "${speciesReferenceTaxonId}", SEPARATOR, " - "); 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-03-23 18:20:58 UTC (rev 666) @@ -44,7 +44,6 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; 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.Country; import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -416,11 +415,6 @@ } @Override - public boolean isSortedQualitativeValue(CaracteristicQualitativeValue value) { - return driver.isSortedQualitativeValue(value); - } - - @Override public Person getPerson(Integer personId) { return driver.getPerson(personId); } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,16 +1,39 @@ - package fr.ifremer.tutti.service.pupitri; +/* + * #%L + * Tutti :: Service + * $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 java.io.Serializable; /** - * * @author kmorin <kmorin@codelutin.com> + * @since 1.2 */ public class CarrouselRow implements Serializable { private static final long serialVersionUID = 1L; - + public static final String PROPERTY_FILE_ORIGIN = "fileOrigin"; public static final String PROPERTY_DATE = "date"; Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,21 +1,44 @@ - package fr.ifremer.tutti.service.pupitri; +/* + * #%L + * Tutti :: Service + * $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 fr.ifremer.tutti.service.TuttiCsvUtil; -import java.text.ParseException; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.csv.ValueParser; +import java.text.ParseException; + /** - * * @author kmorin <kmorin@codelutin.com> - * @since + * @since 1.2 */ public class CarrouselRowModel extends TuttiCsvUtil.AbstractTuttiImportExportModel<CarrouselRow> { - private Log log = LogFactory.getLog(CarrouselRowModel.class); + private static final Log log = LogFactory.getLog(CarrouselRowModel.class); public CarrouselRowModel(char separator) { super(separator); Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Directions.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Directions.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Directions.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,9 +1,32 @@ - package fr.ifremer.tutti.service.pupitri; +/* + * #%L + * Tutti :: Service + * $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% + */ + /** - * * @author kmorin <kmorin@codelutin.com> + * @since 1.2 */ public enum Directions { Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Directions.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRow.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRow.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRow.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,16 +1,39 @@ - package fr.ifremer.tutti.service.pupitri; +/* + * #%L + * Tutti :: Service + * $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 java.io.Serializable; /** - * * @author kmorin <kmorin@codelutin.com> + * @since 1.2 */ public class TrunkRow implements Serializable { private static final long serialVersionUID = 1L; - + public static final String PROPERTY_FILE_ORIGIN = "fileOrigin"; public static final String PROPERTY_DATE = "date"; Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRow.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,20 +1,43 @@ - package fr.ifremer.tutti.service.pupitri; +/* + * #%L + * Tutti :: Service + * $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 fr.ifremer.tutti.service.TuttiCsvUtil; -import java.text.ParseException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.csv.ValueParser; +import java.text.ParseException; + /** - * * @author kmorin <kmorin@codelutin.com> - * @since + * @since 1.2 */ public class TrunkRowModel extends TuttiCsvUtil.AbstractTuttiImportExportModel<TrunkRow> { - private Log log = LogFactory.getLog(TrunkRowModel.class); + private static final Log log = LogFactory.getLog(TrunkRowModel.class); public TrunkRowModel(char separator) { super(separator); Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TrunkRowModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,26 +1,49 @@ - package fr.ifremer.tutti.service.pupitri; +/* + * #%L + * Tutti :: Service + * $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.base.Charsets; -import com.google.common.collect.Maps; import com.google.common.io.Files; import fr.ifremer.tutti.TuttiTechnicalException; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.service.AbstractTuttiService; -import java.io.File; -import java.io.Reader; -import java.util.Collections; -import java.util.Map; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.csv.Import; +import java.io.File; +import java.io.Reader; +import java.util.Collections; +import java.util.Map; + /** - * * @author kmorin <kmorin@codelutin.com> + * @since 1.2 */ public class TuttiPupitriImportExportService extends AbstractTuttiService { @@ -44,15 +67,15 @@ try { fileWithHeaders = new File(FileUtils.getTempDirectory(), file.getName()); String headers = TrunkRow.PROPERTY_FILE_ORIGIN + separator + - TrunkRow.PROPERTY_DATE + separator + - TrunkRow.PROPERTY_TIME + separator + - TrunkRow.PROPERTY_BALANCE_ID + separator + - TrunkRow.PROPERTY_SIGN + separator + - TrunkRow.PROPERTY_OPERATION_CODE + separator + - TrunkRow.PROPERTY_RIG_NUMBER + separator + - TrunkRow.PROPERTY_DIRECTION + separator + - TrunkRow.PROPERTY_WEIGHT + separator + - TrunkRow.PROPERTY_EMPTY; + TrunkRow.PROPERTY_DATE + separator + + TrunkRow.PROPERTY_TIME + separator + + TrunkRow.PROPERTY_BALANCE_ID + separator + + TrunkRow.PROPERTY_SIGN + separator + + TrunkRow.PROPERTY_OPERATION_CODE + separator + + TrunkRow.PROPERTY_RIG_NUMBER + separator + + TrunkRow.PROPERTY_DIRECTION + separator + + TrunkRow.PROPERTY_WEIGHT + separator + + TrunkRow.PROPERTY_EMPTY; FileUtils.writeLines(fileWithHeaders, Collections.singletonList(headers)); log.info(FileUtils.readFileToString(fileWithHeaders)); @@ -70,7 +93,7 @@ for (TrunkRow bean : importer) { if (bean.getOperationCode().equals(operationNumber) - && bean.getRigNumber().equals(rigNumber)) { + && bean.getRigNumber().equals(rigNumber)) { switch (bean.getDirection()) { case VAT: @@ -91,7 +114,7 @@ } catch (Exception e) { throw new TuttiTechnicalException("Could not import protocol [" + operation.toString() + "] caracteristic from file " + file, e); - + } finally { IOUtils.closeQuietly(importer); IOUtils.closeQuietly(reader); @@ -121,18 +144,18 @@ try { fileWithHeaders = new File(FileUtils.getTempDirectory(), file.getName()); String headers = CarrouselRow.PROPERTY_FILE_ORIGIN + separator + - CarrouselRow.PROPERTY_DATE + separator + - CarrouselRow.PROPERTY_TIME + separator + - CarrouselRow.PROPERTY_BALANCE_ID + separator + - CarrouselRow.PROPERTY_TO_CONFIRM + separator + - CarrouselRow.PROPERTY_OPERATION_CODE + separator + - CarrouselRow.PROPERTY_RIG_NUMBER + separator + - CarrouselRow.PROPERTY_BOX_TYPE + separator + - CarrouselRow.PROPERTY_SPECIES_ID + separator + - CarrouselRow.PROPERTY_SIGN + separator + - CarrouselRow.PROPERTY_DIRECTION + separator + - CarrouselRow.PROPERTY_WEIGHT + separator + - CarrouselRow.PROPERTY_EMPTY; + CarrouselRow.PROPERTY_DATE + separator + + CarrouselRow.PROPERTY_TIME + separator + + CarrouselRow.PROPERTY_BALANCE_ID + separator + + CarrouselRow.PROPERTY_TO_CONFIRM + separator + + CarrouselRow.PROPERTY_OPERATION_CODE + separator + + CarrouselRow.PROPERTY_RIG_NUMBER + separator + + CarrouselRow.PROPERTY_BOX_TYPE + separator + + CarrouselRow.PROPERTY_SPECIES_ID + separator + + CarrouselRow.PROPERTY_SIGN + separator + + CarrouselRow.PROPERTY_DIRECTION + separator + + CarrouselRow.PROPERTY_WEIGHT + separator + + CarrouselRow.PROPERTY_EMPTY; FileUtils.writeLines(fileWithHeaders, Collections.singletonList(headers)); log.info(FileUtils.readFileToString(fileWithHeaders)); @@ -150,8 +173,8 @@ for (CarrouselRow bean : importer) { if (bean.getOperationCode().equals(operationNumber) - && bean.getRigNumber().equals(rigNumber) - && "0".equals(bean.getSign())) { + && bean.getRigNumber().equals(rigNumber) + && "0".equals(bean.getSign())) { String speciesId = bean.getSpeciesId(); Map<String, Float> weights = null; Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/pom.xml =================================================================== --- trunk/tutti-ui-swing/pom.xml 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/pom.xml 2013-03-23 18:20:58 UTC (rev 666) @@ -84,7 +84,7 @@ <bundlePrefix>tutti-${project.version}</bundlePrefix> <tutti.log.file> - \$\{java.io.tmpdir\}tutti-${project.version}.log + \$\{java.io.tmpdir\}/tutti-${project.version}.log </tutti.log.file> </properties> 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-03-23 18:20:58 UTC (rev 666) @@ -1,5 +1,12 @@ #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Fri Mar 15 11:27:22 CET 2013 +#Sat Mar 23 16:49:12 CET 2013 +tutti.createBenthosBatch.action.addSpecies.help= +tutti.createBenthosBatch.action.cancel.help= +tutti.createBenthosBatch.action.save.help= +tutti.createBenthosBatch.field.batchWeight.help= +tutti.createBenthosBatch.field.sortedUnsortedCategory.help= +tutti.createBenthosBatch.field.species.help= +tutti.createBenthosBatch.help= tutti.createSpeciesBatch.action.addSpecies.help=createSpeciesBatch.html\#actions tutti.createSpeciesBatch.action.cancel.help=createSpeciesBatch.html\#actions tutti.createSpeciesBatch.action.save.help=createSpeciesBatch.html\#actions @@ -15,7 +22,31 @@ tutti.dbManager.action.openDb.help=dbManager.html\#actions tutti.dbManager.action.upgradeDb.help=dbManager.html\#actions tutti.dbManager.help=dbManager.html +tutti.editBenthosBatch.action.createBatch.help= +tutti.editBenthosBatch.action.removeBatch.help= +tutti.editBenthosBatch.action.renameBatch.help= +tutti.editBenthosBatch.action.splitBatch.help= +tutti.editBenthosBatch.field.benthosTotalInertWeight.help= +tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight.help= +tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight.help= +tutti.editBenthosBatch.field.benthosTotalSortedWeight.help= +tutti.editBenthosBatch.field.benthosTotalUnsortedWeight.help= +tutti.editBenthosBatch.field.benthosTotalWeight.help= +tutti.editBenthosBatch.filterBatch.help= tutti.editBenthosBatch.help=editBenthosBatch.html +tutti.editBenthosFrequencies.action.cancel.help= +tutti.editBenthosFrequencies.action.generate.help= +tutti.editBenthosFrequencies.action.save.help= +tutti.editBenthosFrequencies.field.lengthStepCaracteristic.help= +tutti.editBenthosFrequencies.field.maxStep.help= +tutti.editBenthosFrequencies.field.minStep.help= +tutti.editBenthosFrequencies.field.mode.autoGen.help= +tutti.editBenthosFrequencies.field.mode.rafale.help= +tutti.editBenthosFrequencies.field.mode.simple.help= +tutti.editBenthosFrequencies.field.mode.simpleCounting.help= +tutti.editBenthosFrequencies.field.rafaleStep.help= +tutti.editBenthosFrequencies.field.simpleCounting.help= +tutti.editBenthosFrequencies.field.step.help= tutti.editCatchBatch.action.cancelEditCatchBatch.help=editCatchBatch.html\#actions tutti.editCatchBatch.action.computeWeights.help=editCatchBatch.html\#actions tutti.editCatchBatch.action.importPupitri.help=editCatchBatch.html\#actions @@ -108,12 +139,12 @@ tutti.editProtocol.field.vesselUseFeature.help=editProtocol.html\#fields tutti.editProtocol.help=editProtocol.html tutti.editProtocol.pane.caracteristic.help=editProtocol.html\#fields -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 -tutti.editSpeciesBatch.action.renameSpeciesBatch.help=editSpeciesBatch.html\#actions -tutti.editSpeciesBatch.action.splitSpeciesBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.createBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.createMelag.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.removeBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.removeSubBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.renameBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.splitBatch.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.field.speciesTotalInertWeight.help=editSpeciesBatch.html\#fields tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight.help=editSpeciesBatch.html\#fields tutti.editSpeciesBatch.field.speciesTotalSampleSortedWeight.help=editSpeciesBatch.html\#fields @@ -183,6 +214,13 @@ tutti.selectCruise.field.program.help=selectCruise.html\#fields tutti.selectCruise.field.protocol.help=selectCruise.html\#fields tutti.selectCruise.help=selectCruise.html +tutti.splitBenthosBatch.action.cancel.help= +tutti.splitBenthosBatch.action.save.help= +tutti.splitBenthosBatch.field.batchWeightField.help= +tutti.splitBenthosBatch.field.categoryField.help= +tutti.splitBenthosBatch.field.sampleWeightField.help= +tutti.splitBenthosBatch.field.speciesField.help= +tutti.splitBenthosBatch.help= tutti.splitSpeciesBatch.action.cancel.help=splitSpeciesBatch.html\#actions tutti.splitSpeciesBatch.action.save.help=splitSpeciesBatch.html\#actions tutti.splitSpeciesBatch.field.batchWeightField.help=splitSpeciesBatch.html\#fields 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-03-23 18:20:58 UTC (rev 666) @@ -1,5 +1,12 @@ #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Fri Mar 15 11:27:22 CET 2013 +#Sat Mar 23 16:49:12 CET 2013 +tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions +tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions +tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions +tutti.createBenthosBatch.field.batchWeight.help=createBenthosBatch.html\#fields +tutti.createBenthosBatch.field.sortedUnsortedCategory.help=createBenthosBatch.html\#fields +tutti.createBenthosBatch.field.species.help=createBenthosBatch.html\#fields +tutti.createBenthosBatch.help=createBenthosBatch.html tutti.createSpeciesBatch.action.addSpecies.help=createSpeciesBatch.html\#actions tutti.createSpeciesBatch.action.cancel.help=createSpeciesBatch.html\#actions tutti.createSpeciesBatch.action.save.help=createSpeciesBatch.html\#actions @@ -15,7 +22,40 @@ tutti.dbManager.action.openDb.help=dbManager.html\#actions tutti.dbManager.action.upgradeDb.help=dbManager.html\#actions tutti.dbManager.help=dbManager.html +tutti.editBenthosBatch.action.createBatch.help=editBenthosBatch.html\#actions +tutti.editBenthosBatch.action.createMelag.help=editBenthosBatch.html\#actions +tutti.editBenthosBatch.action.removeBatch.help=editBenthosBatch.html\#actions +tutti.editBenthosBatch.action.removeSubBatch.help=editBenthosBatch.html\#actions +tutti.editBenthosBatch.action.renameBatch.help=editBenthosBatch.html\#actions +tutti.editBenthosBatch.action.splitBatch.help=editBenthosBatch.html\#actions +tutti.editBenthosBatch.field.benthosTotalInertWeight.help= +tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight.help= +tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight.help= +tutti.editBenthosBatch.field.benthosTotalSortedWeight.help= +tutti.editBenthosBatch.field.benthosTotalUnsortedWeight.help= +tutti.editBenthosBatch.field.benthosTotalWeight.help= +tutti.editBenthosBatch.field.speciesTotalInertWeight.help=editBenthosBatch.html\#fields +tutti.editBenthosBatch.field.speciesTotalLivingNotItemizedWeight.help=editBenthosBatch.html\#fields +tutti.editBenthosBatch.field.speciesTotalSampleSortedWeight.help=editBenthosBatch.html\#fields +tutti.editBenthosBatch.field.speciesTotalSortedWeight.help=editBenthosBatch.html\#fields +tutti.editBenthosBatch.field.speciesTotalUnsortedWeight.help=editBenthosBatch.html\#fields +tutti.editBenthosBatch.field.speciesTotalWeight.help=editBenthosBatch.html\#fields +tutti.editBenthosBatch.filterBatch.help=editBenthosBatch.html tutti.editBenthosBatch.help=editBenthosBatch.html +tutti.editBenthosFrequencies.action.cancel.help=editBenthosFrequencies.html\#actions +tutti.editBenthosFrequencies.action.generate.help=editBenthosFrequencies.html\#actions +tutti.editBenthosFrequencies.action.save.help=editBenthosFrequencies.html\#actions +tutti.editBenthosFrequencies.field.lengthStepCaracteristic.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.maxStep.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.minStep.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.mode.autoGen.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.mode.rafale.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.mode.simple.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.mode.simpleCounting.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.rafaleStep.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.simpleCounting.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.field.step.help=editBenthosFrequencies.html\#fields +tutti.editBenthosFrequencies.help=editBenthosFrequencies.html tutti.editCatchBatch.action.cancelEditCatchBatch.help=editCatchBatch.html\#actions tutti.editCatchBatch.action.computeWeights.help=editCatchBatch.html\#actions tutti.editCatchBatch.action.importPupitri.help=editCatchBatch.html\#actions @@ -108,12 +148,12 @@ tutti.editProtocol.field.vesselUseFeature.help=editProtocol.html\#fields tutti.editProtocol.help=editProtocol.html tutti.editProtocol.pane.caracteristic.help=editProtocol.html\#fields -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 -tutti.editSpeciesBatch.action.renameSpeciesBatch.help=editSpeciesBatch.html\#actions -tutti.editSpeciesBatch.action.splitSpeciesBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.createBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.createMelag.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.removeBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.removeSubBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.renameBatch.help=editSpeciesBatch.html\#actions +tutti.editSpeciesBatch.action.splitBatch.help=editSpeciesBatch.html\#actions tutti.editSpeciesBatch.field.speciesTotalInertWeight.help=editSpeciesBatch.html\#fields tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight.help=editSpeciesBatch.html\#fields tutti.editSpeciesBatch.field.speciesTotalSampleSortedWeight.help=editSpeciesBatch.html\#fields @@ -183,6 +223,13 @@ tutti.selectCruise.field.program.help=selectCruise.html\#fields tutti.selectCruise.field.protocol.help=selectCruise.html\#fields tutti.selectCruise.help=selectCruise.html +tutti.splitBenthosBatch.action.cancel.help=splitBenthosBatch.html\#actions +tutti.splitBenthosBatch.action.save.help=splitBenthosBatch.html\#actions +tutti.splitBenthosBatch.field.batchWeightField.help=splitBenthosBatch.html\#fields +tutti.splitBenthosBatch.field.categoryField.help=splitBenthosBatch.html\#fields +tutti.splitBenthosBatch.field.sampleWeightField.help=splitBenthosBatch.html\#fields +tutti.splitBenthosBatch.field.speciesField.help=splitBenthosBatch.html\#fields +tutti.splitBenthosBatch.help=splitBenthosBatch.html tutti.splitSpeciesBatch.action.cancel.help=splitSpeciesBatch.html\#actions tutti.splitSpeciesBatch.action.save.help=splitSpeciesBatch.html\#actions tutti.splitSpeciesBatch.field.batchWeightField.help=splitSpeciesBatch.html\#fields Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -36,24 +36,24 @@ import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.content.operation.catches.ComputeWeightsAction; 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.SaveCatchBatchAction; import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUI; import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUI; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTabbedPane; import java.awt.BorderLayout; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collections; import java.util.List; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JTabbedPane; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.decorator.Decorator; import static org.nuiton.i18n.I18n._; @@ -552,18 +552,15 @@ catchesUIModel.setCatchBatch(batch); catchesUIModel.setFishingOperation(bean); - catchesUIModel.fromBean(batch); - catchesUIModel.addAllAttachment(attachments); - catchesUIModel.setModify(false); catchBatchMonitor.clearModified(); // 3) Propagate title to others tabs ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText); ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText); -// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText); + ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText); // ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText); // ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText); // ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText); @@ -573,7 +570,7 @@ // 4) Propagate new selected fishingoperation to others tabs ui.getSpeciesTabContent().getHandler().selectFishingOperation(batch == null ? null : bean); -// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean); + ui.getBenthosTabContent().getHandler().selectFishingOperation(batch == null ? null : bean); // ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean); // ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean); // ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean); 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -26,9 +26,10 @@ */ import fr.ifremer.tutti.TuttiBusinessException; -import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel; 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; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; @@ -50,36 +51,38 @@ super(handler, false); } - //FIXME Non, y'a des trucs qui vont pas du tout - //FIXME 1) eviter de faire des repaint (surtout dans ce thread) - //FIXME 2) pas gestion à la mimine des exceptions avec un new Exception(XXX) c moche :( - //FIXME 3) le releaseAction c'est pas trop le moment pour envoyer des exception non plus :( - @Override protected void doAction() throws Exception { EditCatchesUIModel model = getModel(); computeSpeciesBatches(); + computeBenthosBatches(); Float speciesTotalSortedWeight = model.getSpeciesTotalSortedWeight(); if (speciesTotalSortedWeight == null) { speciesTotalSortedWeight = model.getSpeciesTotalSortedComputedWeight(); } + Float benthosTotalSortedWeight = model.getBenthosTotalSortedWeight(); + if (benthosTotalSortedWeight == null) { + benthosTotalSortedWeight = model.getBenthosTotalSortedComputedWeight(); + } + Float carrouselWeight = model.getCatchTotalSortedCarousselWeight(); - Float totalUnsortedWeight = model.getSpeciesTotalUnsortedComputedWeight(); + Float totalUnsortedWeight = model.getSpeciesTotalUnsortedComputedWeight() + + model.getBenthosTotalUnsortedComputedWeight(); Float totalSortedWeight; if (carrouselWeight != null) { totalSortedWeight = carrouselWeight; } else { - totalSortedWeight = speciesTotalSortedWeight; + totalSortedWeight = speciesTotalSortedWeight + benthosTotalSortedWeight; } - model.setCatchTotalSortedComputedWeight(speciesTotalSortedWeight); + model.setCatchTotalSortedComputedWeight(totalSortedWeight); model.setCatchTotalUnsortedComputedWeight(totalUnsortedWeight); Float totalWeight = model.getCatchTotalWeight(); Float rejectedWeight = model.getCatchTotalRejectedWeight(); - + if (rejectedWeight == null && totalWeight != null) { if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight)) { @@ -100,13 +103,16 @@ + totalSortedWeight + rejectedWeight); - } else if (rejectedWeight != null - && !totalWeight.equals(totalUnsortedWeight - + totalSortedWeight - + rejectedWeight)) { + } else if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight + rejectedWeight)) { throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentTotal")); } + } + @Override + public void postSuccessAction() { + super.postSuccessAction(); + + getUI().repaint(); } //------------------------------------------------------------------------// @@ -114,14 +120,10 @@ //------------------------------------------------------------------------// protected void computeSpeciesBatches() { - PersistenceService persistenceService = - getContext().getPersistenceService(); EditCatchesUIModel model = getModel(); Float totalSortedWeight = 0f; Float totalUnsortedWeight = 0f; - SpeciesBatchUI speciesUI = getUI().getSpeciesTabContent(); - EditCatchesUI ui = getUI(); List<SpeciesBatchRowModel> roots = getUI().getSpeciesTabContent().getModel().getRows(); for (int i = 0; i < roots.size(); i++) { @@ -129,10 +131,10 @@ if (row.isBatchRoot()) { Float weight = computeSpeciesBatch(row); if (weight == null) { - AbstractSelectTableAction.doSelectCell(speciesUI.getTable(), i, 1); + AbstractSelectTableAction.doSelectCell(getUI().getSpeciesTabContent().getTable(), i, 1); throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.noWeight")); } - if (persistenceService.isSortedQualitativeValue(row.getSortedUnsortedCategory().getCategoryValue())) { + if (SortedUnsortedEnum.SORTED.matchValue(row.getSortedUnsortedCategory().getCategoryValue())) { totalSortedWeight += weight; } else { totalUnsortedWeight += weight; @@ -193,8 +195,6 @@ Float totalWeight = totalUnsortedWeight + speciesTotalSortedWeight; model.setSpeciesTotalComputedWeight(totalWeight); - - speciesUI.getTable().repaint(); } protected Float computeSpeciesBatch(SpeciesBatchRowModel row) { @@ -298,4 +298,183 @@ return result; } + protected void computeBenthosBatches() { + + EditCatchesUIModel model = getModel(); + + Float totalSortedWeight = 0f; + Float totalUnsortedWeight = 0f; + + List<BenthosBatchRowModel> roots = getUI().getBenthosTabContent().getModel().getRows(); + for (int i = 0; i < roots.size(); i++) { + BenthosBatchRowModel row = roots.get(i); + if (row.isBatchRoot()) { + Float weight = computeBenthosBatch(row); + if (weight == null) { + AbstractSelectTableAction.doSelectCell(getUI().getBenthosTabContent().getTable(), i, 1); + throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.noWeight")); + } + if (SortedUnsortedEnum.SORTED.matchValue(row.getSortedUnsortedCategory().getCategoryValue())) { + totalSortedWeight += weight; + } else { + totalUnsortedWeight += weight; + } + } + } + + Number inertWeight = model.getBenthosTotalInertWeight(); + if (inertWeight != null) { + totalSortedWeight += inertWeight.floatValue(); + } else { + model.setBenthosTotalInertComputedWeight(0f); + } + + Number livingNotItemizedWeight = model.getBenthosTotalLivingNotItemizedWeight(); + if (livingNotItemizedWeight != null) { + totalSortedWeight += livingNotItemizedWeight.floatValue(); + } else { + model.setBenthosTotalLivingNotItemizedComputedWeight(0f); + } + + model.setBenthosTotalSampleSortedComputedWeight(totalSortedWeight); + + Float benthosTotalSortedWeight = model.getBenthosTotalSortedWeight(); + Float rate = getConfig().getDifferenceRateBetweenSortedAndTotalWeights(); + if (benthosTotalSortedWeight == null) { + benthosTotalSortedWeight = totalSortedWeight; + model.setBenthosTotalSortedComputedWeight(totalSortedWeight); + + } else if (benthosTotalSortedWeight < totalSortedWeight) { + throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentSpeciesTotalSorted")); + + } else if (benthosTotalSortedWeight < (1 + rate / 100) * totalSortedWeight) { + // Si le "Poids total VRAC" est saisi est que sa valeur + // est supérieure de moins de x% (x en configuration) + // du "Poids total Vrac trié", demander confirmation que + // le "Poids total VRAC" est bien une valeur observée + // sinon la remplacer par le "Poids total Vrac trié" + String htmlMessage = String.format( + AbstractTuttiUIHandler.CONFIRMATION_FORMAT, + _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message", rate), + _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help")); + + int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(), + htmlMessage, + _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (answer == JOptionPane.NO_OPTION) { + model.setSpeciesTotalSortedWeight(null); + benthosTotalSortedWeight = totalSortedWeight; + model.setBenthosTotalSortedComputedWeight(totalSortedWeight); + } + } + + model.setBenthosTotalUnsortedComputedWeight(totalUnsortedWeight); + + Float totalWeight = totalUnsortedWeight + benthosTotalSortedWeight; + model.setBenthosTotalComputedWeight(totalWeight); + } + + protected Float computeBenthosBatch(BenthosBatchRowModel row) { + SampleCategory finestCategory = row.getFinestCategory(); + + Float result = null; + Float categoryWeight = finestCategory.getCategoryWeight(); + Float rowWeight = row.getWeight(); + + List<BenthosBatchRowModel> children = row.getChildBatch(); + // if the row is not a leaf + if (!row.isBatchLeaf()) { + Float sum = 0f; + // make the sum of the children weights + for (BenthosBatchRowModel child : children) { + Float weight = computeBenthosBatch(child); + if (weight == null) { + sum = null; + break; + } + sum += weight; + } + + if (sum != null) { + if (categoryWeight == null) { + finestCategory.setComputedWeight(sum); + for (BenthosBatchRowModel child : children) { + child.getFinestCategory().setSubSample(false); + } + + } else if (categoryWeight < sum) { + throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight")); + + } else { + boolean subSample = categoryWeight > sum; + for (BenthosBatchRowModel child : children) { + child.getFinestCategory().setSubSample(subSample); + } + sum = categoryWeight; + } + result = sum; + } + + } else {// the row is a leaf + row.setComputedWeight(null); + + List<BenthosFrequencyRowModel> frequency = row.getFrequency(); + + if (CollectionUtils.isNotEmpty(frequency)) { + // if there are frequencies, then compute their weight + Float frequencyWeight = 0f; + for (BenthosFrequencyRowModel frequencyModel : frequency) { + Float w = frequencyModel.getWeight(); + if (w == null) { + + // can't sum when a null value appears + frequencyWeight = null; + break; + + } else if (frequencyWeight != null) { + + // still can sum weights + frequencyWeight += w; + } + } + + if (categoryWeight == null && rowWeight != null) { + throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightCategory")); + + } else if (categoryWeight == null && frequencyWeight != null) { + // if the category weight is null and the frequencies have a weight, + // then this weight is the result + finestCategory.setComputedWeight(frequencyWeight); + result = frequencyWeight; + + } else if (frequencyWeight != null + && !frequencyWeight.equals(categoryWeight)) { + + // if the weight of the frequencies is different from the category + // weight, then set the weight of the sample + if (frequencyWeight > categoryWeight) { + throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentCategoryWeight")); + + } else if (rowWeight == null) { + row.setComputedWeight(frequencyWeight); + + } else if (!rowWeight.equals(frequencyWeight)) { + throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightFrequency")); + } + result = categoryWeight; + + } else { + result = categoryWeight; + } + + } else { + result = categoryWeight; + } + } + + return result; + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -63,6 +63,10 @@ rightDecoration: {speciesTabContent.getSpeciesBatchTabToolBar()}; } +#benthosTabFishingOperationReminderLabel { + rightDecoration: {benthosTabContent.getBenthosBatchTabToolBar()}; +} + #catchTable { border: {BorderFactory.createTitledBorder(_("tutti.editCatchBatch.legend.total"))}; } @@ -204,6 +208,10 @@ _computed: true; } +#benthosTabPanel { + layout:{benthosTabPanelLayout}; +} + #benthosTable { border: {BorderFactory.createTitledBorder(_("tutti.editCatchBatch.legend.benthos"))}; } @@ -217,6 +225,7 @@ } #benthosTotalWeightField { + text: {getWeightStringValue(model.getBenthosTotalComputedWeight())}; _computed: true; } @@ -228,6 +237,9 @@ } #benthosTotalSortedWeightField { + text: {model.getBenthosTotalSortedWeight() != null ? + getStringValue(model.getBenthosTotalSortedWeight()) : + getWeightStringValue(model.getBenthosTotalSortedComputedWeight())}; _computed: true; } @@ -240,6 +252,7 @@ } #benthosTotalSampleSortedWeightField { + text: {getWeightStringValue(model.getBenthosTotalSampleSortedComputedWeight())}; _computed: true; } @@ -251,9 +264,11 @@ } #benthosTotalUnsortedWeightField { + text: {getWeightStringValue(model.getBenthosTotalUnsortedComputedWeight())}; _computed: true; } + #macroWasteTable { border: {BorderFactory.createTitledBorder(_("tutti.editCatchBatch.legend.macroWaste"))}; } @@ -270,10 +285,6 @@ _computed: true; } -#benthosTab { - enabled: {false}; -} - #planktonTab { enabled: {false}; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -30,11 +30,14 @@ fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUI fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI + fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyUI + fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUI + fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUI fr.ifremer.tutti.ui.swing.content.operation.catches.macrowaste.MacroWasteBatchUI fr.ifremer.tutti.ui.swing.content.operation.catches.plankton.PlanktonBatchUI fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI - fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI + fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUI fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI @@ -84,10 +87,6 @@ <field name='benthosTotalSortedWeight' component='benthosTotalSortedWeightField'/> - <field name='benthosTotalSampleSortedWeight' - component='benthosTotalSampleSortedWeightField'/> - <field name='benthosTotalUnsortedWeight' - component='benthosTotalUnsortedWeightField'/> <field name='macroWasteTotalWeight' component='macroWasteTotalWeightField'/> @@ -96,6 +95,9 @@ <CardLayout2Ext id='speciesTabPanelLayout' constructorParams='this, "speciesTabPanel"'/> + <CardLayout2Ext id='benthosTabPanelLayout' + constructorParams='this, "benthosTabPanel"'/> + <CardLayout2Ext id='catchTotalSortedWeightPanelLayout' constructorParams='this, "catchTotalSortedWeightPanel"'/> @@ -231,6 +233,7 @@ <row> <cell> <Table id='benthosTable' fill='both'> + <!-- Poids total capture --> <row> <cell anchor='west'> @@ -318,9 +321,27 @@ </JPanel> </tab> <tab id='benthosTab' title='tutti.label.tab.benthos'> - <!--JXTitledPanel id='benthosTabFishingOperationReminderLabel'> - <BenthosBatchUI id='benthosTabContent' constructorParams='this'/> - </JXTitledPanel--> + <JPanel id='benthosTabPanel'> + <JXTitledPanel id='benthosTabFishingOperationReminderLabel' + constraints='EditCatchesUIHandler.MAIN_CARD'> + <BenthosBatchUI id='benthosTabContent' constructorParams='this'/> + </JXTitledPanel> + <JXTitledPanel id='benthosTabCreateBatchReminderLabel' + constraints='EditCatchesUIHandler.CREATE_BATCH_CARD'> + <CreateBenthosBatchUI id='benthosTabCreateBatch' + constructorParams='this'/> + </JXTitledPanel> + <JXTitledPanel id='benthosTabSplitBatchReminderLabel' + constraints='EditCatchesUIHandler.SPLIT_BATCH_CARD'> + <SplitBenthosBatchUI id='benthosTabSplitBatch' + constructorParams='this'/> + </JXTitledPanel> + <JXTitledPanel id='benthosTabFrequencyEditorReminderLabel' + constraints='EditCatchesUIHandler.EDIT_FREQUENCY_CARD'> + <BenthosFrequencyUI id='benthosTabFrequencyEditor' + constructorParams='benthosTabContent'/> + </JXTitledPanel> + </JPanel> </tab> <tab id='planktonTab' title='tutti.label.tab.plancton'> <!--JXTitledPanel id='planktonTabFishingOperationReminderLabel'> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -45,9 +45,7 @@ import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.io.File; import java.util.Set; -import javax.swing.Action; import static org.nuiton.i18n.I18n._; import static org.nuiton.i18n.I18n.n_; @@ -88,7 +86,8 @@ super(parentUi.getHandler().getContext(), ui); this.parentUi = parentUi; this.catchBatchMonitor = new TuttiBeanMonitor<EditCatchesUIModel>( - EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT); + EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT); } //------------------------------------------------------------------------// @@ -135,7 +134,7 @@ ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI(); // close batches tabs, then general tab closeUI(ui.getSpeciesTabContent()); -// closeUI(ui.getBenthosTabContent()); + closeUI(ui.getBenthosTabContent()); // closeUI(ui.getPlanktonTabContent()); // closeUI(ui.getMacroWasteTabContent()); // closeUI(ui.getAccidentalTabContent()); @@ -159,7 +158,13 @@ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_COMPUTED_WEIGHT, EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_INERT_COMPUTED_WEIGHT, - EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT + EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_INERT_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT )); return result; } @@ -173,6 +178,7 @@ protected boolean onTabChanged(int currentIndex, int newIndex) { ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI(); ui.getSpeciesTabContent().getSpeciesBatchAttachmentsButton().onCloseUI(); + ui.getBenthosTabContent().getBenthosBatchAttachmentsButton().onCloseUI(); return super.onTabChanged(currentIndex, newIndex); } @@ -181,7 +187,8 @@ ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI(); ui.getSpeciesTabContent().getSpeciesBatchAttachmentsButton().onCloseUI(); - //FIXME 20130203 kmorin: cannot change tab if model is modified + ui.getBenthosTabContent().getBenthosBatchAttachmentsButton().onCloseUI(); + //FIXME 20130203 kmorin: cannot change tab if model is modified // (I do not even know why it is set to modified and have no time // before the demo) EditCatchesUIModel model = getModel(); @@ -261,7 +268,9 @@ } protected void registerValidators() { - registerValidators(getValidator(), ui.getSpeciesTabContent().getHandler().getValidator()); + registerValidators(getValidator(), + ui.getSpeciesTabContent().getHandler().getValidator(), + ui.getBenthosTabContent().getHandler().getValidator()); } public void setSpeciesSelectedCard(String card) { @@ -303,6 +312,45 @@ } } + public void setBenthosSelectedCard(String card) { + JPanel panel = ui.getBenthosTabPanel(); + CardLayout2Ext layout = (CardLayout2Ext) panel.getLayout(); + layout.setSelected(card); + + JPanel actionPanel = getUI().getCreateFishingOperationActions(); + if (MAIN_CARD.equals(card)) { + registerValidators(); + actionPanel.setVisible(true); + } else { + actionPanel.setVisible(false); + TuttiUI tuttiUi = null; + JXTitledPanel titlePanel = null; + String title = ""; + if (CREATE_BATCH_CARD.equals(card)) { + tuttiUi = ui.getBenthosTabCreateBatch(); + titlePanel = ui.getBenthosTabCreateBatchReminderLabel(); + title = n_("tutti.createBenthosBatch.title"); + + } else if (SPLIT_BATCH_CARD.equals(card)) { + tuttiUi = ui.getBenthosTabSplitBatch(); + titlePanel = ui.getBenthosTabSplitBatchReminderLabel(); + title = n_("tutti.splitBenthosBatch.title"); + + } else if (EDIT_FREQUENCY_CARD.equals(card)) { + tuttiUi = ui.getBenthosTabFrequencyEditor(); + titlePanel = ui.getBenthosTabFrequencyEditorReminderLabel(); + title = n_("tutti.editBenthosFrequencies.title"); + } + + if (tuttiUi != null) { + registerValidators(tuttiUi.getHandler().getValidator()); + } + if (titlePanel != null) { + titlePanel.setTitle(ui.getBenthosTabFishingOperationReminderLabel().getTitle() + " - " + _(title)); + } + } + } + public void selectCatchTotalSortedWeightPanel(Vessel vessel) { String card; String carousselTremieVesselId = getConfig().getTremieCarousselVesselId(); 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -88,14 +88,24 @@ public static final String PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT = "speciesTotalLivingNotItemizedComputedWeight"; - public static final String PROPERTY_BENTHOS_TOTAL_WEIGHT = "benthosTotalWeight"; + public static final String PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT = "benthosTotalComputedWeight"; public static final String PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT = "benthosTotalSortedWeight"; - public static final String PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT = "benthosTotalUnsortedWeight"; + public static final String PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT = "benthosTotalSortedComputedWeight"; - public static final String PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT = "benthosTotalSampleSortedWeight"; + public static final String PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT = "benthosTotalUnsortedComputedWeight"; + public static final String PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT = "benthosTotalSampleSortedComputedWeight"; + + public static final String PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT = "benthosTotalInertWeight"; + + public static final String PROPERTY_BENTHOS_TOTAL_INERT_COMPUTED_WEIGHT = "benthosTotalInerComputedtWeight"; + + public static final String PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT = "benthosTotalLivingNotItemizedWeight"; + + public static final String PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT = "benthosTotalLivingNotItemizedComputedWeight"; + public static final String PROPERTY_PLANKTON_TOTAL_WEIGHT = "planktonTotalWeight"; public static final String PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT = "planktonTotalSampleWeight"; @@ -122,14 +132,18 @@ protected TuttiComputedOrNotData<Float> speciesTotalLivingNotItemizedComputedOrNotWeight = new TuttiComputedOrNotData<Float>(); - protected Float benthosTotalWeight; + protected Float benthosTotalComputedWeight; - protected Float benthosTotalSortedWeight; + protected TuttiComputedOrNotData<Float> benthosTotalSortedComputedOrNotWeight = new TuttiComputedOrNotData<Float>(); - protected Float benthosTotalUnsortedWeight; + protected Float benthosTotalUnsortedComputedWeight; - protected Float benthosTotalSampleSortedWeight; + protected Float benthosTotalSampleSortedComputedWeight; + protected TuttiComputedOrNotData<Float> benthosTotalInertComputedOrNotWeight = new TuttiComputedOrNotData<Float>(); + + protected TuttiComputedOrNotData<Float> benthosTotalLivingNotItemizedComputedOrNotWeight = new TuttiComputedOrNotData<Float>(); + protected Float planktonTotalWeight; protected Float planktonTotalSampleWeight; @@ -175,6 +189,16 @@ evt.getOldValue(), evt.getNewValue()); } }); + benthosTotalSortedComputedOrNotWeight.addPropertyChangeListener( + TuttiComputedOrNotData.PROPERTY_DATA, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange(PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, + evt.getOldValue(), evt.getNewValue()); + } + }); + catchTotalComputedOrNotWeight.addPropertyChangeListener( TuttiComputedOrNotData.PROPERTY_DATA, new PropertyChangeListener() { @@ -226,6 +250,10 @@ return speciesUsed; } + //------------------------------------------------------------------------// + //-- Total --// + //------------------------------------------------------------------------// + public TuttiComputedOrNotData<Float> getCatchTotalComputedOrNotWeight() { return catchTotalComputedOrNotWeight; } @@ -314,6 +342,10 @@ firePropertyChange(PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT, oldValue, catchTotalRejectedComputedWeight); } + //------------------------------------------------------------------------// + //-- Species --// + //------------------------------------------------------------------------// + public Float getSpeciesTotalComputedWeight() { return speciesTotalComputedWeight; } @@ -416,46 +448,117 @@ firePropertyChange(PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT, oldValue, speciesTotalLivingNotItemizedComputedWeight); } - public Float getBenthosTotalWeight() { - return benthosTotalWeight; - } + //------------------------------------------------------------------------// + //-- Benthos --// + //------------------------------------------------------------------------// - public void setBenthosTotalWeight(Float benthosTotalWeight) { - Object oldValue = getBenthosTotalWeight(); - this.benthosTotalWeight = benthosTotalWeight; - firePropertyChange(PROPERTY_BENTHOS_TOTAL_WEIGHT, oldValue, benthosTotalWeight); + public Float getBenthosTotalComputedWeight() { + return benthosTotalComputedWeight; } - public Float getBenthosTotalSampleSortedWeight() { - return benthosTotalSampleSortedWeight; + public void setBenthosTotalComputedWeight(Float benthosTotalComputedWeight) { + Object oldValue = getBenthosTotalComputedWeight(); + this.benthosTotalComputedWeight = benthosTotalComputedWeight; + firePropertyChange(PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, oldValue, benthosTotalComputedWeight); } - public void setBenthosTotalSampleSortedWeight(Float benthosTotalSampleSortedWeight) { - Object oldValue = getBenthosTotalSampleSortedWeight(); - this.benthosTotalSampleSortedWeight = benthosTotalSampleSortedWeight; - firePropertyChange(PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT, oldValue, benthosTotalSampleSortedWeight); + public TuttiComputedOrNotData<Float> getBenthosTotalSortedComputedOrNotWeight() { + return benthosTotalSortedComputedOrNotWeight; } public Float getBenthosTotalSortedWeight() { - return benthosTotalSortedWeight; + return benthosTotalSortedComputedOrNotWeight.getData(); } public void setBenthosTotalSortedWeight(Float benthosTotalSortedWeight) { Object oldValue = getBenthosTotalSortedWeight(); - this.benthosTotalSortedWeight = benthosTotalSortedWeight; + this.benthosTotalSortedComputedOrNotWeight.setData(benthosTotalSortedWeight); firePropertyChange(PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, oldValue, benthosTotalSortedWeight); } - public Float getBenthosTotalUnsortedWeight() { - return benthosTotalUnsortedWeight; + public Float getBenthosTotalSortedComputedWeight() { + return benthosTotalSortedComputedOrNotWeight.getComputedData(); } - public void setBenthosTotalUnsortedWeight(Float benthosTotalUnsortedWeight) { - Object oldValue = getBenthosTotalUnsortedWeight(); - this.benthosTotalUnsortedWeight = benthosTotalUnsortedWeight; - firePropertyChange(PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT, oldValue, benthosTotalUnsortedWeight); + public void setBenthosTotalSortedComputedWeight(Float benthosTotalSortedComputedWeight) { + Object oldValue = getBenthosTotalSortedComputedWeight(); + this.benthosTotalSortedComputedOrNotWeight.setComputedData(benthosTotalSortedComputedWeight); + firePropertyChange(PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT, oldValue, benthosTotalSortedComputedWeight); } + public Float getBenthosTotalSampleSortedComputedWeight() { + return benthosTotalSampleSortedComputedWeight; + } + + public void setBenthosTotalSampleSortedComputedWeight(Float benthosTotalSampleSortedComputedWeight) { + Object oldValue = getBenthosTotalSampleSortedComputedWeight(); + this.benthosTotalSampleSortedComputedWeight = benthosTotalSampleSortedComputedWeight; + firePropertyChange(PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, oldValue, benthosTotalSampleSortedComputedWeight); + } + + public Float getBenthosTotalUnsortedComputedWeight() { + return benthosTotalUnsortedComputedWeight; + } + + public void setBenthosTotalUnsortedComputedWeight(Float benthosTotalUnsortedComputedWeight) { + Object oldValue = getBenthosTotalUnsortedComputedWeight(); + this.benthosTotalUnsortedComputedWeight = benthosTotalUnsortedComputedWeight; + firePropertyChange(PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT, oldValue, benthosTotalUnsortedComputedWeight); + } + + public TuttiComputedOrNotData<Float> getBenthosTotalInertComputedOrNotWeight() { + return benthosTotalInertComputedOrNotWeight; + } + + public Float getBenthosTotalInertWeight() { + return benthosTotalInertComputedOrNotWeight.getData(); + } + + public void setBenthosTotalInertWeight(Float benthosTotalInertWeight) { + Object oldValue = getBenthosTotalInertWeight(); + this.benthosTotalInertComputedOrNotWeight.setData(benthosTotalInertWeight); + firePropertyChange(PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, oldValue, benthosTotalInertWeight); + } + + public Float getBenthosTotalInertComputedWeight() { + return benthosTotalInertComputedOrNotWeight.getComputedData(); + } + + public void setBenthosTotalInertComputedWeight(Float benthosTotalInertComputedWeight) { + Object oldValue = getBenthosTotalInertComputedWeight(); + this.benthosTotalInertComputedOrNotWeight.setComputedData(benthosTotalInertComputedWeight); + firePropertyChange(PROPERTY_BENTHOS_TOTAL_INERT_COMPUTED_WEIGHT, oldValue, benthosTotalInertComputedWeight); + } + + public TuttiComputedOrNotData<Float> getBenthosTotalLivingNotItemizedComputedOrNotWeight() { + return benthosTotalLivingNotItemizedComputedOrNotWeight; + } + + public Float getBenthosTotalLivingNotItemizedWeight() { + return benthosTotalLivingNotItemizedComputedOrNotWeight.getData(); + } + + public void setBenthosTotalLivingNotItemizedWeight(Float benthosTotalLivingNotItemizedWeight) { + Object oldValue = getBenthosTotalLivingNotItemizedComputedWeight(); + this.benthosTotalLivingNotItemizedComputedOrNotWeight.setData(benthosTotalLivingNotItemizedWeight); + firePropertyChange(PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, oldValue, benthosTotalLivingNotItemizedWeight); + } + + public Float getBenthosTotalLivingNotItemizedComputedWeight() { + return benthosTotalLivingNotItemizedComputedOrNotWeight.getComputedData(); + } + + public void setBenthosTotalLivingNotItemizedComputedWeight(Float benthosTotalLivingNotItemizedComputedWeight) { + Object oldValue = getBenthosTotalLivingNotItemizedComputedWeight(); + this.benthosTotalLivingNotItemizedComputedOrNotWeight.setComputedData(benthosTotalLivingNotItemizedComputedWeight); + firePropertyChange(PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT, oldValue, benthosTotalLivingNotItemizedComputedWeight); + } + + //------------------------------------------------------------------------// + //-- Plankton --// + //------------------------------------------------------------------------// + + public Float getPlanktonTotalWeight() { return planktonTotalWeight; } @@ -476,6 +579,10 @@ firePropertyChange(PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT, oldValue, planktonTotalSampleWeight); } + //------------------------------------------------------------------------// + //-- Macro Waste --// + //------------------------------------------------------------------------// + public Float getMacroWasteTotalWeight() { return macroWasteTotalWeight; } @@ -486,6 +593,10 @@ firePropertyChange(PROPERTY_MACRO_WASTE_TOTAL_WEIGHT, oldValue, macroWasteTotalWeight); } + //------------------------------------------------------------------------// + //-- Attachment --// + //------------------------------------------------------------------------// + @Override public AttachementObjectTypeEnum getObjectType() { return AttachementObjectTypeEnum.CATCH_BATCH; @@ -532,11 +643,18 @@ setSpeciesTotalSortedComputedWeight(null); setSpeciesTotalUnsortedComputedWeight(null); setSpeciesTotalComputedWeight(null); + setBenthosTotalInertComputedWeight(null); + setBenthosTotalLivingNotItemizedComputedWeight(null); + setBenthosTotalSampleSortedComputedWeight(null); + setBenthosTotalSortedComputedWeight(null); + setBenthosTotalUnsortedComputedWeight(null); + setBenthosTotalComputedWeight(null); setCatchTotalRejectedComputedWeight(null); setCatchTotalSortedComputedWeight(null); setCatchTotalUnsortedComputedWeight(null); setCatchTotalComputedWeight(null); removeAllAttachment(getAttachment()); + getSpeciesUsed().clear(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -25,7 +25,6 @@ */ import com.google.common.base.Function; -import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; @@ -33,26 +32,25 @@ 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.protocol.SpeciesProtocol; +import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum; 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.PersistenceService; import fr.ifremer.tutti.service.pupitri.TuttiPupitriImportExportService; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRootRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JOptionPane; import java.io.File; -import java.util.Collection; import java.util.List; import java.util.Map; -import javax.swing.JOptionPane; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import static org.nuiton.i18n.I18n._; @@ -95,9 +93,9 @@ if (!result) { JOptionPane.showMessageDialog(getContext().getActionUI(), - _("tutti.editCatchBatch.action.importPupitri.noProtocol.message"), - _("tutti.editCatchBatch.action.importPupitri.noProtocol.title"), - JOptionPane.ERROR_MESSAGE); + _("tutti.editCatchBatch.action.importPupitri.noProtocol.message"), + _("tutti.editCatchBatch.action.importPupitri.noProtocol.title"), + JOptionPane.ERROR_MESSAGE); } SpeciesBatchUIModel speciesBatchUIModel = getUI().getSpeciesTabContent().getModel(); @@ -122,7 +120,7 @@ importedCarrouselFile = importPupitriDialog.getCarrouselFile().getSelectedFile(); result = importedTrunkFile != null && importedCarrouselFile != null; } - + return result; } @@ -132,7 +130,7 @@ getContext().getTuttiPupitriImportExportService(); EditCatchesUIModel model = getModel(); - + FishingOperation operation = model.getFishingOperation(); CatchBatch catchBatch = model.getCatchBatch(); @@ -162,24 +160,19 @@ // get the map of species by survey code Multimap<String, Species> speciesBySurveyCode = Multimaps.index(getDataContext().getReferentSpeciesWithSurveyCode(), new Function<Species, String>() { - @Override - public String apply(Species input) { - String surveyCode = String.valueOf(input.getSurveyCode()); - int end = Math.min(surveyCode.length(), 7); - return surveyCode.substring(0, end); - } - }); + @Override + public String apply(Species input) { + String surveyCode = String.valueOf(input.getSurveyCode()); + int end = Math.min(surveyCode.length(), 7); + return surveyCode.substring(0, end); + } + }); // get the sorted/unsorted caracteristic Caracteristic caracteristic = persistenceService.getSortedUnsortedCaracteristic(); - CaracteristicQualitativeValue sortedvalue = null; - for (CaracteristicQualitativeValue value : caracteristic.getQualitativeValue()) { - if (persistenceService.isSortedQualitativeValue(value)) { - sortedvalue = value; - break; - } - } + CaracteristicQualitativeValue sortedvalue = + SortedUnsortedEnum.SORTED.getValue(caracteristic); // add the valid species in the species table SpeciesBatchUIHandler speciesBatchUIHandler = getUI().getSpeciesTabContent().getHandler(); @@ -190,7 +183,7 @@ if (!speciesList.isEmpty()) { Species species = speciesList.get(0); ImportPupitriSpeciesBatchRootRowModel rowModel = new ImportPupitriSpeciesBatchRootRowModel(species, sortedvalue, weight); - speciesBatchUIHandler.addSpeciesBatch(rowModel); + speciesBatchUIHandler.addBatch(rowModel); } } @@ -208,7 +201,7 @@ attachment.setName(f.getName()); attachment.setComment("import pupitri"); attachment = persistenceService.createAttachment(attachment, f); - + model.addAttachment(attachment); } @@ -235,9 +228,9 @@ Float batchWeight; public ImportPupitriSpeciesBatchRootRowModel(Species species, - CaracteristicQualitativeValue sortedUnsortedCategory, - Float batchWeight) { - + CaracteristicQualitativeValue sortedUnsortedCategory, + Float batchWeight) { + this.species = species; this.sortedUnsortedCategory = sortedUnsortedCategory; this.batchWeight = batchWeight; Modified: 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/SampleCategory.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java 2013-03-23 18:20:58 UTC (rev 666) @@ -24,6 +24,7 @@ * #L% */ +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import java.io.Serializable; @@ -43,7 +44,7 @@ * * @since 0.3 */ - protected SampleCategoryType categoryType; + protected SampleCategoryEnum categoryType; /** * Sample category value. @@ -82,7 +83,7 @@ */ protected boolean onlyOneFrequency; - public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryType categoryType) { + public static <C extends Serializable> SampleCategory<C> newSample(SampleCategoryEnum categoryType) { SampleCategory<C> result = new SampleCategory<C>(); result.setCategoryType(categoryType); return result; @@ -91,11 +92,11 @@ protected SampleCategory() { } - public SampleCategoryType getCategoryType() { + public SampleCategoryEnum getCategoryType() { return categoryType; } - public void setCategoryType(SampleCategoryType categoryType) { + public void setCategoryType(SampleCategoryEnum categoryType) { this.categoryType = categoryType; } Modified: 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 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,5 +1,6 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; @@ -12,10 +13,10 @@ private static final long serialVersionUID = 1L; public static <R> SampleCategoryColumnIdentifier<R> newId(String propertyName, - String weightPropertyName, - SampleCategoryType sampleCategoryType, - String headerI18nKey, - String headerTipI18nKey) { + String weightPropertyName, + SampleCategoryEnum sampleCategoryType, + String headerI18nKey, + String headerTipI18nKey) { return new SampleCategoryColumnIdentifier<R>(propertyName, weightPropertyName, sampleCategoryType, @@ -23,15 +24,15 @@ headerTipI18nKey); } - private final SampleCategoryType sampleCategoryType; + private final SampleCategoryEnum sampleCategoryType; private final String weightPropertyName; SampleCategoryColumnIdentifier(String propertyName, - String weightPropertyName, - SampleCategoryType sampleCategoryType, - String headerI18nKey, - String headerTipI18nKey + String weightPropertyName, + SampleCategoryEnum sampleCategoryType, + String headerI18nKey, + String headerTipI18nKey ) { super(propertyName, headerI18nKey, headerTipI18nKey); this.weightPropertyName = weightPropertyName; @@ -42,7 +43,7 @@ TuttiUIUtil.setProperty(entry, weightPropertyName, value); } - public SampleCategoryType getSampleCategoryType() { + public SampleCategoryEnum getSampleCategoryType() { return sampleCategoryType; } } Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Deleted: 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/SampleCategoryType.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryType.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,98 +0,0 @@ -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/SpeciesBatchRootRowModel.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRootRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchRootRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchRootRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,20 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches; + +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.persistence.entities.referential.Species; + +/** + * TODO explain why ? + * @author kmorin <kmorin@codelutin.com> + * @since 1.2 + */ +public interface SpeciesBatchRootRowModel { + + Species getSpecies(); + + CaracteristicQualitativeValue getSortedUnsortedCategory(); + + Float getBatchWeight(); + + boolean isValid(); +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SpeciesBatchRootRowModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -27,20 +27,29 @@ import com.google.common.collect.Lists; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; +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.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.benthos.frequency.BenthosFrequencyRowModel; 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; import fr.ifremer.tutti.ui.swing.util.comment.CommentModelAware; import org.apache.commons.collections.CollectionUtils; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.Collection; +import java.util.Collections; import java.util.List; /** - * Define a benthos batch row. + * Represents a species batch (i.e a row in the batch table). * * @author tchemit <chemit@codelutin.com> * @since 0.2 @@ -49,18 +58,52 @@ private static final long serialVersionUID = 1L; + public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm"; + public static final String PROPERTY_SPECIES = "species"; - public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm"; + public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory"; + public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue"; + + public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight"; + + public static final String PROPERTY_SORTED_UNSORTED_COMPUTED_WEIGHT = "sortedUnsortedComputedWeight"; + + public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory"; + + public static final String PROPERTY_SIZE_CATEGORY_VALUE = "sizeCategoryValue"; + + public static final String PROPERTY_SIZE_CATEGORY_WEIGHT = "sizeCategoryWeight"; + + public static final String PROPERTY_SEX_CATEGORY = "sexCategory"; + + public static final String PROPERTY_SEX_CATEGORY_VALUE = "sexCategoryValue"; + + public static final String PROPERTY_SEX_CATEGORY_WEIGHT = "sexCategoryWeight"; + + public static final String PROPERTY_MATURITY_CATEGORY = "maturityCategory"; + + public static final String PROPERTY_MATURITY_CATEGORY_VALUE = "maturityCategoryValue"; + + public static final String PROPERTY_MATURITY_CATEGORY_WEIGHT = "maturityCategoryWeight"; + + public static final String PROPERTY_AGE_CATEGORY = "ageCategory"; + + public static final String PROPERTY_AGE_CATEGORY_VALUE = "ageCategoryValue"; + + public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight"; + public static final String PROPERTY_WEIGHT = "weight"; public static final String PROPERTY_NUMBER = "number"; - public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; + public static final String PROPERTY_FREQUENCY = "frequency"; -// public static final String PROPERTY_ATTACHMENTS = "attachments"; + public static final String PROPERTY_COMPUTED_NUMBER = "computedOrNotNumber"; + public static final String PROPERTY_COMPUTED_WEIGHT = "computedOrNotWeight"; + public static final String PROPERTY_PARENT_BATCH = "parentBatch"; public static final String PROPERTY_CHILD_BATCH = "childBatch"; @@ -69,44 +112,84 @@ public static final String PROPERTY_BATCH_ROOT = "batchRoot"; + public static final String PROPERTY_SAMPLE_CATEGORY = "sampleCategory"; /** - * Species observed. + * Species. * - * @since 0.2 + * @since 0.3 */ protected Species species; /** - * Is the species need to be confirmed?. + * Is catch is vrac or horsVrac?. * * @since 0.2 */ - protected boolean speciesToConfirm; + protected SampleCategory<CaracteristicQualitativeValue> sortedUnsortedCategory; /** - * Observed weight. + * Weight category (can be null). * * @since 0.2 */ - protected Float weight; + protected SampleCategory<CaracteristicQualitativeValue> sizeCategory; /** - * Observed number. + * Sex (can be null). * + * @since 0.2 + */ + protected SampleCategory<CaracteristicQualitativeValue> sexCategory; + + /** + * Maturity (can be null). + * + * @since 0.2 + */ + protected SampleCategory<CaracteristicQualitativeValue> maturityCategory; + + /** + * Age (can be null). + * + * @since 0.2 + */ + protected SampleCategory<Float> ageCategory; + + /** + * Sample category of this batch. + * <p/> + * This is one of the sample category befined above, used to know if the + * table row which sample category affects this row exactly. + * * @since 0.3 */ - protected Integer number; + private SampleCategory<?> sampleCategory; /** - * Sample weight. + * Is the species need to be confirmed?. * * @since 0.2 */ - protected Float sampleWeight; + protected boolean speciesToConfirm; + /** + * Observed weight. + * + * @since 0.2 + */ + protected TuttiComputedOrNotData<Float> computedOrNotWeight = + new TuttiComputedOrNotData<Float>(); /** + * Total computed number (from frequencies). + * + * @since 0.2 + */ + protected TuttiComputedOrNotData<Integer> computedOrNotNumber = + new TuttiComputedOrNotData<Integer>(); + + /** * Comment. * * @since 0.2 @@ -121,6 +204,13 @@ protected final List<Attachment> attachment = Lists.newArrayList(); /** + * List of frequencies observed for this batch. + * + * @since 0.2 + */ + protected List<BenthosFrequencyRowModel> frequency = Lists.newArrayList(); + + /** * Parent of this batch (can be null if batch is root). * * @see #isBatchRoot() @@ -146,54 +236,291 @@ public BenthosBatchRowModel() { super(SpeciesBatch.class, fromBeanBinder, toBeanBinder); + sortedUnsortedCategory = SampleCategory.newSample(SampleCategoryEnum.sortedUnsorted); + sizeCategory = SampleCategory.newSample(SampleCategoryEnum.size); + sexCategory = SampleCategory.newSample(SampleCategoryEnum.sex); + maturityCategory = SampleCategory.newSample(SampleCategoryEnum.maturity); + ageCategory = SampleCategory.newSample(SampleCategoryEnum.age); + + computedOrNotWeight.addPropertyChangeListener( + TuttiComputedOrNotData.PROPERTY_DATA, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange(PROPERTY_WEIGHT, evt.getOldValue(), evt.getNewValue()); + } + }); + computedOrNotWeight.addPropertyChangeListener( + TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange(PROPERTY_COMPUTED_WEIGHT, evt.getOldValue(), evt.getNewValue()); + } + }); + + computedOrNotNumber.addPropertyChangeListener( + TuttiComputedOrNotData.PROPERTY_DATA, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange(PROPERTY_NUMBER, evt.getOldValue(), evt.getNewValue()); + } + }); + computedOrNotNumber.addPropertyChangeListener( + TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + firePropertyChange(PROPERTY_COMPUTED_NUMBER, evt.getOldValue(), evt.getNewValue()); + } + }); } - public BenthosBatchRowModel(SpeciesBatch aBatch) { + public BenthosBatchRowModel(SpeciesBatch aBatch, + List<SpeciesBatchFrequency> frequencies, + List<Attachment> attachments) { this(); fromBean(aBatch); + List<BenthosFrequencyRowModel> frequencyRows = + BenthosFrequencyRowModel.fromBeans(frequencies); + frequency.addAll(frequencyRows); + this.attachment.addAll(attachments); + Collections.sort(frequency); } + //------------------------------------------------------------------------// + //-- Sample category --// + //------------------------------------------------------------------------// + + public SampleCategory<?> getSampleCategory() { + return sampleCategory; + } + + public void setSampleCategory(SampleCategory<?> sampleCategory) { + Object oldValue = getSampleCategory(); + this.sampleCategory = sampleCategory; + firePropertyChange(PROPERTY_SAMPLE_CATEGORY, oldValue, sampleCategory); + } + + public SampleCategory<?> getSampleCategory(SampleCategoryEnum sampleCategoryEnum) { + switch (sampleCategoryEnum) { + case sortedUnsorted: + sampleCategory = getSortedUnsortedCategory(); + break; + case size: + sampleCategory = getSizeCategory(); + break; + case sex: + sampleCategory = getSexCategory(); + break; + case maturity: + sampleCategory = getMaturityCategory(); + break; + case age: + sampleCategory = getAgeCategory(); + break; + default: + } + return sampleCategory; + } + + public SampleCategory getFinestCategory() { + SampleCategory finestCategory; + if (ageCategory.isValid()) { + finestCategory = ageCategory; + + } else if (maturityCategory.isValid()) { + finestCategory = maturityCategory; + + } else if (sexCategory.isValid()) { + finestCategory = sexCategory; + + } else if (sizeCategory.isValid()) { + finestCategory = sizeCategory; + + } else { + finestCategory = sortedUnsortedCategory; + } + return finestCategory; + } + + //------------------------------------------------------------------------// + //-- Species category --// + //------------------------------------------------------------------------// + public Species getSpecies() { return species; } public void setSpecies(Species species) { - Object oldValue = getSpecies(); + Object oldCategory = getSpecies(); this.species = species; - firePropertyChange(PROPERTY_SPECIES, oldValue, species); + firePropertyChange(PROPERTY_SPECIES, oldCategory, species); } - public Boolean getSpeciesToConfirm() { - return speciesToConfirm; + //------------------------------------------------------------------------// + //-- SortedUnsorted category --// + //------------------------------------------------------------------------// + + public SampleCategory<CaracteristicQualitativeValue> getSortedUnsortedCategory() { + return sortedUnsortedCategory; } - public void setSpeciesToConfirm(Boolean speciesToConfirm) { - Object oldValue = getSpeciesToConfirm(); - this.speciesToConfirm = speciesToConfirm; - firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); + public void setSortedUnsortedCategory(SampleCategory<CaracteristicQualitativeValue> sortedUnsortedCategory) { + Object oldCategory = getSortedUnsortedCategory(); + Object oldValue = getSortedUnsortedCategoryValue(); + Object oldWeight = getSortedUnsortedCategoryWeight(); + this.sortedUnsortedCategory = sortedUnsortedCategory; + firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldCategory, sortedUnsortedCategory); + firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE, oldValue, getSortedUnsortedCategoryValue()); + firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldWeight, getSortedUnsortedCategoryWeight()); } - public Float getWeight() { - return weight; + public CaracteristicQualitativeValue getSortedUnsortedCategoryValue() { + return sortedUnsortedCategory.getCategoryValue(); } - public void setWeight(Float weight) { - Object oldValue = getWeight(); - this.weight = weight; - firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + public Float getSortedUnsortedCategoryWeight() { + return sortedUnsortedCategory.getCategoryWeight(); } - public Float getSampleWeight() { - return sampleWeight; + public void setSortedUnsortedCategoryWeight(Float sortedUnsortedCategoryWeight) { + Object oldValue = getSortedUnsortedCategoryWeight(); + sortedUnsortedCategory.setCategoryWeight(sortedUnsortedCategoryWeight); + firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldValue, sortedUnsortedCategoryWeight); } - public void setSampleWeight(Float sampleWeight) { - Object oldValue = getSampleWeight(); - this.sampleWeight = sampleWeight; - firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight); + //------------------------------------------------------------------------// + //-- Size category --// + //------------------------------------------------------------------------// + + public SampleCategory<CaracteristicQualitativeValue> getSizeCategory() { + return sizeCategory; } + public void setSizeCategory(SampleCategory<CaracteristicQualitativeValue> sizeCategory) { + Object oldCategory = getSizeCategory(); + Object oldValue = getSizeCategoryValue(); + Object oldWeight = getSizeCategoryWeight(); + this.sizeCategory = sizeCategory; + firePropertyChange(PROPERTY_SIZE_CATEGORY, oldCategory, sizeCategory); + firePropertyChange(PROPERTY_SIZE_CATEGORY_VALUE, oldValue, getSizeCategoryValue()); + firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldWeight, getSizeCategoryWeight()); + } + + public CaracteristicQualitativeValue getSizeCategoryValue() { + return sizeCategory.getCategoryValue(); + } + + public Float getSizeCategoryWeight() { + return sizeCategory.getCategoryWeight(); + } + + public void setSizeCategoryWeight(Float sizeCategoryWeight) { + Object oldValue = getSizeCategoryWeight(); + this.sizeCategory.setCategoryWeight(sizeCategoryWeight); + firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldValue, sizeCategoryWeight); + } + //------------------------------------------------------------------------// + //-- Sex category --// + //------------------------------------------------------------------------// + + public SampleCategory<CaracteristicQualitativeValue> getSexCategory() { + return sexCategory; + } + + public void setSexCategory(SampleCategory<CaracteristicQualitativeValue> sexCategory) { + Object oldCategory = getSexCategory(); + Object oldValue = getSexCategoryValue(); + Object oldWeight = getSexCategoryWeight(); + this.sexCategory = sexCategory; + firePropertyChange(PROPERTY_SEX_CATEGORY, oldCategory, sexCategory); + firePropertyChange(PROPERTY_SEX_CATEGORY_VALUE, oldValue, getSexCategoryValue()); + firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldWeight, getSexCategoryWeight()); + } + + public CaracteristicQualitativeValue getSexCategoryValue() { + return sexCategory.getCategoryValue(); + } + + public Float getSexCategoryWeight() { + return sexCategory.getCategoryWeight(); + } + + public void setSexCategoryWeight(Float sexCategoryWeight) { + Object oldValue = getSexCategoryWeight(); + this.sexCategory.setCategoryWeight(sexCategoryWeight); + firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldValue, sexCategoryWeight); + } + + //------------------------------------------------------------------------// + //-- Maturity category --// + //------------------------------------------------------------------------// + + public SampleCategory<CaracteristicQualitativeValue> getMaturityCategory() { + return maturityCategory; + } + + public void setMaturityCategory(SampleCategory<CaracteristicQualitativeValue> maturityCategory) { + Object oldCategory = getMaturityCategory(); + Object oldValue = getMaturityCategoryValue(); + Object oldWeight = getMaturityCategoryWeight(); + this.maturityCategory = maturityCategory; + firePropertyChange(PROPERTY_MATURITY_CATEGORY, oldCategory, maturityCategory); + firePropertyChange(PROPERTY_MATURITY_CATEGORY_VALUE, oldValue, getMaturityCategoryValue()); + firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldWeight, getMaturityCategoryWeight()); + } + + public CaracteristicQualitativeValue getMaturityCategoryValue() { + return maturityCategory.getCategoryValue(); + } + + public Float getMaturityCategoryWeight() { + return maturityCategory.getCategoryWeight(); + } + + public void setMaturityCategoryWeight(Float maturityCategoryWeight) { + Object oldValue = getMaturityCategoryWeight(); + this.maturityCategory.setCategoryWeight(maturityCategoryWeight); + firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldValue, maturityCategoryWeight); + } + + //------------------------------------------------------------------------// + //-- Age category --// + //------------------------------------------------------------------------// + + public SampleCategory<Float> getAgeCategory() { + return ageCategory; + } + + public void setAgeCategory(SampleCategory<Float> ageCategory) { + Object oldCategory = getAgeCategory(); + Object oldValue = getAgeCategoryValue(); + Object oldWeight = getAgeCategoryWeight(); + this.ageCategory = ageCategory; + + firePropertyChange(PROPERTY_AGE_CATEGORY, oldCategory, ageCategory); + firePropertyChange(PROPERTY_AGE_CATEGORY_VALUE, oldValue, getAgeCategoryValue()); + firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldWeight, getAgeCategoryWeight()); + } + + public Float getAgeCategoryValue() { + return ageCategory.getCategoryValue(); + } + + public Float getAgeCategoryWeight() { + return ageCategory.getCategoryWeight(); + } + + public void setAgeCategoryWeight(Float ageCategoryWeight) { + Object oldValue = getAgeCategoryWeight(); + ageCategory.setCategoryWeight(ageCategoryWeight); + firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldValue, ageCategoryWeight); + } + + //------------------------------------------------------------------------// //-- Navigation properties --// //------------------------------------------------------------------------// @@ -227,16 +554,6 @@ return parentBatch == null; } - public Integer getNumber() { - return number; - } - - public void setNumber(Integer number) { - Object oldValue = getNumber(); - this.number = number; - firePropertyChange(PROPERTY_NUMBER, oldValue, number); - } - //------------------------------------------------------------------------// //-- CommentModelAware --// //------------------------------------------------------------------------// @@ -296,4 +613,76 @@ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); } + //------------------------------------------------------------------------// + //-- Other properties --// + //------------------------------------------------------------------------// + + public Boolean getSpeciesToConfirm() { + return speciesToConfirm; + } + + public void setSpeciesToConfirm(Boolean speciesToConfirm) { + Object oldValue = getSpeciesToConfirm(); + this.speciesToConfirm = speciesToConfirm; + firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); + } + + public Float getWeight() { + return computedOrNotWeight.getData(); + } + + public void setWeight(Float weight) { + this.computedOrNotWeight.setData(weight); + } + + public Integer getNumber() { + return computedOrNotNumber.getData(); + } + + public void setNumber(Integer number) { + computedOrNotNumber.setData(number); + } + + public List<BenthosFrequencyRowModel> getFrequency() { + return frequency; + } + + public void setFrequency(List<BenthosFrequencyRowModel> frequency) { + this.frequency = frequency; + // force to propagate frequencies changes + firePropertyChange(PROPERTY_FREQUENCY, null, frequency); + } + + public Integer getComputedNumber() { + return computedOrNotNumber.getComputedData(); + } + + public void setComputedNumber(Integer computedNumber) { + computedOrNotNumber.setComputedData(computedNumber); + } + + public Float getComputedWeight() { + return computedOrNotWeight.getComputedData(); + } + + public void setComputedWeight(Float computedWeight) { + computedOrNotWeight.setComputedData(computedWeight); + } + + public TuttiComputedOrNotData<Integer> getComputedOrNotNumber() { + return computedOrNotNumber; + } + + public void setComputedOrNotNumber(TuttiComputedOrNotData<Integer> computedOrNotNumber) { + this.computedOrNotNumber = computedOrNotNumber; + } + + public TuttiComputedOrNotData<Float> getComputedOrNotWeight() { + return computedOrNotWeight; + } + + public void setComputedOrNotWeight(TuttiComputedOrNotData<Float> computedOrNotWeight) { + this.computedOrNotWeight = computedOrNotWeight; + } + } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -24,10 +24,17 @@ * #L% */ +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; +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.SampleCategoryColumnIdentifier; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import org.jdesktop.swingx.table.TableColumnModelExt; +import java.util.Set; + import static org.nuiton.i18n.I18n.n_; /** @@ -38,38 +45,62 @@ private static final long serialVersionUID = 1L; - public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId( + public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES = ColumnIdentifier.newId( BenthosBatchRowModel.PROPERTY_SPECIES, - n_("tutti.editBenthosBatch.table.header.speciesByCode"), - n_("tutti.editBenthosBatch.table.header.speciesByCode")); + n_("tutti.editBenthosBatch.table.header.species"), + n_("tutti.editBenthosBatch.table.header.species")); - public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId( - BenthosBatchRowModel.PROPERTY_SPECIES, - n_("tutti.editBenthosBatch.table.header.speciesByGenusCode"), - n_("tutti.editBenthosBatch.table.header.speciesByGenusCode")); + public static final ColumnIdentifier<BenthosBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, + BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, + SampleCategoryEnum.sortedUnsorted, + n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory"), + n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory")); + public static final ColumnIdentifier<BenthosBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY, + BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, + SampleCategoryEnum.size, + n_("tutti.editBenthosBatch.table.header.sizeCategory"), + n_("tutti.editBenthosBatch.table.header.sizeCategory")); + + public static final ColumnIdentifier<BenthosBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SEX_CATEGORY, + BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, + SampleCategoryEnum.sex, + n_("tutti.editBenthosBatch.table.header.sexCategory"), + n_("tutti.editBenthosBatch.table.header.sexCategory")); + + public static final ColumnIdentifier<BenthosBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY, + BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, + SampleCategoryEnum.maturity, + n_("tutti.editBenthosBatch.table.header.maturityCategory"), + n_("tutti.editBenthosBatch.table.header.maturityCategory")); + + public static final ColumnIdentifier<BenthosBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_AGE_CATEGORY, + BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT, + SampleCategoryEnum.age, + n_("tutti.editBenthosBatch.table.header.ageCategory"), + n_("tutti.editBenthosBatch.table.header.ageCategory")); + public static final ColumnIdentifier<BenthosBatchRowModel> WEIGHT = ColumnIdentifier.newId( - BenthosBatchRowModel.PROPERTY_WEIGHT, + BenthosBatchRowModel.PROPERTY_COMPUTED_WEIGHT, n_("tutti.editBenthosBatch.table.header.weight"), n_("tutti.editBenthosBatch.table.header.weight")); - public static final ColumnIdentifier<BenthosBatchRowModel> NUMBER = ColumnIdentifier.newId( - BenthosBatchRowModel.PROPERTY_NUMBER, - n_("tutti.editBenthosBatch.table.header.number"), - n_("tutti.editBenthosBatch.table.header.number")); + public static final ColumnIdentifier<BenthosBatchRowModel> COMPUTED_NUMBER = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_COMPUTED_NUMBER, + n_("tutti.editBenthosBatch.table.header.computedNumber"), + n_("tutti.editBenthosBatch.table.header.computedNumber")); - - public static final ColumnIdentifier<BenthosBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId( - BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT, - n_("tutti.editBenthosBatch.table.header.sampleWeight"), - n_("tutti.editBenthosBatch.table.header.sampleWeight")); - public static final ColumnIdentifier<BenthosBatchRowModel> COMMENT = ColumnIdentifier.newId( BenthosBatchRowModel.PROPERTY_COMMENT, n_("tutti.editBenthosBatch.table.header.comment"), n_("tutti.editBenthosBatch.table.header.comment")); - public static final ColumnIdentifier<BenthosBatchRowModel> ATTACHMENT = ColumnIdentifier.newId( + public static final ColumnIdentifier<BenthosBatchRowModel> ATTACHMENT = ColumnIdentifier.newReadOnlyId( BenthosBatchRowModel.PROPERTY_ATTACHMENT, n_("tutti.editBenthosBatch.table.header.file"), n_("tutti.editBenthosBatch.table.header.file")); @@ -79,9 +110,34 @@ n_("tutti.editBenthosBatch.table.header.toConfirm"), n_("tutti.editBenthosBatch.table.header.toConfirm")); + /** + * Columns for the frequency edition. + * + * @since 0.2 + */ + protected final Set<ColumnIdentifier<BenthosBatchRowModel>> frequencyCols; + + /** + * Columns implies in the sample category definition. + * + * @since 0.2 + */ + protected final Set<ColumnIdentifier<BenthosBatchRowModel>> sampleCols; + public BenthosBatchTableModel(TableColumnModelExt columnModel) { - super(columnModel, true, true); - setNoneEditableCols(); + super(columnModel, false, false); + setNoneEditableCols(SPECIES); + + frequencyCols = Sets.newHashSet(); + frequencyCols.add(COMPUTED_NUMBER); + frequencyCols.add(WEIGHT); + + sampleCols = Sets.newHashSet(); + sampleCols.add(SORTED_UNSORTED_CATEGORY); + sampleCols.add(SIZE_CATEGORY); + sampleCols.add(SEX_CATEGORY); + sampleCols.add(MATURITY_CATEGORY); + sampleCols.add(AGE_CATEGORY); } @Override @@ -93,4 +149,81 @@ return result; } -} \ No newline at end of file + @Override + public void setValueAt(Object aValue, + int rowIndex, + int columnIndex, + ColumnIdentifier<BenthosBatchRowModel> propertyName, + BenthosBatchRowModel entry) { + if (sampleCols.contains(propertyName)) { + + ((SampleCategoryColumnIdentifier<BenthosBatchRowModel>) propertyName).setWeightValue(entry, aValue); + } else { + super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + } + +// if (propertyName == COMPUTED_NUMBER) { +// +// // update also other columns +// fireTableCellUpdated(rowIndex, COMPUTED_WEIGHT); +// +// } else if (propertyName == COMPUTED_WEIGHT) { +// +// // update also other columns +// fireTableCellUpdated(rowIndex, COMPUTED_NUMBER); +// } + } + + public void updateSamplingRatio(Set<BenthosBatchRowModel> rows) { +// for (BenthosBatchRowModel row : rows) { +// int rowIndex = getRows().indexOf(row); +// fireTableCellUpdated(rowIndex, SAMPLE_WEIGHT, SAMPLING_RATIO); +// } + } + + @Override + protected boolean isCellEditable(int rowIndex, + int columnIndex, + ColumnIdentifier<BenthosBatchRowModel> propertyName) { + + boolean result = super.isCellEditable(rowIndex, + columnIndex, + propertyName); + if (result) { + + if (frequencyCols.contains(propertyName)) { + + // must have filled a species to edit this column + BenthosBatchRowModel entry = getEntry(rowIndex); + result = entry.isValid() && entry.isBatchLeaf(); + + } else if (sampleCols.contains(propertyName)) { + + SampleCategoryColumnIdentifier<BenthosBatchRowModel> samplePropertyName = (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) propertyName; + + // can only edit if a category value is setted + BenthosBatchRowModel entry = getEntry(rowIndex); + + // check from protocol what is possible ? + Species species = entry.getSpecies(); + + if (species == null) { + + // no species, can not edit + result = false; + } else { + + // protocol authorize it + + // final test: can edit only if sample category is setted + SampleCategory<?> value = + (SampleCategory<?>) propertyName.getValue(entry); + + result = value.getCategoryValue() != null; + + } + } + } + return result; + } +} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -27,62 +27,207 @@ showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; bean: {model}; showReset: true; + useFloat: true; + numberPattern: {DECIMAL3_PATTERN}; } -#benthosBatchTopPanel { +TuttiComputedOrNotDataEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + showReset: true; + useFloat: true; + numberPattern: {DECIMAL3_PATTERN}; + decimalNumber: 3; + computedDataColor: {handler.getConfig().getColorComputedWeights()}; +} + +#editBenthosBatchTopPanel { _help: {"tutti.editBenthosBatch.help"}; } +#benthosBatchTabToolBar { + floatable: false; + opaque: false; + borderPainted: false; +} + +#benthosBatchAttachmentsButton { + enabled: {model.getObjectId() != null}; +} + #benthosTotalWeightLabel { text: "tutti.editBenthosBatch.field.benthosTotalWeight"; + toolTipText: "tutti.editBenthosBatch.field.benthosTotalWeight.tip"; labelFor: {benthosTotalWeightField}; + _help: {"tutti.editBenthosBatch.field.benthosTotalWeight.help"}; } #benthosTotalWeightField { - property: benthosTotalWeight; - model: {model.getBenthosTotalWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; + text: {getWeightStringValue(model.getBenthosTotalComputedWeight())}; + _computed: true; } #benthosTotalSortedWeightLabel { text: "tutti.editBenthosBatch.field.benthosTotalSortedWeight"; + toolTipText: "tutti.editBenthosBatch.field.benthosTotalSortedWeight.tip"; labelFor: {benthosTotalSortedWeightField}; + _help: {"tutti.editBenthosBatch.field.benthosTotalSortedWeight.help"}; } #benthosTotalSortedWeightField { - property: benthosTotalSortedWeight; + bean: {model.getBenthosTotalSortedComputedOrNotWeight()}; model: {model.getBenthosTotalSortedWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; } #benthosTotalSampleSortedWeightLabel { text: "tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight"; + toolTipText: "tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight.tip"; labelFor: {benthosTotalSampleSortedWeightField}; + _help: {"tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight.help"}; } #benthosTotalSampleSortedWeightField { - property: benthosTotalSampleSortedWeight; - model: {model.getBenthosTotalSampleSortedWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; + text: {getWeightStringValue(model.getBenthosTotalSampleSortedComputedWeight())}; + _computed: true; } #benthosTotalUnsortedWeightLabel { text: "tutti.editBenthosBatch.field.benthosTotalUnsortedWeight"; + toolTipText: "tutti.editBenthosBatch.field.benthosTotalUnsortedWeight.tip"; labelFor: {benthosTotalUnsortedWeightField}; + _help: {"tutti.editBenthosBatch.field.benthosTotalUnsortedWeight.help"}; } #benthosTotalUnsortedWeightField { - text: {getStringValue(model.getBenthosTotalUnsortedWeight())}; - editable: false; - enabled: false; + text: {getWeightStringValue(model.getBenthosTotalUnsortedComputedWeight())}; + _computed: true; } +#benthosTotalInertWeightLabel { + text: "tutti.editBenthosBatch.field.benthosTotalInertWeight"; + toolTipText: "tutti.editBenthosBatch.field.benthosTotalInertWeight.tip"; + labelFor: {benthosTotalInertWeightField}; + _help: {"tutti.editBenthosBatch.field.benthosTotalInertWeight.help"}; +} + +#benthosTotalInertWeightField { + bean: {model.getBenthosTotalInertComputedOrNotWeight()}; + model: {model.getBenthosTotalInertWeight()}; +} + +#benthosTotalLivingNotItemizedWeightLabel { + text: "tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight"; + toolTipText: "tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight.tip"; + labelFor: {benthosTotalLivingNotItemizedWeightField}; + _help: {"tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight.help"}; +} + +#benthosTotalLivingNotItemizedWeightField { + bean: {model.getBenthosTotalLivingNotItemizedComputedOrNotWeight()}; + model: {model.getBenthosTotalLivingNotItemizedWeight()}; +} + +#tablePopup { + label: "tutti.editBenthosBatch.title.batchActions"; +} + #table { - selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionMode: {ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}; selectionBackground: {null}; selectionForeground: {Color.BLACK}; sortable: false; } + +#filterTablePane { + border: {new TitledBorder(null, "")}; +} + +#filterBenthosBatchLabel { + actionIcon: filter; + text: "tutti.editBenthosBatch.filterBatch"; + toolTipText: "tutti.editBenthosBatch.filterBatch.tip"; + _strongStyle: true; + _help: {"tutti.editBenthosBatch.filterBatch.help"}; +} + +#filterBenthosBatchAllButton { + text: "tutti.editBenthosBatch.filterBatch.mode.all"; + toolTipText: "tutti.editBenthosBatch.filterBatch.mode.all.tip"; + value: "all"; + selected: {model.isTableViewModeAll()}; + buttonGroup: "filterBenthosBatchMode"; +} + +#filterBenthosBatchLeafButton { + text: "tutti.editBenthosBatch.filterBatch.mode.leaf"; + toolTipText: "tutti.editBenthosBatch.filterBatch.mode.leaf.tip"; + value: "leaf"; + selected: {model.isTableViewModeLeaf()}; + buttonGroup: "filterBenthosBatchMode"; +} + +#filterBenthosBatchRootButton { + text: {handler.getFilterBenthosBatchRootButtonText(model.getRootNumber())}; + toolTipText: "tutti.editBenthosBatch.filterBatch.mode.root.tip"; + value: "root"; + selected: {model.isTableViewModeRoot()}; + buttonGroup: "filterBenthosBatchMode"; +} + +#splitBenthosBatchMenu { + actionIcon: batch-split; + text: "tutti.editBenthosBatch.action.splitBatch"; + toolTipText: "tutti.editBenthosBatch.action.splitBatch.tip"; + i18nMnemonic: "tutti.editBenthosBatch.action.splitBatch.mnemonic"; + enabled: {model.isTableViewModeAll() && model.isSplitBatchEnabled()}; + _help: {"tutti.editBenthosBatch.action.splitBatch.help"}; +} + +#removeBenthosBatchMenu { + actionIcon: batch-delete; + text: "tutti.editBenthosBatch.action.removeBatch"; + toolTipText: "tutti.editBenthosBatch.action.removeBatch.tip"; + i18nMnemonic: "tutti.editBenthosBatch.action.removeBatch.mnemonic"; + _tuttiAction: {RemoveBenthosBatchAction.class}; + enabled: {model.isTableViewModeAll() && model.isRemoveBatchEnabled()}; + _help: {"tutti.editBenthosBatch.action.removeBatch.help"}; +} + +#removeBenthosSubBatchMenu { + actionIcon: batch-delete; + text: "tutti.editBenthosBatch.action.removeSubBatch"; + toolTipText: "tutti.editBenthosBatch.action.removeSubBatch.tip"; + i18nMnemonic: "tutti.editBenthosBatch.action.removeSubBatch.mnemonic"; + _tuttiAction: {RemoveBenthosSubBatchAction.class}; + enabled: {model.isTableViewModeAll() && model.isRemoveSubBatchEnabled()}; + _help: {"tutti.editBenthosBatch.action.removeSubBatch.help"}; +} + +#renameBenthosBatchMenu { + actionIcon: batch-rename; + text: "tutti.editBenthosBatch.action.renameBatch"; + toolTipText: "tutti.editBenthosBatch.action.renameBatch.tip"; + i18nMnemonic: "tutti.editBenthosBatch.action.renameBatch.mnemonic"; + _tuttiAction: {RenameBenthosBatchAction.class}; + enabled: {model.isTableViewModeAll() && model.isRenameBatchEnabled()}; + _help: {"tutti.editBenthosBatch.action.renameBatch.help"}; +} + +#createBenthosMelagMenu { + actionIcon: batch-rename; + text: "tutti.editBenthosBatch.action.createMelag"; + toolTipText: "tutti.editBenthosBatch.action.createMelag.tip"; + i18nMnemonic: "tutti.editBenthosBatch.action.createMelag.mnemonic"; + _tuttiAction: {CreateBenthosMelagAction.class}; + enabled: {!model.isTableViewModeLeaf() && model.isCreateMelagEnabled()}; + _help: {"tutti.editBenthosBatch.action.createMelag.help"}; +} + +#createBenthosBatchButton { + actionIcon: batch-create; + text: "tutti.editBenthosBatch.action.createBatch"; + toolTipText: "tutti.editBenthosBatch.action.createBatch.tip"; + i18nMnemonic: "tutti.editBenthosBatch.action.createBatch.mnemonic"; + enabled: {model.isCreateBatchEnabled()}; + _help: {"tutti.editBenthosBatch.action.createBatch.help"}; +} \ No newline at end of file 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -21,20 +21,18 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JPanel id='benthosBatchTopPanel' layout='{new BorderLayout()}' decorator='help' +<JPanel id='editBenthosBatchTopPanel' layout='{new BorderLayout()}' + decorator='help' implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<BenthosBatchUIModel, BenthosBatchUIHandler>'> <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 + fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment + fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor - jaxx.runtime.swing.editor.NumberEditor - org.jdesktop.swingx.JXTable javax.swing.ListSelectionModel @@ -42,7 +40,7 @@ java.awt.Color static org.nuiton.i18n.I18n._ - static jaxx.runtime.SwingUtil.getStringValue + static fr.ifremer.tutti.ui.swing.util.TuttiUIUtil.getWeightStringValue </import> <script><![CDATA[ @@ -65,18 +63,26 @@ <BeanValidator id='validator' bean='model' uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='benthosTotalWeight' component='benthosTotalWeightField'/> <field name='benthosTotalSortedWeight' component='benthosTotalSortedWeightField'/> - <field name='benthosTotalSampleSortedWeight' - component='benthosTotalSampleSortedWeightField'/> - <field name='benthosTotalUnsortedWeight' - component='benthosTotalUnsortedWeightField'/> </BeanValidator> <TuttiHelpBroker id='broker' constructorParams='"tutti.editBenthosBatch.help"'/> + <JToolBar id='benthosBatchTabToolBar'> + <ButtonAttachment id='benthosBatchAttachmentsButton' + constructorParams='getHandler().getContext(), getModel()'/> + </JToolBar> + + <JPopupMenu id='tablePopup'> + <JMenuItem id='splitBenthosBatchMenu' + onActionPerformed='handler.splitBatch()'/> + <JMenuItem id='removeBenthosBatchMenu'/> + <JMenuItem id='removeSpeciesSubBatchMenu'/> + <JMenuItem id='renameBenthosBatchMenu'/> + <JMenuItem id='createSpeciesMelagMenu'/> + </JPopupMenu> <Table id='form' fill='both' constraints='BorderLayout.NORTH'> <!-- Poids total / Poids total vrac --> @@ -85,14 +91,14 @@ <JLabel id='benthosTotalWeightLabel'/> </cell> <cell weightx='1.0'> - <NumberEditor id='benthosTotalWeightField' constructorParams='this'/> + <JTextField id='benthosTotalWeightField'/> </cell> <cell anchor='west'> <JLabel id='benthosTotalSortedWeightLabel'/> </cell> <cell weightx='1.0'> - <NumberEditor id='benthosTotalSortedWeightField' - constructorParams='this'/> + <TuttiComputedOrNotDataEditor id='benthosTotalSortedWeightField' + constructorParams='this'/> </cell> </row> @@ -102,8 +108,7 @@ <JLabel id='benthosTotalSampleSortedWeightLabel'/> </cell> <cell> - <NumberEditor id='benthosTotalSampleSortedWeightField' - constructorParams='this'/> + <JTextField id='benthosTotalSampleSortedWeightField'/> </cell> <cell> <JLabel id='benthosTotalUnsortedWeightLabel'/> @@ -113,32 +118,52 @@ </cell> </row> + <!-- Poids inerte / Poids vivant non détaillé --> + <row> + <cell> + <JLabel id='benthosTotalInertWeightLabel'/> + </cell> + <cell> + <TuttiComputedOrNotDataEditor id='benthosTotalInertWeightField' + constructorParams='this'/> + </cell> + <cell> + <JLabel id='benthosTotalLivingNotItemizedWeightLabel'/> + </cell> + <cell> + <TuttiComputedOrNotDataEditor + id='benthosTotalLivingNotItemizedWeightField' + constructorParams='this'/> + </cell> + </row> + <!-- Toolbar / Filter --> <row> <cell columns="4"> <JPanel id='tableToolbar' layout='{new BorderLayout()}'> <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.WEST'> - <!--<JButton id='createSpeciesBatchButton' onActionPerformed='handler.createSpeciesBatch()'/>--> - <JButton id='attachmentsButton'/> + <JButton id='createBenthosBatchButton' + onActionPerformed='handler.createBatch()'/> </JPanel> - <!--JPanel id='filterTablePane' constraints='BorderLayout.CENTER'> - <JLabel id='filterSpeciesBatchLabel'/> - <JRadioButton id='filterSpeciesBatchAllButton' + <JPanel id='filterTablePane' constraints='BorderLayout.CENTER'> + <JLabel id='filterBenthosBatchLabel'/> + <JRadioButton id='filterBenthosBatchAllButton' onActionPerformed='model.setTableViewMode(TableViewMode.ALL)'/> - <JRadioButton id='filterSpeciesBatchLeafButton' + <JRadioButton id='filterBenthosBatchLeafButton' onActionPerformed='model.setTableViewMode(TableViewMode.LEAF)'/> - <JRadioButton id='filterSpeciesBatchRootButton' + <JRadioButton id='filterBenthosBatchRootButton' onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/> - </JPanel--> + </JPanel> </JPanel> </cell> </row> + </Table> <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JXTable id='table' - onFocusLost='handler.saveSelectedRowIfRequired(event)'/> + <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event)' + onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/> </JScrollPane> </JPanel> 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -24,30 +24,75 @@ * #L% */ +import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; 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.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler; +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.SpeciesBatchRootRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUI; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyCellComponent; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUI; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer; +import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.nuiton.util.decorator.Decorator; +import javax.swing.JOptionPane; +import javax.swing.RowFilter; +import javax.swing.UIManager; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.Serializable; +import java.util.EnumMap; import java.util.List; +import java.util.Map; +import java.util.Set; +import static org.nuiton.i18n.I18n._; + /** * @author tchemit <chemit@codelutin.com> * @since 0.1 @@ -58,15 +103,78 @@ private static final Log log = LogFactory.getLog(BenthosBatchUIHandler.class); + public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet( + BenthosBatchRowModel.PROPERTY_SAMPLE_CATEGORY, + BenthosBatchRowModel.PROPERTY_SPECIES, + BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, + BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY, + BenthosBatchRowModel.PROPERTY_SEX_CATEGORY, + BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY, + BenthosBatchRowModel.PROPERTY_AGE_CATEGORY, + BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT); + + private final EnumMap<TableViewMode, RowFilter<BenthosBatchTableModel, Integer>> tableFilters; + public BenthosBatchUIHandler(TuttiUI<?, ?> parentUi, - BenthosBatchUI ui) { + BenthosBatchUI ui) { super(parentUi, ui, - BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, BenthosBatchRowModel.PROPERTY_SPECIES, + BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, + BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY, + BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_SEX_CATEGORY, + BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY, + BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, + BenthosBatchRowModel.PROPERTY_AGE_CATEGORY, + BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT, BenthosBatchRowModel.PROPERTY_WEIGHT, BenthosBatchRowModel.PROPERTY_NUMBER, - BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT, - BenthosBatchRowModel.PROPERTY_COMMENT); + BenthosBatchRowModel.PROPERTY_COMMENT, + BenthosBatchRowModel.PROPERTY_ATTACHMENT, + BenthosBatchRowModel.PROPERTY_FREQUENCY, + BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM); + tableFilters = new EnumMap<TableViewMode, RowFilter<BenthosBatchTableModel, Integer>>(TableViewMode.class); + + tableFilters.put(TableViewMode.ALL, new RowFilter<BenthosBatchTableModel, Integer>() { + @Override + public boolean include(Entry<? extends BenthosBatchTableModel, ? extends Integer> entry) { + return true; + } + }); + + tableFilters.put(TableViewMode.ROOT, new RowFilter<BenthosBatchTableModel, Integer>() { + @Override + public boolean include(Entry<? extends BenthosBatchTableModel, ? extends Integer> entry) { + boolean result = false; + Integer rowIndex = entry.getIdentifier(); + if (rowIndex != null) { + BenthosBatchTableModel model = entry.getModel(); + BenthosBatchRowModel row = model.getEntry(rowIndex); + result = row != null && row.isBatchRoot(); + } + return result; + } + }); + + tableFilters.put(TableViewMode.LEAF, new RowFilter<BenthosBatchTableModel, Integer>() { + @Override + public boolean include(Entry<? extends BenthosBatchTableModel, ? extends Integer> entry) { + boolean result = false; + Integer rowIndex = entry.getIdentifier(); + if (rowIndex != null) { + BenthosBatchTableModel model = entry.getModel(); + BenthosBatchRowModel row = model.getEntry(rowIndex); + result = row != null && row.isBatchLeaf(); + } + return result; + } + }); } //------------------------------------------------------------------------// @@ -87,23 +195,54 @@ } else { if (log.isInfoEnabled()) { - log.info("Get benthos batch for fishingOperation: " + - bean.getId()); + log.info("Get species batch for fishingOperation: " + + bean.getId()); } rows = Lists.newArrayList(); + model.removeAllAttachment(model.getAttachment()); + if (!TuttiEntities.isNew(bean)) { - BatchContainer<SpeciesBatch> catches = + + // get all batch species root (says the one with only a species sample category) + BatchContainer<SpeciesBatch> rootBenthosBatch = persistenceService.getRootBenthosBatch(bean.getId()); - for (SpeciesBatch aBatch : catches.getChildren() - ) { - BenthosBatchRowModel entry = - new BenthosBatchRowModel(aBatch); - rows.add(entry); + + model.setRootBatchId(rootBenthosBatch.getId()); + + List<Attachment> attachments = + persistenceService.getAllAttachments( + Integer.valueOf(model.getObjectId())); + model.addAllAttachment(attachments); + + if (log.isInfoEnabled()) { + log.info("species root batch id: " + model.getRootBatchId()); } + + List<SpeciesBatch> catches = rootBenthosBatch.getChildren(); + + for (SpeciesBatch aBatch : catches) { + + // root batch sample categroy is species + Preconditions.checkState( + aBatch.getSampleCategoryType() == SampleCategoryEnum.sortedUnsorted, + "Root species batch must be a sortedUnsorted sample " + + "category but was:" + aBatch.getSampleCategoryType()); + + BenthosBatchRowModel rootRow = + loadBatch(aBatch, null, rows); + + if (log.isDebugEnabled()) { + log.debug("Loaded root batch " + + decorate(rootRow.getSpecies(), DecoratorService.FROM_PROTOCOL) + " - " + + decorate(rootRow.getSortedUnsortedCategoryValue())); + } + } } } + model.setRows(rows); + recomputeBatchActionEnable(); } //------------------------------------------------------------------------// @@ -122,26 +261,35 @@ @Override protected boolean isRowValid(BenthosBatchRowModel row) { - boolean result = row.getSpecies() != null && row.getWeight() != null; + + // a row is valid if species category is not empty and valid + // then if any of none empty category is valid + boolean result = row.getSpecies() != null; return result; } @Override protected void onRowModified(int rowIndex, - BenthosBatchRowModel row, - String propertyName, - Object oldValue, - Object newValue) { - recomputeRowValidState(row); + BenthosBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + if (SAMPLING_PROPERTIES.contains(propertyName)) { + + // species has changed, recompute valid property + recomputeRowValidState(row); + } + + // when row valid state has changed, recompute action enabled states + recomputeBatchActionEnable(); } @Override protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor, - BenthosBatchRowModel row) { - + BenthosBatchRowModel row) { if (row.isValid()) { // there is a valid bean attached to the monitor - if (rowMonitor.wasModified()) { // monitored bean was modified, save it @@ -149,6 +297,10 @@ log.info("Row " + row + " was modified, will save it"); } + showInformationMessage( + "[ Captures - Benthos ] " + + "Sauvegarde des modifications de " + row + '.'); + saveRow(row); // clear modified flag on the monitor @@ -156,18 +308,52 @@ } } else { - // row is not valid can not save it + //FIXME See how to delete rows ? Or moreover how to save tehem... + if (log.isWarnEnabled()) { + log.warn("Will not remove not valid speciesBatch: " + row.getId()); + } + } + } - SpeciesBatch catchBean = row.toBean(); + @Override + protected void onModelRowsChanged(List<BenthosBatchRowModel> rows) { + super.onModelRowsChanged(rows); - if (!TuttiEntities.isNew(catchBean)) { + BenthosBatchUIModel model = getModel(); + model.setRootNumber(0); - // remove this - persistenceService.deleteBenthosBatch(catchBean.getId()); + for (BenthosBatchRowModel row : rows) { + updateTotalFromFrequencies(row); + if (row.isBatchRoot()) { + + // update speciesUsed + addToSpeciesUsed(row); } } } + @Override + protected void onRowValidStateChanged(int rowIndex, + BenthosBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + super.onRowValidStateChanged(rowIndex, row, oldValue, newValue); + + // when row valid state has changed, recompute action enabled states + recomputeBatchActionEnable(); + } + + @Override + protected void onAfterSelectedRowChanged(int oldRowIndex, + BenthosBatchRowModel oldRow, + int newRowIndex, + BenthosBatchRowModel newRow) { + super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); + + // when selected row has changed, recompute action enabled states + recomputeBatchActionEnable(); + } + //------------------------------------------------------------------------// //-- AbstractTuttiUIHandler methods --// //------------------------------------------------------------------------// @@ -180,77 +366,139 @@ @Override public void beforeInitUI() { - if (log.isInfoEnabled()) { - log.info("beforeInit: " + ui); + if (log.isDebugEnabled()) { + log.debug("beforeInit: " + ui); } EditCatchesUIModel catchesUIModel = ui.getContextValue(EditCatchesUIModel.class); BenthosBatchUIModel model = new BenthosBatchUIModel(catchesUIModel); + model.setTableViewMode(TableViewMode.ALL); ui.setContextValue(model); } @Override public void afterInitUI() { - if (log.isInfoEnabled()) { - log.info("afterInit: " + ui); + if (log.isDebugEnabled()) { + log.debug("afterInit: " + ui); } initUI(ui); + Map<Integer, SampleCategoryEnum> categoryEnumMap = + SampleCategoryEnum.toIdMapping(); + + List<SampleCategoryEnum> samplingOrder = Lists.newArrayList(); + + List<Integer> samplingOrderIds = getConfig().getSamplingOrderIds(); + for (Integer id : samplingOrderIds) { + samplingOrder.add(categoryEnumMap.get(id)); + } + if (log.isInfoEnabled()) { + log.info("Will use sampling order: " + samplingOrder); + } + JXTable table = getTable(); + // can show / hide some columns in model + table.setColumnControlVisible(true); + // create table column model + TableCellRenderer defaultRenderer = + table.getDefaultRenderer(Object.class); DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); - List<Species> allSpecies = persistenceService.getAllSpecies(); + Decorator<CaracteristicQualitativeValue> caracteristicDecorator = + getDecorator(CaracteristicQualitativeValue.class, null); - { - // Species (by code) column + Color computedDataColor = getConfig().getColorComputedWeights(); - Decorator<Species> decorator = getDecorator( - Species.class, null); + { // Species column - addComboDataColumnToModel(columnModel, - BenthosBatchTableModel.SPECIES_BY_CODE, - decorator, allSpecies); + addColumnToModel(columnModel, + null, + newTableCellRender(Species.class, DecoratorService.FROM_PROTOCOL), + BenthosBatchTableModel.SPECIES); } - { - // Species (by genusCode) column + { // SortedUnsortedCategory column - Decorator<Species> decorator = getDecorator( - Species.class, null); + addSampleCategoryColumnToModel(columnModel, + BenthosBatchTableModel.SORTED_UNSORTED_CATEGORY, + caracteristicDecorator, + defaultRenderer); + } - addComboDataColumnToModel(columnModel, - BenthosBatchTableModel.SPECIES_BY_GENUS_CODE, - decorator, allSpecies); + for (SampleCategoryEnum sampleCategoryType : samplingOrder) { + switch (sampleCategoryType) { - } + case size: - { // Weight column + { // SizeCategory column - addFloatColumnToModel(columnModel, - BenthosBatchTableModel.WEIGHT, - TuttiUI.DECIMAL3_PATTERN); + addSampleCategoryColumnToModel(columnModel, + BenthosBatchTableModel.SIZE_CATEGORY, + caracteristicDecorator, + defaultRenderer); + } + break; + case sex: + + { // SexCategory column + + addSampleCategoryColumnToModel(columnModel, + BenthosBatchTableModel.SEX_CATEGORY, + caracteristicDecorator, + defaultRenderer); + } + break; + case maturity: + + { // MaturityCategory column + + addSampleCategoryColumnToModel(columnModel, + BenthosBatchTableModel.MATURITY_CATEGORY, + caracteristicDecorator, + defaultRenderer); + } + + break; + case age: + + + { // AgeCategory column + + addSampleCategoryColumnToModel(columnModel, + BenthosBatchTableModel.AGE_CATEGORY, + getDecorator(Float.class, null), + defaultRenderer); + } + + break; + } } - { // Number column - addIntegerColumnToModel(columnModel, - BenthosBatchTableModel.NUMBER, - TuttiUI.INT_3_DIGITS_PATTERN); + { // Weight column + + addColumnToModel(columnModel, + TuttiComputedOrNotDataTableCell.newEditor( + Float.class, false, true, 3, computedDataColor), + TuttiComputedOrNotDataTableCell.newRender( + defaultRenderer, true, 3, computedDataColor), + BenthosBatchTableModel.WEIGHT); } - { // Sample weight column + { // Number column (from frequencies) - addFloatColumnToModel(columnModel, - BenthosBatchTableModel.SAMPLE_WEIGHT, - TuttiUI.DECIMAL3_PATTERN); + addColumnToModel(columnModel, + BenthosFrequencyCellComponent.newEditor(ui, computedDataColor), + BenthosFrequencyCellComponent.newRender(computedDataColor), + BenthosBatchTableModel.COMPUTED_NUMBER); } { // Comment column @@ -284,33 +532,269 @@ table.setColumnModel(columnModel); initBatchTable(table, columnModel, tableModel); + + getModel().addPropertyChangeListener(BenthosBatchUIModel.PROPERTY_TABLE_VIEW_MODE, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + TableViewMode tableViewMode = (TableViewMode) evt.getNewValue(); + + if (tableViewMode == null) { + tableViewMode = TableViewMode.ALL; + } + + if (log.isDebugEnabled()) { + log.debug("Will use rowfilter for viewMode: " + tableViewMode); + } + RowFilter<BenthosBatchTableModel, Integer> filter = tableFilters.get(tableViewMode); + getTable().setRowFilter(filter); + } + }); } @Override public void onCloseUI() { if (log.isDebugEnabled()) { - log.debug("closing: " + ui); + log.debug("Closing: " + ui); } + ui.getBenthosBatchAttachmentsButton().onCloseUI(); } + @Override + protected void addHighlighters(JXTable table) { + + super.addHighlighters(table); + + Color toConfirmColor = getConfig().getColorRowToConfirm(); + + // paint the cell in orange if the row is to confirm + Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate() { + + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + BenthosBatchRowModel row = getTableModel().getEntry(adapter.row); + return row.getSpeciesToConfirm(); + } + + }, toConfirmColor); + table.addHighlighter(confirmHighlighter); + + // highlight only the species column if the row is selected + Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate( + HighlightPredicate.IS_SELECTED, + new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.SPECIES)), + UIManager.getColor("Table[Enabled+Selected].textBackground")); + + table.addHighlighter(selectedHighlighter); + + // paint the cell in dark orange if the row is to confirm and the cell is not editable + Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate() { + + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + BenthosBatchRowModel row = getTableModel().getEntry(adapter.row); + return row.getSpeciesToConfirm() && !adapter.isEditable(); + } + + }, toConfirmColor.darker()); + table.addHighlighter(confirmNotEditableHighlighter); + + } + //------------------------------------------------------------------------// //-- Public methods --// //------------------------------------------------------------------------// - //------------------------------------------------------------------------// - //-- Internal methods --// - //------------------------------------------------------------------------// + public void createBatch() { + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + CreateBenthosBatchUI createBatchEditor = parent.getBenthosTabCreateBatch(); + + createBatchEditor.getHandler().openUI(getModel()); + parent.getHandler().setBenthosSelectedCard(EditCatchesUIHandler.CREATE_BATCH_CARD); + } + + public void addBatch(SpeciesBatchRootRowModel speciesBatchRootRowModel) { + if (speciesBatchRootRowModel.isValid()) { + + BenthosBatchTableModel tableModel = getTableModel(); + + BenthosBatchRowModel newRow = tableModel.createNewRow(); + Species species = speciesBatchRootRowModel.getSpecies(); + newRow.setSpecies(species); + + CaracteristicQualitativeValue sortedUnsortedCategory = speciesBatchRootRowModel.getSortedUnsortedCategory(); + SampleCategory<CaracteristicQualitativeValue> category = newRow.getSortedUnsortedCategory(); + category.setCategoryValue(sortedUnsortedCategory); + category.setCategoryWeight(speciesBatchRootRowModel.getBatchWeight()); + newRow.setSampleCategory(category); + + recomputeRowValidState(newRow); + + tableModel.addNewRow(newRow); + AbstractSelectTableAction.doSelectCell(getTable(), tableModel.getRowCount() - 1, 0); + + saveRow(newRow); + + // update speciesUsed + addToSpeciesUsed(newRow); + } + + recomputeBatchActionEnable(); + } + + public void splitBatch() { + + JXTable table = getTable(); + + // get selected row + int rowIndex = table.getSelectedRow(); + + Preconditions.checkState(rowIndex != -1, + "Cant split batch if no batch selected"); + + BenthosBatchTableModel tableModel = getTableModel(); + + BenthosBatchRowModel parentBatch = tableModel.getEntry(rowIndex); + + boolean split = true; + if (parentBatch.getWeight() != null) { + String htmlMessage = String.format( + CONFIRMATION_FORMAT, + _("tutti.editBenthosBatch.split.weightNotNull.message"), + _("tutti.editBenthosBatch.split.weightNotNull.help")); + int i = JOptionPane.showConfirmDialog( + getTopestUI(), + htmlMessage, + _("tutti.editBenthosBatch.split.weightNotNull.title"), + JOptionPane.OK_CANCEL_OPTION); + + if (i == JOptionPane.OK_OPTION) { + parentBatch.setWeight(null); + + } else { + split = false; + } + } + + if (split) { + if (log.isInfoEnabled()) { + log.info("Open split batch ui for row [" + rowIndex + ']'); + } + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + SplitBenthosBatchUI splitBatchEditor = parent.getBenthosTabSplitBatch(); + + splitBatchEditor.getHandler().editBatch(parentBatch); + parent.getHandler().setBenthosSelectedCard(EditCatchesUIHandler.SPLIT_BATCH_CARD); + } + } + + public void splitBatch(SplitBenthosBatchUIModel splitModel) { + if (splitModel.isValid()) { + + JXTable table = getTable(); + + // get selected row + int insertRow = table.getSelectedRow(); + + BenthosBatchTableModel tableModel = getTableModel(); + BenthosBatchRowModel parentBatch = tableModel.getEntry(insertRow); + + // create batch rows + + SampleCategoryEnum sampleCategoryEnum = splitModel.getSelectedCategory(); + + // Create rows in batch table model + + List<BenthosBatchRowModel> newBatches = Lists.newArrayList(); + for (SplitBenthosBatchRowModel row : splitModel.getRows()) { + if (row.isValid()) { + + // can keep this row + BenthosBatchRowModel newBatch = tableModel.createNewRow(); + + loadBatchRow(parentBatch, + newBatch, + sampleCategoryEnum, + row.getCategoryValue(), + row.getWeight()); + + recomputeRowValidState(newBatch); + newBatches.add(newBatch); + + tableModel.addNewRow(++insertRow, newBatch); + } + } + + // add new batches to his parent + parentBatch.setChildBatch(newBatches); + + //TODO Should only save parentBatch (will persist all his childs) + //saveRow(parentBatch); + + // save new batches + saveRows(newBatches); + + BenthosBatchUIModel model = getModel(); + model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1); + } + + recomputeBatchActionEnable(); + +// // reselect this cell +// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); +// table.requestFocus(); + } + + public void updateTotalFromFrequencies(BenthosBatchRowModel row) { + List<BenthosFrequencyRowModel> frequency = row.getFrequency(); + + Integer totalNumber = 0; + boolean onlyOneFrequency = false; + if (CollectionUtils.isNotEmpty(frequency)) { + for (BenthosFrequencyRowModel frequencyModel : frequency) { + if (frequencyModel.getNumber() != null) { + totalNumber += frequencyModel.getNumber(); + } + } + onlyOneFrequency = frequency.size() == 1; + } + row.setComputedNumber(totalNumber); + row.getFinestCategory().setOnlyOneFrequency(onlyOneFrequency); + + } + + public void saveRows(Iterable<BenthosBatchRowModel> rows) { + for (BenthosBatchRowModel row : rows) { + saveRow(row); + } + } + protected void saveRow(BenthosBatchRowModel row) { + FishingOperation fishingOperation = getModel().getFishingOperation(); + Preconditions.checkNotNull(fishingOperation); + + Preconditions.checkNotNull(row.getSpecies()); + SampleCategory<?> sampleCategory = row.getSampleCategory(); + Preconditions.checkNotNull(sampleCategory); + Preconditions.checkNotNull(sampleCategory.getCategoryType()); + Preconditions.checkNotNull(sampleCategory.getCategoryValue()); + SpeciesBatch catchBean = row.toBean(); + catchBean.setFishingOperation(fishingOperation); - FishingOperation fishingOperation = getModel().getFishingOperation(); - catchBean.setFishingOperation(fishingOperation); - if (log.isInfoEnabled()) { - log.info("Selected fishingOperation: " + fishingOperation.getId()); + BenthosBatchRowModel parent = row.getParentBatch(); + if (parent != null) { + catchBean.setParentBatch(parent.toBean()); } + // apply sample category + catchBean.setSampleCategoryType(sampleCategory.getCategoryType()); + catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue()); + catchBean.setSampleCategoryWeight(sampleCategory.getCategoryWeight()); + if (TuttiEntities.isNew(catchBean)) { BenthosBatchRowModel batchParent = row.getParentBatch(); @@ -321,13 +805,305 @@ } if (log.isInfoEnabled()) { - log.info("Persist new benthos batch with parentId: " + parentBatchId); + log.info("Persist new species batch with parentId: " + + parentBatchId); } - catchBean = persistenceService.createBenthosBatch(catchBean, parentBatchId); + catchBean = persistenceService.createBenthosBatch(catchBean, + parentBatchId); row.setId(catchBean.getId()); } else { + if (log.isInfoEnabled()) { + log.info("Persist existing species batch: " + catchBean.getId() + " (parent : " + catchBean.getParentBatch() + ")"); + } persistenceService.saveBenthosBatch(catchBean); } + + List<BenthosFrequencyRowModel> frequencyRows = row.getFrequency(); + + List<SpeciesBatchFrequency> frequency = + BenthosFrequencyRowModel.toBeans(frequencyRows, catchBean); + + if (log.isInfoEnabled()) { + log.info("Will save " + frequency.size() + " frequencies."); + } + frequency = persistenceService.saveBenthosBatchFrequency( + catchBean.getId(), frequency); + + // push it back to row model + frequencyRows = BenthosFrequencyRowModel.fromBeans(frequency); + row.setFrequency(frequencyRows); } -} + public String getFilterBenthosBatchRootButtonText(int rootNumber) { + return _("tutti.editBenthosBatch.filterBatch.mode.root", rootNumber); + } + + protected void recomputeBatchActionEnable() { + + int rowIndex = getTable().getSelectedRow(); + + //TODO Improve this test + boolean enableAdd = true; +// CollectionUtils.isNotEmpty(getModel().getAvailableSpecies()); + + boolean enableRename = false; + boolean enableSplit = false; + boolean enableRemove = false; + boolean enableRemoveSub = false; + boolean enableCreateMelag = false; + + if (rowIndex != -1) { + + // there is a selected row + + //TODO If there is some sub-batch, can remove them + //TODO If there is no sub-batch, can split current batch + + BenthosBatchTableModel tableModel = getTableModel(); + BenthosBatchRowModel row = tableModel.getEntry(rowIndex); + int selectedRowCount = getTable().getSelectedRowCount(); + + if (row.isValid()) { + + // must have at least species filled in row + // otherwise nothing can be done + + enableSplit = true; + enableRemove = true; + enableRemoveSub = true; + enableRename = true; + enableCreateMelag = true; + } + + if (enableSplit) { + + // can split if selected batch is a leaf + enableSplit = row.isBatchLeaf() + && selectedRowCount == 1 + && row.getNumber() == null + && (row.getComputedNumber() == null + || row.getComputedNumber() == 0); + } + + if (enableRename) { + + // can rename if selected batch is a parent + enableRename = row.isBatchRoot() + && selectedRowCount == 1; + } + + if (enableRemove) { + + // can always remove the batch + enableRemove = selectedRowCount == 1; + } + + if (enableRemoveSub) { + + // can remove sub batch if selected batch is not a leaf + enableRemoveSub = !row.isBatchLeaf() + && selectedRowCount == 1; + } + + if (enableCreateMelag) { + + JXTable table = getTable(); + + // can add species to a melag if several root are selected + + if (selectedRowCount < 2) { + enableCreateMelag = false; + + } else { + int[] selectedRows = table.getSelectedRows(); + for (int selectedRowIndex : selectedRows) { + BenthosBatchRowModel selectedRow = + tableModel.getEntry(selectedRowIndex); + + if (!selectedRow.isBatchRoot()) { + enableCreateMelag = false; + break; + } + } + } + } + } + + BenthosBatchUIModel model = getModel(); + model.setCreateBatchEnabled(enableAdd); + model.setSplitBatchEnabled(enableSplit); + model.setRemoveBatchEnabled(enableRemove); + model.setRemoveSubBatchEnabled(enableRemoveSub); + model.setRenameBatchEnabled(enableRename); + model.setCreateMelagEnabled(enableCreateMelag); + } + + public void collectChildren(BenthosBatchRowModel row, + Set<BenthosBatchRowModel> collectedRows) { + + if (!row.isBatchLeaf()) { + + for (BenthosBatchRowModel batchChild : row.getChildBatch()) { + collectedRows.add(batchChild); + collectChildren(batchChild, collectedRows); + } + } + } + + protected BenthosBatchRowModel loadBatch(SpeciesBatch aBatch, + BenthosBatchRowModel parentRow, + List<BenthosBatchRowModel> rows) { + + String id = aBatch.getId(); + + List<SpeciesBatchFrequency> frequencies = + persistenceService.getAllBenthosBatchFrequency(id); + + List<Attachment> attachments = + persistenceService.getAllAttachments(Integer.valueOf(id)); + + BenthosBatchRowModel newRow = + new BenthosBatchRowModel(aBatch, frequencies, attachments); + // set the surveycode, do it only on the parent, + // 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 + List<Species> speciesList = getDataContext().getReferentSpeciesWithSurveyCode(); + int i = speciesList.indexOf(newRow.getSpecies()); + if (i > -1) { + newRow.setSpecies(speciesList.get(i)); + } + } + + SampleCategoryEnum sampleCategoryEnum = aBatch.getSampleCategoryType(); + + Preconditions.checkNotNull( + sampleCategoryEnum, + "Can't have a batch with no sample category, but was: " + aBatch); + + loadBatchRow(parentRow, + newRow, + sampleCategoryEnum, + aBatch.getSampleCategoryValue(), + aBatch.getSampleCategoryWeight()); + + rows.add(newRow); + + if (!aBatch.isChildBatchsEmpty()) { + + // create batch childs rows + + List<BenthosBatchRowModel> batchChilds = Lists. + newArrayListWithCapacity(aBatch.sizeChildBatchs()); + + for (SpeciesBatch childBatch : aBatch.getChildBatchs()) { + BenthosBatchRowModel childRow = loadBatch(childBatch, newRow, rows); + batchChilds.add(childRow); + } + newRow.setChildBatch(batchChilds); + } + + return newRow; + } + + protected void loadBatchRow(BenthosBatchRowModel parentRow, + BenthosBatchRowModel newRow, + SampleCategoryEnum sampleCategoryEnum, + Serializable categoryValue, + Float categoryWeight) { + + // get sample category from his type + SampleCategory sampleCategory = + newRow.getSampleCategory(sampleCategoryEnum); + + // fill it + sampleCategory.setCategoryValue(categoryValue); + sampleCategory.setCategoryWeight(categoryWeight); + + // push it back to row as his *main* sample category + newRow.setSampleCategory(sampleCategory); + + if (parentRow != null) { + + // copy back parent data (mainly other sample categories) + + newRow.setSpecies(parentRow.getSpecies()); + newRow.setSpeciesToConfirm(parentRow.getSpeciesToConfirm()); + newRow.setParentBatch(parentRow); + + newRow.setSpecies(parentRow.getSpecies()); + if (sampleCategoryEnum != SampleCategoryEnum.sortedUnsorted) { + newRow.setSortedUnsortedCategory(parentRow.getSortedUnsortedCategory()); + } + if (sampleCategoryEnum != SampleCategoryEnum.size) { + newRow.setSizeCategory(parentRow.getSizeCategory()); + } + if (sampleCategoryEnum != SampleCategoryEnum.sex) { + newRow.setSexCategory(parentRow.getSexCategory()); + } + if (sampleCategoryEnum != SampleCategoryEnum.maturity) { + newRow.setMaturityCategory(parentRow.getMaturityCategory()); + } + if (sampleCategoryEnum != SampleCategoryEnum.age) { + newRow.setAgeCategory(parentRow.getAgeCategory()); + } + } + } + + protected <C extends Serializable> void addSampleCategoryColumnToModel(TableColumnModel columnModel, + ColumnIdentifier<BenthosBatchRowModel> columnIdentifier, + Decorator<C> decorator, + TableCellRenderer defaultRenderer) { + addColumnToModel( + columnModel, + SampleCategoryComponent.newEditor(decorator), + SampleCategoryComponent.newRender(defaultRenderer, + decorator, + getConfig().getColorComputedWeights()), + columnIdentifier); + } + + public void removeFromSpeciesUsed(BenthosBatchRowModel row) { + Preconditions.checkNotNull(row); + Preconditions.checkNotNull(row.getSpecies()); + Preconditions.checkNotNull(row.getSortedUnsortedCategoryValue()); + if (log.isInfoEnabled()) { + log.info("Remove from speciesUsed: " + decorate(row.getSortedUnsortedCategoryValue()) + " - " + decorate(row.getSpecies())); + } + BenthosBatchUIModel model = getModel(); + model.getSpeciesUsed().remove(row.getSortedUnsortedCategoryValue(), + row.getSpecies()); + + if (row.isBatchRoot()) { + model.setRootNumber(model.getRootNumber() - 1); + } + } + + protected void addToSpeciesUsed(BenthosBatchRowModel row) { + Preconditions.checkNotNull(row); + Preconditions.checkNotNull(row.getSpecies()); + Preconditions.checkNotNull(row.getSortedUnsortedCategoryValue()); + if (log.isDebugEnabled()) { + log.debug("Add to speciesUsed: " + + decorate(row.getSortedUnsortedCategoryValue()) + + " - " + decorate(row.getSpecies())); + } + BenthosBatchUIModel model = getModel(); + model.getSpeciesUsed().put(row.getSortedUnsortedCategoryValue(), + row.getSpecies()); + + model.setRootNumber(model.getRootNumber() + 1); + } + + public Species openAddSpeciesDialog(String title, List<Species> species) { + SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui); + SelectSpeciesUIModel model = dialogContent.getModel(); + model.setSelectedSpecies(null); + model.setSpecies(species); + + openDialog(dialogContent, title, new Dimension(400, 130)); + + return model.getSelectedSpecies(); + } + +} \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -24,54 +24,362 @@ * #L% */ +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.referential.CaracteristicQualitativeValue; +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; +import java.util.Collection; +import java.util.List; + /** * @author tchemit <chemit@codelutin.com> * @since 0.1 */ -public class BenthosBatchUIModel extends AbstractTuttiBatchUIModel<BenthosBatchRowModel, BenthosBatchUIModel> { +public class BenthosBatchUIModel extends AbstractTuttiBatchUIModel<BenthosBatchRowModel, BenthosBatchUIModel> implements AttachmentModelAware { private static final long serialVersionUID = 1L; + public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode"; + + public static final String PROPERTY_CREATE_BATCH_ENABLED = "createBatchEnabled"; + + public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled"; + + public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled"; + + public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled"; + + public static final String PROPERTY_REMOVE_BATCH_ENABLED = "removeBatchEnabled"; + + public static final String PROPERTY_CREATE_MELAG_ENABLED = "createMelagEnabled"; + + public static final String PROPERTY_TABLE_VIEW_MODE_ALL = "tableViewModeAll"; + + public static final String PROPERTY_TABLE_VIEW_MODE_LEAF = "tableViewModeLeaf"; + + public static final String PROPERTY_TABLE_VIEW_MODE_ROOT = "tableViewModeRoot"; + + public static final String PROPERTY_ROOT_NUMBER = "rootNumber"; + + public static final String PROPERTY_LEAF_NUMBER = "leafNumber"; + + /** + * Can user create a new species batch ? + * + * @since 0.3 + */ + protected boolean createBatchEnabled; + + /** + * Can user split a selected species batch ? + * + * @since 0.3 + */ + protected boolean splitBatchEnabled; + + /** + * Can user remove a selected species batch? + * + * @since 0.3 + */ + protected boolean removeBatchEnabled; + + /** + * Can user remove a selected species sub batches? + * + * @since 0.3 + */ + protected boolean removeSubBatchEnabled; + + /** + * Can user create a melag from the selected species? + * + * @since 0.3 + */ + protected boolean createMelagEnabled = true; + + /** + * Can user rename the selected species? + * + * @since 0.3 + */ + protected boolean renameBatchEnabled; + + /** + * What to show in the table. + * + * @since 0.3 + */ + protected TableViewMode tableViewMode; + + /** @since 1.0 */ + protected int rootNumber; + + /** @since 1.0 */ + protected int leafNumber; + + protected final List<Attachment> attachment = Lists.newArrayList(); + + private String rootBatchId; + public BenthosBatchUIModel(EditCatchesUIModel catchesUIModel) { super(catchesUIModel, - EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, - EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT, - EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT); + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, + EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT); } - public Float getBenthosTotalWeight() { - return catchesUIModel.getBenthosTotalWeight(); + public Float getBenthosTotalComputedWeight() { + return catchesUIModel.getBenthosTotalComputedWeight(); } - public void setBenthosTotalWeight(Float benthosTotalWeight) { - catchesUIModel.setBenthosTotalWeight(benthosTotalWeight); + public void setBenthosTotalComputedWeight(Float speciesTotalComputedWeight) { + catchesUIModel.setBenthosTotalComputedWeight(speciesTotalComputedWeight); } - public Float getBenthosTotalSampleSortedWeight() { - return catchesUIModel.getBenthosTotalSampleSortedWeight(); + public TuttiComputedOrNotData<Float> getBenthosTotalSortedComputedOrNotWeight() { + return catchesUIModel.getBenthosTotalSortedComputedOrNotWeight(); } - public void setBenthosTotalSampleSortedWeight(Float benthosTotalSampleSortedWeight) { - catchesUIModel.setBenthosTotalSampleSortedWeight(benthosTotalSampleSortedWeight); - } - public Float getBenthosTotalSortedWeight() { return catchesUIModel.getBenthosTotalSortedWeight(); } - public void setBenthosTotalSortedWeight(Float benthosTotalSortedWeight) { - catchesUIModel.setBenthosTotalSortedWeight(benthosTotalSortedWeight); + public void setBenthosTotalSortedWeight(Float speciesTotalSortedWeight) { + catchesUIModel.setBenthosTotalSortedWeight(speciesTotalSortedWeight); } - public Float getBenthosTotalUnsortedWeight() { - return catchesUIModel.getBenthosTotalUnsortedWeight(); + public Float getBenthosTotalSortedComputedWeight() { + return catchesUIModel.getBenthosTotalSortedComputedWeight(); } - public void setBenthosTotalUnsortedWeight(Float benthosTotalUnsortedWeight) { - catchesUIModel.setBenthosTotalUnsortedWeight(benthosTotalUnsortedWeight); + public void setBenthosTotalSortedComputedWeight(Float speciesTotalSortedComputedWeight) { + catchesUIModel.setBenthosTotalSortedComputedWeight(speciesTotalSortedComputedWeight); } -} \ No newline at end of file + + public Float getBenthosTotalUnsortedComputedWeight() { + return catchesUIModel.getBenthosTotalUnsortedComputedWeight(); + } + + public void setBenthosTotalUnsortedComputedWeight(Float speciesTotalUnsortedComputedWeight) { + catchesUIModel.setBenthosTotalUnsortedComputedWeight(speciesTotalUnsortedComputedWeight); + } + + public Float getBenthosTotalSampleSortedComputedWeight() { + return catchesUIModel.getBenthosTotalSampleSortedComputedWeight(); + } + + public void setBenthosTotalSampleSortedComputedWeight(Float speciesTotalSampleSortedComputedWeight) { + catchesUIModel.setBenthosTotalSampleSortedComputedWeight(speciesTotalSampleSortedComputedWeight); + } + + public TuttiComputedOrNotData<Float> getBenthosTotalInertComputedOrNotWeight() { + return catchesUIModel.getBenthosTotalInertComputedOrNotWeight(); + } + + public Float getBenthosTotalInertWeight() { + return catchesUIModel.getBenthosTotalInertWeight(); + } + + public void setBenthosTotalInertWeight(Float speciesTotalInertWeight) { + catchesUIModel.setBenthosTotalInertWeight(speciesTotalInertWeight); + } + + public Float getBenthosTotalInertComputedWeight() { + return catchesUIModel.getBenthosTotalInertComputedWeight(); + } + + public void setBenthosTotalInertComputedWeight(Float speciesTotalInertComputedWeight) { + catchesUIModel.setBenthosTotalInertComputedWeight(speciesTotalInertComputedWeight); + } + + public TuttiComputedOrNotData<Float> getBenthosTotalLivingNotItemizedComputedOrNotWeight() { + return catchesUIModel.getBenthosTotalLivingNotItemizedComputedOrNotWeight(); + } + + public Float getBenthosTotalLivingNotItemizedWeight() { + return catchesUIModel.getBenthosTotalLivingNotItemizedWeight(); + } + + public void setBenthosTotalLivingNotItemizedWeight(Float speciesTotalLivingNotItemizedWeight) { + catchesUIModel.setBenthosTotalLivingNotItemizedWeight(speciesTotalLivingNotItemizedWeight); + } + + public Float getBenthosTotalLivingNotItemizedComputedWeight() { + return catchesUIModel.getBenthosTotalLivingNotItemizedComputedWeight(); + } + + public void setBenthosTotalLivingNotItemizedComputedWeight(Float speciesTotalLivingNotItemizedComputedWeight) { + catchesUIModel.setBenthosTotalLivingNotItemizedComputedWeight(speciesTotalLivingNotItemizedComputedWeight); + } + + public TableViewMode getTableViewMode() { + return tableViewMode; + } + + public void setTableViewMode(TableViewMode tableViewMode) { + Object oldValue = getTableViewMode(); + this.tableViewMode = tableViewMode; + firePropertyChange(PROPERTY_TABLE_VIEW_MODE, oldValue, tableViewMode); + firePropertyChange(PROPERTY_TABLE_VIEW_MODE_ALL, null, isTableViewModeAll()); + firePropertyChange(PROPERTY_TABLE_VIEW_MODE_LEAF, null, isTableViewModeLeaf()); + firePropertyChange(PROPERTY_TABLE_VIEW_MODE_ROOT, null, isTableViewModeRoot()); + } + + public boolean isTableViewModeAll() { + return TableViewMode.ALL.equals(tableViewMode); + } + + public boolean isTableViewModeLeaf() { + return TableViewMode.LEAF.equals(tableViewMode); + } + + public boolean isTableViewModeRoot() { + return TableViewMode.ROOT.equals(tableViewMode); + } + + public Multimap<CaracteristicQualitativeValue, Species> getSpeciesUsed() { + return catchesUIModel.getSpeciesUsed(); + } + + public int getRootNumber() { + return rootNumber; + } + + public void setRootNumber(int rootNumber) { + Object oldValue = getRootNumber(); + this.rootNumber = rootNumber; + firePropertyChange(PROPERTY_ROOT_NUMBER, oldValue, rootNumber); + } + + public int getLeafNumber() { + return leafNumber; + } + + public void setLeafNumber(int leafNumber) { + Object oldValue = getLeafNumber(); + this.leafNumber = leafNumber; + firePropertyChange(PROPERTY_LEAF_NUMBER, oldValue, leafNumber); + } + + public boolean isCreateBatchEnabled() { + return createBatchEnabled; + } + + public void setCreateBatchEnabled(boolean createBatchEnabled) { + Object oldValue = isCreateBatchEnabled(); + this.createBatchEnabled = createBatchEnabled; + firePropertyChange(PROPERTY_CREATE_BATCH_ENABLED, oldValue, createBatchEnabled); + } + + public boolean isSplitBatchEnabled() { + return splitBatchEnabled; + } + + public void setSplitBatchEnabled(boolean splitBatchEnabled) { + Object oldValue = isSplitBatchEnabled(); + this.splitBatchEnabled = splitBatchEnabled; + firePropertyChange(PROPERTY_SPLIT_BATCH_ENABLED, oldValue, splitBatchEnabled); + } + + public boolean isRemoveBatchEnabled() { + return removeBatchEnabled; + } + + public void setRemoveBatchEnabled(boolean removeBatchEnabled) { + Object oldValue = isRemoveBatchEnabled(); + this.removeBatchEnabled = removeBatchEnabled; + firePropertyChange(PROPERTY_REMOVE_BATCH_ENABLED, oldValue, removeBatchEnabled); + } + + public boolean isRemoveSubBatchEnabled() { + return removeSubBatchEnabled; + } + + public void setRemoveSubBatchEnabled(boolean removeSubBatchEnabled) { + Object oldValue = isRemoveSubBatchEnabled(); + this.removeSubBatchEnabled = removeSubBatchEnabled; + firePropertyChange(PROPERTY_REMOVE_SUB_BATCH_ENABLED, oldValue, removeSubBatchEnabled); + } + + public void setRenameBatchEnabled(boolean renameBatchEnabled) { + Object oldValue = isRenameBatchEnabled(); + this.renameBatchEnabled = renameBatchEnabled; + firePropertyChange(PROPERTY_RENAME_BATCH_ENABLED, oldValue, renameBatchEnabled); + } + + public boolean isRenameBatchEnabled() { + return renameBatchEnabled; + } + + public boolean isCreateMelagEnabled() { + return createMelagEnabled; + } + + public void setCreateMelagEnabled(boolean createMelagEnabled) { + Object oldValue = isCreateMelagEnabled(); + this.createMelagEnabled = createMelagEnabled; + firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled); + } + + public void setRootBatchId(String rootBatchId) { + String oldValue = getObjectId(); + this.rootBatchId = rootBatchId; + firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId()); + } + + public String getRootBatchId() { + return rootBatchId; + } + + @Override + public AttachementObjectTypeEnum getObjectType() { + return AttachementObjectTypeEnum.CATCH_BATCH; + } + + @Override + public String getObjectId() { + return rootBatchId; + } + + @Override + public List<Attachment> getAttachment() { + return attachment; + } + + @Override + public void addAllAttachment(Collection<Attachment> attachments) { + this.attachment.addAll(attachments); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + } + + @Override + public void addAttachment(Attachment attachment) { + this.attachment.add(attachment); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + } + + @Override + public void removeAllAttachment(Collection<Attachment> attachments) { + this.attachment.removeAll(attachments); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + } + + @Override + public void removeAttachment(Attachment attachment) { + this.attachment.remove(attachment); + firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,183 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos; + +/* + * #%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.benthos.frequency.BenthosFrequencyRowModel; +import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog; +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 CreateBenthosMelagAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> { + + protected Map<BenthosBatchRowModel, Float> selectedRows = Maps.newHashMap(); + + protected Float melagWeight = null; + + protected Float sampleMelagWeight = null; + + protected Float sortedWeight = null; + + public CreateBenthosMelagAction(BenthosBatchUIHandler handler) { + super(handler, false); + } + + @Override + protected boolean prepareAction() throws Exception { + boolean result = super.prepareAction(); + + int[] selectedRowIndexes = handler.getTable().getSelectedRows(); + + BenthosBatchTableModel tableModel = handler.getTableModel(); + + // sum of the weights already entered by the user + Float alreadyKnownWeights = 0f; + sortedWeight = 0f; + + for (int selectedRowIndex : selectedRowIndexes) { + BenthosBatchRowModel 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 (BenthosFrequencyRowModel frequency : selectedRow.getFrequency()) { + if (frequency.getWeight() == null) { + sampleWeight = 0f; + break; + } + sampleWeight += frequency.getWeight(); + } + } + } + + if (sampleWeight != null) { + if (sampleWeight == 0f) { + JOptionPane.showMessageDialog( + getUI(), + _("tutti.createBenthosMelag.error.message", selectedRowIndex + 1), + _("tutti.createBenthosMelag.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 (BenthosBatchRowModel 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/benthos/RemoveBenthosBatchAction.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,132 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos; + +/* + * #%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.base.Preconditions; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.TuttiPersistence; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; + +import java.util.Set; + +/** + * To remove a species batch and all his children. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class RemoveBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(RemoveBenthosBatchAction.class); + + protected RemoveBenthosSubBatchAction removeSpeciesSubBatchAction; + + public RemoveBenthosBatchAction(BenthosBatchUIHandler handler) { + super(handler, false); + + removeSpeciesSubBatchAction = new RemoveBenthosSubBatchAction(handler); + } + + @Override + protected void doAction() throws Exception { + + TuttiPersistence persistenceService = + getContext().getPersistenceService(); + + JXTable table = handler.getTable(); + + int rowIndex = table.getSelectedRow(); + + Preconditions.checkState(rowIndex != -1, + "Cant remove batch if no batch selected"); + + BenthosBatchTableModel tableModel = handler.getTableModel(); + BenthosBatchRowModel selectedBatch = tableModel.getEntry(rowIndex); + + Preconditions.checkState(!TuttiEntities.isNew(selectedBatch), + "Can't remove batch if batch is not persisted"); + + if (!selectedBatch.isBatchRoot()) { + + // remove all sub batches of his parent + BenthosBatchRowModel parentBatch = selectedBatch.getParentBatch(); + + // get parent row index + int parentIndex = tableModel.getRowIndex(parentBatch); + + // select it + table.setRowSelectionInterval(parentIndex, parentIndex); + + // remove all his children + runAction(removeSpeciesSubBatchAction); + + } else { + + // remove selected batch and all his children + + // remove parent batch (will destroy all his childs from db) + persistenceService.deleteBenthosBatch(selectedBatch.getId()); + + // update speciesUsed + handler.removeFromSpeciesUsed(selectedBatch); + + // collect of rows to remove from model + Set<BenthosBatchRowModel> rowToRemove = + Sets.newHashSet(selectedBatch); + + handler.collectChildren(selectedBatch, rowToRemove); + + table.clearSelection(); + + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + + // refresh table from parent batch row index to the end + tableModel.fireTableDataChanged(); + + if (!getModel().getRows().isEmpty()) { + + // select first row + AbstractSelectTableAction.doSelectCell(table, 0, 0); + + } + + if (table.isEditing()) { + + // but no edit it + table.getCellEditor().stopCellEditing(); + } + + } + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,102 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos; + +/* + * #%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.base.Preconditions; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.TuttiPersistence; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import org.jdesktop.swingx.JXTable; + +import java.util.Set; + +/** + * To remove a species batch children. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class RemoveBenthosSubBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> { + + public RemoveBenthosSubBatchAction(BenthosBatchUIHandler handler) { + super(handler, false); + } + + @Override + protected void doAction() throws Exception { + + TuttiPersistence persistenceService = + getContext().getPersistenceService(); + + JXTable table = handler.getTable(); + + int rowIndex = table.getSelectedRow(); + + Preconditions.checkState(rowIndex != -1, + "Cant remove sub batch if no batch selected"); + + BenthosBatchRowModel parentBatch = handler.getTableModel().getEntry(rowIndex); + + Preconditions.checkState(!TuttiEntities.isNew(parentBatch), + "Can't remove sub batch if batch is not persisted"); + + // save parent batch (will destroy all his childs from db) + persistenceService.deleteSpeciesSubBatch(parentBatch.getId()); + + if (parentBatch.isBatchRoot()) { + + // update speciesUsed + handler.removeFromSpeciesUsed(parentBatch); + } + + // collect of rows to remove from model + Set<BenthosBatchRowModel> rowToRemove = Sets.newHashSet(); + + handler.collectChildren(parentBatch, rowToRemove); + + table.clearSelection(); + + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); + + // remove childs from parent batch + parentBatch.setChildBatch(null); + + // refresh table from parent batch row index to the end + handler.getTableModel().fireTableDataChanged(); + + // select parent batch row + AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); + + if (table.isEditing()) { + + // but no edit it + table.getCellEditor().stopCellEditing(); + } + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java (from rev 665, 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/benthos/RenameBenthosBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,109 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos; + +/* + * #%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.Lists; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; +import org.jdesktop.swingx.JXTable; + +import java.util.Collection; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * To rename the species for a species batch and all his children. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class RenameBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> { + + protected Species selectedSpecies; + + public RenameBenthosBatchAction(BenthosBatchUIHandler handler) { + super(handler, false); + + } + + @Override + protected boolean prepareAction() throws Exception { + boolean result = super.prepareAction(); + + BenthosBatchTableModel tableModel = handler.getTableModel(); + JXTable table = handler.getTable(); + BenthosBatchRowModel row = tableModel.getEntry(table.getSelectedRow()); + + BenthosBatchUIModel model = handler.getModel(); + List<Species> speciesList = Lists.newArrayList(getDataContext().getReferentSpeciesWithSurveyCode()); + speciesList.removeAll( + model.getSpeciesUsed().get( + row.getSortedUnsortedCategoryValue())); + + selectedSpecies = getHandler().openAddSpeciesDialog( + _("tutti.selectSpecies.title"), + speciesList + ); + + result &= selectedSpecies != null; + return result; + } + + @Override + protected void releaseAction() { + selectedSpecies = null; + super.releaseAction(); + } + + @Override + protected void doAction() throws Exception { + + BenthosBatchTableModel tableModel = handler.getTableModel(); + JXTable table = handler.getTable(); + BenthosBatchRowModel row = tableModel.getEntry(table.getSelectedRow()); + + PersistenceService persistenceService = getContext().getPersistenceService(); + persistenceService.changeBenthosBatchSpecies(row.getId(), selectedSpecies); + + Collection<Species> speciesUsed = getModel().getSpeciesUsed() + .get(row.getSortedUnsortedCategoryValue()); + speciesUsed.remove(row.getSpecies()); + changeChildrenSpecies(row, selectedSpecies); + speciesUsed.add(selectedSpecies); + } + + protected void changeChildrenSpecies(BenthosBatchRowModel row, + Species species) { + row.setSpecies(species); + List<BenthosBatchRowModel> children = row.getChildBatch(); + if (children != null) { + for (BenthosBatchRowModel child : children) { + changeChildrenSpecies(child, species); + } + } + } +} Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,104 @@ +/* + * #%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% + */ + +BeanFilterableComboBox { + showReset: true; + i18nPrefix: "tutti.property."; + bean: {model}; +} + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + showReset: true; +} + +#createBenthosBatchTopPanel { + _help: {"tutti.createBenthosBatch.help"}; +} + +#speciesLabel { + text: "tutti.createBenthosBatch.field.species"; + toolTipText: "tutti.createBenthosBatch.field.species.tip"; + labelFor: {speciesComboBox}; + _help: {"tutti.createBenthosBatch.field.species.help"}; +} + +#speciesComboBox { + property: species; + selectedItem: {model.getSpecies()}; + data: {model.getAvailableSpecies()}; +} + +#sortedUnsortedCategoryLabel { + text: "tutti.createBenthosBatch.field.sortedUnsortedCategory"; + toolTipText: "tutti.createBenthosBatch.field.sortedUnsortedCategory.tip"; + labelFor: {sortedUnsortedCategoryComboBox}; + _help: {"tutti.createBenthosBatch.field.sortedUnsortedCategory.help"}; +} + +#sortedUnsortedCategoryComboBox { + property: sortedUnsortedCategory; + selectedItem: {model.getSortedUnsortedCategory()}; +} + +#batchWeightLabel { + text: "tutti.createBenthosBatch.field.batchWeight"; + toolTipText: "tutti.createBenthosBatch.field.batchWeight.tip"; + labelFor: {batchWeightField}; + _help: {"tutti.createBenthosBatch.field.batchWeight.help"}; +} + +#batchWeightField { + property: batchWeight; + model: {model.getBatchWeight()}; + useFloat: true; + numberPattern: {DECIMAL3_PATTERN}; + bean: {model}; +} + +#addSpeciesButton { + text: "tutti.createBenthosBatch.action.addSpecies"; + toolTipText: "tutti.createBenthosBatch.action.addSpecies.tip"; + i18nMnemonic: "tutti.createBenthosBatch.action.addSpecies.mnemonic"; + _tuttiAction: {SelectSpeciesForBenthosBatchAction.class}; + _help: {"tutti.createBenthosBatch.action.addSpecies.help"}; +} + +#saveButton { + actionIcon: save; + text: "tutti.createBenthosBatch.action.save"; + toolTipText: "tutti.createBenthosBatch.action.save.tip"; + i18nMnemonic: "tutti.createBenthosBatch.action.save.mnemonic"; + enabled: {model.isValid()}; + _help: {"tutti.createBenthosBatch.action.save.help"}; +} + +#cancelButton { + actionIcon: cancel; + text: "tutti.createBenthosBatch.action.cancel"; + toolTipText: "tutti.createBenthosBatch.action.cancel.tip"; + i18nMnemonic: "tutti.createBenthosBatch.action.cancel.mnemonic"; + _help: {"tutti.createBenthosBatch.action.cancel.help"}; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,122 @@ +<!-- + #%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% + --> +<JPanel id='createBenthosBatchTopPanel' layout='{new BorderLayout()}' + decorator='help' + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<CreateBenthosBatchUIModel, CreateBenthosBatchUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.referential.Species + fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue + + fr.ifremer.tutti.ui.swing.TuttiHelpBroker + fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI + fr.ifremer.tutti.ui.swing.util.TuttiUI + + org.jdesktop.swingx.JXTable + + jaxx.runtime.swing.editor.bean.BeanFilterableComboBox + jaxx.runtime.swing.editor.NumberEditor + + java.awt.Color + + static org.nuiton.i18n.I18n._ + static jaxx.runtime.SwingUtil.getStringValue + </import> + + <script><![CDATA[ + +public CreateBenthosBatchUI(EditCatchesUI parentUI) { + JAXXUtil.initContext(this, parentUI); + CreateBenthosBatchUIHandler handler = new CreateBenthosBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <CreateBenthosBatchUIHandler id='handler' + initializer='getContextValue(CreateBenthosBatchUIHandler.class)'/> + + <CreateBenthosBatchUIModel id='model' + initializer='getContextValue(CreateBenthosBatchUIModel.class)'/> + + <BeanValidator id='validator' bean='model' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='species' component='speciesComboBox'/> + <field name='sortedUnsortedCategory' + component='sortedUnsortedCategoryComboBox'/> + <field name='batchWeight' component='batchWeightField'/> + </BeanValidator> + + <TuttiHelpBroker id='broker' + constructorParams='"tutti.createBenthosBatch.help"'/> + + <Table id='configurationPanel' constraints='BorderLayout.CENTER' fill='both'> + + <!-- Species --> + <row> + <cell anchor='west'> + <JLabel id='speciesLabel'/> + </cell> + <cell weightx='1.0'> + <BeanFilterableComboBox id='speciesComboBox' constructorParams='this' + genericType='Species'/> + </cell> + <cell> + <JButton id='addSpeciesButton'/> + </cell> + </row> + + <!-- Sorted / Unsorted Category --> + <row> + <cell anchor='west'> + <JLabel id='sortedUnsortedCategoryLabel'/> + </cell> + <cell weightx='1.0' columns='2'> + <BeanFilterableComboBox id='sortedUnsortedCategoryComboBox' + constructorParams='this' + genericType='CaracteristicQualitativeValue'/> + </cell> + </row> + + <!-- Species batch weight --> + <row> + <cell anchor='west'> + <JLabel id='batchWeightLabel'/> + </cell> + <cell weightx='1.0' columns='2'> + <NumberEditor id='batchWeightField' constructorParams='this'/> + </cell> + </row> + + + </Table> + + <!-- Form Actions --> + <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'> + <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> + <JButton id='saveButton' onActionPerformed='handler.save()'/> + </JPanel> +</JPanel> Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,245 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create; + +/* + * #%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.Lists; +import com.google.common.collect.Multimap; +import fr.ifremer.tutti.persistence.TuttiPersistence; +import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum; +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; +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.benthos.BenthosBatchUIModel; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.util.Cancelable; +import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.Dimension; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +/** + * Handler of {@link CreateBenthosBatchUI}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class CreateBenthosBatchUIHandler extends AbstractTuttiUIHandler<CreateBenthosBatchUIModel, CreateBenthosBatchUI> implements Cancelable { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(CreateBenthosBatchUIHandler.class); + + private final TuttiPersistence persistenceService; + + private final CaracteristicQualitativeValue sortedValue; + + public CreateBenthosBatchUIHandler(TuttiUI parentUi, + CreateBenthosBatchUI ui) { + super(parentUi.getHandler().getContext(), ui); + this.persistenceService = context.getPersistenceService(); + + Caracteristic caracteristic = + persistenceService.getSortedUnsortedCaracteristic(); + sortedValue = SortedUnsortedEnum.SORTED.getValue(caracteristic); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + CreateBenthosBatchUIModel model = new CreateBenthosBatchUIModel(); + ui.setContextValue(model); + listModelIsModify(model); + } + + @Override + public void afterInitUI() { + + initUI(ui); + + initBeanFilterableComboBox(ui.getSpeciesComboBox(), + Lists.<Species>newArrayList(), + null, + DecoratorService.FROM_PROTOCOL); + + Caracteristic caracteristic = + persistenceService.getSortedUnsortedCaracteristic(); + + initBeanFilterableComboBox(ui.getSortedUnsortedCategoryComboBox(), + caracteristic.getQualitativeValue(), + null); + + getModel().addPropertyChangeListener(CreateBenthosBatchUIModel.PROPERTY_SPECIES, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + CreateBenthosBatchUIModel source = + (CreateBenthosBatchUIModel) evt.getSource(); + Species newValue = (Species) evt.getNewValue(); + + if (log.isInfoEnabled()) { + log.info("New Selected species " + (newValue == null ? null : newValue.getRefTaxCode())); + } + + if (newValue == null || source.getSpeciesUsed() == null) { + + source.setSortedUnsortedCategory(null); + + } else { + + // look for best value : if sorted is available then use it + + List<CaracteristicQualitativeValue> qualitativeValues = + ui.getSortedUnsortedCategoryComboBox().getData(); + + CaracteristicQualitativeValue newCategory = null; + + for (CaracteristicQualitativeValue qualitativeValue : qualitativeValues) { + if (source.isSpeciesAndCategoryAvailable(newValue, qualitativeValue)) { + newCategory = qualitativeValue; + + if (newCategory.equals(sortedValue)) { + break; + } + } + } + source.setSortedUnsortedCategory(newCategory); + } + } + }); + + listenValidatorValid(ui.getValidator(), getModel()); + } + + @Override + public void onCloseUI() { + + if (log.isDebugEnabled()) { + log.debug("closing: " + ui); + } + + // evict model from validator + ui.getValidator().setBean(null); + + // when canceling always invalid model + getModel().setValid(false); + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + parent.getHandler().setBenthosSelectedCard(EditCatchesUIHandler.MAIN_CARD); + + } + + @Override + public SwingValidator<CreateBenthosBatchUIModel> getValidator() { + return ui.getValidator(); + } + + //------------------------------------------------------------------------// + //-- Cancelable methods --// + //------------------------------------------------------------------------// + + @Override + public void cancel() { + if (log.isInfoEnabled()) { + log.info("Cancel UI " + ui); + } + closeUI(ui); + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void openUI(BenthosBatchUIModel batchModel) { + + CreateBenthosBatchUIModel model = getModel(); + + // connect model to validator + ui.getValidator().setBean(model); + + model.setSpecies(null); + model.setSortedUnsortedCategory(null); + model.setBatchWeight(null); + + List<Species> speciesToUse = Lists.newArrayList(); + + Multimap<CaracteristicQualitativeValue, Species> speciesUsed = + model.getSpeciesUsed(); + speciesUsed.clear(); + + if (batchModel != null) { + + speciesUsed.putAll(batchModel.getSpeciesUsed()); + + // compute which species can still be used + + List<Species> allSpecies = getDataContext().getReferentSpeciesWithSurveyCode(); + + speciesToUse.addAll(allSpecies); + } + + model.setAvailableSpecies(speciesToUse); + ui.getSpeciesComboBox().requestFocus(); + } + + public void save() { + + if (log.isInfoEnabled()) { + log.info("Save UI " + ui); + } + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + parent.getBenthosTabContent().getHandler().addBatch(getModel()); + + // close dialog + closeUI(ui); + } + + public Species openAddSpeciesDialog(String title, List<Species> species) { + SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui); + SelectSpeciesUIModel model = dialogContent.getModel(); + model.setSelectedSpecies(null); + model.setSpecies(species); + + openDialog(dialogContent, title, new Dimension(400, 130)); + + Species result = model.getSelectedSpecies(); + return result; + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,161 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create; + +/* + * #%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.ArrayListMultimap; +import com.google.common.collect.Multimap; +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.SpeciesBatchRootRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUI; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.List; + +/** + * Model of {@link CreateSpeciesBatchUI}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class CreateBenthosBatchUIModel extends AbstractTuttiBeanUIModel<CreateBenthosBatchUIModel, CreateBenthosBatchUIModel> + implements SpeciesBatchRootRowModel { + + private final static Log log = LogFactory.getLog(CreateBenthosBatchUIModel.class); + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_AVAILABLE_SPECIES = "availableSpecies"; + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory"; + + public static final String PROPERTY_BATCH_WEIGHT = "batchWeight"; + + /** + * All available species (sets by protocol). + * + * @since 0.3 + */ + protected List<Species> availableSpecies; + + /** + * Species to select. + * + * @since 0.3 + */ + protected Species species; + + /** + * Sorted Unsorted category. + * + * @since 0.3 + */ + protected CaracteristicQualitativeValue sortedUnsortedCategory; + + /** + * Incoming batch weight to split. + * + * @since 0.3 + */ + protected Float batchWeight; + + /** + * Already used species by sortedUnsorted category. + * + * @since 0.3 + */ + protected final Multimap<CaracteristicQualitativeValue, Species> speciesUsed = ArrayListMultimap.create(); + + public CreateBenthosBatchUIModel() { + super(CreateBenthosBatchUIModel.class, null, null); + } + + public List<Species> getAvailableSpecies() { + if (log.isDebugEnabled()) { + log.debug("getAvailableSpecies " + availableSpecies); + } + return availableSpecies; + } + + public void setAvailableSpecies(List<Species> availableSpecies) { + + if (log.isDebugEnabled()) { + log.debug("setAvailableSpecies " + availableSpecies); + } + Object oldValue = getAvailableSpecies(); + this.availableSpecies = availableSpecies; + firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies); + } + + public Species getSpecies() { + return species; + } + + public void setSpecies(Species species) { + Object oldSpecies = getSpecies(); + this.species = species; + firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies()); + } + + public CaracteristicQualitativeValue getSortedUnsortedCategory() { + return sortedUnsortedCategory; + } + + public void setSortedUnsortedCategory(CaracteristicQualitativeValue sortedUnsortedCategory) { + Object oldSpecies = getSortedUnsortedCategory(); + this.sortedUnsortedCategory = sortedUnsortedCategory; + firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldSpecies, sortedUnsortedCategory); + } + + public Float getBatchWeight() { + return batchWeight; + } + + public void setBatchWeight(Float batchWeight) { + Object oldValue = getBatchWeight(); + this.batchWeight = batchWeight; + firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight); + } + + public Multimap<CaracteristicQualitativeValue, Species> getSpeciesUsed() { + return speciesUsed; + } + + public boolean isSpeciesAndCategoryAvailable() { + boolean result = species != null && sortedUnsortedCategory != null && + isSpeciesAndCategoryAvailable(species, sortedUnsortedCategory); + return result; + } + + public boolean isSpeciesAndCategoryAvailable(Species species, + CaracteristicQualitativeValue sortedUnsortedCategory) { + boolean result = !speciesUsed.containsEntry(sortedUnsortedCategory, species); + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,101 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create; + +/* + * #%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.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; + +import java.util.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; + +/** + * Enable to select a species to the species selected in the protocol. + * + * @author kmorin <kmorin@codelutin.com> + * @since 1.0 + */ +public class SelectSpeciesForBenthosBatchAction extends AbstractTuttiAction<CreateBenthosBatchUIModel, CreateBenthosBatchUI, CreateBenthosBatchUIHandler> { + + protected List<Species> allSpecies; + + protected List<Species> referentSpecies; + + protected Species selectedSpecies; + + public SelectSpeciesForBenthosBatchAction(CreateBenthosBatchUIHandler handler) { + super(handler, false); + + allSpecies = getDataContext().getSpecies(); + referentSpecies = getDataContext().getReferentSpecies(); + } + + @Override + protected boolean prepareAction() throws Exception { + boolean canContinue = super.prepareAction(); + if (canContinue) { + + CreateBenthosBatchUIModel model = getModel(); + + List<Species> species = Lists.newArrayList(allSpecies); + species.removeAll(model.getAvailableSpecies()); + + selectedSpecies = getHandler().openAddSpeciesDialog( + _("tutti.selectSpecies.title"), species); + canContinue = selectedSpecies != null; + } + return canContinue; + } + + @Override + protected void doAction() throws Exception { + + CreateBenthosBatchUIModel model = getModel(); + + List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies()); + + if (!selectedSpecies.isReferenceTaxon()) { + String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); + List<Species> referents = referentSpecies; + Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents); + String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId()); + selectedSpecies = referentsById.get(taxonId); + String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); + sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent)); + } + + if (!availableSpecies.contains(selectedSpecies)) { + availableSpecies.add(selectedSpecies); + } + model.setAvailableSpecies(availableSpecies); + model.setSpecies(selectedSpecies); + + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,293 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency; + +/* + * #%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.base.Preconditions; +import com.google.common.collect.Lists; +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.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchTableModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUIModel; +import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.border.LineBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +/** + * Component to render and edit frequency stuff from batch table. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class BenthosFrequencyCellComponent extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + protected Color computedDataColor; + + /** Logger. */ + private static final Log log = + LogFactory.getLog(BenthosFrequencyCellComponent.class); + + public BenthosFrequencyCellComponent(Color computedDataColor) { + setHorizontalAlignment(CENTER); + setIcon(SwingUtil.createActionIcon("show-frequency")); + this.computedDataColor = computedDataColor; + } + + public void setComputedOrNotText(TuttiComputedOrNotData<Integer> data) { + String text; + + if (data != null && data.getData() != null) { + text = String.valueOf(data.getData()); + + } else if (data != null + && data.getComputedData() != null + && data.getComputedData() != 0) { + + String blue = Integer.toHexString(computedDataColor.getRGB()).substring(2); + text = "<html><em style='color: #" + blue + "'>" + data.getComputedData() + "</em></html>"; + + } else { + text = " - "; + } + setText(text); + setToolTipText(text); + } + + public static TableCellRenderer newRender(Color computedDataColor) { + return new FrequencyCellRenderer(computedDataColor); + } + + public static TableCellEditor newEditor(BenthosBatchUI ui, Color computedDataColor) { + return new FrequencyCellEditor(ui, computedDataColor); + } + + public static class FrequencyCellEditor extends AbstractCellEditor implements TableCellEditor { + + private static final long serialVersionUID = 1L; + + protected final BenthosFrequencyCellComponent component; + + protected final BenthosBatchUI ui; + + protected JTable table; + + protected BenthosBatchTableModel tableModel; + + protected ColumnIdentifier<BenthosBatchRowModel> columnIdentifier; + + protected BenthosBatchRowModel editRow; + + protected Integer rowIndex; + + protected Integer columnIndex; + + public FrequencyCellEditor(BenthosBatchUI ui, Color computedDataColor) { + this.ui = ui; + component = new BenthosFrequencyCellComponent(computedDataColor); + component.setBorder(new LineBorder(Color.BLACK)); + component.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER || + e.getKeyCode() == KeyEvent.VK_SPACE) { + e.consume(); + startEdit(); + } + } + }); + + component.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + e.consume(); + startEdit(); + } + }); + } + + protected void startEdit() { + + Preconditions.checkNotNull(tableModel, "No table model assigned."); + + // open frequency dialog + + Preconditions.checkNotNull(editRow, "No editRow found."); + + if (log.isInfoEnabled()) { + log.info("Will edit frequencies for row: " + rowIndex); + } + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + BenthosFrequencyUI frequencyEditor = parent.getBenthosTabFrequencyEditor(); + + frequencyEditor.getHandler().editBatch(editRow, this); + + // open frequency editor + parent.getHandler().setBenthosSelectedCard(EditCatchesUIHandler.EDIT_FREQUENCY_CARD); + } + + public void validateEdition(BenthosFrequencyUIModel frequencyModel) { + if (frequencyModel.isValid()) { + + // at close, synch back frequencies + List<BenthosFrequencyRowModel> frequency = Lists.newArrayList(); + + if (frequencyModel.isSimpleCountingMode()) { + editRow.setNumber(frequencyModel.getSimpleCount()); + + } else { + // transfer rows to editor + + for (BenthosFrequencyRowModel row : frequencyModel.getRows()) { + if (row.isValid()) { + + // can keep this row + frequency.add(row); + } + } + if (log.isInfoEnabled()) { + log.info("Push back " + frequency.size() + + " frequency to batch " + frequencyModel.getBatch()); + } + + // push back to batch + editRow.setNumber(null); + + } + + editRow.setFrequency(frequency); + // update frequencies total + ui.getHandler().updateTotalFromFrequencies(editRow); + + } + + int r = rowIndex; + int c = columnIndex; + + // stop edition + stopCellEditing(); + + // reselect this cell + AbstractSelectTableAction.doSelectCell(table, r, c); + table.requestFocus(); + } + + @Override + public Component getTableCellEditorComponent(JTable table, + Object value, + boolean isSelected, + int row, + int column) { + tableModel = (BenthosBatchTableModel) table.getModel(); + this.table = table; + columnIdentifier = BenthosBatchTableModel.COMPUTED_NUMBER; + if (log.isDebugEnabled()) { + log.debug("Set columnIdentifier (" + column + ") :: " + columnIdentifier.getPropertyName()); + } + TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value; + component.setComputedOrNotText(data); + + rowIndex = row; + columnIndex = column; + + editRow = tableModel.getEntry(row); + + return component; + } + + @Override + public Object getCellEditorValue() { + + Preconditions.checkNotNull(editRow, "No editRow found in editor."); + + Object result = null; + if (columnIdentifier == BenthosBatchTableModel.COMPUTED_NUMBER) { + result = editRow.getComputedOrNotNumber(); + } + if (log.isDebugEnabled()) { + log.debug("editor value (" + columnIdentifier + "): " + result); + } + + return result; + } + + @Override + public void cancelCellEditing() { + super.cancelCellEditing(); + rowIndex = null; + columnIndex = null; + editRow = null; + } + } + + public static class FrequencyCellRenderer implements TableCellRenderer { + + protected final BenthosFrequencyCellComponent component; + + public FrequencyCellRenderer(Color computedDataColor) { + component = new BenthosFrequencyCellComponent(computedDataColor); + } + + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { + + TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value; + BenthosFrequencyCellComponent result = + (BenthosFrequencyCellComponent) component.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + boolean editable = table.isCellEditable(row, column); + result.setEnabled(editable); + result.setComputedOrNotText(data); + return result; + } + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyRowModel.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,164 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency; + +/* + * #%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.Lists; +import com.google.common.collect.Ordering; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; + +/** + * Represents a batch frequency row. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class BenthosFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBatchFrequency, BenthosFrequencyRowModel> implements Comparable<BenthosFrequencyRowModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_LENGTH_STEP = "lengthStep"; + + public static final String PROPERTY_NUMBER = "number"; + + public static final String PROPERTY_WEIGHT = "weight"; + + public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic"; + + /** + * Length step. + * + * @since 0.2 + */ + protected Float lengthStep; + + /** + * Count of fishes for this lengthStep. + * + * @since 0.2 + */ + protected Integer number; + + /** + * Weight of fishes observed. + * + * @since 0.2 + */ + protected Float weight; + + /** + * Length step caracteristic. + * + * @since 0.3 + */ + protected Caracteristic lengthStepCaracteristic; + + protected static final Binder<SpeciesBatchFrequency, BenthosFrequencyRowModel> fromBeanBinder = + BinderFactory.newBinder(SpeciesBatchFrequency.class, + BenthosFrequencyRowModel.class); + + protected static final Binder<BenthosFrequencyRowModel, SpeciesBatchFrequency> toBeanBinder = + BinderFactory.newBinder(BenthosFrequencyRowModel.class, + SpeciesBatchFrequency.class); + + private static final Ordering<Float> ordering = Ordering.natural().nullsFirst(); + + public static List<BenthosFrequencyRowModel> fromBeans(List<SpeciesBatchFrequency> frequency) { + List<BenthosFrequencyRowModel> result = Lists.newArrayList(); + for (SpeciesBatchFrequency b : frequency) { + BenthosFrequencyRowModel model = new BenthosFrequencyRowModel(); + fromBeanBinder.copy(b, model); + result.add(model); + } + return result; + } + + public static List<SpeciesBatchFrequency> toBeans(List<BenthosFrequencyRowModel> frequency, SpeciesBatch batch) { + List<SpeciesBatchFrequency> result = Lists.newArrayList(); + for (BenthosFrequencyRowModel b : frequency) { + SpeciesBatchFrequency model = new SpeciesBatchFrequency(); + toBeanBinder.copy(b, model); + model.setBatch(batch); + result.add(model); + } + return result; + } + + public BenthosFrequencyRowModel() { + super(SpeciesBatchFrequency.class, fromBeanBinder, toBeanBinder); + } + + public Float getLengthStep() { + return lengthStep; + } + + public void setLengthStep(Float lengthStep) { + Object oldValue = getLengthStep(); + this.lengthStep = lengthStep; + firePropertyChange(PROPERTY_LENGTH_STEP, oldValue, lengthStep); + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + Object oldValue = getNumber(); + this.number = number; + firePropertyChange(PROPERTY_NUMBER, oldValue, number); + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + Object oldValue = getWeight(); + this.weight = weight; + firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + } + + public Caracteristic getLengthStepCaracteristic() { + return lengthStepCaracteristic; + } + + public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) { + Object oldValue = getLengthStepCaracteristic(); + this.lengthStepCaracteristic = lengthStepCaracteristic; + firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic); + } + + @Override + public int compareTo(BenthosFrequencyRowModel o) { + int result = ordering.compare(lengthStep, o.lengthStep); + return result; + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyTableModel.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyTableModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,143 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency; + +/* + * #%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.base.Preconditions; +import com.google.common.collect.Maps; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import org.jdesktop.swingx.table.TableColumnModelExt; + +import java.util.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n.n_; + +/** + * Model of the species frequency table. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class BenthosFrequencyTableModel extends AbstractTuttiTableModel<BenthosFrequencyRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<BenthosFrequencyRowModel> LENGTH_STEP = ColumnIdentifier.newId( + BenthosFrequencyRowModel.PROPERTY_LENGTH_STEP, + n_("tutti.editSpeciesFrequencies.table.header.lengthStep"), + n_("tutti.editSpeciesFrequencies.table.header.lengthStep")); + + public static final ColumnIdentifier<BenthosFrequencyRowModel> NUMBER = ColumnIdentifier.newId( + BenthosFrequencyRowModel.PROPERTY_NUMBER, + n_("tutti.editSpeciesFrequencies.table.header.number"), + n_("tutti.editSpeciesFrequencies.table.header.number")); + + public static final ColumnIdentifier<BenthosFrequencyRowModel> WEIGHT = ColumnIdentifier.newId( + BenthosFrequencyRowModel.PROPERTY_WEIGHT, + n_("tutti.editSpeciesFrequencies.table.header.weight"), + n_("tutti.editSpeciesFrequencies.table.header.weight")); + + private final BenthosFrequencyUIModel uiModel; + + private final Map<Float, BenthosFrequencyRowModel> rowCache; + + public BenthosFrequencyTableModel(TableColumnModelExt columnModel, + BenthosFrequencyUIModel uiModel) { + super(columnModel, true, true); + this.uiModel = uiModel; + this.rowCache = Maps.newTreeMap(); + setNoneEditableCols(); + } + + @Override + public BenthosFrequencyRowModel createNewRow() { + Float defaultStep = null; + + int rowCount = getRowCount(); + if (rowCount > 0) { + + BenthosFrequencyRowModel rowModel = getEntry(rowCount - 1); + Float lengthStep = rowModel.getLengthStep(); + if (lengthStep != null) { + defaultStep = uiModel.getLengthStep( + lengthStep + uiModel.getStep()); + } + } + BenthosFrequencyRowModel result = new BenthosFrequencyRowModel(); + result.setLengthStep(defaultStep); + result.setValid(false); + return result; + } + + @Override + public void setValueAt(Object aValue, + int rowIndex, + int columnIndex, + ColumnIdentifier<BenthosFrequencyRowModel> propertyName, + BenthosFrequencyRowModel entry) { + super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + // TODO Rebuild the computedWeight if possible... + } + + public Map<Float, BenthosFrequencyRowModel> getRowCache() { + return rowCache; + } + + @Override + protected void onRowsChanged(List<BenthosFrequencyRowModel> data) { + + // rebuild row cache + rowCache.clear(); + + for (BenthosFrequencyRowModel row : data) { + Float lengthStep = row.getLengthStep(); + if (lengthStep != null) { + rowCache.put(lengthStep, row); + } + } + } + + @Override + protected void onRowAdded(int rowIndex, BenthosFrequencyRowModel newValue) { + + Preconditions.checkNotNull(newValue, "can't add a null row"); + + newValue.setLengthStepCaracteristic(uiModel.getLengthStepCaracteristic()); + + // add new row to cache + Float lengthStep = newValue.getLengthStep(); + + Preconditions.checkNotNull(lengthStep, + "can't add a null lengthStep row"); + + float roundLenghtValue = uiModel.getLengthStep(lengthStep); + + if (!rowCache.containsKey(roundLenghtValue)) { + + rowCache.put(roundLenghtValue, newValue); + } + } +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,245 @@ +/* + * #%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% + */ + +BeanFilterableComboBox { + showReset: true; + i18nPrefix: "tutti.property."; + bean: {model}; +} + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; +} + +#editSpeciesFrequenciesTopPanel { + _help: {"tutti.editBenthosFrequencies.help"}; +} + +#stepLabel { + text: "tutti.editBenthosFrequencies.field.step"; + toolTipText: "tutti.editBenthosFrequencies.field.step.tip"; + labelFor: {stepField}; + enabled: {!model.isSimpleCountingMode()}; + _help: {"tutti.editBenthosFrequencies.field.step.help"}; +} + +#stepField { + property: step; + model: {model.getStep()}; + useFloat: true; + numberPattern: {DECIMAL1_PATTERN}; + bean: {model}; + enabled: {!model.isSimpleCountingMode()}; +} + +#lengthStepCaracteristicLabel { + text: "tutti.editBenthosFrequencies.field.lengthStepCaracteristic"; + toolTipText: "tutti.editBenthosFrequencies.field.lengthStepCaracteristic.tip"; + labelFor: {lengthStepCaracteristicComboBox}; + enabled: {!model.isSimpleCountingMode()}; + _help: {"tutti.editBenthosFrequencies.field.lengthStepCaracteristic.help"}; +} + +#lengthStepCaracteristicComboBox { + property: lengthStepCaracteristic; + selectedItem: {model.getLengthStepCaracteristic()}; + enabled: {!model.isSimpleCountingMode()}; +} + +#minStepLabel { + text: "tutti.editBenthosFrequencies.field.minStep"; + toolTipText: "tutti.editBenthosFrequencies.field.minStep.tip"; + labelFor: {minStepField}; + _help: {"tutti.editBenthosFrequencies.field.minStep.help"}; +} + +#minStepField { + property: minStep; + model: {model.getMinStep()}; + useFloat: true; + showReset: true; + numberPattern: {DECIMAL1_PATTERN}; + bean: {model}; +} + +#maxStepLabel { + text: "tutti.editBenthosFrequencies.field.maxStep"; + toolTipText: "tutti.editBenthosFrequencies.field.maxStep.tip"; + labelFor: {maxStepField}; + _help: {"tutti.editBenthosFrequencies.field.maxStep.help"}; +} + +#maxStepField { + property: maxStep; + model: {model.getMaxStep()}; + useFloat: true; + showReset: true; + numberPattern: {DECIMAL1_PATTERN}; + bean: {model}; +} + +#rafaleStepLabel { + text: "tutti.editBenthosFrequencies.field.rafaleStep"; + toolTipText: "tutti.editBenthosFrequencies.field.rafaleStep.tip"; + labelFor: {rafaleStepField}; + _help: {"tutti.editBenthosFrequencies.field.rafaleStep.help"}; +} + +#rafaleStepField { + modelType: {Float.class}; + useFloat: true; + showReset: true; + numberPattern: {DECIMAL1_PATTERN}; + enabled: {model.getLengthStepCaracteristic() != null}; +} + +#configurationPanel { + border: {new TitledBorder(null, _("tutti.legend.frequencyConfiguration"))}; +} + +#modeConfigurationLayout { + selected: {String.valueOf(mode.getSelectedValue())}; +} + +#modeConfigurationPanel { + layout: {modeConfigurationLayout}; +} + +#simpleModeButton { + text: "tutti.editBenthosFrequencies.field.mode.simple"; + toolTipText: "tutti.editBenthosFrequencies.field.mode.simple.tip"; + value: "simpleMode"; + selected: {model.isSimpleMode()}; + buttonGroup: "mode"; + _help: {"tutti.editBenthosFrequencies.field.mode.simple.help"}; +} + +#simpleModeLabel { + text: "tutti.editBenthosFrequencies.label.no.configuration"; + horizontalAlignment: {JLabel.CENTER}; + enabled: false; +} + +#autoGenModeButton { + text: "tutti.editBenthosFrequencies.field.mode.autoGen"; + toolTipText: "tutti.editBenthosFrequencies.field.mode.autoGen.tip"; + value: "autoGenMode"; + selected: {model.isAutoGenMode()}; + buttonGroup: "mode"; + _help: {"tutti.editBenthosFrequencies.field.mode.autoGen.help"}; +} + +#rafaleModeButton { + text: "tutti.editBenthosFrequencies.field.mode.rafale"; + toolTipText: "tutti.editBenthosFrequencies.field.mode.rafale.tip"; + value: "rafaleMode"; + selected: {model.isRafaleMode()}; + buttonGroup: "mode"; + _help: {"tutti.editBenthosFrequencies.field.mode.rafale.help"}; +} + +#simpleCountingModeButton { + text: "tutti.editBenthosFrequencies.field.mode.simpleCounting"; + toolTipText: "tutti.editBenthosFrequencies.field.mode.simpleCounting.tip"; + value: "simpleCountingMode"; + selected: {model.isSimpleCountingMode()}; + buttonGroup: "mode"; + _help: {"tutti.editBenthosFrequencies.field.mode.simpleCounting.help"}; +} + +#simpleCountingModeLabel { + text: "tutti.editBenthosFrequencies.label.no.configuration"; + horizontalAlignment: {JLabel.CENTER}; + enabled: false; +} + +#dataFieldLayout { + selected: {model.isSimpleCountingMode() ? "noLengthCaracteristicPmfm" : "lengthCaracteristicPmfm"}; +} + +#dataFieldPanel { + layout: {dataFieldLayout}; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; + enabled: {model.getLengthStepCaracteristic() != null} +} + +#simpleCountingLabel { + text: "tutti.editBenthosFrequencies.field.simpleCounting"; + toolTipText: "tutti.editBenthosFrequencies.field.simpleCounting.tip"; + labelFor: {simpleCountingField}; + _help: {"tutti.editBenthosFrequencies.field.simpleCounting.help"}; +} + +#simpleCountingField { + property: simpleCount; + model: {model.getSimpleCount()}; + useFloat: false; + showReset: true; + numberPattern: {TuttiUI.INT_6_DIGITS_PATTERN}; + bean: {model}; +} + +#generateButton { + actionIcon: generate; + text: "tutti.editBenthosFrequencies.action.generate"; + toolTipText: "tutti.editBenthosFrequencies.action.generate.tip"; + i18nMnemonic: "tutti.editBenthosFrequencies.action.generate.mnemonic"; + enabled: {model.isCanGenerate()}; + _help: {"tutti.editBenthosFrequencies.action.generate.help"}; +} + +#cancelButton { + actionIcon: cancel; + text: "tutti.editBenthosFrequencies.action.cancel"; + toolTipText: "tutti.editBenthosFrequencies.action.cancel.tip"; + i18nMnemonic: "tutti.editBenthosFrequencies.action.cancel.mnemonic"; + _help: {"tutti.editBenthosFrequencies.action.cancel.help"}; +} + +#saveButton { + actionIcon: save; + text: "tutti.editBenthosFrequencies.action.save"; + toolTipText: "tutti.editBenthosFrequencies.action.save.tip"; + i18nMnemonic: "tutti.editBenthosFrequencies.action.save.mnemonic"; + enabled: {model.isValid()}; + _help: {"tutti.editBenthosFrequencies.action.save.help"}; +} + +#dataInFrequenciesWarningContainer { + background: {new java.awt.Color(245, 218, 88)}; + visible: {!org.apache.commons.collections.CollectionUtils.isEmpty(model.getBatch().getFrequency())}; +} + +#dataInFrequenciesWarning { + actionIcon: warning; + border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)}; + text: "tutti.editBenthosFrequencies.simpleCountingAndFrequencies"; +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,223 @@ +<!-- + #%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% + --> +<JPanel id='editBenthosFrequenciesTopPanel' layout='{new BorderLayout()}' + decorator='help' + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<BenthosFrequencyUIModel, BenthosFrequencyUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.referential.Caracteristic + + fr.ifremer.tutti.ui.swing.TuttiHelpBroker + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI + fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel + fr.ifremer.tutti.ui.swing.util.TuttiUI + + jaxx.runtime.swing.CardLayout2Ext + jaxx.runtime.swing.editor.bean.BeanFilterableComboBox + jaxx.runtime.swing.editor.NumberEditor + + org.jdesktop.swingx.JXTable + + javax.swing.ListSelectionModel + javax.swing.SwingConstants + + java.awt.Color + java.awt.Dimension + + static org.nuiton.i18n.I18n._ + static jaxx.runtime.SwingUtil.getStringValue + </import> + + <script><![CDATA[ + + public BenthosFrequencyUI(TuttiUI parentUI) { + JAXXUtil.initContext(this, parentUI); + BenthosFrequencyUIHandler handler = new BenthosFrequencyUIHandler(parentUI.getHandler().getContext(), this); + setContextValue(handler); + handler.beforeInitUI(); + } + + protected void $afterCompleteSetup() { + handler.afterInitUI(); + } + ]]></script> + + <BenthosFrequencyUIHandler id='handler' + initializer='getContextValue(BenthosFrequencyUIHandler.class)'/> + + <BenthosFrequencyUIModel id='model' + initializer='getContextValue(BenthosFrequencyUIModel.class)'/> + + <BeanValidator id='validator' bean='model' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='lengthStepCaracteristic' + component='lengthStepCaracteristicComboBox'/> + <field name='rows' component='tableScrollPane'/> + </BeanValidator> + + <TuttiHelpBroker id='broker' + constructorParams='"tutti.editBenthosFrequencies.help"'/> + + <CardLayout2Ext id='modeConfigurationLayout' + constructorParams='this, "modeConfigurationPanel"'/> + + <CardLayout2Ext id='dataFieldLayout' + constructorParams='this, "dataFieldPanel"'/> + + <JPanel id='configurationPanel' layout='{new BorderLayout()}' + constraints='BorderLayout.NORTH'> + + <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'> + <VBox id='modePanel' constraints='BorderLayout.WEST' + verticalAlignment='{SwingConstants.CENTER}'> + <JRadioButton id='simpleModeButton' + onActionPerformed='model.setConfigurationMode(BenthosFrequencyUIModel.ConfigurationMode.SIMPLE)'/> + <JRadioButton id='autoGenModeButton' + onActionPerformed='model.setConfigurationMode(BenthosFrequencyUIModel.ConfigurationMode.AUTO_GEN)'/> + <JRadioButton id='rafaleModeButton' + onActionPerformed='model.setConfigurationMode(BenthosFrequencyUIModel.ConfigurationMode.RAFALE)'/> + <JRadioButton id='simpleCountingModeButton' + onActionPerformed='model.setConfigurationMode(BenthosFrequencyUIModel.ConfigurationMode.SIMPLE_COUNTING)'/> + </VBox> + + <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'> + <JPanel id='simpleModePanel' constraints='"simpleMode"' + layout='{new BorderLayout()}'> + <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/> + </JPanel> + <JPanel id='autoGenModePanel' constraints='"autoGenMode"'> + <Table fill='both' constraints='BorderLayout.SOUTH'> + <!-- Min step--> + <row> + <cell anchor='west'> + <JLabel id='minStepLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='minStepField' constructorParams='this'/> + </cell> + </row> + <!-- Max step--> + <row> + <cell anchor='west'> + <JLabel id='maxStepLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='maxStepField' constructorParams='this'/> + </cell> + </row> + <!-- Actions --> + <row> + <cell columns='2'> + <JPanel layout='{new GridLayout(1, 0)}'> + <JButton id='generateButton' + onActionPerformed='handler.generateLengthSteps()'/> + </JPanel> + </cell> + </row> + </Table> + </JPanel> + <JPanel id='rafaleModePanel' constraints='"rafaleMode"'> + <Table fill='both' constraints='BorderLayout.SOUTH'> + <!-- Rafale step--> + <row> + <cell weightx='1.0'> + <JLabel id='rafaleStepLabel'/> + </cell> + </row> + <row> + <cell weightx='1.0'> + <NumberEditor id='rafaleStepField' + constructorParams='this'/> + </cell> + </row> + </Table> + </JPanel> + <JPanel id='simpleCountingModePanel' constraints='"simpleCountingMode"' + layout='{new BorderLayout()}'> + <JLabel id='simpleCountingModeLabel' + constraints='BorderLayout.CENTER'/> + </JPanel> + </JPanel> + </JPanel> + <Table fill='both' constraints='BorderLayout.SOUTH'> + <row> + <cell columns='2'> + <JSeparator/> + </cell> + </row> + <!-- length step caracteristic --> + <row> + <cell anchor='west'> + <JLabel id='lengthStepCaracteristicLabel'/> + </cell> + <cell weightx='1.0'> + <BeanFilterableComboBox id='lengthStepCaracteristicComboBox' + constructorParams='this' + genericType='Caracteristic'/> + </cell> + </row> + <!-- Step --> + <row> + <cell anchor='west'> + <JLabel id='stepLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='stepField' constructorParams='this'/> + </cell> + </row> + </Table> + </JPanel> + + <JPanel id='dataFieldPanel' constraints='BorderLayout.CENTER'> + <JScrollPane id='tableScrollPane' constraints='"lengthCaracteristicPmfm"'> + <JXTable id='table'/> + </JScrollPane> + <Table constraints='"noLengthCaracteristicPmfm"' fill='horizontal'> + <row> + <cell columns='2'> + <JPanel id='dataInFrequenciesWarningContainer' layout='{new BorderLayout(10, 10)}'> + <JLabel id='dataInFrequenciesWarning' constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> + <row> + <cell> + <JLabel id='simpleCountingLabel'/> + </cell> + <cell weightx='1'> + <NumberEditor id='simpleCountingField' constructorParams='this'/> + </cell> + </row> + </Table> + </JPanel> + + <!-- actions --> + <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}' + constraints='BorderLayout.SOUTH'> + <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> + <JButton id='saveButton' onActionPerformed='handler.save()'/> + </JPanel> + +</JPanel> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java (from rev 665, 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/benthos/frequency/BenthosFrequencyUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,534 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency; + +/* + * #%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.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +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.Species; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; +import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; +import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; +import fr.ifremer.tutti.ui.swing.util.Cancelable; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +import javax.swing.JTextField; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class BenthosFrequencyUIHandler extends AbstractTuttiTableUIHandler<BenthosFrequencyRowModel, BenthosFrequencyUIModel, BenthosFrequencyUI> implements Cancelable { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(BenthosFrequencyUIHandler.class); + + private BenthosFrequencyCellComponent.FrequencyCellEditor frequencyEditor; + + private TuttiProtocol protocol; + + private Map<Integer, SpeciesProtocol> speciesProtocol; + + private Map<String, Caracteristic> lengthStepCaracteristics; + + protected Set<BenthosFrequencyRowModel> withWeightRows = Sets.newHashSet(); + + public BenthosFrequencyUIHandler(TuttiUIContext context, + BenthosFrequencyUI ui) { + super(context, ui, + BenthosFrequencyRowModel.PROPERTY_LENGTH_STEP, + BenthosFrequencyRowModel.PROPERTY_NUMBER, + BenthosFrequencyRowModel.PROPERTY_WEIGHT); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public BenthosFrequencyTableModel getTableModel() { + return (BenthosFrequencyTableModel) getTable().getModel(); + } + + @Override + public JXTable getTable() { + return ui.getTable(); + } + + @Override + protected boolean isRowValid(BenthosFrequencyRowModel row) { + return row.getLengthStepCaracteristic() != null && + row.getLengthStep() != null && + row.getNumber() != null && row.getNumber() > 0 && + (withWeightRows.isEmpty() || row.getWeight() != null && row.getWeight() > 0); + } + + @Override + protected void onRowModified(int rowIndex, + BenthosFrequencyRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + boolean recomputeAllRows; + + if (row.getWeight() != null) { + // check if no row had a weight, then if one of them now has a weight, + // the other ones must have one too to be valid + recomputeAllRows = withWeightRows.isEmpty(); + withWeightRows.add(row); + + } else { + withWeightRows.remove(row); + // check if no row has a weight, then if none of them now has a weight, + // the other ones do not need to have a weight to be valid + recomputeAllRows = withWeightRows.isEmpty(); + } + if (recomputeAllRows) { + List<BenthosFrequencyRowModel> rows = getModel().getRows(); + for (BenthosFrequencyRowModel r : rows) { + recomputeRowValidState(r); + } + } else { + recomputeRowValidState(row); + } + } + + @Override + protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosFrequencyRowModel> rowMonitor, + BenthosFrequencyRowModel row) { + } + + @Override + protected void onRowValidStateChanged(int rowIndex, + BenthosFrequencyRowModel row, + Boolean oldValue, + Boolean newValue) { + super.onRowValidStateChanged(rowIndex, row, oldValue, newValue); + ui.getValidator().doValidate(); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public SwingValidator<BenthosFrequencyUIModel> getValidator() { + return ui.getValidator(); + } + + @Override + public void beforeInitUI() { + + BenthosFrequencyUIModel model = new BenthosFrequencyUIModel(); + + ui.setContextValue(model); + } + + @Override + public void afterInitUI() { + + initUI(ui); + + List<Caracteristic> lengthStepCaracterics = + Lists.newArrayList(getDataContext().getLengthStepCaracteristics()); + + lengthStepCaracteristics = TuttiEntities.splitById(lengthStepCaracterics); + + BenthosFrequencyUIModel model = getModel(); + + if (context.isProtocolFilled()) { + + // get loaded protocol + protocol = getDataContext().getProtocol(); + Preconditions.checkNotNull(protocol, + "Could not find protocol in ui context"); + + // FIXME 20130128 kmorin: the species have no technical id + speciesProtocol = Maps.newHashMap(); + for (SpeciesProtocol sp : protocol.getSpecies()) { + speciesProtocol.put(sp.getSpeciesReferenceTaxonId(), sp); + } + + } + + Caracteristic modelCaracteristic = model.getLengthStepCaracteristic(); + initBeanFilterableComboBox(ui.getLengthStepCaracteristicComboBox(), + lengthStepCaracterics, + modelCaracteristic); + + // get precision from the pmfm + Float precision = null; + if (modelCaracteristic != null) { + precision = model.getLengthStepCaracteristic().getPrecision(); + } + if (precision == null) { + precision = 1f; + } + model.setStep(precision); + + model.setMinStep(10f); + model.setMaxStep(20f); + + ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() { + + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + e.consume(); + Float step = (Float) ui.getRafaleStepField().getModel(); + + applyRafaleStep(step); + + //select text + JTextField field = (JTextField) e.getSource(); + field.selectAll(); + } + } + }); + + // when lengthStepCaracteristic changed, let's updates all row with the new value + model.addPropertyChangeListener(BenthosFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Caracteristic newValue = (Caracteristic) evt.getNewValue(); + for (BenthosFrequencyRowModel rowModel : getModel().getRows()) { + rowModel.setLengthStepCaracteristic(newValue); + // get precision from the pmfm + Float precision = null; + if (newValue != null) { + precision = newValue.getPrecision(); + } + if (precision == null) { + precision = .5f; + } + getModel().setStep(precision); + recomputeRowValidState(rowModel); + } + ui.getValidator().doValidate(); + } + }); + + // create table column model + DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); + + { // LengthStep + + addFloatColumnToModel(columnModel, + BenthosFrequencyTableModel.LENGTH_STEP, + TuttiUI.DECIMAL1_PATTERN); + } + + { // Number + + addIntegerColumnToModel(columnModel, + BenthosFrequencyTableModel.NUMBER, + TuttiUI.INT_6_DIGITS_PATTERN); + } + + { // Weight + + addFloatColumnToModel(columnModel, + BenthosFrequencyTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + + // create table model + BenthosFrequencyTableModel tableModel = + new BenthosFrequencyTableModel(columnModel, model); + + JXTable table = getTable(); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + + initTable(table); + + installTableKeyListener(columnModel, table); + + listenValidatorValid(ui.getValidator(), model); + } + + @Override + public void onCloseUI() { + if (log.isDebugEnabled()) { + log.debug("closing: " + ui); + } + + frequencyEditor = null; + + // evict model from validator + ui.getValidator().setBean(null); + + // when canceling always invalid model (in that way) + getModel().setValid(false); + + getModel().setSimpleCount(null); + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + parent.getHandler().setBenthosSelectedCard(EditCatchesUIHandler.MAIN_CARD); + } + + //------------------------------------------------------------------------// + //-- Cancelable methods --// + //------------------------------------------------------------------------// + + @Override + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel UI " + ui); + } + + // close dialog + closeUI(ui); + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void generateLengthSteps() { + + BenthosFrequencyUIModel model = getModel(); + BenthosFrequencyTableModel tableModel = getTableModel(); + + Map<Float, BenthosFrequencyRowModel> rowsByStep = + getTableModel().getRowCache(); + + Float minStep = model.getLengthStep(model.getMinStep()); + Float maxStep = model.getLengthStep(model.getMaxStep()); + Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic(); + + for (float i = minStep, step = model.getStep(); i <= maxStep; i += step) { + if (!rowsByStep.containsKey(i)) { + + // add it + BenthosFrequencyRowModel newRow = tableModel.createNewRow(); + newRow.setLengthStep(i); + newRow.setLengthStepCaracteristic(lengthStepCaracteristic); + rowsByStep.put(i, newRow); + } + } + + List<BenthosFrequencyRowModel> rows = + Lists.newArrayList(rowsByStep.values()); + + model.setRows(rows); + } + + public void applyRafaleStep(Float step) { + + if (log.isInfoEnabled()) { + log.info("Will apply rafale step: " + step); + } + BenthosFrequencyUIModel model = getModel(); + BenthosFrequencyTableModel tableModel = getTableModel(); + + Map<Float, BenthosFrequencyRowModel> rowsByStep = tableModel.getRowCache(); + + float aroundLengthStep = model.getLengthStep(step); + + BenthosFrequencyRowModel row = rowsByStep.get(aroundLengthStep); + + int rowIndex; + + if (row != null) { + + // increments current row + Integer number = row.getNumber(); + row.setNumber((number == null ? 0 : number) + 1); + rowIndex = tableModel.updateRow(row); + + } else { + + // create a new row + + row = tableModel.createNewRow(); + row.setLengthStep(aroundLengthStep); + row.setNumber(1); + row.setValid(true); + + // get new index + List<Float> steps = Lists.newArrayList(rowsByStep.keySet()); + steps.add(aroundLengthStep); + + Collections.sort(steps); + + rowIndex = steps.indexOf(aroundLengthStep); + + tableModel.addNewRow(rowIndex, row); + } + + getTable().scrollRowToVisible(rowIndex); + } + + public void editBatch(BenthosBatchRowModel speciesBatch, BenthosFrequencyCellComponent.FrequencyCellEditor editor) { + withWeightRows.clear(); + + frequencyEditor = editor; + + Caracteristic lengthStepCaracteristic = null; + Float lengthStep = 1f; + + List<BenthosFrequencyRowModel> editFrequency = Lists.newArrayList(); + + if (speciesBatch != null) { + + List<BenthosFrequencyRowModel> frequency = + speciesBatch.getFrequency(); + + // try to load existing frequency + + if (!CollectionUtils.isEmpty(frequency)) { + + BenthosFrequencyTableModel tableModel = getTableModel(); + + for (BenthosFrequencyRowModel rowModel : frequency) { + + BenthosFrequencyRowModel newRow = tableModel.createNewRow(); + newRow.setLengthStepCaracteristic(rowModel.getLengthStepCaracteristic()); + newRow.setLengthStep(rowModel.getLengthStep()); + newRow.setNumber(rowModel.getNumber()); + newRow.setWeight(rowModel.getWeight()); + editFrequency.add(newRow); + + if (newRow.getWeight() != null) { + withWeightRows.add(newRow); + } + } + + // use first frequency row length step caracteristics + + BenthosFrequencyRowModel rowModel = frequency.get(0); + lengthStepCaracteristic = rowModel.getLengthStepCaracteristic(); + lengthStep = rowModel.getLengthStep(); + + if (log.isInfoEnabled()) { + log.info("Use existing lengthStep " + + "caracteristic / step " + + decorate(lengthStepCaracteristic) + " / " + + lengthStep); + } + } + + if (lengthStepCaracteristic == null && protocol != null) { + + Species species = speciesBatch.getSpecies(); + + SpeciesProtocol sProtocol = + speciesProtocol.get(species.getReferenceTaxonId()); + + if (sProtocol != null) { + + + String lengthStepPmfmId = sProtocol.getLengthStepPmfmId(); + + lengthStepCaracteristic = + this.lengthStepCaracteristics.get(lengthStepPmfmId); + lengthStep = sProtocol.getLengthStep(); + + if (log.isInfoEnabled()) { + log.info("Use existing from protocol lengthStep " + + "caracteristic / step " + + decorate(lengthStepCaracteristic) + " / " + + lengthStep); + } + } + } + } + + if (log.isDebugEnabled()) { + log.debug("Will edit batch row: " + speciesBatch + " with " + + editFrequency.size() + " frequency"); + } + + BenthosFrequencyUIModel model = getModel(); + + BenthosFrequencyUIModel.ConfigurationMode mode = BenthosFrequencyUIModel.ConfigurationMode.SIMPLE; + if (lengthStepCaracteristic == null && protocol != null) { + Integer taxonId = speciesBatch.getSpecies().getReferenceTaxonId(); + SpeciesProtocol speciesProtocol = this.speciesProtocol.get(taxonId); + if (speciesProtocol == null || speciesProtocol.getLengthStepPmfmId() == null) { + mode = BenthosFrequencyUIModel.ConfigurationMode.SIMPLE_COUNTING; + } + } + if (speciesBatch.getNumber() != null && editFrequency.isEmpty()) { + mode = BenthosFrequencyUIModel.ConfigurationMode.SIMPLE_COUNTING; + model.setSimpleCount(speciesBatch.getNumber()); + } + model.setConfigurationMode(mode); + + // connect model to validator + ui.getValidator().setBean(model); + + model.setRows(editFrequency); + model.setLengthStepCaracteristic(lengthStepCaracteristic); + + // keep batch (will be used to push back editing entry) + model.setBatch(speciesBatch); + } + + public void save() { + + if (log.isInfoEnabled()) { + log.info("Save UI " + ui); + } + + frequencyEditor.validateEdition(getModel()); + + closeUI(ui); + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,238 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency; + +/* + * #%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.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class BenthosFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, BenthosFrequencyRowModel, BenthosFrequencyUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_CONFIGURATION_MODE = "configurationMode"; + + public static final String PROPERTY_STEP = "step"; + + private static final String PROPERTY_MIN_STEP = "minStep"; + + private static final String PROPERTY_MAX_STEP = "maxStep"; + + public static final String PROPERTY_CAN_GENERATE = "canGenerate"; + + public static final String PROPERTY_SIMPLE_MODE = "simpleMode"; + + public static final String PROPERTY_AUTO_GEN_MODE = "autoGenMode"; + + public static final String PROPERTY_RAFALE_MODE = "rafaleMode"; + + public static final String PROPERTY_SIMPLE_COUNTING_MODE = "simpleCountingMode"; + + public static final String PROPERTY_SIMPLE_COUNT = "simpleCount"; + + public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic"; + + public static enum ConfigurationMode { + SIMPLE, + AUTO_GEN, + RAFALE, + SIMPLE_COUNTING + } + + /** + * Fill mode. + * + * @since 0.2 + */ + protected ConfigurationMode configurationMode; + + /** + * Batch that contains frequencies. + * + * @since 0.2 + */ + protected BenthosBatchRowModel batch; + + /** + * Default step to increment length step. + * + * @since 0.2 + */ + protected float step; + + /** + * Min step to auto generate length steps. + * + * @since 0.2 + */ + protected Float minStep; + + /** + * Max step to auto generate length steps. + * + * @since 0.2 + */ + protected Float maxStep; + + /** + * Length step caracteristic. + * + * @since 0.3 + */ + protected Caracteristic lengthStepCaracteristic; + + /** + * Number in case of simple counting mode + * + * @since 1.0 + */ + protected Integer simpleCount; + + public BenthosFrequencyUIModel() { + super(SpeciesBatchRowModel.class, null, null); + } + + public ConfigurationMode getConfigurationMode() { + return configurationMode; + } + + public void setConfigurationMode(ConfigurationMode configurationMode) { + Object oldValue = getConfigurationMode(); + this.configurationMode = configurationMode; + firePropertyChange(PROPERTY_CONFIGURATION_MODE, oldValue, configurationMode); + firePropertyChange(PROPERTY_SIMPLE_MODE, null, isSimpleMode()); + firePropertyChange(PROPERTY_AUTO_GEN_MODE, null, isAutoGenMode()); + firePropertyChange(PROPERTY_RAFALE_MODE, null, isRafaleMode()); + firePropertyChange(PROPERTY_SIMPLE_COUNTING_MODE, null, isSimpleCountingMode()); + } + + public float getStep() { + return step; + } + + public void setStep(float step) { + Object oldValue = getStep(); + this.step = step; + firePropertyChange(PROPERTY_STEP, oldValue, step); + } + + public Caracteristic getLengthStepCaracteristic() { + return lengthStepCaracteristic; + } + + public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) { + Object oldValue = getLengthStepCaracteristic(); + this.lengthStepCaracteristic = lengthStepCaracteristic; + firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic); + firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate()); + } + + public Float getMinStep() { + return minStep; + } + + public void setMinStep(Float minStep) { + Object oldValue = getMinStep(); + this.minStep = minStep; + firePropertyChange(PROPERTY_MIN_STEP, oldValue, minStep); + firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate()); + } + + public Float getMaxStep() { + return maxStep; + } + + public void setMaxStep(Float maxStep) { + Object oldValue = getMaxStep(); + this.maxStep = maxStep; + firePropertyChange(PROPERTY_MAX_STEP, oldValue, maxStep); + firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate()); + } + + public Integer getSimpleCount() { + return simpleCount; + } + + public void setSimpleCount(Integer simpleCount) { + Object oldValue = getSimpleCount(); + this.simpleCount = simpleCount; + firePropertyChange(PROPERTY_SIMPLE_COUNT, oldValue, simpleCount); + } + + public boolean isSimpleMode() { + return ConfigurationMode.SIMPLE == configurationMode; + } + + public boolean isAutoGenMode() { + return ConfigurationMode.AUTO_GEN == configurationMode; + } + + public boolean isRafaleMode() { + return ConfigurationMode.RAFALE == configurationMode; + } + + public boolean isSimpleCountingMode() { + return ConfigurationMode.SIMPLE_COUNTING == configurationMode; + } + + public boolean isCanGenerate() { + return minStep != null && maxStep != null && maxStep > minStep && lengthStepCaracteristic != null; + } + + public BenthosBatchRowModel getBatch() { + return batch; + } + + public void setBatch(BenthosBatchRowModel batch) { + this.batch = batch; + } + + public float getLengthStep(float lengthStep) { + int intValue = (int) (lengthStep * 10); + int intStep = (int) (step * 10); + int correctIntStep = intValue - (intValue % intStep); + float result = correctIntStep / 10f; + return result; + } + + public boolean isOneRowValid() { + boolean result = getRowCount() > 0; + if (result) { + result = false; + for (BenthosFrequencyRowModel row : rows) { + if (row.isValid()) { + result = true; + break; + } + } + } + return result; + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java (from rev 665, 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/benthos/split/SplitBenthosBatchRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,111 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split; + +/* + * #%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.persistence.entities.data.SampleCategoryEnum; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import java.io.Serializable; + +/** + * A row in the {@link SplitSpeciesBatchUIModel}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SplitBenthosBatchRowModel + extends AbstractTuttiBeanUIModel<SplitBenthosBatchRowModel, SplitBenthosBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_CATEGORY_VALUE = "categoryValue"; + + public static final String PROPERTY_WEIGHT = "weight"; + + /** + * Delegate sample category which contains category value + weight. + * + * @since 0.3 + */ + protected final SampleCategory<Serializable> category = SampleCategory.newSample(null); + + protected static final Binder<SplitBenthosBatchRowModel, SplitBenthosBatchRowModel> fromBeanBinder = + BinderFactory.newBinder(SplitBenthosBatchRowModel.class, + SplitBenthosBatchRowModel.class); + + protected static final Binder<SplitBenthosBatchRowModel, SplitBenthosBatchRowModel> toBeanBinder = + BinderFactory.newBinder(SplitBenthosBatchRowModel.class, + SplitBenthosBatchRowModel.class); + + public SplitBenthosBatchRowModel() { + super(SplitBenthosBatchRowModel.class, fromBeanBinder, toBeanBinder); + } + + public SampleCategoryEnum getCategoryType() { + return category.getCategoryType(); + } + + public void setCategoryType(SampleCategoryEnum categoryType) { + category.setCategoryType(categoryType); + } + + public Serializable getCategoryValue() { + return category.getCategoryValue(); + } + + public void setCategoryValue(Serializable categoryValue) { + Object oldValue = getCategoryValue(); + category.setCategoryValue(categoryValue); + firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue); + } + + public void setCategoryValue(CaracteristicQualitativeValue categoryValue) { + Object oldValue = getCategoryValue(); + category.setCategoryValue(categoryValue); + firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue); + } + + public void setCategoryValue(Float categoryValue) { + Object oldValue = getCategoryValue(); + category.setCategoryValue(categoryValue); + firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue); + } + + public Float getWeight() { + return category.getCategoryWeight(); + } + + public void setWeight(Float weight) { + Object oldValue = getWeight(); + category.setCategoryWeight(weight); + firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + } + +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,82 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split; + +/* + * #%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.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import org.jdesktop.swingx.table.TableColumnModelExt; + +import static org.nuiton.i18n.I18n.n_; + +/** + * Table model of sample categories values. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SplitBenthosBatchTableModel + extends AbstractTuttiTableModel<SplitBenthosBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<SplitBenthosBatchRowModel> SELECTED = ColumnIdentifier.newId( + SplitBenthosBatchRowModel.PROPERTY_VALID, + n_("tutti.splitBenthosBatch.table.header.selected"), + n_("tutti.splitBenthosBatch.table.header.selected")); + + public static final ColumnIdentifier<SplitBenthosBatchRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId( + SplitBenthosBatchRowModel.PROPERTY_CATEGORY_VALUE, + n_("tutti.splitBenthosBatch.table.header.category"), + n_("tutti.splitBenthosBatch.table.header.category")); + + public static final ColumnIdentifier<SplitBenthosBatchRowModel> READ_ONLY_CATEGORY_VALUE = ColumnIdentifier.newId( + SplitBenthosBatchRowModel.PROPERTY_CATEGORY_VALUE, + n_("tutti.splitBenthosBatch.table.header.category"), + n_("tutti.splitBenthosBatch.table.header.category")); + + public static final ColumnIdentifier<SplitBenthosBatchRowModel> WEIGHT = ColumnIdentifier.newId( + SplitBenthosBatchRowModel.PROPERTY_WEIGHT, + n_("tutti.splitBenthosBatch.table.header.weight"), + n_("tutti.splitBenthosBatch.table.header.weight")); + + private final SplitBenthosBatchUIModel uiModel; + + public SplitBenthosBatchTableModel(TableColumnModelExt columnModel, + SplitBenthosBatchUIModel uiModel, + boolean createEmptyRowIsEmpty) { + super(columnModel, createEmptyRowIsEmpty, createEmptyRowIsEmpty); + this.uiModel = uiModel; + setNoneEditableCols(READ_ONLY_CATEGORY_VALUE); + } + + @Override + public SplitBenthosBatchRowModel createNewRow() { + SplitBenthosBatchRowModel result = new SplitBenthosBatchRowModel(); + result.setCategoryType(uiModel.getSelectedCategory()); + result.setValid(false); + return result; + } + +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.css (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,112 @@ +/* + * #%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% + */ + +BeanFilterableComboBox { + showReset: true; + i18nPrefix: "tutti.property."; + bean: {model}; +} + +#splitBenthosBatchTopPanel { + _help: {"tutti.splitBenthosBatch.help"}; +} + +#configurationPanel { + border: {new TitledBorder(null, _("tutti.legend.splitBenthosBatchConfiguration"))}; +} + +#categoryLabel { + text: "tutti.splitBenthosBatch.field.category"; + toolTipText: "tutti.splitBenthosBatch.field.categoryField.tip"; + labelFor: {categoryComboBox}; + _help: {"tutti.splitBenthosBatch.field.categoryField.help"}; +} + +#categoryComboBox { + selectedItem: {model.getSelectedCategory()}; +} + +#speciesLabel { + text: "tutti.splitBenthosBatch.field.species"; + toolTipText: "tutti.splitBenthosBatch.field.speciesField.tip"; + labelFor: {speciesField}; + _help: {"tutti.splitBenthosBatch.field.speciesField.help"}; +} + +#speciesField { + editable: false; + enabled: false; + text: {handler.decorateSpecies(model.getSpecies())}; +} + +#batchWeightLabel { + text: "tutti.splitBenthosBatch.field.batchWeight"; + toolTipText: "tutti.splitBenthosBatch.field.batchWeightField.tip"; + labelFor: {batchWeightField}; + _help: {"tutti.splitBenthosBatch.field.batchWeightField.help"}; +} + +#batchWeightField { + editable: false; + enabled: false; + text: {getStringValue(model.getBatchWeight())}; +} + +#sampleWeightLabel { + text: "tutti.splitBenthosBatch.field.sampleWeight"; + toolTipText: "tutti.splitBenthosBatch.field.sampleWeightField.tip"; + labelFor: {sampleWeightField}; + _help: {"tutti.splitBenthosBatch.field.sampleWeightField.help"}; +} + +#sampleWeightField { + editable: false; + enabled: false; + text: {getStringValue(model.getSampleWeight())}; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; + enabled: {model.getSelectedCategory() != null} +} + +#cancelButton { + actionIcon: cancel; + text: "tutti.splitBenthosBatch.action.cancel"; + toolTipText: "tutti.splitBenthosBatch.action.cancel.tip"; + i18nMnemonic: "tutti.splitBenthosBatch.action.cancel.mnemonic"; + _help: {"tutti.splitBenthosBatch.action.cancel.help"}; +} + +#saveButton { + actionIcon: save; + text: "tutti.splitBenthosBatch.action.save"; + toolTipText: "tutti.splitBenthosBatch.action.save.tip"; + i18nMnemonic: "tutti.splitBenthosBatch.action.save.mnemonic"; + enabled: {model.isValid()}; + _help: {"tutti.splitBenthosBatch.action.save.help"}; +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.jaxx (from rev 665, 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/benthos/split/SplitBenthosBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,136 @@ +<!-- + #%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% + --> +<JPanel id='splitBenthosBatchTopPanel' layout='{new BorderLayout()}' + decorator='help' + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<SplitBenthosBatchUIModel, SplitBenthosBatchUIHandler>'> + + <import> + fr.ifremer.tutti.ui.swing.TuttiHelpBroker + fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI + fr.ifremer.tutti.ui.swing.util.TuttiUI + + org.jdesktop.swingx.JXTable + + jaxx.runtime.swing.editor.bean.BeanFilterableComboBox + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + javax.swing.ListSelectionModel + + java.awt.Color + + static org.nuiton.i18n.I18n._ + static jaxx.runtime.SwingUtil.getStringValue + </import> + + <script><![CDATA[ + +public SplitBenthosBatchUI(EditCatchesUI parentUI) { + JAXXUtil.initContext(this, parentUI); + SplitBenthosBatchUIHandler handler = new SplitBenthosBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <SplitBenthosBatchUIHandler id='handler' + initializer='getContextValue(SplitBenthosBatchUIHandler.class)'/> + + <SplitBenthosBatchUIModel id='model' + initializer='getContextValue(SplitBenthosBatchUIModel.class)'/> + + <BeanValidator id='validator' bean='model' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='selectedCategory' component='categoryComboBox'/> + <field name='sampleWeight' component='sampleWeightField'/> + </BeanValidator> + + <TuttiHelpBroker id='broker' + constructorParams='"tutti.splitBenthosBatch.help"'/> + + <Table id='configurationPanel' fill='both' + constraints='BorderLayout.NORTH'> + + <!-- SampleCategory choice --> + <row> + <cell anchor='west'> + <JLabel id='categoryLabel'/> + </cell> + <cell weightx='1.0'> + <JComboBox id='categoryComboBox'/> + </cell> + </row> + + <row> + <cell columns="2"> + <JSeparator/> + </cell> + </row> + + <!-- Incoming Batch Species --> + <row> + <cell anchor='west'> + <JLabel id='speciesLabel'/> + </cell> + <cell weightx='1.0'> + <JTextField id='speciesField'/> + </cell> + </row> + + <!-- Incoming Batch Total weight --> + <row> + <cell anchor='west'> + <JLabel id='batchWeightLabel'/> + </cell> + <cell weightx='1.0'> + <JTextField id='batchWeightField'/> + </cell> + </row> + + <!-- Sample Total weight --> + <row> + <cell anchor='west'> + <JLabel id='sampleWeightLabel'/> + </cell> + <cell weightx='1.0'> + <JTextField id='sampleWeightField'/> + </cell> + </row> + + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JXTable id='table'/> + </JScrollPane> + + <!-- actions --> + <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}' + constraints='BorderLayout.SOUTH'> + <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> + <JButton id='saveButton' onActionPerformed='handler.save()'/> + </JPanel> + +</JPanel> Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java (from rev 665, 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/benthos/split/SplitBenthosBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,435 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split; + +/* + * #%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.base.Preconditions; +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; +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.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.SampleCategory; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI; +import fr.ifremer.tutti.ui.swing.util.Cancelable; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +/** + * Handler of {@link SplitBenthosBatchUI}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SplitBenthosBatchUIHandler + extends AbstractTuttiTableUIHandler<SplitBenthosBatchRowModel, SplitBenthosBatchUIModel, SplitBenthosBatchUI> implements Cancelable { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(SplitBenthosBatchUIHandler.class); + + /** + * Parent UI. + * + * @since 0.3 + */ + private final BenthosBatchUI parentUi; + + public SplitBenthosBatchUIHandler(EditCatchesUI parentUi, + SplitBenthosBatchUI ui) { + super(parentUi.getHandler().getContext(), ui, + SplitBenthosBatchRowModel.PROPERTY_CATEGORY_VALUE, + SplitBenthosBatchRowModel.PROPERTY_WEIGHT); + this.parentUi = parentUi.getBenthosTabContent(); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public SplitBenthosBatchTableModel getTableModel() { + return (SplitBenthosBatchTableModel) getTable().getModel(); + } + + @Override + public JXTable getTable() { + return ui.getTable(); + } + + @Override + protected boolean isRowValid(SplitBenthosBatchRowModel row) { + return row.isValid(); + } + + @Override + protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitBenthosBatchRowModel> rowMonitor, + SplitBenthosBatchRowModel row) { + if (rowMonitor.wasModified()) { + + if (row.isValid()) { + if (log.isInfoEnabled()) { + log.info("Change row that was modified and valid"); + } + } + + rowMonitor.clearModified(); + } + } + + @Override + protected void onRowModified(int rowIndex, + SplitBenthosBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + recomputeRowValidState(row); + + if (SplitBenthosBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) { + + // Need to recompute the sample weight + computeSampleWeight(row); + } + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public SwingValidator<SplitBenthosBatchUIModel> getValidator() { + return ui.getValidator(); + } + + @Override + public void beforeInitUI() { + + SplitBenthosBatchUIModel model = new SplitBenthosBatchUIModel(); + + ui.setContextValue(model); + } + + @Override + public void afterInitUI() { + + initUI(ui); + + SplitBenthosBatchUIModel model = getModel(); + + // when category changed, remove selected category + model.addPropertyChangeListener(SplitBenthosBatchUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + SplitBenthosBatchUIModel source = + (SplitBenthosBatchUIModel) evt.getSource(); + + // unselect previous selected category + source.setSelectedCategory(null); + + // fill comboBox with new list + List<SampleCategoryEnum> data = (List<SampleCategoryEnum>) evt.getNewValue(); + ui.getCategoryComboBox().setModel(new DefaultComboBoxModel(data.toArray())); + } + }); + + // when selected category changed, regenerate the table model + add inside some default rows + model.addPropertyChangeListener(SplitBenthosBatchUIModel.PROPERTY_SELECTED_CATEGORY, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + SplitBenthosBatchUIModel source = + (SplitBenthosBatchUIModel) evt.getSource(); + + // when selected category change, sample total weight is reset + source.setSampleWeight(null); + + SampleCategoryEnum newValue = + (SampleCategoryEnum) evt.getNewValue(); + generateTableModel(newValue); + } + }); + + ui.getCategoryComboBox().addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + JComboBox comboBox = (JComboBox) e.getSource(); + getModel().setSelectedCategory((SampleCategoryEnum) comboBox.getSelectedItem()); + } + }); + + generateTableModel(null); + + initTable(getTable()); + + listenValidatorValid(ui.getValidator(), model); + } + + @Override + public void onCloseUI() { + if (log.isDebugEnabled()) { + log.debug("closing: " + ui); + } + + // evict model from validator + ui.getValidator().setBean(null); + + // when canceling always invalid model + getModel().setValid(false); + getModel().setSelectedCategory(null); + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + parent.getHandler().setBenthosSelectedCard(EditCatchesUIHandler.MAIN_CARD); + } + + //------------------------------------------------------------------------// + //-- Cancelable methods --// + //------------------------------------------------------------------------// + + @Override + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel UI " + ui); + } + closeUI(ui); + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public String decorateSpecies(Species object) { + String result = object == null ? "" : super.decorate(object); + return result; + } + + public void editBatch(BenthosBatchRowModel batch) { + + // get possible the last used + List<SampleCategoryEnum> categories = + Lists.newArrayList(SampleCategoryEnum.values()); + + if (batch != null) { + //TODO Use the samplingOrder (+ the one from the table model) + + SampleCategory<?> lastCategory = batch.getSampleCategory(); + + Preconditions.checkNotNull( + lastCategory, + "Can't split a species batch with no sample category."); + + if (batch.getSortedUnsortedCategory().isValid()) { + categories.remove(SampleCategoryEnum.sortedUnsorted); + } + + if (batch.getSizeCategory().isValid()) { + categories.remove(SampleCategoryEnum.size); + } + + if (batch.getSexCategory().isValid()) { + categories.remove(SampleCategoryEnum.sex); + } + + if (batch.getMaturityCategory().isValid()) { + categories.remove(SampleCategoryEnum.maturity); + } + + if (batch.getAgeCategory().isValid()) { + categories.remove(SampleCategoryEnum.age); + } + } + + SplitBenthosBatchUIModel model = getModel(); + + // connect model to validator + ui.getValidator().setBean(model); + + model.setSampleWeight(null); + model.setCategory(categories); + model.setSelectedCategory(categories.get(0)); + + // keep batch (will be used to push back editing entry) + model.setBatch(batch); + } + + public void save() { + + if (log.isInfoEnabled()) { + log.info("Save UI " + ui); + } + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + parent.getBenthosTabContent().getHandler().splitBatch(getModel()); + + // close dialog + closeUI(ui); + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected void computeSampleWeight(SplitBenthosBatchRowModel row) { + + if (log.isInfoEnabled()) { + log.info("Will recompute sample weight from row: " + row); + } + + Float result = 0f; + List<SplitBenthosBatchRowModel> rows = getTableModel().getRows(); + for (SplitBenthosBatchRowModel rowModel : rows) { + Float weight = rowModel.getWeight(); + if (weight != null) { + result += weight; + } + } + getModel().setSampleWeight(result); + } + + protected void generateTableModel(SampleCategoryEnum category) { + + // when generate a new table model, then reset previous rows from model + getModel().setRows(null); + + Caracteristic data = null; + + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { // Selection + + addBooleanColumnToModel(columnModel, SplitBenthosBatchTableModel.SELECTED, getTable()); + } + + boolean editableCategoryValue = false; + if (category != null) { + + switch (category) { + + case sortedUnsorted: + data = persistenceService.getSortedUnsortedCaracteristic(); + break; + case size: + data = persistenceService.getSizeCategoryCaracteristic(); + break; + case sex: + data = persistenceService.getSexCaracteristic(); + break; + case maturity: + data = persistenceService.getMaturityCaracteristic(); + break; + case age: + editableCategoryValue = true; + addFloatColumnToModel(columnModel, + SplitBenthosBatchTableModel.EDITABLE_CATEGORY_VALUE, + TuttiUI.DECIMAL1_PATTERN); + break; + } + + if (data != null) { + + if (log.isDebugEnabled()) { + log.debug("Got " + data.sizeQualitativeValue() + " qualitative data to add"); + } + addColumnToModel(columnModel, + null, + newTableCellRender(CaracteristicQualitativeValue.class), + SplitBenthosBatchTableModel.READ_ONLY_CATEGORY_VALUE); + } + { // Weight + + addFloatColumnToModel(columnModel, + SplitBenthosBatchTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + } + + // create table model + SplitBenthosBatchTableModel tableModel = + new SplitBenthosBatchTableModel(columnModel, + getModel(), + editableCategoryValue); + + JXTable table = getTable(); + + // remove all listener on tables we could add before + uninstallTableSaveOnRowChangedSelectionListener(); + uninstallTableKeyListener(); + + if (log.isDebugEnabled()) { + log.debug("Install new table model " + tableModel); + } + table.setModel(tableModel); + table.setColumnModel(columnModel); + + // install table listeners + installTableSaveOnRowChangedSelectionListener(); + installTableKeyListener(columnModel, table); + + // fill datas + + List<SplitBenthosBatchRowModel> rows = Lists.newArrayList(); + + if (data != null) { + + // add a row for each qualitive value + for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) { + if (log.isDebugEnabled()) { + log.debug("Add QV: " + qualitativeValue); + } + SplitBenthosBatchRowModel newRow = tableModel.createNewRow(); + newRow.setCategoryValue(qualitativeValue); + rows.add(newRow); + } + } + + if (log.isDebugEnabled()) { + log.debug("Will add " + rows.size() + " rows in table model " + + "(can add a first empty row? " + editableCategoryValue + ")."); + } + + getModel().setRows(rows); + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java (from rev 665, 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/benthos/split/SplitBenthosBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,137 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split; + +/* + * #%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.persistence.entities.data.SampleCategoryEnum; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; + +import java.util.List; + +/** + * Model of {@link SplitBenthosBatchUI}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SplitBenthosBatchUIModel + extends AbstractTuttiTableUIModel<BenthosBatchRowModel, SplitBenthosBatchRowModel, SplitBenthosBatchUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_CATEGORY = "category"; + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_SELECTED_CATEGORY = "selectedCategory"; + + public static final String PROPERTY_BATCH_WEIGHT = "batchWeight"; + + public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; + + /** + * Batch which fires the editor. + * + * @since 0.3 + */ + protected BenthosBatchRowModel batch; + + /** + * Sample categories. + * + * @since 0.3 + */ + protected List<SampleCategoryEnum> category; + + /** + * Selected Sample category. + * + * @since 0.3 + */ + protected SampleCategoryEnum selectedCategory; + + /** + * Sample weight of split batches. + * + * @since 0.3 + */ + protected Float sampleWeight; + + public SplitBenthosBatchUIModel() { + super(BenthosBatchRowModel.class, null, null); + } + + public BenthosBatchRowModel getBatch() { + return batch; + } + + public void setBatch(BenthosBatchRowModel batch) { + Object oldSpecies = getSpecies(); + Object oldWeight = getBatchWeight(); + + this.batch = batch; + firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies()); + firePropertyChange(PROPERTY_BATCH_WEIGHT, oldWeight, getBatchWeight()); + } + + public Species getSpecies() { + return batch == null ? null : batch.getSpecies(); + } + + public List<SampleCategoryEnum> getCategory() { + return category; + } + + public void setCategory(List<SampleCategoryEnum> category) { + Object oldValue = getCategory(); + this.category = category; + firePropertyChange(PROPERTY_CATEGORY, oldValue, category); + } + + public SampleCategoryEnum getSelectedCategory() { + return selectedCategory; + } + + public void setSelectedCategory(SampleCategoryEnum selectedCategory) { + Object oldValue = getSelectedCategory(); + this.selectedCategory = selectedCategory; + firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory); + } + + public Float getBatchWeight() { + return batch == null ? null : batch.getSampleCategory().getCategoryWeight(); + } + + public Float getSampleWeight() { + return sampleWeight; + } + + public void setSampleWeight(Float sampleWeight) { + Object oldValue = getSampleWeight(); + this.sampleWeight = sampleWeight; + firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight); + } +} \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,4 +1,3 @@ - package fr.ifremer.tutti.ui.swing.content.operation.catches.species; /* @@ -28,6 +27,7 @@ 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 fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog; import jaxx.runtime.SwingUtil; import org.apache.commons.lang3.StringUtils; @@ -98,8 +98,8 @@ if (sampleWeight == 0f) { JOptionPane.showMessageDialog( getUI(), - _("tutti.createMelag.error.message", selectedRowIndex + 1), - _("tutti.createMelag.error.title"), + _("tutti.createSpeciesMelag.error.message", selectedRowIndex + 1), + _("tutti.createSpeciesMelag.error.title"), JOptionPane.ERROR_MESSAGE); handler.getTable().getSelectionModel().setSelectionInterval(selectedRowIndex, selectedRowIndex); Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.css 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.css 2013-03-23 18:20:58 UTC (rev 666) @@ -1,53 +0,0 @@ -/* - * #%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% - */ - -#dialog { - title: "tutti.createMelag.title"; -} - -#message { - text: "tutti.createMelag.message"; - horizontalAlignment: {JLabel.CENTER}; -} - -#editor { - useFloat: true; - useSign: false; - autoPopup: true; - showPopupButton: true; - showReset: true; -} - -#cancelButton { - text: "tutti.createMelag.action.cancel"; - toolTipText: "tutti.createMelag.action.cancel.tip"; - i18nMnemonic: "tutti.createMelag.action.cancel.mnemonic"; -} - -#validateButton { - text: "tutti.createMelag.action.validate"; - toolTipText: "tutti.createMelag.action.validate.tip"; - i18nMnemonic: "tutti.createMelag.action.validate.mnemonic"; - enabled: { editor.getModel() != null }; -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.jaxx 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -1,73 +0,0 @@ -<!-- - #%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% - --> -<JDialog id='dialog' layout='{new BorderLayout()}'> - <import> - java.awt.Component; - java.awt.event.WindowAdapter; - java.awt.event.WindowEvent; - javax.swing.JComponent - javax.swing.JRootPane; - javax.swing.KeyStroke; - jaxx.runtime.swing.editor.NumberEditor - </import> - - <script><![CDATA[ - -public EnterMelagWeightDialog(Frame frame, KeyStroke shortcutClosePopup) { - super(frame, true); - - // add a auto-close action - rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( - shortcutClosePopup, "close"); - - addWindowListener(new WindowAdapter() { - - @Override - public void windowClosed(WindowEvent e) { - Component ui = (Component) e.getSource(); - JAXXUtil.destroy(ui); - } - }); -} - - ]]></script> - - <Table id='table' fill='both' constraints='BorderLayout.CENTER'> - <row> - <cell insets='10, 10, 5, 10'> - <JLabel id='message'/> - </cell> - </row> - <row> - <cell insets='5, 10, 10, 10'> - <NumberEditor id='editor'/> - </cell> - </row> - </Table> - <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> - <JButton id='cancelButton' - onActionPerformed='editor.setModel(null); dispose();'/> - <JButton id='validateButton' onActionPerformed='dispose();'/> - </JPanel> -</JDialog> \ No newline at end of file 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -59,7 +59,8 @@ SpeciesBatchRowModel row = tableModel.getEntry(table.getSelectedRow()); SpeciesBatchUIModel model = handler.getModel(); - List<Species> speciesList = Lists.newArrayList(getDataContext().getReferentSpeciesWithSurveyCode()); + 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/SelectSpeciesUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -1,46 +0,0 @@ -/* - * #%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% - */ -#speciesCombo { - showReset: true; - i18nPrefix: "tutti.property."; - bean: {model}; - property: selectedSpecies; - selectedItem: {model.getSelectedSpecies()}; - data: {model.getSpecies()}; -} - -#cancelButton { - actionIcon: cancel; - text: "tutti.selectSpecies.action.cancel"; - toolTipText: "tutti.selectSpecies.action.cancel.tip"; - i18nMnemonic: "tutti.selectSpecies.action.cancel.mnemonic"; -} - -#validateButton { - actionIcon: accept; - text: "tutti.selectSpecies.action.validate"; - toolTipText: "tutti.selectSpecies.action.validate.tip"; - i18nMnemonic: "tutti.selectSpecies.action.validate.mnemonic"; - enabled: {model.getSelectedSpecies() != null}; -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -1,61 +0,0 @@ -<!-- - #%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% - --> -<JPanel layout='{new BorderLayout()}' id='selectSpeciesPopup' - implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<SelectSpeciesUIModel, SelectSpeciesUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.Species - fr.ifremer.tutti.ui.swing.util.TuttiUI - jaxx.runtime.swing.editor.bean.BeanFilterableComboBox - </import> - - <script><![CDATA[ - -public SelectSpeciesUI(TuttiUI parentUI) { - JAXXUtil.initContext(this, parentUI); - SelectSpeciesUIHandler handler = new SelectSpeciesUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <SelectSpeciesUIHandler id='handler' - initializer='getContextValue(SelectSpeciesUIHandler.class)'/> - - <SelectSpeciesUIModel id='model' - initializer='getContextValue(SelectSpeciesUIModel.class)'/> - - <BeanFilterableComboBox id='speciesCombo' constraints='BorderLayout.CENTER' - constructorParams='this' genericType='Species'/> - - <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'> - <JButton id='cancelButton' - onActionPerformed='handler.cancel()'/> - <JButton id='validateButton' - onActionPerformed='handler.validate()'/> - </JPanel> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIHandler.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,95 +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.Lists; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; -import fr.ifremer.tutti.ui.swing.util.TuttiUI; -import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -/** - * @author kmorin <kmorin@codelutin.com> - * @since 1.0 - */ -public class SelectSpeciesUIHandler extends AbstractTuttiUIHandler<SelectSpeciesUIModel, SelectSpeciesUI> { - - private static final Log log = LogFactory.getLog(SelectSpeciesUIHandler.class); - - public SelectSpeciesUIHandler(TuttiUI parentUI, SelectSpeciesUI ui) { - super(parentUI.getHandler().getContext(), ui); - } - - @Override - public void beforeInitUI() { - SelectSpeciesUIModel model = new SelectSpeciesUIModel(); - ui.setContextValue(model); - } - - @Override - public void afterInitUI() { - initUI(ui); - - initBeanFilterableComboBox(ui.getSpeciesCombo(), - Lists.<Species>newArrayList(), - null); - - getModel().addPropertyChangeListener( - SelectSpeciesUIModel.PROPERTY_SPECIES, - new PropertyChangeListener() { - - public void propertyChange(PropertyChangeEvent evt) { - ui.getSpeciesCombo().getHandler().sortData(); - } - }); - } - - @Override - public void onCloseUI() { - if (log.isDebugEnabled()) { - log.debug("closing: " + ui); - } - } - - @Override - public SwingValidator<SelectSpeciesUIModel> getValidator() { - return null; - } - - public void validate() { - closeDialog(ui); - } - - public void cancel() { - getModel().setSelectedSpecies(null); - closeDialog(ui); - } -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,72 +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.Lists; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; - -import java.util.List; - -/** - * @author kmorin <kmorin@codelutin.com> - * @since 1.0 - */ -public class SelectSpeciesUIModel extends AbstractTuttiBeanUIModel<SelectSpeciesUIModel, SelectSpeciesUIModel> { - - public static final String PROPERTY_SPECIES = "species"; - - public static final String PROPERTY_SELECTED_SPECIES = "selectedSpecies"; - - protected List<Species> species = Lists.newArrayList(); - - protected Species selectedSpecies; - - public SelectSpeciesUIModel() { - super(SelectSpeciesUIModel.class, null, null); - } - - public List<Species> getSpecies() { - return species; - } - - public void setSpecies(List<Species> species) { - Object oldValue = getSpecies(); - this.species = Lists.newArrayList(species); - firePropertyChange(PROPERTY_SPECIES, oldValue, this.species); - } - - public Species getSelectedSpecies() { - return selectedSpecies; - } - - public void setSelectedSpecies(Species selectedSpecies) { - Object oldValue = getSelectedSpecies(); - this.selectedSpecies = selectedSpecies; - firePropertyChange(PROPERTY_SELECTED_SPECIES, oldValue, selectedSpecies); - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRootRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRootRowModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRootRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,19 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.species; - -import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; -import fr.ifremer.tutti.persistence.entities.referential.Species; - -/** - * - * @author kmorin <kmorin@codelutin.com> - */ -public interface SpeciesBatchRootRowModel { - - Species getSpecies(); - - CaracteristicQualitativeValue getSortedUnsortedCategory(); - - Float getBatchWeight(); - - boolean isValid(); -} 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -33,7 +33,6 @@ 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; @@ -237,11 +236,11 @@ public SpeciesBatchRowModel() { super(SpeciesBatch.class, fromBeanBinder, toBeanBinder); - sortedUnsortedCategory = SampleCategory.newSample(SampleCategoryType.sortedUnsorted); - sizeCategory = SampleCategory.newSample(SampleCategoryType.size); - sexCategory = SampleCategory.newSample(SampleCategoryType.sex); - maturityCategory = SampleCategory.newSample(SampleCategoryType.maturity); - ageCategory = SampleCategory.newSample(SampleCategoryType.age); + sortedUnsortedCategory = SampleCategory.newSample(SampleCategoryEnum.sortedUnsorted); + sizeCategory = SampleCategory.newSample(SampleCategoryEnum.size); + sexCategory = SampleCategory.newSample(SampleCategoryEnum.sex); + maturityCategory = SampleCategory.newSample(SampleCategoryEnum.maturity); + ageCategory = SampleCategory.newSample(SampleCategoryEnum.age); computedOrNotWeight.addPropertyChangeListener( TuttiComputedOrNotData.PROPERTY_DATA, 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -25,10 +25,10 @@ */ import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; 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.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; @@ -53,35 +53,35 @@ public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, - SampleCategoryType.sortedUnsorted, + SampleCategoryEnum.sortedUnsorted, n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory"), n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, - SampleCategoryType.size, + SampleCategoryEnum.size, n_("tutti.editSpeciesBatch.table.header.sizeCategory"), n_("tutti.editSpeciesBatch.table.header.sizeCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, - SampleCategoryType.sex, + SampleCategoryEnum.sex, n_("tutti.editSpeciesBatch.table.header.sexCategory"), n_("tutti.editSpeciesBatch.table.header.sexCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, - SampleCategoryType.maturity, + SampleCategoryEnum.maturity, n_("tutti.editSpeciesBatch.table.header.maturityCategory"), n_("tutti.editSpeciesBatch.table.header.maturityCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY, SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT, - SampleCategoryType.age, + SampleCategoryEnum.age, n_("tutti.editSpeciesBatch.table.header.ageCategory"), n_("tutti.editSpeciesBatch.table.header.ageCategory")); 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -131,64 +131,6 @@ label: "tutti.editSpeciesBatch.title.batchActions"; } -#splitSpeciesBatchMenu { - actionIcon: batch-split; - text: "tutti.editSpeciesBatch.action.splitSpeciesBatch"; - toolTipText: "tutti.editSpeciesBatch.action.splitSpeciesBatch.tip"; - i18nMnemonic: "tutti.editSpeciesBatch.action.splitSpeciesBatch.mnemonic"; - enabled: {model.isTableViewModeAll() && model.isSplitSpeciesBatchEnabled()}; - _help: {"tutti.editSpeciesBatch.action.splitSpeciesBatch.help"}; -} - -#removeSpeciesBatchMenu { - actionIcon: batch-delete; - text: "tutti.editSpeciesBatch.action.removeSpeciesBatch"; - toolTipText: "tutti.editSpeciesBatch.action.removeSpeciesBatch.tip"; - i18nMnemonic: "tutti.editSpeciesBatch.action.removeSpeciesBatch.mnemonic"; - _tuttiAction: {RemoveSpeciesBatchAction.class}; - enabled: {model.isTableViewModeAll() && model.isRemoveSpeciesBatchEnabled()}; - _help: {"tutti.editSpeciesBatch.action.removeSpeciesBatch.help"}; -} - -#removeSpeciesSubBatchMenu { - actionIcon: batch-delete; - text: "tutti.editSpeciesBatch.action.removeSpeciesSubBatch"; - toolTipText: "tutti.editSpeciesBatch.action.removeSpeciesSubBatch.tip"; - i18nMnemonic: "tutti.editSpeciesBatch.action.removeSpeciesSubBatch.mnemonic"; - _tuttiAction: {RemoveSpeciesSubBatchAction.class}; - enabled: {model.isTableViewModeAll() && model.isRemoveSpeciesSubBatchEnabled()}; - _help: {"tutti.editSpeciesBatch.action.removeSpeciesSubBatch.help"}; -} - -#renameSpeciesBatchMenu { - actionIcon: batch-rename; - text: "tutti.editSpeciesBatch.action.renameSpeciesBatch"; - toolTipText: "tutti.editSpeciesBatch.action.renameSpeciesBatch.tip"; - i18nMnemonic: "tutti.editSpeciesBatch.action.renameSpeciesBatch.mnemonic"; - _tuttiAction: {RenameSpeciesBatchAction.class}; - enabled: {model.isTableViewModeAll() && model.isRenameSpeciesBatchEnabled()}; - _help: {"tutti.editSpeciesBatch.action.renameSpeciesBatch.help"}; -} - -#createSpeciesMelag { - actionIcon: batch-rename; - 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 { - actionIcon: batch-create; - text: "tutti.editSpeciesBatch.action.createSpeciesBatch"; - toolTipText: "tutti.editSpeciesBatch.action.createSpeciesBatch.tip"; - i18nMnemonic: "tutti.editSpeciesBatch.action.createSpeciesBatch.mnemonic"; - enabled: {model.isCreateSpeciesBatchEnabled()}; - _help: {"tutti.editSpeciesBatch.action.createSpeciesBatch.help"}; -} - #table { selectionMode: {ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}; selectionBackground: {null}; @@ -202,23 +144,23 @@ #filterSpeciesBatchLabel { actionIcon: filter; - text: "tutti.editSpeciesBatch.filterSpeciesBatchMode"; + text: "tutti.editSpeciesBatch.filterBatch"; toolTipText: "tutti.editSpeciesBatch.filterSpeciesBatch.tip"; _strongStyle: true; _help: {"tutti.editSpeciesBatch.filterSpeciesBatch.help"}; } #filterSpeciesBatchAllButton { - text: "tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.all"; - toolTipText: "tutti.editSpeciesBatch.filterSpeciesBatch.mode.all.tip"; + text: "tutti.editSpeciesBatch.filterBatch.mode.all"; + toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.all.tip"; value: "all"; selected: {model.isTableViewModeAll()}; buttonGroup: "filterSpeciesBatchMode"; } #filterSpeciesBatchLeafButton { - text: "tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.leaf"; - toolTipText: "tutti.editSpeciesBatch.filterSpeciesBatch.mode.leaf.tip"; + text: "tutti.editSpeciesBatch.filterBatch.mode.leaf"; + toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.leaf.tip"; value: "leaf"; selected: {model.isTableViewModeLeaf()}; buttonGroup: "filterSpeciesBatchMode"; @@ -226,8 +168,66 @@ #filterSpeciesBatchRootButton { text: {handler.getFilterSpeciesBatchRootButtonText(model.getRootNumber())}; - toolTipText: "tutti.editSpeciesBatch.filterSpeciesBatch.mode.root.tip"; + toolTipText: "tutti.editSpeciesBatch.filterBatch.mode.root.tip"; value: "root"; selected: {model.isTableViewModeRoot()}; buttonGroup: "filterSpeciesBatchMode"; } + +#splitSpeciesBatchMenu { + actionIcon: batch-split; + text: "tutti.editSpeciesBatch.action.splitBatch"; + toolTipText: "tutti.editSpeciesBatch.action.splitBatch.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.splitBatch.mnemonic"; + enabled: {model.isTableViewModeAll() && model.isSplitBatchEnabled()}; + _help: {"tutti.editSpeciesBatch.action.splitBatch.help"}; +} + +#removeSpeciesBatchMenu { + actionIcon: batch-delete; + text: "tutti.editSpeciesBatch.action.removeBatch"; + toolTipText: "tutti.editSpeciesBatch.action.removeBatch.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.removeBatch.mnemonic"; + _tuttiAction: {RemoveSpeciesBatchAction.class}; + enabled: {model.isTableViewModeAll() && model.isRemoveBatchEnabled()}; + _help: {"tutti.editSpeciesBatch.action.removeBatch.help"}; +} + +#removeSpeciesSubBatchMenu { + actionIcon: batch-delete; + text: "tutti.editSpeciesBatch.action.removeSubBatch"; + toolTipText: "tutti.editSpeciesBatch.action.removeSubBatch.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.removeSubBatch.mnemonic"; + _tuttiAction: {RemoveSpeciesSubBatchAction.class}; + enabled: {model.isTableViewModeAll() && model.isRemoveSubBatchEnabled()}; + _help: {"tutti.editSpeciesBatch.action.removeSubBatch.help"}; +} + +#renameSpeciesBatchMenu { + actionIcon: batch-rename; + text: "tutti.editSpeciesBatch.action.renameBatch"; + toolTipText: "tutti.editSpeciesBatch.action.renameBatch.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.renameBatch.mnemonic"; + _tuttiAction: {RenameSpeciesBatchAction.class}; + enabled: {model.isTableViewModeAll() && model.isRenameBatchEnabled()}; + _help: {"tutti.editSpeciesBatch.action.renameBatch.help"}; +} + +#createSpeciesMelagMenu { + actionIcon: batch-rename; + text: "tutti.editSpeciesBatch.action.createMelag"; + toolTipText: "tutti.editSpeciesBatch.action.createMelag.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.createMelag.mnemonic"; + _tuttiAction: {CreateSpeciesMelagAction.class}; + enabled: {!model.isTableViewModeLeaf() && model.isCreateMelagEnabled()}; + _help: {"tutti.editSpeciesBatch.action.createMelag.help"}; +} + +#createSpeciesBatchButton { + actionIcon: batch-create; + text: "tutti.editSpeciesBatch.action.createBatch"; + toolTipText: "tutti.editSpeciesBatch.action.createBatch.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.createBatch.mnemonic"; + enabled: {model.isCreateBatchEnabled()}; + _help: {"tutti.editSpeciesBatch.action.createBatch.help"}; +} 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -28,7 +28,6 @@ <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 @@ -36,14 +35,11 @@ org.jdesktop.swingx.JXTable - jaxx.runtime.swing.editor.NumberEditor - javax.swing.ListSelectionModel java.awt.Color static org.nuiton.i18n.I18n._ - static jaxx.runtime.SwingUtil.getStringValue static fr.ifremer.tutti.ui.swing.util.TuttiUIUtil.getWeightStringValue </import> @@ -80,13 +76,12 @@ </JToolBar> <JPopupMenu id='tablePopup'> - <!--onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>--> <JMenuItem id='splitSpeciesBatchMenu' - onActionPerformed='handler.splitSpeciesBatch()'/> + onActionPerformed='handler.splitBatch()'/> <JMenuItem id='removeSpeciesBatchMenu'/> <JMenuItem id='removeSpeciesSubBatchMenu'/> <JMenuItem id='renameSpeciesBatchMenu'/> - <JMenuItem id='createSpeciesMelag'/> + <JMenuItem id='createSpeciesMelagMenu'/> </JPopupMenu> <Table id='form' fill='both' constraints='BorderLayout.NORTH'> @@ -149,7 +144,7 @@ <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.WEST'> <JButton id='createSpeciesBatchButton' - onActionPerformed='handler.createSpeciesBatch()'/> + onActionPerformed='handler.createBatch()'/> </JPanel> <JPanel id='filterTablePane' constraints='BorderLayout.CENTER'> <JLabel id='filterSpeciesBatchLabel'/> 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -43,12 +43,11 @@ 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.SpeciesBatchRootRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyCellComponent; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel; @@ -60,6 +59,8 @@ import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor; import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer; import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; import jaxx.runtime.SwingUtil; @@ -98,9 +99,7 @@ */ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<SpeciesBatchRowModel, SpeciesBatchUIModel, SpeciesBatchUI> { - /** - * Logger. - */ + /** Logger. */ private static final Log log = LogFactory.getLog(SpeciesBatchUIHandler.class); @@ -123,23 +122,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>() { @@ -197,7 +196,7 @@ if (log.isInfoEnabled()) { log.info("Get species batch for fishingOperation: " + - bean.getId()); + bean.getId()); } rows = Lists.newArrayList(); @@ -227,15 +226,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); + loadBatch(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())); } } } @@ -265,13 +264,6 @@ // a row is valid if species category is not empty and valid // then if any of none empty category is valid boolean result = row.getSpecies() != null; -// &&!row.getSortedUnsortedCategory().isEmpty() && -// row.getSortedUnsortedCategory().isValid(); - -// result &= row.getSizeCategory().isEmptyOrValid(); -// result &= row.getSexCategory().isEmptyOrValid(); -// result &= row.getMaturityCategory().isEmptyOrValid(); -// result &= row.getAgeCategory().isEmptyOrValid(); return result; } @@ -286,9 +278,6 @@ // species has changed, recompute valid property recomputeRowValidState(row); - - // recompute the totalUnsorted weight -// recomputeTotalUnsortedWeight(); } // when row valid state has changed, recompute action enabled states @@ -309,7 +298,7 @@ showInformationMessage( "[ Captures - Espèces ] " + - "Sauvegarde des modifications de " + row + '.'); + "Sauvegarde des modifications de " + row + '.'); saveRow(row); @@ -322,17 +311,6 @@ if (log.isWarnEnabled()) { log.warn("Will not remove not valid speciesBatch: " + row.getId()); } - -// // row is not valid can not save it -// -// SpeciesBatch catchBean = row.toBean(); -// -// if (!TuttiEntities.isNew(catchBean)) { -// -// // remove this -// persistenceService.deleteSpeciesBatch(catchBean.getId()); -// row.setId(null); -// } } } @@ -340,9 +318,7 @@ protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) { super.onModelRowsChanged(rows); - // clear speciesUsed SpeciesBatchUIModel model = getModel(); - model.getSpeciesUsed().clear(); model.setRootNumber(0); for (SpeciesBatchRowModel row : rows) { @@ -443,17 +419,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) { @@ -464,9 +440,9 @@ { // SizeCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.SIZE_CATEGORY, - caracteristicDecorator, - defaultRenderer); + SpeciesBatchTableModel.SIZE_CATEGORY, + caracteristicDecorator, + defaultRenderer); } break; case sex: @@ -474,9 +450,9 @@ { // SexCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.SEX_CATEGORY, - caracteristicDecorator, - defaultRenderer); + SpeciesBatchTableModel.SEX_CATEGORY, + caracteristicDecorator, + defaultRenderer); } break; case maturity: @@ -484,9 +460,9 @@ { // MaturityCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.MATURITY_CATEGORY, - caracteristicDecorator, - defaultRenderer); + SpeciesBatchTableModel.MATURITY_CATEGORY, + caracteristicDecorator, + defaultRenderer); } break; @@ -496,9 +472,9 @@ { // AgeCategory column addSampleCategoryColumnToModel(columnModel, - SpeciesBatchTableModel.AGE_CATEGORY, - getDecorator(Float.class, null), - defaultRenderer); + SpeciesBatchTableModel.AGE_CATEGORY, + getDecorator(Float.class, null), + defaultRenderer); } break; @@ -509,42 +485,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, - SpeciesFrequencyCellComponent.newEditor(ui, computedDataColor), - SpeciesFrequencyCellComponent.newRender(computedDataColor), - SpeciesBatchTableModel.COMPUTED_NUMBER); + SpeciesFrequencyCellComponent.newEditor(ui, computedDataColor), + SpeciesFrequencyCellComponent.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 @@ -629,7 +605,7 @@ //-- Public methods --// //------------------------------------------------------------------------// - public void createSpeciesBatch() { + public void createBatch() { EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); CreateSpeciesBatchUI createBatchEditor = parent.getSpeciesTabCreateBatch(); @@ -638,7 +614,7 @@ parent.getHandler().setSpeciesSelectedCard(EditCatchesUIHandler.CREATE_BATCH_CARD); } - public void addSpeciesBatch(SpeciesBatchRootRowModel speciesBatchRootRowModel) { + public void addBatch(SpeciesBatchRootRowModel speciesBatchRootRowModel) { if (speciesBatchRootRowModel.isValid()) { SpeciesBatchTableModel tableModel = getTableModel(); @@ -667,7 +643,7 @@ recomputeBatchActionEnable(); } - public void splitSpeciesBatch() { + public void splitBatch() { JXTable table = getTable(); @@ -675,7 +651,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(); @@ -727,8 +703,7 @@ // create batch rows - SampleCategoryType selectedCategory = splitModel.getSelectedCategory(); - SampleCategoryEnum sampleCategoryEnum = selectedCategory.getType(); + SampleCategoryEnum sampleCategoryEnum = splitModel.getSelectedCategory(); // Create rows in batch table model @@ -740,10 +715,10 @@ SpeciesBatchRowModel newBatch = tableModel.createNewRow(); loadBatchRow(parentBatch, - newBatch, - sampleCategoryEnum, - row.getCategoryValue(), - row.getWeight()); + newBatch, + sampleCategoryEnum, + row.getCategoryValue(), + row.getWeight()); recomputeRowValidState(newBatch); newBatches.add(newBatch); @@ -816,7 +791,7 @@ } // apply sample category - catchBean.setSampleCategoryType(sampleCategory.getCategoryType().getType()); + catchBean.setSampleCategoryType(sampleCategory.getCategoryType()); catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue()); catchBean.setSampleCategoryWeight(sampleCategory.getCategoryWeight()); @@ -831,10 +806,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()) { @@ -860,7 +835,7 @@ } public String getFilterSpeciesBatchRootButtonText(int rootNumber) { - return _("tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.root", rootNumber); + return _("tutti.editSpeciesBatch.filterBatch.mode.root", rootNumber); } protected void recomputeBatchActionEnable() { @@ -907,14 +882,14 @@ && selectedRowCount == 1 && row.getNumber() == null && (row.getComputedNumber() == null - || row.getComputedNumber() == 0); + || row.getComputedNumber() == 0); } if (enableRename) { // can rename if selected batch is a parent enableRename = row.isBatchRoot() - && selectedRowCount == 1; + && selectedRowCount == 1; } if (enableRemove) { @@ -927,7 +902,7 @@ // can remove sub batch if selected batch is not a leaf enableRemoveSub = !row.isBatchLeaf() - && selectedRowCount == 1; + && selectedRowCount == 1; } if (enableCreateMelag) { @@ -955,10 +930,10 @@ } SpeciesBatchUIModel model = getModel(); - model.setCreateSpeciesBatchEnabled(enableAdd); - model.setSplitSpeciesBatchEnabled(enableSplit); - model.setRemoveSpeciesBatchEnabled(enableRemove); - model.setRemoveSpeciesSubBatchEnabled(enableRemoveSub); + model.setCreateBatchEnabled(enableAdd); + model.setSplitBatchEnabled(enableSplit); + model.setRemoveBatchEnabled(enableRemove); + model.setRemoveSubBatchEnabled(enableRemoveSub); model.setRenameSpeciesBatchEnabled(enableRename); model.setCreateSpeciesMelagEnabled(enableCreateMelag); } @@ -975,9 +950,9 @@ } } - protected SpeciesBatchRowModel loadSpeciesBatch(SpeciesBatch aBatch, - SpeciesBatchRowModel parentRow, - List<SpeciesBatchRowModel> rows) { + protected SpeciesBatchRowModel loadBatch(SpeciesBatch aBatch, + SpeciesBatchRowModel parentRow, + List<SpeciesBatchRowModel> rows) { String id = aBatch.getId(); @@ -1000,18 +975,17 @@ } } - SampleCategoryEnum sampleCategoryEnum = - aBatch.getSampleCategoryType(); + SampleCategoryEnum sampleCategoryEnum = aBatch.getSampleCategoryType(); Preconditions.checkNotNull( sampleCategoryEnum, "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); @@ -1023,7 +997,7 @@ newArrayListWithCapacity(aBatch.sizeChildBatchs()); for (SpeciesBatch childBatch : aBatch.getChildBatchs()) { - SpeciesBatchRowModel childRow = loadSpeciesBatch(childBatch, newRow, rows); + SpeciesBatchRowModel childRow = loadBatch(childBatch, newRow, rows); batchChilds.add(childRow); } newRow.setChildBatch(batchChilds); @@ -1080,11 +1054,12 @@ ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier, Decorator<C> decorator, TableCellRenderer defaultRenderer) { - addColumnToModel(columnModel, + addColumnToModel( + columnModel, SampleCategoryComponent.newEditor(decorator), SampleCategoryComponent.newRender(defaultRenderer, - decorator, - getConfig().getColorComputedWeights()), + decorator, + getConfig().getColorComputedWeights()), columnIdentifier); } @@ -1097,7 +1072,7 @@ } SpeciesBatchUIModel model = getModel(); model.getSpeciesUsed().remove(row.getSortedUnsortedCategoryValue(), - row.getSpecies()); + row.getSpecies()); if (row.isBatchRoot()) { model.setRootNumber(model.getRootNumber() - 1); @@ -1110,12 +1085,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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -47,19 +47,19 @@ private static final long serialVersionUID = 1L; - public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode"; + public static final String PROPERTY_CREATE_BATCH_ENABLED = "createBatchEnabled"; - public static final String PROPERTY_CREATE_SPECIES_BATCH_ENABLED = "createSpeciesBatchEnabled"; + public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled"; - public static final String PROPERTY_SPLIT_SPECIES_BATCH_ENABLED = "splitSpeciesBatchEnabled"; + public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled"; - public static final String PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED = "removeSpeciesSubBatchEnabled"; + public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled"; - public static final String PROPERTY_RENAME_SPECIES_BATCH_ENABLED = "renameSpeciesBatchEnabled"; + public static final String PROPERTY_REMOVE_BATCH_ENABLED = "removeBatchEnabled"; - 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 = "tableViewMode"; public static final String PROPERTY_TABLE_VIEW_MODE_ALL = "tableViewModeAll"; @@ -76,42 +76,42 @@ * * @since 0.3 */ - protected boolean createSpeciesBatchEnabled; + protected boolean createBatchEnabled; /** * Can user split a selected species batch ? * * @since 0.3 */ - protected boolean splitSpeciesBatchEnabled; + protected boolean splitBatchEnabled; /** * Can user remove a selected species batch? * * @since 0.3 */ - protected boolean removeSpeciesBatchEnabled; + protected boolean removeBatchEnabled; /** * Can user remove a selected species sub batches? * * @since 0.3 */ - protected boolean removeSpeciesSubBatchEnabled; + protected boolean removeSubBatchEnabled; /** * Can user create a melag from the selected species? * * @since 0.3 */ - protected boolean createSpeciesMelagEnabled = true; + protected boolean createMelagEnabled = true; /** * Can user rename the selected species? * * @since 0.3 */ - protected boolean renameSpeciesBatchEnabled; + protected boolean renameBatchEnabled; /** * What to show in the table. @@ -273,64 +273,64 @@ firePropertyChange(PROPERTY_LEAF_NUMBER, oldValue, leafNumber); } - public boolean isCreateSpeciesBatchEnabled() { - return createSpeciesBatchEnabled; + public boolean isCreateBatchEnabled() { + return createBatchEnabled; } - public void setCreateSpeciesBatchEnabled(boolean createSpeciesBatchEnabled) { - Object oldValue = isCreateSpeciesBatchEnabled(); - this.createSpeciesBatchEnabled = createSpeciesBatchEnabled; - firePropertyChange(PROPERTY_CREATE_SPECIES_BATCH_ENABLED, oldValue, createSpeciesBatchEnabled); + public void setCreateBatchEnabled(boolean createBatchEnabled) { + Object oldValue = isCreateBatchEnabled(); + this.createBatchEnabled = createBatchEnabled; + firePropertyChange(PROPERTY_CREATE_BATCH_ENABLED, oldValue, createBatchEnabled); } - public boolean isSplitSpeciesBatchEnabled() { - return splitSpeciesBatchEnabled; + public boolean isSplitBatchEnabled() { + return splitBatchEnabled; } - public void setSplitSpeciesBatchEnabled(boolean splitSpeciesBatchEnabled) { - Object oldValue = isSplitSpeciesBatchEnabled(); - this.splitSpeciesBatchEnabled = splitSpeciesBatchEnabled; - firePropertyChange(PROPERTY_SPLIT_SPECIES_BATCH_ENABLED, oldValue, splitSpeciesBatchEnabled); + public void setSplitBatchEnabled(boolean splitBatchEnabled) { + Object oldValue = isSplitBatchEnabled(); + this.splitBatchEnabled = splitBatchEnabled; + firePropertyChange(PROPERTY_SPLIT_BATCH_ENABLED, oldValue, splitBatchEnabled); } - public boolean isRemoveSpeciesBatchEnabled() { - return removeSpeciesBatchEnabled; + public boolean isRemoveBatchEnabled() { + return removeBatchEnabled; } - public void setRemoveSpeciesBatchEnabled(boolean removeSpeciesBatchEnabled) { - Object oldValue = isRemoveSpeciesBatchEnabled(); - this.removeSpeciesBatchEnabled = removeSpeciesBatchEnabled; - firePropertyChange(PROPERTY_REMOVE_SPECIES_BATCH_ENABLED, oldValue, removeSpeciesBatchEnabled); + public void setRemoveBatchEnabled(boolean removeBatchEnabled) { + Object oldValue = isRemoveBatchEnabled(); + this.removeBatchEnabled = removeBatchEnabled; + firePropertyChange(PROPERTY_REMOVE_BATCH_ENABLED, oldValue, removeBatchEnabled); } - public boolean isRemoveSpeciesSubBatchEnabled() { - return removeSpeciesSubBatchEnabled; + public boolean isRemoveSubBatchEnabled() { + return removeSubBatchEnabled; } - public void setRemoveSpeciesSubBatchEnabled(boolean removeSpeciesSubBatchEnabled) { - Object oldValue = isRemoveSpeciesSubBatchEnabled(); - this.removeSpeciesSubBatchEnabled = removeSpeciesSubBatchEnabled; - firePropertyChange(PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED, oldValue, removeSpeciesSubBatchEnabled); + public void setRemoveSubBatchEnabled(boolean removeSubBatchEnabled) { + Object oldValue = isRemoveSubBatchEnabled(); + this.removeSubBatchEnabled = removeSubBatchEnabled; + firePropertyChange(PROPERTY_REMOVE_SUB_BATCH_ENABLED, oldValue, removeSubBatchEnabled); } - public void setRenameSpeciesBatchEnabled(boolean renameSpeciesBatchEnabled) { - Object oldValue = isRenameSpeciesBatchEnabled(); - this.renameSpeciesBatchEnabled = renameSpeciesBatchEnabled; - firePropertyChange(PROPERTY_RENAME_SPECIES_BATCH_ENABLED, oldValue, renameSpeciesBatchEnabled); + public void setRenameSpeciesBatchEnabled(boolean renameBatchEnabled) { + Object oldValue = isRenameBatchEnabled(); + this.renameBatchEnabled = renameBatchEnabled; + firePropertyChange(PROPERTY_RENAME_BATCH_ENABLED, oldValue, renameBatchEnabled); } - public boolean isRenameSpeciesBatchEnabled() { - return renameSpeciesBatchEnabled; + public boolean isRenameBatchEnabled() { + return renameBatchEnabled; } - public boolean isCreateSpeciesMelagEnabled() { - return createSpeciesMelagEnabled; + public boolean isCreateMelagEnabled() { + return createMelagEnabled; } - public void setCreateSpeciesMelagEnabled(boolean createSpeciesMelagEnabled) { - Object oldValue = isCreateSpeciesMelagEnabled(); - this.createSpeciesMelagEnabled = createSpeciesMelagEnabled; - firePropertyChange(PROPERTY_CREATE_SPECIES_MELAG_ENABLED, oldValue, createSpeciesMelagEnabled); + public void setCreateSpeciesMelagEnabled(boolean createMelagEnabled) { + Object oldValue = isCreateMelagEnabled(); + this.createMelagEnabled = createMelagEnabled; + firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled); } public void setRootBatchId(String rootBatchId) { Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,104 @@ +/* + * #%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% + */ + +BeanFilterableComboBox { + showReset: true; + i18nPrefix: "tutti.property."; + bean: {model}; +} + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + showReset: true; +} + +#createSpeciesBatchTopPanel { + _help: {"tutti.createSpeciesBatch.help"}; +} + +#speciesLabel { + text: "tutti.createSpeciesBatch.field.species"; + toolTipText: "tutti.createSpeciesBatch.field.species.tip"; + labelFor: {speciesComboBox}; + _help: {"tutti.createSpeciesBatch.field.species.help"}; +} + +#speciesComboBox { + property: species; + selectedItem: {model.getSpecies()}; + data: {model.getAvailableSpecies()}; +} + +#sortedUnsortedCategoryLabel { + text: "tutti.createSpeciesBatch.field.sortedUnsortedCategory"; + toolTipText: "tutti.createSpeciesBatch.field.sortedUnsortedCategory.tip"; + labelFor: {sortedUnsortedCategoryComboBox}; + _help: {"tutti.createSpeciesBatch.field.sortedUnsortedCategory.help"}; +} + +#sortedUnsortedCategoryComboBox { + property: sortedUnsortedCategory; + selectedItem: {model.getSortedUnsortedCategory()}; +} + +#batchWeightLabel { + text: "tutti.createSpeciesBatch.field.batchWeight"; + toolTipText: "tutti.createSpeciesBatch.field.batchWeight.tip"; + labelFor: {batchWeightField}; + _help: {"tutti.createSpeciesBatch.field.batchWeight.help"}; +} + +#batchWeightField { + property: batchWeight; + model: {model.getBatchWeight()}; + useFloat: true; + numberPattern: {DECIMAL3_PATTERN}; + bean: {model}; +} + +#addSpeciesButton { + text: "tutti.createSpeciesBatch.action.addSpecies"; + toolTipText: "tutti.createSpeciesBatch.action.addSpecies.tip"; + i18nMnemonic: "tutti.createSpeciesBatch.action.addSpecies.mnemonic"; + _tuttiAction: {SelectSpeciesForSpeciesBatchAction.class}; + _help: {"tutti.createSpeciesBatch.action.addSpecies.help"}; +} + +#saveButton { + actionIcon: save; + text: "tutti.createSpeciesBatch.action.save"; + toolTipText: "tutti.createSpeciesBatch.action.save.tip"; + i18nMnemonic: "tutti.createSpeciesBatch.action.save.mnemonic"; + enabled: {model.isValid()}; + _help: {"tutti.createSpeciesBatch.action.save.help"}; +} + +#cancelButton { + actionIcon: cancel; + text: "tutti.createSpeciesBatch.action.cancel"; + toolTipText: "tutti.createSpeciesBatch.action.cancel.tip"; + i18nMnemonic: "tutti.createSpeciesBatch.action.cancel.mnemonic"; + _help: {"tutti.createSpeciesBatch.action.cancel.help"}; +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx (from rev 665, 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/create/CreateSpeciesBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,122 @@ +<!-- + #%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% + --> +<JPanel id='createSpeciesBatchTopPanel' layout='{new BorderLayout()}' + decorator='help' + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.referential.Species + fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue + + fr.ifremer.tutti.ui.swing.TuttiHelpBroker + fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI + fr.ifremer.tutti.ui.swing.util.TuttiUI + + org.jdesktop.swingx.JXTable + + jaxx.runtime.swing.editor.bean.BeanFilterableComboBox + jaxx.runtime.swing.editor.NumberEditor + + java.awt.Color + + static org.nuiton.i18n.I18n._ + static jaxx.runtime.SwingUtil.getStringValue + </import> + + <script><![CDATA[ + +public CreateSpeciesBatchUI(EditCatchesUI parentUI) { + JAXXUtil.initContext(this, parentUI); + CreateSpeciesBatchUIHandler handler = new CreateSpeciesBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <CreateSpeciesBatchUIHandler id='handler' + initializer='getContextValue(CreateSpeciesBatchUIHandler.class)'/> + + <CreateSpeciesBatchUIModel id='model' + initializer='getContextValue(CreateSpeciesBatchUIModel.class)'/> + + <BeanValidator id='validator' bean='model' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='species' component='speciesComboBox'/> + <field name='sortedUnsortedCategory' + component='sortedUnsortedCategoryComboBox'/> + <field name='batchWeight' component='batchWeightField'/> + </BeanValidator> + + <TuttiHelpBroker id='broker' + constructorParams='"tutti.createSpeciesBatch.help"'/> + + <Table id='configurationPanel' constraints='BorderLayout.CENTER' fill='both'> + + <!-- Species --> + <row> + <cell anchor='west'> + <JLabel id='speciesLabel'/> + </cell> + <cell weightx='1.0'> + <BeanFilterableComboBox id='speciesComboBox' constructorParams='this' + genericType='Species'/> + </cell> + <cell> + <JButton id='addSpeciesButton'/> + </cell> + </row> + + <!-- Sorted / Unsorted Category --> + <row> + <cell anchor='west'> + <JLabel id='sortedUnsortedCategoryLabel'/> + </cell> + <cell weightx='1.0' columns='2'> + <BeanFilterableComboBox id='sortedUnsortedCategoryComboBox' + constructorParams='this' + genericType='CaracteristicQualitativeValue'/> + </cell> + </row> + + <!-- Species batch weight --> + <row> + <cell anchor='west'> + <JLabel id='batchWeightLabel'/> + </cell> + <cell weightx='1.0' columns='2'> + <NumberEditor id='batchWeightField' constructorParams='this'/> + </cell> + </row> + + + </Table> + + <!-- Form Actions --> + <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'> + <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> + <JButton id='saveButton' onActionPerformed='handler.save()'/> + </JPanel> +</JPanel> Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java (from rev 665, 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/create/CreateSpeciesBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,245 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.create; + +/* + * #%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.Lists; +import com.google.common.collect.Multimap; +import fr.ifremer.tutti.persistence.TuttiPersistence; +import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum; +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; +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.SpeciesBatchUIModel; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.util.Cancelable; +import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.Dimension; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +/** + * Handler of {@link CreateSpeciesBatchUI}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel, CreateSpeciesBatchUI> implements Cancelable { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(CreateSpeciesBatchUIHandler.class); + + private final TuttiPersistence persistenceService; + + private final CaracteristicQualitativeValue sortedValue; + + public CreateSpeciesBatchUIHandler(TuttiUI parentUi, + CreateSpeciesBatchUI ui) { + super(parentUi.getHandler().getContext(), ui); + this.persistenceService = context.getPersistenceService(); + + Caracteristic caracteristic = + persistenceService.getSortedUnsortedCaracteristic(); + sortedValue = SortedUnsortedEnum.SORTED.getValue(caracteristic); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + CreateSpeciesBatchUIModel model = new CreateSpeciesBatchUIModel(); + ui.setContextValue(model); + listModelIsModify(model); + } + + @Override + public void afterInitUI() { + + initUI(ui); + + initBeanFilterableComboBox(ui.getSpeciesComboBox(), + Lists.<Species>newArrayList(), + null, + DecoratorService.FROM_PROTOCOL); + + Caracteristic caracteristic = + persistenceService.getSortedUnsortedCaracteristic(); + + initBeanFilterableComboBox(ui.getSortedUnsortedCategoryComboBox(), + caracteristic.getQualitativeValue(), + null); + + getModel().addPropertyChangeListener(CreateSpeciesBatchUIModel.PROPERTY_SPECIES, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + CreateSpeciesBatchUIModel source = + (CreateSpeciesBatchUIModel) evt.getSource(); + Species newValue = (Species) evt.getNewValue(); + + if (log.isInfoEnabled()) { + log.info("New Selected species " + (newValue == null ? null : newValue.getRefTaxCode())); + } + + if (newValue == null || source.getSpeciesUsed() == null) { + + source.setSortedUnsortedCategory(null); + + } else { + + // look for best value : if sorted is available then use it + + List<CaracteristicQualitativeValue> qualitativeValues = + ui.getSortedUnsortedCategoryComboBox().getData(); + + CaracteristicQualitativeValue newCategory = null; + + for (CaracteristicQualitativeValue qualitativeValue : qualitativeValues) { + if (source.isSpeciesAndCategoryAvailable(newValue, qualitativeValue)) { + newCategory = qualitativeValue; + + if (newCategory.equals(sortedValue)) { + break; + } + } + } + source.setSortedUnsortedCategory(newCategory); + } + } + }); + + listenValidatorValid(ui.getValidator(), getModel()); + } + + @Override + public void onCloseUI() { + + if (log.isDebugEnabled()) { + log.debug("closing: " + ui); + } + + // evict model from validator + ui.getValidator().setBean(null); + + // when canceling always invalid model + getModel().setValid(false); + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + parent.getHandler().setSpeciesSelectedCard(EditCatchesUIHandler.MAIN_CARD); + + } + + @Override + public SwingValidator<CreateSpeciesBatchUIModel> getValidator() { + return ui.getValidator(); + } + + //------------------------------------------------------------------------// + //-- Cancelable methods --// + //------------------------------------------------------------------------// + + @Override + public void cancel() { + if (log.isInfoEnabled()) { + log.info("Cancel UI " + ui); + } + closeUI(ui); + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void openUI(SpeciesBatchUIModel batchModel) { + + CreateSpeciesBatchUIModel model = getModel(); + + // connect model to validator + ui.getValidator().setBean(model); + + model.setSpecies(null); + model.setSortedUnsortedCategory(null); + model.setBatchWeight(null); + + List<Species> speciesToUse = Lists.newArrayList(); + + Multimap<CaracteristicQualitativeValue, Species> speciesUsed = + model.getSpeciesUsed(); + speciesUsed.clear(); + + if (batchModel != null) { + + speciesUsed.putAll(batchModel.getSpeciesUsed()); + + // compute which species can still be used + + List<Species> allSpecies = getDataContext().getReferentSpeciesWithSurveyCode(); + + speciesToUse.addAll(allSpecies); + } + + model.setAvailableSpecies(speciesToUse); + ui.getSpeciesComboBox().requestFocus(); + } + + public void save() { + + if (log.isInfoEnabled()) { + log.info("Save UI " + ui); + } + + EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); + parent.getSpeciesTabContent().getHandler().addBatch(getModel()); + + // close dialog + closeUI(ui); + } + + public Species openAddSpeciesDialog(String title, List<Species> species) { + SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui); + SelectSpeciesUIModel model = dialogContent.getModel(); + model.setSelectedSpecies(null); + model.setSpecies(species); + + openDialog(dialogContent, title, new Dimension(400, 130)); + + Species result = model.getSelectedSpecies(); + return result; + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,160 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.create; + +/* + * #%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.ArrayListMultimap; +import com.google.common.collect.Multimap; +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.SpeciesBatchRootRowModel; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.List; + +/** + * Model of {@link CreateSpeciesBatchUI}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class CreateSpeciesBatchUIModel extends AbstractTuttiBeanUIModel<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIModel> + implements SpeciesBatchRootRowModel { + + private final static Log log = LogFactory.getLog(CreateSpeciesBatchUIModel.class); + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_AVAILABLE_SPECIES = "availableSpecies"; + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory"; + + public static final String PROPERTY_BATCH_WEIGHT = "batchWeight"; + + /** + * All available species (sets by protocol). + * + * @since 0.3 + */ + protected List<Species> availableSpecies; + + /** + * Species to select. + * + * @since 0.3 + */ + protected Species species; + + /** + * Sorted Unsorted category. + * + * @since 0.3 + */ + protected CaracteristicQualitativeValue sortedUnsortedCategory; + + /** + * Incoming batch weight to split. + * + * @since 0.3 + */ + protected Float batchWeight; + + /** + * Already used species by sortedUnsorted category. + * + * @since 0.3 + */ + protected final Multimap<CaracteristicQualitativeValue, Species> speciesUsed = ArrayListMultimap.create(); + + public CreateSpeciesBatchUIModel() { + super(CreateSpeciesBatchUIModel.class, null, null); + } + + public List<Species> getAvailableSpecies() { + if (log.isDebugEnabled()) { + log.debug("getAvailableSpecies " + availableSpecies); + } + return availableSpecies; + } + + public void setAvailableSpecies(List<Species> availableSpecies) { + + if (log.isDebugEnabled()) { + log.debug("setAvailableSpecies " + availableSpecies); + } + Object oldValue = getAvailableSpecies(); + this.availableSpecies = availableSpecies; + firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies); + } + + public Species getSpecies() { + return species; + } + + public void setSpecies(Species species) { + Object oldSpecies = getSpecies(); + this.species = species; + firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies()); + } + + public CaracteristicQualitativeValue getSortedUnsortedCategory() { + return sortedUnsortedCategory; + } + + public void setSortedUnsortedCategory(CaracteristicQualitativeValue sortedUnsortedCategory) { + Object oldSpecies = getSortedUnsortedCategory(); + this.sortedUnsortedCategory = sortedUnsortedCategory; + firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldSpecies, sortedUnsortedCategory); + } + + public Float getBatchWeight() { + return batchWeight; + } + + public void setBatchWeight(Float batchWeight) { + Object oldValue = getBatchWeight(); + this.batchWeight = batchWeight; + firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight); + } + + public Multimap<CaracteristicQualitativeValue, Species> getSpeciesUsed() { + return speciesUsed; + } + + public boolean isSpeciesAndCategoryAvailable() { + boolean result = species != null && sortedUnsortedCategory != null && + isSpeciesAndCategoryAvailable(species, sortedUnsortedCategory); + return result; + } + + public boolean isSpeciesAndCategoryAvailable(Species species, + CaracteristicQualitativeValue sortedUnsortedCategory) { + boolean result = !speciesUsed.containsEntry(sortedUnsortedCategory, species); + return result; + } +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/AddSpeciesAction.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,101 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.create; + +/* + * #%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.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; + +import java.util.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n._; + +/** + * Enable to select a species to the species selected in the protocol. + * + * @author kmorin <kmorin@codelutin.com> + * @since 1.0 + */ +public class SelectSpeciesForSpeciesBatchAction extends AbstractTuttiAction<CreateSpeciesBatchUIModel, CreateSpeciesBatchUI, CreateSpeciesBatchUIHandler> { + + protected List<Species> allSpecies; + + protected List<Species> referentSpecies; + + protected Species selectedSpecies; + + public SelectSpeciesForSpeciesBatchAction(CreateSpeciesBatchUIHandler handler) { + super(handler, false); + + allSpecies = getDataContext().getSpecies(); + referentSpecies = getDataContext().getReferentSpecies(); + } + + @Override + protected boolean prepareAction() throws Exception { + boolean canContinue = super.prepareAction(); + if (canContinue) { + + CreateSpeciesBatchUIModel model = getModel(); + + List<Species> species = Lists.newArrayList(allSpecies); + species.removeAll(model.getAvailableSpecies()); + + selectedSpecies = getHandler().openAddSpeciesDialog( + _("tutti.selectSpecies.title"), species); + canContinue = selectedSpecies != null; + } + return canContinue; + } + + @Override + protected void doAction() throws Exception { + + CreateSpeciesBatchUIModel model = getModel(); + + List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies()); + + if (!selectedSpecies.isReferenceTaxon()) { + String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); + List<Species> referents = referentSpecies; + Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents); + String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId()); + selectedSpecies = referentsById.get(taxonId); + String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); + sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent)); + } + + if (!availableSpecies.contains(selectedSpecies)) { + availableSpecies.add(selectedSpecies); + } + model.setAvailableSpecies(availableSpecies); + model.setSpecies(selectedSpecies); + + } + +} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-03-23 18:20:58 UTC (rev 666) @@ -62,8 +62,6 @@ private static final long serialVersionUID = 1L; - public static final String ROW_INDEX = "rowIndex"; - protected Color computedDataColor; /** Logger. */ @@ -254,17 +252,6 @@ return result; } -// @Override -// public boolean stopCellEditing() { -// boolean b = super.stopCellEditing(); -// if (b) { -// rowIndex = null; -// editRow = null; -// columnIndex = null; -// } -// return b; -// } - @Override public void cancelCellEditing() { super.cancelCellEditing(); Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/AddSpeciesAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/AddSpeciesAction.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/AddSpeciesAction.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,102 +0,0 @@ - -package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split; - -/* - * #%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.Lists; -import fr.ifremer.tutti.persistence.entities.TuttiEntities; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.service.DecoratorService; -import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; - -import java.util.List; -import java.util.Map; - -import static org.nuiton.i18n.I18n._; - -/** - * Enable to select a species to the species selected in the protocol. - * - * @author kmorin <kmorin@codelutin.com> - * @since 1.0 - */ -public class AddSpeciesAction extends AbstractTuttiAction<CreateSpeciesBatchUIModel, CreateSpeciesBatchUI, CreateSpeciesBatchUIHandler> { - - protected List<Species> allSpecies; - - protected List<Species> referentSpecies; - - protected Species selectedSpecies; - - public AddSpeciesAction(CreateSpeciesBatchUIHandler handler) { - super(handler, false); - - allSpecies = getDataContext().getSpecies(); - referentSpecies = getDataContext().getReferentSpecies(); - } - - @Override - protected boolean prepareAction() throws Exception { - boolean canContinue = super.prepareAction(); - if (canContinue) { - - CreateSpeciesBatchUIModel model = getModel(); - - List<Species> species = Lists.newArrayList(allSpecies); - species.removeAll(model.getAvailableSpecies()); - - selectedSpecies = getHandler().openAddSpeciesDialog( - _("tutti.selectSpecies.title"), species); - canContinue = selectedSpecies != null; - } - return canContinue; - } - - @Override - protected void doAction() throws Exception { - - CreateSpeciesBatchUIModel model = getModel(); - - List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies()); - - if (!selectedSpecies.isReferenceTaxon()) { - String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); - List<Species> referents = referentSpecies; - Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents); - String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId()); - selectedSpecies = referentsById.get(taxonId); - String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL); - sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent)); - } - - if (!availableSpecies.contains(selectedSpecies)) { - availableSpecies.add(selectedSpecies); - } - model.setAvailableSpecies(availableSpecies); - model.setSpecies(selectedSpecies); - - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -1,104 +0,0 @@ -/* - * #%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% - */ - -BeanFilterableComboBox { - showReset: true; - i18nPrefix: "tutti.property."; - bean: {model}; -} - -NumberEditor { - autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; - showReset: true; -} - -#createSpeciesBatchTopPanel { - _help: {"tutti.createSpeciesBatch.help"}; -} - -#speciesLabel { - text: "tutti.createSpeciesBatch.field.species"; - toolTipText: "tutti.createSpeciesBatch.field.species.tip"; - labelFor: {speciesComboBox}; - _help: {"tutti.createSpeciesBatch.field.species.help"}; -} - -#speciesComboBox { - property: species; - selectedItem: {model.getSpecies()}; - data: {model.getAvailableSpecies()}; -} - -#sortedUnsortedCategoryLabel { - text: "tutti.createSpeciesBatch.field.sortedUnsortedCategory"; - toolTipText: "tutti.createSpeciesBatch.field.sortedUnsortedCategory.tip"; - labelFor: {sortedUnsortedCategoryComboBox}; - _help: {"tutti.createSpeciesBatch.field.sortedUnsortedCategory.help"}; -} - -#sortedUnsortedCategoryComboBox { - property: sortedUnsortedCategory; - selectedItem: {model.getSortedUnsortedCategory()}; -} - -#batchWeightLabel { - text: "tutti.createSpeciesBatch.field.batchWeight"; - toolTipText: "tutti.createSpeciesBatch.field.batchWeight.tip"; - labelFor: {batchWeightField}; - _help: {"tutti.createSpeciesBatch.field.batchWeight.help"}; -} - -#batchWeightField { - property: batchWeight; - model: {model.getBatchWeight()}; - useFloat: true; - numberPattern: {DECIMAL3_PATTERN}; - bean: {model}; -} - -#addSpeciesButton { - text: "tutti.createSpeciesBatch.action.addSpecies"; - toolTipText: "tutti.createSpeciesBatch.action.addSpecies.tip"; - i18nMnemonic: "tutti.createSpeciesBatch.action.addSpecies.mnemonic"; - _tuttiAction: {AddSpeciesAction.class}; - _help: {"tutti.createSpeciesBatch.action.addSpecies.help"}; -} - -#saveButton { - actionIcon: save; - text: "tutti.createSpeciesBatch.action.save"; - toolTipText: "tutti.createSpeciesBatch.action.save.tip"; - i18nMnemonic: "tutti.createSpeciesBatch.action.save.mnemonic"; - enabled: {model.isValid()}; - _help: {"tutti.createSpeciesBatch.action.save.help"}; -} - -#cancelButton { - actionIcon: cancel; - text: "tutti.createSpeciesBatch.action.cancel"; - toolTipText: "tutti.createSpeciesBatch.action.cancel.tip"; - i18nMnemonic: "tutti.createSpeciesBatch.action.cancel.mnemonic"; - _help: {"tutti.createSpeciesBatch.action.cancel.help"}; -} Deleted: 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -1,128 +0,0 @@ -<!-- - #%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% - --> -<JPanel id='createSpeciesBatchTopPanel' layout='{new BorderLayout()}' - decorator='help' - implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.Species - fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue - - fr.ifremer.tutti.ui.swing.TuttiHelpBroker - fr.ifremer.tutti.ui.swing.TuttiUIContext - - 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 - - org.jdesktop.swingx.JXTable - - jaxx.runtime.swing.editor.bean.BeanFilterableComboBox - jaxx.runtime.swing.editor.NumberEditor - - javax.swing.ListSelectionModel - - java.awt.Color - - static org.nuiton.i18n.I18n._ - static jaxx.runtime.SwingUtil.getStringValue - </import> - - <script><![CDATA[ - -public CreateSpeciesBatchUI(EditCatchesUI parentUI) { - JAXXUtil.initContext(this, parentUI); - CreateSpeciesBatchUIHandler handler = new CreateSpeciesBatchUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <CreateSpeciesBatchUIHandler id='handler' - initializer='getContextValue(CreateSpeciesBatchUIHandler.class)'/> - - <CreateSpeciesBatchUIModel id='model' - initializer='getContextValue(CreateSpeciesBatchUIModel.class)'/> - - <BeanValidator id='validator' bean='model' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='species' component='speciesComboBox'/> - <field name='sortedUnsortedCategory' - component='sortedUnsortedCategoryComboBox'/> - <field name='batchWeight' component='batchWeightField'/> - </BeanValidator> - - <TuttiHelpBroker id='broker' - constructorParams='"tutti.createSpeciesBatch.help"'/> - - <Table id='configurationPanel' constraints='BorderLayout.CENTER' fill='both'> - - <!-- Species --> - <row> - <cell anchor='west'> - <JLabel id='speciesLabel'/> - </cell> - <cell weightx='1.0'> - <BeanFilterableComboBox id='speciesComboBox' constructorParams='this' - genericType='Species'/> - </cell> - <cell> - <JButton id='addSpeciesButton'/> - </cell> - </row> - - <!-- Sorted / Unsorted Category --> - <row> - <cell anchor='west'> - <JLabel id='sortedUnsortedCategoryLabel'/> - </cell> - <cell weightx='1.0' columns='2'> - <BeanFilterableComboBox id='sortedUnsortedCategoryComboBox' - constructorParams='this' - genericType='CaracteristicQualitativeValue'/> - </cell> - </row> - - <!-- Species batch weight --> - <row> - <cell anchor='west'> - <JLabel id='batchWeightLabel'/> - </cell> - <cell weightx='1.0' columns='2'> - <NumberEditor id='batchWeightField' constructorParams='this'/> - </cell> - </row> - - - </Table> - - <!-- Form Actions --> - <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'> - <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> - <JButton id='saveButton' onActionPerformed='handler.save()'/> - </JPanel> -</JPanel> Deleted: 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,252 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split; - -/* - * #%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.Lists; -import com.google.common.collect.Multimap; -import fr.ifremer.tutti.persistence.TuttiPersistence; -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; -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.SelectSpeciesUI; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SelectSpeciesUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; -import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; -import fr.ifremer.tutti.ui.swing.util.Cancelable; -import fr.ifremer.tutti.ui.swing.util.TuttiUI; -import jaxx.runtime.SwingUtil; -import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.awt.Dimension; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -/** - * Handler of {@link CreateSpeciesBatchUI}. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel, CreateSpeciesBatchUI> implements Cancelable { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(CreateSpeciesBatchUIHandler.class); - - private final TuttiPersistence persistenceService; - - private final CaracteristicQualitativeValue sortedValue; - - public CreateSpeciesBatchUIHandler(TuttiUI parentUi, - CreateSpeciesBatchUI ui) { - super(parentUi.getHandler().getContext(), ui); - this.persistenceService = context.getPersistenceService(); - - Caracteristic caracteristic = - persistenceService.getSortedUnsortedCaracteristic(); - - CaracteristicQualitativeValue v = null; - for (CaracteristicQualitativeValue value : caracteristic.getQualitativeValue()) { - if (persistenceService.isSortedQualitativeValue(value)) { - v = value; - break; - } - } - sortedValue = v; - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public void beforeInitUI() { - CreateSpeciesBatchUIModel model = new CreateSpeciesBatchUIModel(); - ui.setContextValue(model); - listModelIsModify(model); - } - - @Override - public void afterInitUI() { - - initUI(ui); - - initBeanFilterableComboBox(ui.getSpeciesComboBox(), - Lists.<Species>newArrayList(), - null, - DecoratorService.FROM_PROTOCOL); - - Caracteristic caracteristic = - persistenceService.getSortedUnsortedCaracteristic(); - - initBeanFilterableComboBox(ui.getSortedUnsortedCategoryComboBox(), - caracteristic.getQualitativeValue(), - null); - - getModel().addPropertyChangeListener(CreateSpeciesBatchUIModel.PROPERTY_SPECIES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - - CreateSpeciesBatchUIModel source = - (CreateSpeciesBatchUIModel) evt.getSource(); - Species newValue = (Species) evt.getNewValue(); - - if (log.isInfoEnabled()) { - log.info("New Selected species " + (newValue == null ? null : newValue.getRefTaxCode())); - } - - if (newValue == null || source.getSpeciesUsed() == null) { - - source.setSortedUnsortedCategory(null); - - } else { - - // look for best value : if sorted is available then use it - - List<CaracteristicQualitativeValue> qualitativeValues = - ui.getSortedUnsortedCategoryComboBox().getData(); - - CaracteristicQualitativeValue newCategory = null; - - for (CaracteristicQualitativeValue qualitativeValue : qualitativeValues) { - if (source.isSpeciesAndCategoryAvailable(newValue, qualitativeValue)) { - newCategory = qualitativeValue; - - if (newCategory.equals(sortedValue)) { - break; - } - } - } - source.setSortedUnsortedCategory(newCategory); - } - } - }); - - listenValidatorValid(ui.getValidator(), getModel()); - } - - @Override - public void onCloseUI() { - - if (log.isDebugEnabled()) { - log.debug("closing: " + ui); - } - - // evict model from validator - ui.getValidator().setBean(null); - - // when canceling always invalid model - getModel().setValid(false); - - EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); - parent.getHandler().setSpeciesSelectedCard(EditCatchesUIHandler.MAIN_CARD); - - } - - @Override - public SwingValidator<CreateSpeciesBatchUIModel> getValidator() { - return ui.getValidator(); - } - - //------------------------------------------------------------------------// - //-- Cancelable methods --// - //------------------------------------------------------------------------// - - @Override - public void cancel() { - if (log.isInfoEnabled()) { - log.info("Cancel UI " + ui); - } - closeUI(ui); - } - - //------------------------------------------------------------------------// - //-- Public methods --// - //------------------------------------------------------------------------// - - public void openUI(SpeciesBatchUIModel batchModel) { - - CreateSpeciesBatchUIModel model = getModel(); - - // connect model to validator - ui.getValidator().setBean(model); - - model.setSpecies(null); - model.setSortedUnsortedCategory(null); - model.setBatchWeight(null); - - List<Species> speciesToUse = Lists.newArrayList(); - - Multimap<CaracteristicQualitativeValue, Species> speciesUsed = - model.getSpeciesUsed(); - speciesUsed.clear(); - - if (batchModel != null) { - - speciesUsed.putAll(batchModel.getSpeciesUsed()); - - // compute which species can still be used - - List<Species> allSpecies = getDataContext().getReferentSpeciesWithSurveyCode(); - - speciesToUse.addAll(allSpecies); - } - - model.setAvailableSpecies(speciesToUse); - ui.getSpeciesComboBox().requestFocus(); - } - - public void save() { - - if (log.isInfoEnabled()) { - log.info("Save UI " + ui); - } - - EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); - parent.getSpeciesTabContent().getHandler().addSpeciesBatch(getModel()); - - // close dialog - closeUI(ui); - } - - public Species openAddSpeciesDialog(String title, List<Species> species) { - SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui); - SelectSpeciesUIModel model = dialogContent.getModel(); - model.setSelectedSpecies(null); - model.setSpecies(species); - - openDialog(dialogContent, title, new Dimension(400, 130)); - - Species result = model.getSelectedSpecies(); - return result; - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -1,160 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split; - -/* - * #%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.ArrayListMultimap; -import com.google.common.collect.Multimap; -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.species.SpeciesBatchRootRowModel; -import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.List; - -/** - * Model of {@link CreateSpeciesBatchUI}. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class CreateSpeciesBatchUIModel extends AbstractTuttiBeanUIModel<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIModel> - implements SpeciesBatchRootRowModel { - - private final static Log log = LogFactory.getLog(CreateSpeciesBatchUIModel.class); - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_AVAILABLE_SPECIES = "availableSpecies"; - - public static final String PROPERTY_SPECIES = "species"; - - public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory"; - - public static final String PROPERTY_BATCH_WEIGHT = "batchWeight"; - - /** - * All available species (sets by protocol). - * - * @since 0.3 - */ - protected List<Species> availableSpecies; - - /** - * Species to select. - * - * @since 0.3 - */ - protected Species species; - - /** - * Sorted Unsorted category. - * - * @since 0.3 - */ - protected CaracteristicQualitativeValue sortedUnsortedCategory; - - /** - * Incoming batch weight to split. - * - * @since 0.3 - */ - protected Float batchWeight; - - /** - * Already used species by sortedUnsorted category. - * - * @since 0.3 - */ - protected final Multimap<CaracteristicQualitativeValue, Species> speciesUsed = ArrayListMultimap.create(); - - public CreateSpeciesBatchUIModel() { - super(CreateSpeciesBatchUIModel.class, null, null); - } - - public List<Species> getAvailableSpecies() { - if (log.isDebugEnabled()) { - log.debug("getAvailableSpecies " + availableSpecies); - } - return availableSpecies; - } - - public void setAvailableSpecies(List<Species> availableSpecies) { - - if (log.isDebugEnabled()) { - log.debug("setAvailableSpecies " + availableSpecies); - } - Object oldValue = getAvailableSpecies(); - this.availableSpecies = availableSpecies; - firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies); - } - - public Species getSpecies() { - return species; - } - - public void setSpecies(Species species) { - Object oldSpecies = getSpecies(); - this.species = species; - firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies()); - } - - public CaracteristicQualitativeValue getSortedUnsortedCategory() { - return sortedUnsortedCategory; - } - - public void setSortedUnsortedCategory(CaracteristicQualitativeValue sortedUnsortedCategory) { - Object oldSpecies = getSortedUnsortedCategory(); - this.sortedUnsortedCategory = sortedUnsortedCategory; - firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldSpecies, sortedUnsortedCategory); - } - - public Float getBatchWeight() { - return batchWeight; - } - - public void setBatchWeight(Float batchWeight) { - Object oldValue = getBatchWeight(); - this.batchWeight = batchWeight; - firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight); - } - - public Multimap<CaracteristicQualitativeValue, Species> getSpeciesUsed() { - return speciesUsed; - } - - public boolean isSpeciesAndCategoryAvailable() { - boolean result = species != null && sortedUnsortedCategory != null && - isSpeciesAndCategoryAvailable(species, sortedUnsortedCategory); - return result; - } - - public boolean isSpeciesAndCategoryAvailable(Species species, - CaracteristicQualitativeValue sortedUnsortedCategory) { - boolean result = !speciesUsed.containsEntry(sortedUnsortedCategory, species); - return result; - } -} \ No newline at end of file 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -24,9 +24,9 @@ * #L% */ +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; 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; @@ -67,11 +67,11 @@ super(SplitSpeciesBatchRowModel.class, fromBeanBinder, toBeanBinder); } - public SampleCategoryType getCategoryType() { + public SampleCategoryEnum getCategoryType() { return category.getCategoryType(); } - public void setCategoryType(SampleCategoryType categoryType) { + public void setCategoryType(SampleCategoryEnum categoryType) { category.setCategoryType(categoryType); } 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -26,12 +26,8 @@ implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<SplitSpeciesBatchUIModel, SplitSpeciesBatchUIHandler>'> <import> - fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI - 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 - fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI fr.ifremer.tutti.ui.swing.util.TuttiUI org.jdesktop.swingx.JXTable 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -26,13 +26,13 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; 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.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.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; @@ -168,7 +168,7 @@ source.setSelectedCategory(null); // fill comboBox with new list - List<SampleCategoryType> data = (List<SampleCategoryType>) evt.getNewValue(); + List<SampleCategoryEnum> data = (List<SampleCategoryEnum>) evt.getNewValue(); ui.getCategoryComboBox().setModel(new DefaultComboBoxModel(data.toArray())); } }); @@ -184,8 +184,8 @@ // when selected category change, sample total weight is reset source.setSampleWeight(null); - SampleCategoryType newValue = - (SampleCategoryType) evt.getNewValue(); + SampleCategoryEnum newValue = + (SampleCategoryEnum) evt.getNewValue(); generateTableModel(newValue); } }); @@ -194,7 +194,7 @@ public void actionPerformed(ActionEvent e) { JComboBox comboBox = (JComboBox) e.getSource(); - getModel().setSelectedCategory((SampleCategoryType) comboBox.getSelectedItem()); + getModel().setSelectedCategory((SampleCategoryEnum) comboBox.getSelectedItem()); } }); @@ -247,8 +247,8 @@ public void editBatch(SpeciesBatchRowModel batch) { // get possible the last used - List<SampleCategoryType> categories = - Lists.newArrayList(SampleCategoryType.values()); + List<SampleCategoryEnum> categories = + Lists.newArrayList(SampleCategoryEnum.values()); if (batch != null) { //TODO Use the samplingOrder (+ the one from the table model) @@ -260,23 +260,23 @@ "Can't split a species batch with no sample category."); if (batch.getSortedUnsortedCategory().isValid()) { - categories.remove(SampleCategoryType.sortedUnsorted); + categories.remove(SampleCategoryEnum.sortedUnsorted); } if (batch.getSizeCategory().isValid()) { - categories.remove(SampleCategoryType.size); + categories.remove(SampleCategoryEnum.size); } if (batch.getSexCategory().isValid()) { - categories.remove(SampleCategoryType.sex); + categories.remove(SampleCategoryEnum.sex); } if (batch.getMaturityCategory().isValid()) { - categories.remove(SampleCategoryType.maturity); + categories.remove(SampleCategoryEnum.maturity); } if (batch.getAgeCategory().isValid()) { - categories.remove(SampleCategoryType.age); + categories.remove(SampleCategoryEnum.age); } } @@ -327,7 +327,7 @@ getModel().setSampleWeight(result); } - protected void generateTableModel(SampleCategoryType category) { + protected void generateTableModel(SampleCategoryEnum category) { // when generate a new table model, then reset previous rows from model getModel().setRows(null); 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -24,8 +24,8 @@ * #L% */ +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.referential.Species; -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; @@ -64,14 +64,14 @@ * * @since 0.3 */ - protected List<SampleCategoryType> category; + protected List<SampleCategoryEnum> category; /** * Selected Sample category. * * @since 0.3 */ - protected SampleCategoryType selectedCategory; + protected SampleCategoryEnum selectedCategory; /** * Sample weight of split batches. @@ -101,21 +101,21 @@ return batch == null ? null : batch.getSpecies(); } - public List<SampleCategoryType> getCategory() { + public List<SampleCategoryEnum> getCategory() { return category; } - public void setCategory(List<SampleCategoryType> category) { + public void setCategory(List<SampleCategoryEnum> category) { Object oldValue = getCategory(); this.category = category; firePropertyChange(PROPERTY_CATEGORY, oldValue, category); } - public SampleCategoryType getSelectedCategory() { + public SampleCategoryEnum getSelectedCategory() { return selectedCategory; } - public void setSelectedCategory(SampleCategoryType selectedCategory) { + public void setSelectedCategory(SampleCategoryEnum selectedCategory) { Object oldValue = getSelectedCategory(); this.selectedCategory = selectedCategory; firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -35,8 +35,8 @@ import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.ui.swing.content.home.CloneProtocolAction; import fr.ifremer.tutti.ui.swing.content.home.ImportProtocolAction; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SelectSpeciesUI; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SelectSpeciesUIModel; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI; +import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel; import fr.ifremer.tutti.ui.swing.util.CloseableUI; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -30,6 +30,7 @@ import fr.ifremer.tutti.TuttiTechnicalException; import fr.ifremer.tutti.persistence.entities.IdAware; import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.LabelAware; import fr.ifremer.tutti.ui.swing.TuttiDataContext; import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig; @@ -646,8 +647,8 @@ Decorator decorator = decoratorService.getDecoratorByType(type, name); if (decorator == null) { - if (DecoratorService.LabelAware.class.isAssignableFrom(type)) { - decorator = getDecorator(DecoratorService.LabelAware.class, null); + if (LabelAware.class.isAssignableFrom(type)) { + decorator = getDecorator(LabelAware.class, null); } } Preconditions.checkNotNull(decorator); Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.css 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,53 @@ +/* + * #%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% + */ + +#dialog { + title: "tutti.createSpeciesMelag.title"; +} + +#message { + text: "tutti.createSpeciesMelag.message"; + horizontalAlignment: {JLabel.CENTER}; +} + +#editor { + useFloat: true; + useSign: false; + autoPopup: true; + showPopupButton: true; + showReset: true; +} + +#cancelButton { + text: "tutti.createSpeciesMelag.action.cancel"; + toolTipText: "tutti.createSpeciesMelag.action.cancel.tip"; + i18nMnemonic: "tutti.createSpeciesMelag.action.cancel.mnemonic"; +} + +#validateButton { + text: "tutti.createSpeciesMelag.action.validate"; + toolTipText: "tutti.createSpeciesMelag.action.validate.tip"; + i18nMnemonic: "tutti.createSpeciesMelag.action.validate.mnemonic"; + enabled: { editor.getModel() != null }; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/EnterMelagWeightDialog.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/EnterMelagWeightDialog.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,73 @@ +<!-- + #%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% + --> +<JDialog id='dialog' layout='{new BorderLayout()}'> + <import> + java.awt.Component; + java.awt.event.WindowAdapter; + java.awt.event.WindowEvent; + javax.swing.JComponent + javax.swing.JRootPane; + javax.swing.KeyStroke; + jaxx.runtime.swing.editor.NumberEditor + </import> + + <script><![CDATA[ + +public EnterMelagWeightDialog(Frame frame, KeyStroke shortcutClosePopup) { + super(frame, true); + + // add a auto-close action + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( + shortcutClosePopup, "close"); + + addWindowListener(new WindowAdapter() { + + @Override + public void windowClosed(WindowEvent e) { + Component ui = (Component) e.getSource(); + JAXXUtil.destroy(ui); + } + }); +} + + ]]></script> + + <Table id='table' fill='both' constraints='BorderLayout.CENTER'> + <row> + <cell insets='10, 10, 5, 10'> + <JLabel id='message'/> + </cell> + </row> + <row> + <cell insets='5, 10, 10, 10'> + <NumberEditor id='editor'/> + </cell> + </row> + </Table> + <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'> + <JButton id='cancelButton' + onActionPerformed='editor.setModel(null); dispose();'/> + <JButton id='validateButton' onActionPerformed='dispose();'/> + </JPanel> +</JDialog> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.css (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.css 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,46 @@ +/* + * #%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% + */ +#speciesCombo { + showReset: true; + i18nPrefix: "tutti.property."; + bean: {model}; + property: selectedSpecies; + selectedItem: {model.getSelectedSpecies()}; + data: {model.getSpecies()}; +} + +#cancelButton { + actionIcon: cancel; + text: "tutti.selectSpecies.action.cancel"; + toolTipText: "tutti.selectSpecies.action.cancel.tip"; + i18nMnemonic: "tutti.selectSpecies.action.cancel.mnemonic"; +} + +#validateButton { + actionIcon: accept; + text: "tutti.selectSpecies.action.validate"; + toolTipText: "tutti.selectSpecies.action.validate.tip"; + i18nMnemonic: "tutti.selectSpecies.action.validate.mnemonic"; + enabled: {model.getSelectedSpecies() != null}; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.jaxx (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUI.jaxx 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,61 @@ +<!-- + #%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% + --> +<JPanel layout='{new BorderLayout()}' id='selectSpeciesPopup' + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<SelectSpeciesUIModel, SelectSpeciesUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.referential.Species + fr.ifremer.tutti.ui.swing.util.TuttiUI + jaxx.runtime.swing.editor.bean.BeanFilterableComboBox + </import> + + <script><![CDATA[ + +public SelectSpeciesUI(TuttiUI parentUI) { + JAXXUtil.initContext(this, parentUI); + SelectSpeciesUIHandler handler = new SelectSpeciesUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <SelectSpeciesUIHandler id='handler' + initializer='getContextValue(SelectSpeciesUIHandler.class)'/> + + <SelectSpeciesUIModel id='model' + initializer='getContextValue(SelectSpeciesUIModel.class)'/> + + <BeanFilterableComboBox id='speciesCombo' constraints='BorderLayout.CENTER' + constructorParams='this' genericType='Species'/> + + <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'> + <JButton id='cancelButton' + onActionPerformed='handler.cancel()'/> + <JButton id='validateButton' + onActionPerformed='handler.validate()'/> + </JPanel> + +</JPanel> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIHandler.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIHandler.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,96 @@ + +package fr.ifremer.tutti.ui.swing.util.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.Lists; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** + * @author kmorin <kmorin@codelutin.com> + * @since 1.0 + */ +public class SelectSpeciesUIHandler extends AbstractTuttiUIHandler<SelectSpeciesUIModel, SelectSpeciesUI> { + + private static final Log log = + LogFactory.getLog(SelectSpeciesUIHandler.class); + + public SelectSpeciesUIHandler(TuttiUI parentUI, SelectSpeciesUI ui) { + super(parentUI.getHandler().getContext(), ui); + } + + @Override + public void beforeInitUI() { + SelectSpeciesUIModel model = new SelectSpeciesUIModel(); + ui.setContextValue(model); + } + + @Override + public void afterInitUI() { + initUI(ui); + + initBeanFilterableComboBox(ui.getSpeciesCombo(), + Lists.<Species>newArrayList(), + null); + + getModel().addPropertyChangeListener( + SelectSpeciesUIModel.PROPERTY_SPECIES, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + ui.getSpeciesCombo().getHandler().sortData(); + } + }); + } + + @Override + public void onCloseUI() { + if (log.isDebugEnabled()) { + log.debug("closing: " + ui); + } + } + + @Override + public SwingValidator<SelectSpeciesUIModel> getValidator() { + return null; + } + + public void validate() { + closeDialog(ui); + } + + public void cancel() { + getModel().setSelectedSpecies(null); + closeDialog(ui); + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIModel.java (from rev 665, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SelectSpeciesUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/species/SelectSpeciesUIModel.java 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,72 @@ + +package fr.ifremer.tutti.ui.swing.util.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.Lists; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; + +import java.util.List; + +/** + * @author kmorin <kmorin@codelutin.com> + * @since 1.0 + */ +public class SelectSpeciesUIModel extends AbstractTuttiBeanUIModel<SelectSpeciesUIModel, SelectSpeciesUIModel> { + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_SELECTED_SPECIES = "selectedSpecies"; + + protected List<Species> species = Lists.newArrayList(); + + protected Species selectedSpecies; + + public SelectSpeciesUIModel() { + super(SelectSpeciesUIModel.class, null, null); + } + + public List<Species> getSpecies() { + return species; + } + + public void setSpecies(List<Species> species) { + Object oldValue = getSpecies(); + this.species = Lists.newArrayList(species); + firePropertyChange(PROPERTY_SPECIES, oldValue, this.species); + } + + public Species getSelectedSpecies() { + return selectedSpecies; + } + + public void setSelectedSpecies(Species selectedSpecies) { + Object oldValue = getSelectedSpecies(); + this.selectedSpecies = selectedSpecies; + firePropertyChange(PROPERTY_SELECTED_SPECIES, oldValue, selectedSpecies); + } + +} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/CaracteristicRow.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/CaracteristicRow.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/CaracteristicRow.java 2013-03-23 18:20:58 UTC (rev 666) @@ -25,13 +25,13 @@ */ import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.LabelAware; /** * @author kmorin <kmorin@codelutin.com> * @since 0.3 */ -public class CaracteristicRow implements DecoratorService.LabelAware { +public class CaracteristicRow implements LabelAware { private static final long serialVersionUID = 1L; Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml =================================================================== --- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml (rev 0) +++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,69 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL: http://svn.forge.codelutin.com/svn/tutti/trunk/tutti-ui-swing/src/main/resou... $ + %% + 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% + --> +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="species"> + <field-validator type="required" short-circuit="true"> + <message>tutti.validator.error.createSpeciesBatch.species.required + </message> + </field-validator> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ sortedUnsortedCategory == null || speciesAndCategoryAvailable ]]> + </param> + <message> + tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable + </message> + </field-validator> + </field> + + <field name="sortedUnsortedCategory"> + <field-validator type="required" short-circuit="true"> + <message>tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required + </message> + </field-validator> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ species == null || speciesAndCategoryAvailable ]]> + </param> + <message> + tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable + </message> + </field-validator> + </field> + + <field name="batchWeight"> + + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"><![CDATA[ batchWeight == null || batchWeight > 0 ]]></param> + <message> + tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue + </message> + </field-validator> + + </field> +</validators> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml (from rev 665, trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml) =================================================================== --- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml (rev 0) +++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,50 @@ +<!-- + #%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% + --> +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="lengthStepCaracteristic"> + + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ isSimpleCountingMode() || lengthStepCaracteristic != null ]]> + </param> + <message>tutti.validator.error.speciesFrequency.lengthStepCaracteristic.required</message> + </field-validator> + + </field> + + <field name="rows"> + + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ isSimpleCountingMode() || rows != null ]]> + </param> + <message>tutti.validator.error.speciesFrequency.oneRowRequired</message> + </field-validator> + + </field> +</validators> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml (from rev 665, trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml) =================================================================== --- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml (rev 0) +++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,55 @@ +<!-- + #%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% + --> +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="selectedCategory"> + <field-validator type="required" short-circuit="true"> + <message> + tutti.validator.error.splitSpeciesBatch.selectedCategory.required + </message> + </field-validator> + </field> + + <field name="sampleWeight"> + + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"><![CDATA[ sampleWeight == null || sampleWeight > 0 ]]></param> + <message> + tutti.validator.error.splitSpeciesBatch.sampleWeight.invalidValue + </message> + </field-validator> + + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ sampleWeight == null || batchWeight == null || sampleWeight <= batchWeight]]></param> + <message> + tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight + </message> + </field-validator> + + </field> +</validators> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml (from rev 665, trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml) =================================================================== --- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml (rev 0) +++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml 2013-03-23 18:20:58 UTC (rev 666) @@ -0,0 +1,69 @@ +<!-- + #%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% + --> +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="species"> + <field-validator type="required" short-circuit="true"> + <message>tutti.validator.error.createSpeciesBatch.species.required + </message> + </field-validator> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ sortedUnsortedCategory == null || speciesAndCategoryAvailable ]]> + </param> + <message> + tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable + </message> + </field-validator> + </field> + + <field name="sortedUnsortedCategory"> + <field-validator type="required" short-circuit="true"> + <message>tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required + </message> + </field-validator> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ species == null || speciesAndCategoryAvailable ]]> + </param> + <message> + tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable + </message> + </field-validator> + </field> + + <field name="batchWeight"> + + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"><![CDATA[ batchWeight == null || batchWeight > 0 ]]></param> + <message> + tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue + </message> + </field-validator> + + </field> +</validators> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml =================================================================== --- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml 2013-03-23 18:20:58 UTC (rev 666) @@ -1,69 +0,0 @@ -<!-- - #%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% - --> -<!DOCTYPE validators PUBLIC - "-//Apache Struts//XWork Validator 1.0.3//EN" - "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> -<validators> - - <field name="species"> - <field-validator type="required" short-circuit="true"> - <message>tutti.validator.error.createSpeciesBatch.species.required - </message> - </field-validator> - <field-validator type="fieldexpression" short-circuit="true"> - <param name="expression"> - <![CDATA[ sortedUnsortedCategory == null || speciesAndCategoryAvailable ]]> - </param> - <message> - tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable - </message> - </field-validator> - </field> - - <field name="sortedUnsortedCategory"> - <field-validator type="required" short-circuit="true"> - <message>tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required - </message> - </field-validator> - <field-validator type="fieldexpression" short-circuit="true"> - <param name="expression"> - <![CDATA[ species == null || speciesAndCategoryAvailable ]]> - </param> - <message> - tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable - </message> - </field-validator> - </field> - - <field name="batchWeight"> - - <field-validator type="fieldexpression" short-circuit="true"> - <param name="expression"><![CDATA[ batchWeight == null || batchWeight > 0 ]]></param> - <message> - tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue - </message> - </field-validator> - - </field> -</validators> \ No newline at end of file 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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-03-23 18:20:58 UTC (rev 666) @@ -94,16 +94,24 @@ tutti.config.option.weights.rate.difference.totalAndSorted.description= tutti.config.sampleOrder.title= tutti.config.title= -tutti.createMelag.action.cancel= -tutti.createMelag.action.cancel.mnemonic= -tutti.createMelag.action.cancel.tip= -tutti.createMelag.action.validate= -tutti.createMelag.action.validate.mnemonic= -tutti.createMelag.action.validate.tip= -tutti.createMelag.error.message= -tutti.createMelag.error.title= -tutti.createMelag.message= -tutti.createMelag.title= +tutti.createBenthosBatch.action.addSpecies= +tutti.createBenthosBatch.action.addSpecies.mnemonic= +tutti.createBenthosBatch.action.addSpecies.tip= +tutti.createBenthosBatch.action.cancel= +tutti.createBenthosBatch.action.cancel.mnemonic= +tutti.createBenthosBatch.action.cancel.tip= +tutti.createBenthosBatch.action.save= +tutti.createBenthosBatch.action.save.mnemonic= +tutti.createBenthosBatch.action.save.tip= +tutti.createBenthosBatch.field.batchWeight= +tutti.createBenthosBatch.field.batchWeight.tip= +tutti.createBenthosBatch.field.sortedUnsortedCategory= +tutti.createBenthosBatch.field.sortedUnsortedCategory.tip= +tutti.createBenthosBatch.field.species= +tutti.createBenthosBatch.field.species.tip= +tutti.createBenthosBatch.title= +tutti.createBenthosMelag.error.message= +tutti.createBenthosMelag.error.title= tutti.createSpeciesBatch.action.addSpecies= tutti.createSpeciesBatch.action.addSpecies.mnemonic= tutti.createSpeciesBatch.action.addSpecies.tip= @@ -120,6 +128,16 @@ tutti.createSpeciesBatch.field.species= tutti.createSpeciesBatch.field.species.tip= tutti.createSpeciesBatch.title= +tutti.createSpeciesMelag.action.cancel= +tutti.createSpeciesMelag.action.cancel.mnemonic= +tutti.createSpeciesMelag.action.cancel.tip= +tutti.createSpeciesMelag.action.validate= +tutti.createSpeciesMelag.action.validate.mnemonic= +tutti.createSpeciesMelag.action.validate.tip= +tutti.createSpeciesMelag.error.message= +tutti.createSpeciesMelag.error.title= +tutti.createSpeciesMelag.message= +tutti.createSpeciesMelag.title= tutti.dbMabager.title= tutti.dbManager.action.chooseDbExportFile= tutti.dbManager.action.chooseDbFile= @@ -154,18 +172,88 @@ tutti.editAccidentalBatch.table.header.speciesByCode= tutti.editAccidentalBatch.table.header.speciesByGenusCode= tutti.editAccidentalBatch.table.header.weight= +tutti.editBenthosBatch.action.createBatch= +tutti.editBenthosBatch.action.createBatch.mnemonic= +tutti.editBenthosBatch.action.createBatch.tip= +tutti.editBenthosBatch.action.removeBatch= +tutti.editBenthosBatch.action.removeBatch.mnemonic= +tutti.editBenthosBatch.action.removeBatch.tip= +tutti.editBenthosBatch.action.renameBatch= +tutti.editBenthosBatch.action.renameBatch.mnemonic= +tutti.editBenthosBatch.action.renameBatch.tip= +tutti.editBenthosBatch.action.splitBatch= +tutti.editBenthosBatch.action.splitBatch.mnemonic= +tutti.editBenthosBatch.action.splitBatch.tip= +tutti.editBenthosBatch.field.benthosTotalInertWeight= +tutti.editBenthosBatch.field.benthosTotalInertWeight.tip= +tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight= +tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight.tip= tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight= +tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight.tip= tutti.editBenthosBatch.field.benthosTotalSortedWeight= +tutti.editBenthosBatch.field.benthosTotalSortedWeight.tip= tutti.editBenthosBatch.field.benthosTotalUnsortedWeight= +tutti.editBenthosBatch.field.benthosTotalUnsortedWeight.tip= tutti.editBenthosBatch.field.benthosTotalWeight= +tutti.editBenthosBatch.field.benthosTotalWeight.tip= +tutti.editBenthosBatch.filterBatch= +tutti.editBenthosBatch.filterBatch.mode.all= +tutti.editBenthosBatch.filterBatch.mode.all.tip= +tutti.editBenthosBatch.filterBatch.mode.leaf= +tutti.editBenthosBatch.filterBatch.mode.leaf.tip= +tutti.editBenthosBatch.filterBatch.mode.root= +tutti.editBenthosBatch.filterBatch.mode.root.tip= +tutti.editBenthosBatch.filterBatch.tip= +tutti.editBenthosBatch.split.weightNotNull.help= +tutti.editBenthosBatch.split.weightNotNull.message= +tutti.editBenthosBatch.split.weightNotNull.title= +tutti.editBenthosBatch.table.header.ageCategory= tutti.editBenthosBatch.table.header.comment= +tutti.editBenthosBatch.table.header.computedNumber= tutti.editBenthosBatch.table.header.file= +tutti.editBenthosBatch.table.header.maturityCategory= tutti.editBenthosBatch.table.header.number= tutti.editBenthosBatch.table.header.sampleWeight= +tutti.editBenthosBatch.table.header.sexCategory= +tutti.editBenthosBatch.table.header.sizeCategory= +tutti.editBenthosBatch.table.header.sortedUnsortedCategory= +tutti.editBenthosBatch.table.header.species= tutti.editBenthosBatch.table.header.speciesByCode= tutti.editBenthosBatch.table.header.speciesByGenusCode= tutti.editBenthosBatch.table.header.toConfirm= tutti.editBenthosBatch.table.header.weight= +tutti.editBenthosFrequencies.action.cancel= +tutti.editBenthosFrequencies.action.cancel.mnemonic= +tutti.editBenthosFrequencies.action.cancel.tip= +tutti.editBenthosFrequencies.action.generate= +tutti.editBenthosFrequencies.action.generate.mnemonic= +tutti.editBenthosFrequencies.action.generate.tip= +tutti.editBenthosFrequencies.action.save= +tutti.editBenthosFrequencies.action.save.mnemonic= +tutti.editBenthosFrequencies.action.save.tip= +tutti.editBenthosFrequencies.field.lengthStepCaracteristic= +tutti.editBenthosFrequencies.field.lengthStepCaracteristic.tip= +tutti.editBenthosFrequencies.field.maxStep= +tutti.editBenthosFrequencies.field.maxStep.tip= +tutti.editBenthosFrequencies.field.minStep= +tutti.editBenthosFrequencies.field.minStep.tip= +tutti.editBenthosFrequencies.field.mode.autoGen= +tutti.editBenthosFrequencies.field.mode.autoGen.tip= +tutti.editBenthosFrequencies.field.mode.rafale= +tutti.editBenthosFrequencies.field.mode.rafale.tip= +tutti.editBenthosFrequencies.field.mode.simple= +tutti.editBenthosFrequencies.field.mode.simple.tip= +tutti.editBenthosFrequencies.field.mode.simpleCounting= +tutti.editBenthosFrequencies.field.mode.simpleCounting.tip= +tutti.editBenthosFrequencies.field.rafaleStep= +tutti.editBenthosFrequencies.field.rafaleStep.tip= +tutti.editBenthosFrequencies.field.simpleCounting= +tutti.editBenthosFrequencies.field.simpleCounting.tip= +tutti.editBenthosFrequencies.field.step= +tutti.editBenthosFrequencies.field.step.tip= +tutti.editBenthosFrequencies.label.no.configuration= +tutti.editBenthosFrequencies.simpleCountingAndFrequencies= +tutti.editBenthosFrequencies.title= tutti.editCatchBatch.action.cancelEditCatchBatch= tutti.editCatchBatch.action.cancelEditCatchBatch.mnemonic= tutti.editCatchBatch.action.cancelEditCatchBatch.tip= @@ -470,24 +558,24 @@ tutti.editProtocol.title.edit.protocol= tutti.editProtocol.warn.clone= tutti.editProtocol.warn.import= -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= -tutti.editSpeciesBatch.action.removeSpeciesSubBatch= -tutti.editSpeciesBatch.action.removeSpeciesSubBatch.mnemonic= -tutti.editSpeciesBatch.action.removeSpeciesSubBatch.tip= -tutti.editSpeciesBatch.action.renameSpeciesBatch= -tutti.editSpeciesBatch.action.renameSpeciesBatch.mnemonic= -tutti.editSpeciesBatch.action.renameSpeciesBatch.tip= -tutti.editSpeciesBatch.action.splitSpeciesBatch= -tutti.editSpeciesBatch.action.splitSpeciesBatch.mnemonic= -tutti.editSpeciesBatch.action.splitSpeciesBatch.tip= +tutti.editSpeciesBatch.action.createBatch= +tutti.editSpeciesBatch.action.createBatch.mnemonic= +tutti.editSpeciesBatch.action.createBatch.tip= +tutti.editSpeciesBatch.action.createMelag= +tutti.editSpeciesBatch.action.createMelag.mnemonic= +tutti.editSpeciesBatch.action.createMelag.tip= +tutti.editSpeciesBatch.action.removeBatch= +tutti.editSpeciesBatch.action.removeBatch.mnemonic= +tutti.editSpeciesBatch.action.removeBatch.tip= +tutti.editSpeciesBatch.action.removeSubBatch= +tutti.editSpeciesBatch.action.removeSubBatch.mnemonic= +tutti.editSpeciesBatch.action.removeSubBatch.tip= +tutti.editSpeciesBatch.action.renameBatch= +tutti.editSpeciesBatch.action.renameBatch.mnemonic= +tutti.editSpeciesBatch.action.renameBatch.tip= +tutti.editSpeciesBatch.action.splitBatch= +tutti.editSpeciesBatch.action.splitBatch.mnemonic= +tutti.editSpeciesBatch.action.splitBatch.tip= tutti.editSpeciesBatch.field.speciesTotalInertWeight= tutti.editSpeciesBatch.field.speciesTotalInertWeight.tip= tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight= @@ -500,14 +588,14 @@ tutti.editSpeciesBatch.field.speciesTotalUnsortedWeight.tip= tutti.editSpeciesBatch.field.speciesTotalWeight= tutti.editSpeciesBatch.field.speciesTotalWeight.tip= -tutti.editSpeciesBatch.filterSpeciesBatch.mode.all.tip= -tutti.editSpeciesBatch.filterSpeciesBatch.mode.leaf.tip= -tutti.editSpeciesBatch.filterSpeciesBatch.mode.root.tip= +tutti.editSpeciesBatch.filterBatch= +tutti.editSpeciesBatch.filterBatch.mode.all= +tutti.editSpeciesBatch.filterBatch.mode.all.tip= +tutti.editSpeciesBatch.filterBatch.mode.leaf= +tutti.editSpeciesBatch.filterBatch.mode.leaf.tip= +tutti.editSpeciesBatch.filterBatch.mode.root= +tutti.editSpeciesBatch.filterBatch.mode.root.tip= tutti.editSpeciesBatch.filterSpeciesBatch.tip= -tutti.editSpeciesBatch.filterSpeciesBatchMode= -tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.all= -tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.leaf= -tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.root= tutti.editSpeciesBatch.split.weightNotNull.help= tutti.editSpeciesBatch.split.weightNotNull.message= tutti.editSpeciesBatch.split.weightNotNull.title= @@ -615,6 +703,7 @@ tutti.label.tab.plancton= tutti.label.tab.species= tutti.legend.frequencyConfiguration= +tutti.legend.splitBenthosBatchConfiguration= tutti.legend.splitSpeciesBatchConfiguration= tutti.main.action..mnemonic= tutti.main.action.about= @@ -797,6 +886,24 @@ tutti.selectSpecies.action.validate.mnemonic= tutti.selectSpecies.action.validate.tip= tutti.selectSpecies.title= +tutti.splitBenthosBatch.action.cancel= +tutti.splitBenthosBatch.action.cancel.mnemonic= +tutti.splitBenthosBatch.action.cancel.tip= +tutti.splitBenthosBatch.action.save= +tutti.splitBenthosBatch.action.save.mnemonic= +tutti.splitBenthosBatch.action.save.tip= +tutti.splitBenthosBatch.field.batchWeight= +tutti.splitBenthosBatch.field.batchWeightField.tip= +tutti.splitBenthosBatch.field.category= +tutti.splitBenthosBatch.field.categoryField.tip= +tutti.splitBenthosBatch.field.sampleWeight= +tutti.splitBenthosBatch.field.sampleWeightField.tip= +tutti.splitBenthosBatch.field.species= +tutti.splitBenthosBatch.field.speciesField.tip= +tutti.splitBenthosBatch.table.header.category= +tutti.splitBenthosBatch.table.header.selected= +tutti.splitBenthosBatch.table.header.weight= +tutti.splitBenthosBatch.title= tutti.splitSpeciesBatch.action.cancel= tutti.splitSpeciesBatch.action.cancel.mnemonic= tutti.splitSpeciesBatch.action.cancel.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-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-23 18:20:58 UTC (rev 666) @@ -91,16 +91,32 @@ tutti.config.option.weights.rate.difference.totalAndSorted.description=Pourcentage de différence entre les Poids totaux VRAC triés et les poids totaux VRAC en dessous duquel on demande confirmation sur la saisie. tutti.config.sampleOrder.title=Catégorie d'échantillonnage tutti.config.title=Configuration -tutti.createMelag.action.cancel=Annuler -tutti.createMelag.action.cancel.mnemonic=A -tutti.createMelag.action.cancel.tip=Annuler la création du MELAG -tutti.createMelag.action.validate=Valider -tutti.createMelag.action.validate.mnemonic=V -tutti.createMelag.action.validate.tip=Valider la création du MELAG -tutti.createMelag.error.message=Erreur à la ligne %s -tutti.createMelag.error.title=Erreur -tutti.createMelag.message=Combien pesait le MELAG (kg) ? -tutti.createMelag.title=Poids du MELAG (kg) +tutti.createBenthosBatch.action.addSpecies=... +tutti.createBenthosBatch.action.addSpecies.mnemonic=. +tutti.createBenthosBatch.action.addSpecies.tip=Sélectionner une autre espèce +tutti.createBenthosBatch.action.cancel=Annuler +tutti.createBenthosBatch.action.cancel.mnemonic=A +tutti.createBenthosBatch.action.cancel.tip=Annuler la création du lôt espèce +tutti.createBenthosBatch.action.save=Enregistrer +tutti.createBenthosBatch.action.save.mnemonic=E +tutti.createBenthosBatch.action.save.tip=Enregister la création du lôt espèce +tutti.createBenthosBatch.field.batchWeight=Poids du lot (kg) +tutti.createBenthosBatch.field.batchWeight.tip= +tutti.createBenthosBatch.field.sortedUnsortedCategory=V / HV +tutti.createBenthosBatch.field.sortedUnsortedCategory.tip= +tutti.createBenthosBatch.field.species=Espèce du lot +tutti.createBenthosBatch.field.species.tip= +tutti.createBenthosBatch.title=Créer un lot +tutti.createBenthosMelag.action.cancel=Annuler +tutti.createBenthosMelag.action.cancel.mnemonic=A +tutti.createBenthosMelag.action.cancel.tip=Annuler la création du MELAG +tutti.createBenthosMelag.action.validate=Valider +tutti.createBenthosMelag.action.validate.mnemonic=V +tutti.createBenthosMelag.action.validate.tip=Valider la création du MELAG +tutti.createBenthosMelag.error.message=Erreur à la ligne %s +tutti.createBenthosMelag.error.title=Erreur +tutti.createBenthosMelag.message=Combien pesait le MELAG (kg) ? +tutti.createBenthosMelag.title=Poids du MELAG (kg) tutti.createSpeciesBatch.action.addSpecies=... tutti.createSpeciesBatch.action.addSpecies.mnemonic=. tutti.createSpeciesBatch.action.addSpecies.tip=Sélectionner une autre espèce @@ -117,6 +133,16 @@ tutti.createSpeciesBatch.field.species=Espèce du lot tutti.createSpeciesBatch.field.species.tip= tutti.createSpeciesBatch.title=Créer un lot +tutti.createSpeciesMelag.action.cancel=Annuler +tutti.createSpeciesMelag.action.cancel.mnemonic=A +tutti.createSpeciesMelag.action.cancel.tip=Annuler la création du MELAG +tutti.createSpeciesMelag.action.validate=Valider +tutti.createSpeciesMelag.action.validate.mnemonic=V +tutti.createSpeciesMelag.action.validate.tip=Valider la création du MELAG +tutti.createSpeciesMelag.error.message=Erreur à la ligne %s +tutti.createSpeciesMelag.error.title=Erreur +tutti.createSpeciesMelag.message=Combien pesait le MELAG (kg) ? +tutti.createSpeciesMelag.title=Poids du MELAG (kg) tutti.dbMabager.title=Gérer les bases de données tutti.dbManager.action.chooseDbExportFile=Exporter la base de données tutti.dbManager.action.chooseDbFile=Choisir la base à importer @@ -151,18 +177,94 @@ tutti.editAccidentalBatch.table.header.speciesByCode=Espèce tutti.editAccidentalBatch.table.header.speciesByGenusCode=Espèce tutti.editAccidentalBatch.table.header.weight=Poids observé +tutti.editBenthosBatch.action.createBatch=Créer un lot pour une espèce +tutti.editBenthosBatch.action.createBatch.mnemonic=C +tutti.editBenthosBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce +tutti.editBenthosBatch.action.createMelag=Espèces d'un MELAG +tutti.editBenthosBatch.action.createMelag.mnemonic=C +tutti.editBenthosBatch.action.createMelag.tip=Calcul des poids des lots appartenant à un MELAG +tutti.editBenthosBatch.action.removeBatch=Supprimer le lot +tutti.editBenthosBatch.action.removeBatch.mnemonic=S +tutti.editBenthosBatch.action.removeBatch.tip=Supprimer le lot courant (celui de la ligne sélectionnée) et tous ces fils +tutti.editBenthosBatch.action.removeSubBatch=Supprimer les lots fils +tutti.editBenthosBatch.action.removeSubBatch.mnemonic=f +tutti.editBenthosBatch.action.removeSubBatch.tip=Supprimer tous les lots fils du lot sélectionné +tutti.editBenthosBatch.action.renameBatch=Corriger l'espèce +tutti.editBenthosBatch.action.renameBatch.mnemonic=o +tutti.editBenthosBatch.action.renameBatch.tip=Corriger l'espèce +tutti.editBenthosBatch.action.splitBatch=Catégoriser le lot +tutti.editBenthosBatch.action.splitBatch.mnemonic=C +tutti.editBenthosBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné) +tutti.editBenthosBatch.field.benthosTotalInertWeight=Poids inerte trié (kg) +tutti.editBenthosBatch.field.benthosTotalInertWeight.tip= +tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight=Poids vivant non détaillé trié (kg) +tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight.tip= tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight=Poids VRAC trié (kg) +tutti.editBenthosBatch.field.benthosTotalSampleSortedWeight.tip= tutti.editBenthosBatch.field.benthosTotalSortedWeight=Poids total VRAC (kg) +tutti.editBenthosBatch.field.benthosTotalSortedWeight.tip= tutti.editBenthosBatch.field.benthosTotalUnsortedWeight=Poids total HORS VRAC (kg) +tutti.editBenthosBatch.field.benthosTotalUnsortedWeight.tip= tutti.editBenthosBatch.field.benthosTotalWeight=Poids TOTAL (kg) +tutti.editBenthosBatch.field.benthosTotalWeight.tip= +tutti.editBenthosBatch.filterBatch=Filtre +tutti.editBenthosBatch.filterBatch.mode.all=Aucun +tutti.editBenthosBatch.filterBatch.mode.all.tip=Pas de filtre (tous les lots sont visibles) +tutti.editBenthosBatch.filterBatch.mode.leaf=Feuilles +tutti.editBenthosBatch.filterBatch.mode.leaf.tip=Voir uniquement les lots *feuilles* +tutti.editBenthosBatch.filterBatch.mode.root=Parents (%s) +tutti.editBenthosBatch.filterBatch.mode.root.tip=Voir uniquement les lots *parents* +tutti.editBenthosBatch.filterBatch.tip=Pour filtrer les lots +tutti.editBenthosBatch.split.weightNotNull.help=Que voulez-vous faire ? <ul><li><strong>Annuler</strong> pour ne pas catégoriser le lot et garder le poids sous-échantilloné</li><li><strong>OK</strong> pour catégoriser le lot et supprimer le poids sous-échantillonné</li></ul>. +tutti.editBenthosBatch.split.weightNotNull.message=Pour catégoriser un lot, il ne doit pas avoir de poids sous-échantillonné. +tutti.editBenthosBatch.split.weightNotNull.title=Poids sous-échantillonné non nul +tutti.editBenthosBatch.table.header.ageCategory=Age tutti.editBenthosBatch.table.header.comment=Commentaire +tutti.editBenthosBatch.table.header.computedNumber=Nombre tutti.editBenthosBatch.table.header.file=Pièces jointes -tutti.editBenthosBatch.table.header.number=Nombre -tutti.editBenthosBatch.table.header.sampleWeight=Poids échantillonné -tutti.editBenthosBatch.table.header.speciesByCode=Espèce -tutti.editBenthosBatch.table.header.speciesByGenusCode=Espèce +tutti.editBenthosBatch.table.header.maturityCategory=Maturité +tutti.editBenthosBatch.table.header.sexCategory=Sexe +tutti.editBenthosBatch.table.header.sizeCategory=Class. Tri +tutti.editBenthosBatch.table.header.sortedUnsortedCategory=V/HV (kg) +tutti.editBenthosBatch.table.header.species=Espèce tutti.editBenthosBatch.table.header.toConfirm=A Confirmer -tutti.editBenthosBatch.table.header.weight=Poids +tutti.editBenthosBatch.table.header.weight=Poids sous-échantillonné (kg) +tutti.editBenthosBatch.title.batchActions=Actions +tutti.editBenthosFrequencies.action.cancel=Annuler +tutti.editBenthosFrequencies.action.cancel.mnemonic=A +tutti.editBenthosFrequencies.action.cancel.tip=Anuler l'édition des mensurations +tutti.editBenthosFrequencies.action.generate=Générer +tutti.editBenthosFrequencies.action.generate.mnemonic=G +tutti.editBenthosFrequencies.action.generate.tip=Générer les mensurations +tutti.editBenthosFrequencies.action.save=Enregistrer +tutti.editBenthosFrequencies.action.save.mnemonic=E +tutti.editBenthosFrequencies.action.save.tip=Enreigstrer les mensurations +tutti.editBenthosFrequencies.field.lengthStepCaracteristic=Type de mesure +tutti.editBenthosFrequencies.field.lengthStepCaracteristic.tip= +tutti.editBenthosFrequencies.field.maxStep=Classe max +tutti.editBenthosFrequencies.field.maxStep.tip= +tutti.editBenthosFrequencies.field.minStep=Classe min +tutti.editBenthosFrequencies.field.minStep.tip= +tutti.editBenthosFrequencies.field.mode.autoGen=Génération des classes +tutti.editBenthosFrequencies.field.mode.autoGen.tip=Mode où toutes les classes de taille sont générées +tutti.editBenthosFrequencies.field.mode.rafale=Mode "rafale" +tutti.editBenthosFrequencies.field.mode.rafale.tip=Mode où on ne saisit uniquement la classe de taille (les nombres seront alors incrémentés...) +tutti.editBenthosFrequencies.field.mode.simple=Mode simple +tutti.editBenthosFrequencies.field.mode.simple.tip=Mode par défaut on on doit tout saisir (les classes de tailles et les nombres) +tutti.editBenthosFrequencies.field.mode.simpleCounting=Mode simple dénombrement +tutti.editBenthosFrequencies.field.mode.simpleCounting.tip=Mode par défaut si la classe de taille n'est pas renseignée dans le protocole. +tutti.editBenthosFrequencies.field.rafaleStep=Classe de taille à incrémenter +tutti.editBenthosFrequencies.field.rafaleStep.tip= +tutti.editBenthosFrequencies.field.simpleCounting=Nombre +tutti.editBenthosFrequencies.field.simpleCounting.tip= +tutti.editBenthosFrequencies.field.step=Pas de la classe de taille +tutti.editBenthosFrequencies.field.step.tip= +tutti.editBenthosFrequencies.label.no.configuration=< Pas de configuration > +tutti.editBenthosFrequencies.simpleCountingAndFrequencies=Des mensurations ont été saisies dans le tableau. Saisir un simple dénombrement les effacera. +tutti.editBenthosFrequencies.table.header.lengthStep=Classe de taille +tutti.editBenthosFrequencies.table.header.number=Nombre +tutti.editBenthosFrequencies.table.header.weight=Poids observé (kg) +tutti.editBenthosFrequencies.title=Mensuration tutti.editCatchBatch.action.cancelEditCatchBatch=Réinitialiser tutti.editCatchBatch.action.cancelEditCatchBatch.mnemonic=R tutti.editCatchBatch.action.cancelEditCatchBatch.tip=Réinitialiser l'édition de la capture @@ -468,24 +570,24 @@ 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.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 -tutti.editSpeciesBatch.action.removeSpeciesSubBatch=Supprimer les lots fils -tutti.editSpeciesBatch.action.removeSpeciesSubBatch.mnemonic=f -tutti.editSpeciesBatch.action.removeSpeciesSubBatch.tip=Supprimer tous les lots fils du lot sélectionné -tutti.editSpeciesBatch.action.renameSpeciesBatch=Corriger l'espèce -tutti.editSpeciesBatch.action.renameSpeciesBatch.mnemonic=o -tutti.editSpeciesBatch.action.renameSpeciesBatch.tip=Corriger l'espèce -tutti.editSpeciesBatch.action.splitSpeciesBatch=Catégoriser le lot -tutti.editSpeciesBatch.action.splitSpeciesBatch.mnemonic=C -tutti.editSpeciesBatch.action.splitSpeciesBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné) +tutti.editSpeciesBatch.action.createBatch=Créer un lot pour une espèce +tutti.editSpeciesBatch.action.createBatch.mnemonic=C +tutti.editSpeciesBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce +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.removeBatch=Supprimer le lot +tutti.editSpeciesBatch.action.removeBatch.mnemonic=S +tutti.editSpeciesBatch.action.removeBatch.tip=Supprimer le lot courant (celui de la ligne sélectionnée) et tous ces fils +tutti.editSpeciesBatch.action.removeSubBatch=Supprimer les lots fils +tutti.editSpeciesBatch.action.removeSubBatch.mnemonic=f +tutti.editSpeciesBatch.action.removeSubBatch.tip=Supprimer tous les lots fils du lot sélectionné +tutti.editSpeciesBatch.action.renameBatch=Corriger l'espèce +tutti.editSpeciesBatch.action.renameBatch.mnemonic=o +tutti.editSpeciesBatch.action.renameBatch.tip=Corriger l'espèce +tutti.editSpeciesBatch.action.splitBatch=Catégoriser le lot +tutti.editSpeciesBatch.action.splitBatch.mnemonic=C +tutti.editSpeciesBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné) tutti.editSpeciesBatch.field.speciesTotalInertWeight=Poids inerte trié (kg) tutti.editSpeciesBatch.field.speciesTotalInertWeight.tip= tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight=Poids vivant non détaillé trié (kg) @@ -498,14 +600,14 @@ tutti.editSpeciesBatch.field.speciesTotalUnsortedWeight.tip= tutti.editSpeciesBatch.field.speciesTotalWeight=Poids TOTAL (kg) tutti.editSpeciesBatch.field.speciesTotalWeight.tip= -tutti.editSpeciesBatch.filterSpeciesBatch.mode.all.tip=Pas de filtre (tous les lots sont visibles) -tutti.editSpeciesBatch.filterSpeciesBatch.mode.leaf.tip=Voir uniquement les lots *feuilles* -tutti.editSpeciesBatch.filterSpeciesBatch.mode.root.tip=Voir uniquement les lots *parents* +tutti.editSpeciesBatch.filterBatch=Filtre +tutti.editSpeciesBatch.filterBatch.mode.all=Aucun +tutti.editSpeciesBatch.filterBatch.mode.all.tip=Pas de filtre (tous les lots sont visibles) +tutti.editSpeciesBatch.filterBatch.mode.leaf=Feuilles +tutti.editSpeciesBatch.filterBatch.mode.leaf.tip=Voir uniquement les lots *feuilles* +tutti.editSpeciesBatch.filterBatch.mode.root=Parents (%s) +tutti.editSpeciesBatch.filterBatch.mode.root.tip=Voir uniquement les lots *parents* tutti.editSpeciesBatch.filterSpeciesBatch.tip=Pour filtrer les lots -tutti.editSpeciesBatch.filterSpeciesBatchMode=Filtre -tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.all=Aucun -tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.leaf=Feuilles -tutti.editSpeciesBatch.filterSpeciesBatchMode.mode.root=Parents (%s) tutti.editSpeciesBatch.split.weightNotNull.help=Que voulez-vous faire ? <ul><li><strong>Annuler</strong> pour ne pas catégoriser le lot et garder le poids sous-échantilloné</li><li><strong>OK</strong> pour catégoriser le lot et supprimer le poids sous-échantillonné</li></ul>. tutti.editSpeciesBatch.split.weightNotNull.message=Pour catégoriser un lot, il ne doit pas avoir de poids sous-échantillonné. tutti.editSpeciesBatch.split.weightNotNull.title=Poids sous-échantillonné non nul @@ -614,6 +716,7 @@ tutti.label.tab.plancton=Plancton tutti.label.tab.species=Espèces tutti.legend.frequencyConfiguration=Configuration +tutti.legend.splitBenthosBatchConfiguration= tutti.legend.splitSpeciesBatchConfiguration=Configuration tutti.main.action.about=À propos tutti.main.action.about.mnemonic=À @@ -795,6 +898,24 @@ tutti.selectSpecies.action.validate.mnemonic=V tutti.selectSpecies.action.validate.tip=Valider la sélection de l'espèce tutti.selectSpecies.title=Choisissez une espèce +tutti.splitBenthosBatch.action.cancel=Annuler +tutti.splitBenthosBatch.action.cancel.mnemonic=A +tutti.splitBenthosBatch.action.cancel.tip=Annuler le sous-échantillonnage +tutti.splitBenthosBatch.action.save=Enregistrer +tutti.splitBenthosBatch.action.save.mnemonic=E +tutti.splitBenthosBatch.action.save.tip=Sauver le sous-échantillonage +tutti.splitBenthosBatch.field.batchWeight=Poids total à catégoriser +tutti.splitBenthosBatch.field.batchWeightField.tip= +tutti.splitBenthosBatch.field.category=Catégorie +tutti.splitBenthosBatch.field.categoryField.tip= +tutti.splitBenthosBatch.field.sampleWeight=Poids total catégorisé +tutti.splitBenthosBatch.field.sampleWeightField.tip= +tutti.splitBenthosBatch.field.species=Espèce +tutti.splitBenthosBatch.field.speciesField.tip= +tutti.splitBenthosBatch.table.header.category=Catégorie +tutti.splitBenthosBatch.table.header.selected=Sélection +tutti.splitBenthosBatch.table.header.weight=Poids (kg) +tutti.splitBenthosBatch.title=Catégorisation du lot tutti.splitSpeciesBatch.action.cancel=Annuler tutti.splitSpeciesBatch.action.cancel.mnemonic=A tutti.splitSpeciesBatch.action.cancel.tip=Annuler le sous-échantillonnage Modified: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/BeanValidatorDetectorTest.java =================================================================== --- trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/BeanValidatorDetectorTest.java 2013-03-22 18:08:00 UTC (rev 665) +++ trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/BeanValidatorDetectorTest.java 2013-03-23 18:20:58 UTC (rev 666) @@ -27,9 +27,12 @@ import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIModel; import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel; import fr.ifremer.tutti.ui.swing.content.program.EditProgramUIModel; import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel; @@ -71,12 +74,12 @@ EditProgramUIModel.class, EditProtocolUIModel.class, EditFishingOperationUIModel.class, - EditCatchesUIModel.class, - SpeciesBatchUIModel.class, + CreateBenthosBatchUIModel.class, CreateSpeciesBatchUIModel.class, + SplitBenthosBatchUIModel.class, SplitSpeciesBatchUIModel.class, - SpeciesFrequencyUIModel.class - + BenthosFrequencyUIModel.class, + SpeciesFrequencyUIModel.class, }; } @@ -91,7 +94,7 @@ SortedSet<NuitonValidator<?>> validators = detectValidators(ALL_TYPES); assertFalse(validators.isEmpty()); - assertEquals(8, validators.size()); + assertEquals(11, validators.size()); } @Test @@ -102,11 +105,14 @@ validators = detectValidators(Pattern.compile(contextName), ALL_TYPES); assertValidatorSetWithSameContextName(validators, null, + BenthosFrequencyUIModel.class, + CreateBenthosBatchUIModel.class, CreateSpeciesBatchUIModel.class, EditCruiseUIModel.class, EditProgramUIModel.class, EditProtocolUIModel.class, SpeciesFrequencyUIModel.class, + SplitBenthosBatchUIModel.class, SplitSpeciesBatchUIModel.class ); }
participants (1)
-
tchemit@users.forge.codelutin.com