branch feature/refactor_reference updated (7235469 -> 0ffc6cb)
This is an automated email from the git hooks/post-receive script. New change to branch feature/refactor_reference in repository observe. See http://git.codelutin.com/observe.git from 7235469 Impact dans les handlers dues aux renommages de l'API des services + début d'utilisation des bons objets là où il faut : si j'ai un ReferentialReference et bien je veux m'en servir; toujours être le plus précis possible) new 26c02d7 Dans une référence, on n'expose pas d'autres références, on récupère juste l'id (si possible) new 0ffc6cb - Suppression des méthodes getDecorator du context applicatif (ce n'est pas le role du context de décorer ou fournir des décorateurs mais celui du DecoratorService) - Arrêter d'exposer comment on récupère un décorateur de référence, on le code une fois pour toute dans DecoratorService et on s'en sert partout ailleurs (ce n'est certainement pas à un handler d'ui à savoir comment récupérer un décorateur...) - Revue un peu des actions pour déplacer les noeuds (manque de [...] The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 0ffc6cb156f4c129f47a013641f95d3fc5e64466 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Nov 21 12:59:34 2015 +0100 - Suppression des méthodes getDecorator du context applicatif (ce n'est pas le role du context de décorer ou fournir des décorateurs mais celui du DecoratorService) - Arrêter d'exposer comment on récupère un décorateur de référence, on le code une fois pour toute dans DecoratorService et on s'en sert partout ailleurs (ce n'est certainement pas à un handler d'ui à savoir comment récupérer un décorateur...) - Revue un peu des actions pour déplacer les noeuds (manque de précision, c'est facile de faire des casts sauvages, mais après on ne sait pas sur quoi on bosse, essayer toujours d'être le plus précis possible) - Les premiers écrans avec tableaux sur la seine refonctionne \o/ (il faut absoluement supprimer les references de references lorsqu'on remonte des dto, remonter juste l'id suffit, ensuite l'ui connait les référeniels et donc sait retrouver la référence complète si besoin...) Je me demande même si on ne devrait pas juste remonter que des ids pour toutes les références et on reconstruit côté applicatif... commit 26c02d75104857d6a517f90977c7bb1142e5bcea Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Nov 21 11:56:52 2015 +0100 Dans une référence, on n'expose pas d'autres références, on récupère juste l'id (si possible) Summary of changes: .../observe/ObserveSwingApplicationContext.java | 32 +---- .../java/fr/ird/observe/ui/DecoratorService.java | 47 ++++--- .../src/main/java/fr/ird/observe/ui/UIHelper.java | 19 ++- .../ird/observe/ui/actions/ShowConfigAction.java | 2 +- .../shared/MoveActivityLonglinesUIAction.java | 27 ++-- .../actions/shared/MoveActivitySeinesUIAction.java | 18 +-- .../ui/actions/shared/MoveRoutesUIAction.java | 13 +- .../ui/actions/shared/MoveTripsUIAction.java | 45 ++---- .../observe/ui/admin/export/ExportUIHandler.java | 5 +- .../ui/admin/gps/GPSActivityTableModel.java | 2 +- .../ird/observe/ui/content/ContentUIHandler.java | 13 +- .../observe/ui/content/ContentUIInitializer.java | 25 ++-- .../fr/ird/observe/ui/content/ContentUIModel.java | 22 +++ .../ui/content/impl/seine/SetSeineUIHandler.java | 6 +- .../ui/content/table/ContentTableModel.java | 4 + .../ui/content/table/ContentTableUIHandler.java | 62 +++++++- .../impl/longline/BaitsCompositionUIHandler.java | 6 +- .../longline/BranchlinesCompositionUIHandler.java | 5 +- .../impl/longline/CatchLonglineUIHandler.java | 23 +-- .../table/impl/longline/EncounterUIHandler.java | 5 +- .../longline/FloatlinesCompositionUIHandler.java | 4 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 4 +- .../impl/longline/HooksCompositionUIHandler.java | 5 +- .../impl/longline/LonglinePositionHelper.java | 4 +- .../table/impl/longline/SensorUsedUIHandler.java | 7 +- .../content/table/impl/longline/TdrUIHandler.java | 23 +-- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 4 +- .../table/impl/seine/NonTargetCatchUIHandler.java | 7 +- .../table/impl/seine/NonTargetSampleUIHandler.java | 7 +- .../impl/seine/ObjectObservedSpeciesUIHandler.java | 5 +- .../impl/seine/ObjectSchoolEstimateUIHandler.java | 3 +- .../table/impl/seine/SchoolEstimateUIHandler.java | 3 +- .../table/impl/seine/TargetCatchUIHandler.java | 69 ++++----- .../impl/seine/TargetDiscardCatchUIHandler.java | 156 +++++++++------------ .../table/impl/seine/TargetSampleUIHandler.java | 5 +- .../fr/ird/observe/ui/tree/ObserveTreeHelper.java | 2 +- .../MoveActivityLonglineNodeMenuPopulator.java | 18 ++- .../menu/MoveActivitySeineNodeMenuPopulator.java | 18 ++- .../ui/tree/menu/MoveRouteNodeMenuPopulator.java | 18 ++- .../ui/tree/menu/MoveTripNodeMenuPopulator.java | 44 +++--- .../fr/ird/observe/ui/usage/UsagesUIHandler.java | 2 +- .../ird/observe/ui/util/DecoratedNodeEntity.java | 18 +-- ...tchDecorator.java => TargetCatchDecorator.java} | 12 +- .../dto/ActivitySimpleSpeedDtoValidator.java | 6 +- .../validator/dto/ActivitySpeedDtoValidator.java | 4 +- .../dto/SetLonglineUniqueHomeIdDtoValidator.java | 2 +- .../dto/SetLonglineUniqueNumberDtoValidator.java | 2 +- .../dto/reference/ObserveReferenceSetBuilder.java | 7 +- 48 files changed, 439 insertions(+), 401 deletions(-) copy observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/{NonTargetCatchDecorator.java => TargetCatchDecorator.java} (81%) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/refactor_reference in repository observe. See http://git.codelutin.com/observe.git commit 26c02d75104857d6a517f90977c7bb1142e5bcea Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Nov 21 11:56:52 2015 +0100 Dans une référence, on n'expose pas d'autres références, on récupère juste l'id (si possible) --- .../observe/services/dto/reference/ObserveReferenceSetBuilder.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/reference/ObserveReferenceSetBuilder.java b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/reference/ObserveReferenceSetBuilder.java index d5d3b12..3c5803e 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/dto/reference/ObserveReferenceSetBuilder.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/dto/reference/ObserveReferenceSetBuilder.java @@ -3,7 +3,6 @@ package fr.ird.observe.services.dto.reference; import com.google.common.base.Defaults; import com.google.common.base.Function; import com.google.common.base.Preconditions; -import fr.ird.observe.entities.referentiel.ReferenceEntities; import fr.ird.observe.entities.referentiel.ReferenceEntity; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ObserveDtosInitializer; @@ -235,9 +234,11 @@ public class ObserveReferenceSetBuilder<D extends IdDto, R extends ObserveRefere Serializable result; if (String.class.equals(propertyType)) { - // Conversion + // On en récupère que son identifiant + //FIXME Voir si cela suffit - result = ReferenceEntities.toString(referentialLocaleOrdinal, referentialEntity); + result = referentialEntity.getTopiaId(); +// result = ReferenceEntities.toString(referentialLocaleOrdinal, referentialEntity); } else { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/refactor_reference in repository observe. See http://git.codelutin.com/observe.git commit 0ffc6cb156f4c129f47a013641f95d3fc5e64466 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Nov 21 12:59:34 2015 +0100 - Suppression des méthodes getDecorator du context applicatif (ce n'est pas le role du context de décorer ou fournir des décorateurs mais celui du DecoratorService) - Arrêter d'exposer comment on récupère un décorateur de référence, on le code une fois pour toute dans DecoratorService et on s'en sert partout ailleurs (ce n'est certainement pas à un handler d'ui à savoir comment récupérer un décorateur...) - Revue un peu des actions pour déplacer les noeuds (manque de précision, c'est facile de faire des casts sauvages, mais après on ne sait pas sur quoi on bosse, essayer toujours d'être le plus précis possible) - Les premiers écrans avec tableaux sur la seine refonctionne \o/ (il faut absoluement supprimer les references de references lorsqu'on remonte des dto, remonter juste l'id suffit, ensuite l'ui connait les référeniels et donc sait retrouver la référence complète si besoin...) Je me demande même si on ne devrait pas juste remonter que des ids pour toutes les références et on reconstruit côté applicatif... --- .../observe/ObserveSwingApplicationContext.java | 32 +---- .../java/fr/ird/observe/ui/DecoratorService.java | 47 ++++--- .../src/main/java/fr/ird/observe/ui/UIHelper.java | 19 ++- .../ird/observe/ui/actions/ShowConfigAction.java | 2 +- .../shared/MoveActivityLonglinesUIAction.java | 27 ++-- .../actions/shared/MoveActivitySeinesUIAction.java | 18 +-- .../ui/actions/shared/MoveRoutesUIAction.java | 13 +- .../ui/actions/shared/MoveTripsUIAction.java | 45 ++---- .../observe/ui/admin/export/ExportUIHandler.java | 5 +- .../ui/admin/gps/GPSActivityTableModel.java | 2 +- .../ird/observe/ui/content/ContentUIHandler.java | 13 +- .../observe/ui/content/ContentUIInitializer.java | 25 ++-- .../fr/ird/observe/ui/content/ContentUIModel.java | 22 +++ .../ui/content/impl/seine/SetSeineUIHandler.java | 6 +- .../ui/content/table/ContentTableModel.java | 4 + .../ui/content/table/ContentTableUIHandler.java | 62 +++++++- .../impl/longline/BaitsCompositionUIHandler.java | 6 +- .../longline/BranchlinesCompositionUIHandler.java | 5 +- .../impl/longline/CatchLonglineUIHandler.java | 23 +-- .../table/impl/longline/EncounterUIHandler.java | 5 +- .../longline/FloatlinesCompositionUIHandler.java | 4 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 4 +- .../impl/longline/HooksCompositionUIHandler.java | 5 +- .../impl/longline/LonglinePositionHelper.java | 4 +- .../table/impl/longline/SensorUsedUIHandler.java | 7 +- .../content/table/impl/longline/TdrUIHandler.java | 23 +-- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 4 +- .../table/impl/seine/NonTargetCatchUIHandler.java | 7 +- .../table/impl/seine/NonTargetSampleUIHandler.java | 7 +- .../impl/seine/ObjectObservedSpeciesUIHandler.java | 5 +- .../impl/seine/ObjectSchoolEstimateUIHandler.java | 3 +- .../table/impl/seine/SchoolEstimateUIHandler.java | 3 +- .../table/impl/seine/TargetCatchUIHandler.java | 69 ++++----- .../impl/seine/TargetDiscardCatchUIHandler.java | 156 +++++++++------------ .../table/impl/seine/TargetSampleUIHandler.java | 5 +- .../fr/ird/observe/ui/tree/ObserveTreeHelper.java | 2 +- .../MoveActivityLonglineNodeMenuPopulator.java | 18 ++- .../menu/MoveActivitySeineNodeMenuPopulator.java | 18 ++- .../ui/tree/menu/MoveRouteNodeMenuPopulator.java | 18 ++- .../ui/tree/menu/MoveTripNodeMenuPopulator.java | 44 +++--- .../fr/ird/observe/ui/usage/UsagesUIHandler.java | 2 +- .../ird/observe/ui/util/DecoratedNodeEntity.java | 18 +-- .../ui/util/decorator/TargetCatchDecorator.java | 53 +++++++ .../dto/ActivitySimpleSpeedDtoValidator.java | 6 +- .../validator/dto/ActivitySpeedDtoValidator.java | 4 +- .../dto/SetLonglineUniqueHomeIdDtoValidator.java | 2 +- .../dto/SetLonglineUniqueNumberDtoValidator.java | 2 +- 47 files changed, 482 insertions(+), 392 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java index 6a6a015..16ac1f0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java @@ -24,14 +24,8 @@ package fr.ird.observe; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import fr.ird.observe.db.DataContext; -import fr.ird.observe.services.dto.IdDto; -import fr.ird.observe.services.dto.ReferenceDto; -import fr.ird.observe.ui.actions.shared.MoveActivityLonglinesUIAction; -import fr.ird.observe.ui.actions.shared.MoveActivitySeinesUIAction; -import fr.ird.observe.ui.actions.shared.MoveRoutesUIAction; -import fr.ird.observe.util.gps.GPSService; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; +import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constants.DbMode; import fr.ird.observe.db.event.ObserveSwingDataSourceEvent; @@ -73,6 +67,9 @@ import fr.ird.observe.ui.actions.shared.DeleteDataUIAction; import fr.ird.observe.ui.actions.shared.DeleteReferenceUIAction; import fr.ird.observe.ui.actions.shared.GoDownUIAction; import fr.ird.observe.ui.actions.shared.GoUpUIAction; +import fr.ird.observe.ui.actions.shared.MoveActivityLonglinesUIAction; +import fr.ird.observe.ui.actions.shared.MoveActivitySeinesUIAction; +import fr.ird.observe.ui.actions.shared.MoveRoutesUIAction; import fr.ird.observe.ui.actions.shared.MoveTripLonglinesUIAction; import fr.ird.observe.ui.actions.shared.MoveTripSeinesUIAction; import fr.ird.observe.ui.actions.shared.ReOpenUIAction; @@ -82,6 +79,7 @@ import fr.ird.observe.ui.actions.shared.SelectNodeUIAction; import fr.ird.observe.ui.actions.shared.SelectOpenNodeUIAction; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.util.gps.GPSService; import fr.ird.observe.validation.ObserveSwingValidator; import fr.ird.observe.validation.ValidationContext; import jaxx.runtime.JAXXUtil; @@ -91,7 +89,6 @@ import jaxx.runtime.swing.CardLayout2; import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.decorator.Decorator; import javax.swing.ActionMap; import javax.swing.JOptionPane; @@ -162,7 +159,6 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im public static final JAXXContextEntryDef<ObserveOpenDataManager> OPEN_DATA_MANAGER_ENTRY_DEF = JAXXUtil.newContextEntryDef(ObserveOpenDataManager.class); - /** the jaxx context entry to store the decorator service */ public static final JAXXContextEntryDef<ObserveSwingBinderService> BINDER_SERVICE_ENTRY_DEF = JAXXUtil.newContextEntryDef(ObserveSwingBinderService.class); @@ -204,23 +200,6 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im public static final JAXXContextEntryDef<List<String>> NODE_TO_RESELECT_ENTRY_DEF = UIHelper.newListContextEntryDef("nodeToReselect"); - public <O> Decorator<O> getDecorator(Class<O> clazz) { - DecoratorService provider = getDecoratorService(); - Decorator<O> value = provider.getDecoratorByType(clazz); - return value; - } - - public <O> Decorator<O> getDecorator(Class<O> clazz, String name) { - DecoratorService provider = getDecoratorService(); - Decorator<O> value = provider.getDecoratorByType(clazz, name); - return value; - } - public <R extends IdDto> Decorator<ReferenceDto<R>> getReferenceDecorator(Class<R> dtoType) { - Decorator<ReferenceDto> decorator1 = getDecorator(ReferenceDto.class, dtoType.getSimpleName()); - return (Decorator) decorator1; - } - - public ObserveSwingApplicationConfig getConfig() { return CONFIG_ENTRY_DEF.getContextValue(this); } @@ -242,6 +221,7 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im ObserveSwingDataSource dataSource = new ObserveSwingDataSource(configuration); dataSource.addObserveSwingDataSourceListener(new ObserveSwingDataSourceListenerAdapter() { + @Override public void onOpened(ObserveSwingDataSourceEvent event) { super.onOpened(event); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java index 8d1b2f7..172ea36 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/DecoratorService.java @@ -22,8 +22,6 @@ package fr.ird.observe.ui; import com.google.common.collect.Lists; -import fr.ird.observe.util.gps.GPSPoint; -import fr.ird.observe.util.gps.GPSPointInterval; import fr.ird.observe.entities.longline.SectionTemplate; import fr.ird.observe.services.dto.AbstractObserveDto; import fr.ird.observe.services.dto.IdDto; @@ -108,7 +106,6 @@ import fr.ird.observe.services.dto.seine.ObjectSchoolEstimateDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.dto.seine.SchoolEstimateDto; import fr.ird.observe.services.dto.seine.SetSeineDto; -import fr.ird.observe.services.dto.seine.TargetCatchDto; import fr.ird.observe.services.dto.seine.TargetLengthDto; import fr.ird.observe.services.dto.seine.TransmittingBuoyDto; import fr.ird.observe.services.dto.seine.TripSeineDto; @@ -119,8 +116,11 @@ import fr.ird.observe.ui.util.decorator.ObjectObservedSpeciesDecorator; import fr.ird.observe.ui.util.decorator.ObserveDecorator; import fr.ird.observe.ui.util.decorator.ReferenceDecorator; import fr.ird.observe.ui.util.decorator.SpeciesDecorator; +import fr.ird.observe.ui.util.decorator.TargetCatchDecorator; import fr.ird.observe.ui.util.decorator.TripLonglineDecorator; import fr.ird.observe.ui.util.decorator.TripSeineDecorator; +import fr.ird.observe.util.gps.GPSPoint; +import fr.ird.observe.util.gps.GPSPointInterval; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -501,15 +501,12 @@ public class DecoratorService extends DecoratorProvider { registerReferenceDtoDecorator(HarbourDto.class, "${code}$s##${name}$s##${locode}$s"); registerReferenceDtoDecorator(ObjectSchoolEstimateDto.class, - "${species/scientificLabel}$s##${weight}$d", - "${species}$s##${weight}$d"); + "${species/scientificLabel}$s##${weight}$d", + "${species}$s##${weight}$d"); registerReferenceDtoDecorator(SchoolEstimateDto.class, - "${species/scientificLabel}$s##${totalWeight}$d##${meanWeight}$d", - "${species}$s##${totalWeight}$d##${meanWeight}$d"); + "${species/scientificLabel}$s##${totalWeight}$d##${meanWeight}$d", + "${species}$s##${totalWeight}$d##${meanWeight}$d"); - registerObserveDecorator( - TargetCatchDto.class, - "${weightCategory/species/scientificLabel}$s##${weightCategory/label}$s##${weight}$f"); registerReferenceDtoDecorator( TargetLengthDto.class, "${species/scientificLabel}$s##${length}$f##${count}$d", @@ -550,22 +547,25 @@ public class DecoratorService extends DecoratorProvider { // Trip commun decorator registerDecorator(TRIP_CONTEXT, - new ReferenceDecorator("${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel}$s##${observer}$s")); + new ReferenceDecorator("${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vessel}$s##${observer}$s")); - String oldCode = l(locale, "observe.common.oldCode3L"); // Species decorator - registerDecorator(new SpeciesDecorator( oldCode)); + String oldCode = l(locale, "observe.common.oldCode3L"); + registerDecorator(new SpeciesDecorator(oldCode)); registerDecorator(SpeciesDto.class.getSimpleName(), new ReferenceDecorator("${faoCode}$s##${scientificLabel}$s##" + oldCode + " ${homeId}$s")); // ObjectObservedSpecies decorator registerDecorator(new ObjectObservedSpeciesDecorator()); + // TargetLength decorator + registerDecorator(new TargetCatchDecorator()); + // NonTargetCatch decorator registerDecorator(new NonTargetCatchDecorator()); registerDecorator(NonTargetCatchDto.class.getSimpleName(), - new ReferenceDecorator("${species}$s##${speciesFate}$s")); + new ReferenceDecorator("${species}$s##${speciesFate}$s")); // NonTargetLength decorator registerDecorator(new NonTargetLengthDecorator()); @@ -574,7 +574,7 @@ public class DecoratorService extends DecoratorProvider { registerDecorator(new LengthWeightParameterDecorator()); registerDecorator(LengthWeightParameterDto.class.getSimpleName(), new ReferenceDecorator("${sex/label}$s##${ocean/label}$s##${species/scientificLabel}$s##" + - t("observe.common.lengthWeightFormula") + " ${lengthWeightFormula}$s")); + t("observe.common.lengthWeightFormula") + " ${lengthWeightFormula}$s")); // gps decorators registerObserveDecorator("activity-gps", @@ -601,18 +601,23 @@ public class DecoratorService extends DecoratorProvider { registerObserveDecorator(GearUseFeaturesMeasurementSeineDto.class, "${id}$s"); registerReferenceDtoDecorator(EncounterDto.class, - "${encounterType/label}$s##${species/label}$s", - "${encounterType}$s##${species}$s", - " - "); + "${encounterType/label}$s##${species/label}$s", + "${encounterType}$s##${species}$s", + " - "); } - public <T extends ReferentialDto> Decorator<ReferentialReferenceDto<T>> getReferenceDecorator(Class<T> referenceType) { - Decorator decoratorByType = getDecoratorByType(ReferenceDto.class, referenceType.getSimpleName()); - return decoratorByType; + public <T extends ReferentialDto> Decorator<ReferentialReferenceDto<T>> getReferentialReferenceDecorator(Class<T> referenceType) { + Decorator decorator = getDecoratorByType(ReferenceDto.class, referenceType.getSimpleName()); + return decorator; } + public <T extends IdDto> Decorator<ReferenceDto<T>> getReferenceDecorator(Class<T> referenceType) { + Decorator decorator = getDecoratorByType(ReferenceDto.class, referenceType.getSimpleName()); + return decorator; + + } protected <T extends ReferentialDto> void registerReferentialReferenceDtoDecorator(Class<T> referenceType, String libelle) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java index c7bc2d1..cb1c9ef 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java @@ -23,6 +23,7 @@ package fr.ird.observe.ui; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.ui.util.table.ObserveBooleanTableCellRenderer; import jaxx.runtime.FileChooserUtil; import jaxx.runtime.JAXXObject; @@ -32,11 +33,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; -import javax.swing.*; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; import javax.swing.event.HyperlinkEvent; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; -import java.awt.*; +import java.awt.Component; +import java.awt.Desktop; +import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.io.File; @@ -338,13 +343,19 @@ public class UIHelper extends SwingUtil { public static DecoratorTableCellRenderer newDecorateTableCellRenderer( TableCellRenderer renderer, Class<?> entityClass) { - Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecorator(entityClass); + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecorator(entityClass); return new DecoratorTableCellRenderer(renderer, decorator); } public static DecoratorTableCellRenderer newDecorateTableCellRenderer( TableCellRenderer renderer, Class<?> entityClass, String context) { - Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecorator(entityClass, context); + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecorator(entityClass, context); + return new DecoratorTableCellRenderer(renderer, decorator); + } + + public static <T extends ReferentialDto> DecoratorTableCellRenderer newReferentialReferenceDecorateTableCellRenderer(TableCellRenderer renderer, + Class<T> entityClass) { + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialReferenceDecorator(entityClass); return new DecoratorTableCellRenderer(renderer, decorator); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java index e1c313d..bcda0e6 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java @@ -127,7 +127,7 @@ public class ShowConfigAction extends AbstractAction { Set<ReferentialReferenceDto<SpeciesListDto>> speciesLists = (Set) referentialReferenceSet.getReference(); Map<String, ReferentialReferenceDto<SpeciesListDto>> speciesListMap = IdDtos.splitById(speciesLists); - Decorator<ReferentialReferenceDto<SpeciesListDto>> referenceDecorator = ObserveSwingApplicationContext.get().getDecoratorService().getReferenceDecorator(SpeciesListDto.class); + Decorator<ReferentialReferenceDto<SpeciesListDto>> referenceDecorator = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialReferenceDecorator(SpeciesListDto.class); editor = new SpeciesListTableCellEditor(speciesLists, speciesListMap, referenceDecorator); renderer = new SpeciesListsTableCellRenderer(speciesListMap, referenceDecorator); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java index 14bed07..0880e1b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java @@ -33,9 +33,9 @@ import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.list.ContentListUIModel; import fr.ird.observe.ui.content.list.impl.longline.ActivityLonglinesUI; -import fr.ird.observe.ui.tree.DtoNodeSupport; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.TripLonglineNode; import fr.ird.observe.ui.util.DecoratedNodeEntity; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -89,7 +89,7 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { if (ui == null) { throw new IllegalStateException( "could not find client property " + - "ui on component" + c); + "ui on component" + c); } if (!(ui instanceof ActivityLonglinesUI)) { @@ -127,31 +127,30 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { int tripLonglineNb = programNode.getChildCount(); ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); - Decorator<ReferenceDto> decorator = applicationContext.getDecorator(ReferenceDto.class, - TripLonglineDto.class.getSimpleName()); + Decorator<ReferenceDto<TripLonglineDto>> decorator = applicationContext.getDecoratorService().getReferenceDecorator(TripLonglineDto.class); //on crée un tableau avec une marée en moins car on ne propose pas la marée actuelle DecoratedNodeEntity[] decoratedTripLonglines = new DecoratedNodeEntity[tripLonglineNb - 1]; int j = 0; - for (int i = 0 ; i < tripLonglineNb ; i++) { + for (int i = 0; i < tripLonglineNb; i++) { - ObserveNode tripLonglineNode = programNode.getChildAt(i); + TripLonglineNode tripLonglineNode = (TripLonglineNode) programNode.getChildAt(i); String tripLonglineId = tripLonglineNode.getId(); if (!oldTripLonglineId.equals(tripLonglineId)) { - decoratedTripLonglines[j++] = new DecoratedNodeEntity((DtoNodeSupport) tripLonglineNode, decorator); + decoratedTripLonglines[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripLonglineNode, decorator); } } Object decoratedTripLongline = JOptionPane.showInputDialog(ui, - t("observe.action.choose.tripLongline.message"), - t("observe.action.choose.tripLongline.title"), - JOptionPane.QUESTION_MESSAGE, - null, - decoratedTripLonglines, - null); + t("observe.action.choose.tripLongline.message"), + t("observe.action.choose.tripLongline.title"), + JOptionPane.QUESTION_MESSAGE, + null, + decoratedTripLonglines, + null); return decoratedTripLongline != null ? ((DecoratedNodeEntity) decoratedTripLongline).getId() : null; } @@ -169,7 +168,7 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { ObserveNode programNode = oldTripLonglineNode.getParent(); ObserveNode newTripLonglineNode = treeHelper.getChild(programNode, tripLonglineId); String activitiesNodeId = DecoratorService.getPropertyLabel(ObserveTreeHelper.TREE_NODE_PREFIX, - TripLonglineDto.PROPERTY_ACTIVITY_LONGLINE); + TripLonglineDto.PROPERTY_ACTIVITY_LONGLINE); ObserveNode newActivitiesNode = treeHelper.getChild(newTripLonglineNode, activitiesNodeId); treeHelper.selectNode(newActivitiesNode); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java index 6ea1874..ae5a511 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java @@ -26,16 +26,17 @@ import fr.ird.observe.ObserveOpenDataManager; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceDtos; +import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.service.seine.ActivitySeineService; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; -import fr.ird.observe.ui.content.list.ContentListUIModel; import fr.ird.observe.ui.content.list.impl.seine.ActivitySeinesUI; -import fr.ird.observe.ui.tree.DtoNodeSupport; +import fr.ird.observe.ui.content.list.impl.seine.ActivitySeinesUIModel; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.RouteSeineNode; import fr.ird.observe.ui.util.DecoratedNodeEntity; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -89,7 +90,7 @@ public class MoveActivitySeinesUIAction extends AbstractUIAction { if (ui == null) { throw new IllegalStateException( "could not find client property " + - "ui on component" + c); + "ui on component" + c); } if (!(ui instanceof ActivitySeinesUI)) { @@ -107,7 +108,7 @@ public class MoveActivitySeinesUIAction extends AbstractUIAction { if (routeId != null) { // change the route of the selected activities - List<ReferenceDto> selectedDatas = ((ContentListUIModel) ui.getModel()).getSelectedDatas(); + List<ReferenceDto<ActivitySeineDto>> selectedDatas = ((ActivitySeinesUIModel) ui.getModel()).getSelectedDatas(); List<String> activityIds = Lists.transform(selectedDatas, ReferenceDtos.getIdFunction()); ActivitySeineService service = ObserveSwingApplicationContext.get().newService(ActivitySeineService.class); List<Integer> positions = service.moveActivitySeinesToRoute(activityIds, routeId); @@ -127,21 +128,20 @@ public class MoveActivitySeinesUIAction extends AbstractUIAction { int routeNb = routesNode.getChildCount(); ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); - Decorator<ReferenceDto> decorator = applicationContext.getDecorator(ReferenceDto.class, - RouteDto.class.getSimpleName()); + Decorator<ReferenceDto<RouteDto>> decorator = applicationContext.getDecoratorService().getReferenceDecorator(RouteDto.class); //on crée un tableau avec une route en moins car on ne propose pas la route actuel DecoratedNodeEntity[] decoratedRoutes = new DecoratedNodeEntity[routeNb - 1]; int j = 0; - for (int i = 0 ; i < routeNb ; i++) { + for (int i = 0; i < routeNb; i++) { - ObserveNode routeNode = routesNode.getChildAt(i); + RouteSeineNode routeNode = (RouteSeineNode) routesNode.getChildAt(i); String routeId = routeNode.getId(); if (!oldRouteId.equals(routeId)) { - decoratedRoutes[j++] = new DecoratedNodeEntity((DtoNodeSupport) routeNode, decorator); + decoratedRoutes[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(routeNode, decorator); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java index 408b194..8c94322 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java @@ -33,9 +33,9 @@ import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.list.ContentListUIModel; import fr.ird.observe.ui.content.list.impl.seine.RoutesUI; -import fr.ird.observe.ui.tree.DtoNodeSupport; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.TripSeineNode; import fr.ird.observe.ui.util.DecoratedNodeEntity; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -89,7 +89,7 @@ public class MoveRoutesUIAction extends AbstractUIAction { if (ui == null) { throw new IllegalStateException( "could not find client property " + - "ui on component" + c); + "ui on component" + c); } if (!(ui instanceof RoutesUI)) { @@ -127,21 +127,20 @@ public class MoveRoutesUIAction extends AbstractUIAction { int tripSeineNb = programNode.getChildCount(); ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); - Decorator<ReferenceDto> decorator = applicationContext.getDecorator(ReferenceDto.class, - TripSeineDto.class.getSimpleName()); + Decorator<ReferenceDto<TripSeineDto>> decorator = applicationContext.getDecoratorService().getReferenceDecorator(TripSeineDto.class); //on crée un tableau avec une marée en moins car on ne propose pas la marée actuel DecoratedNodeEntity[] decoratedTripSeines = new DecoratedNodeEntity[tripSeineNb - 1]; int j = 0; - for (int i = 0 ; i < tripSeineNb ; i++) { + for (int i = 0; i < tripSeineNb; i++) { - ObserveNode tripSeineNode = programNode.getChildAt(i); + TripSeineNode tripSeineNode = (TripSeineNode) programNode.getChildAt(i); String tripSeineId = tripSeineNode.getId(); if (!oldTripSeineId.equals(tripSeineId)) { - decoratedTripSeines[j++] = new DecoratedNodeEntity((DtoNodeSupport) tripSeineNode, decorator); + decoratedTripSeines[j++] = DecoratedNodeEntity.newDecoratedNodeEntity(tripSeineNode, decorator); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java index 809ebea..b9881aa 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java @@ -25,7 +25,6 @@ import com.google.common.collect.Lists; import fr.ird.observe.ObserveOpenDataManager; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.services.dto.IdDto; -import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceDtos; import fr.ird.observe.services.dto.constants.GearType; @@ -33,9 +32,9 @@ import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.list.ContentListUIModel; -import fr.ird.observe.ui.tree.DtoNodeSupport; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.menu.MoveTripNodeMenuPopulator; import fr.ird.observe.ui.util.DecoratedNodeEntity; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -90,7 +89,7 @@ public abstract class MoveTripsUIAction<T extends IdDto> extends AbstractUIActio if (ui == null) { throw new IllegalStateException( "could not find client property " + - "ui on component" + c); + "ui on component" + c); } checkUIClass(ui); @@ -153,45 +152,25 @@ public abstract class MoveTripsUIAction<T extends IdDto> extends AbstractUIActio // racine ObserveNode rootNode = treeHelper.getRootNode(); - Decorator<ReferenceDto> decorator = applicationContext.getDecorator(ReferenceDto.class, - ProgramDto.class.getSimpleName()); + Decorator<ReferenceDto<ProgramDto>> decorator = applicationContext.getDecoratorService().getReferenceDecorator(ProgramDto.class); //on crée un tableau avec un programme en moins car on ne propose pas le programme actuel List<DecoratedNodeEntity> decoratedProgramList = new ArrayList<>(); - for (int i = 0, n = rootNode.getChildCount() ; i < n ; i++) { - - ObserveNode programNode = rootNode.getChildAt(i); - String programId = programNode.getId(); - - // si le noeud programme n'est pas le même que le parent actuel - if (!oldProgramId.equals(programId) - // si le noeud est bien un noeud de programme - && IdDtos.isProgramId(programId)) { - - ReferenceDto<ProgramDto> program = ((DtoNodeSupport) programNode).getEntity(); - - // si le type de marée et le type de prgramme sont les même - if (geartype.equals(program.getPropertyValue(ProgramDto.PROPERTY_GEAR_TYPE))) { - - String decoratedProgram = decorator.toString(program); - decoratedProgramList.add(new DecoratedNodeEntity(programId, decoratedProgram)); - } - } - } + MoveTripNodeMenuPopulator.createPossibleParents(oldProgramId, decoratedProgramList, geartype, rootNode); DecoratedNodeEntity[] decoratedPrograms = decoratedProgramList.toArray(new DecoratedNodeEntity[decoratedProgramList.size()]); - Object decoratedProgram = JOptionPane.showInputDialog(ui, - t("observe.action.choose.program.message"), - t("observe.action.choose.program.title"), - JOptionPane.QUESTION_MESSAGE, - null, - decoratedPrograms, - null); + DecoratedNodeEntity decoratedProgram = (DecoratedNodeEntity) JOptionPane.showInputDialog(ui, + t("observe.action.choose.program.message"), + t("observe.action.choose.program.title"), + JOptionPane.QUESTION_MESSAGE, + null, + decoratedPrograms, + null); - return decoratedProgram != null ? ((DecoratedNodeEntity) decoratedProgram).getId() : null; + return decoratedProgram == null ? null : decoratedProgram.getId(); } protected void updateTree(ContentUI<?> ui, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java index 5ce47f9..8b6d885 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/ExportUIHandler.java @@ -85,6 +85,7 @@ public class ExportUIHandler extends AdminTabUIHandler { final SelectDataUI selectTabUI = (SelectDataUI) ui.getStepUI(AdminStep.SELECT_DATA); tabUI.getModel().addPropertyChangeListener(AdminUIModel.SELECTION_MODEL_CHANGED_PROPERTY_NAME, new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { AdminUIModel model = (AdminUIModel) evt.getSource(); @@ -126,7 +127,7 @@ public class ExportUIHandler extends AdminTabUIHandler { n("observe.synchro.table.exportData.exist.label.tip")); UIHelper.setTableColumnRenderer(table4, 0, UIHelper.newBooleanTableCellRenderer(renderer5)); - UIHelper.setTableColumnRenderer(table4, 1, UIHelper.newDecorateTableCellRenderer(renderer5, ReferenceDto.class, ProgramDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table4, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer5, ProgramDto.class)); UIHelper.setTableColumnRenderer(table4, 2, UIHelper.newDecorateTableCellRenderer(renderer5, ReferenceDto.class, DecoratorService.TRIP_CONTEXT)); UIHelper.setTableColumnRenderer(table4, 3, UIHelper.newBooleanTableCellRenderer(renderer5)); UIHelper.setTableColumnEditor(table4, 0, MyDefaultCellEditor.newBooleanEditor(false)); @@ -166,6 +167,7 @@ public class ExportUIHandler extends AdminTabUIHandler { addAdminWorker( ((ExportUI) ui).getPrepareAction().getToolTipText(), new Callable<WizardState>() { + @Override public WizardState call() throws Exception { return prepareAction(); @@ -184,6 +186,7 @@ public class ExportUIHandler extends AdminTabUIHandler { addAdminWorker( tabUI.getStartAction().getToolTipText(), new Callable<WizardState>() { + @Override public WizardState call() throws Exception { return doAction(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/GPSActivityTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/GPSActivityTableModel.java index 95010ae..704784d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/GPSActivityTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/gps/GPSActivityTableModel.java @@ -74,7 +74,7 @@ public class GPSActivityTableModel extends AbstractTableModel { public GPSActivityTableModel() { selected = new HashSet<Integer>(); - decorator = ObserveSwingApplicationContext.get().getDecorator(ActivitySeineDto.class, + decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecorator(ActivitySeineDto.class, "gps-activity"); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index 8ea91ce..1e00947 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -35,6 +35,7 @@ import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.referential.ReferentialDto; +import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.ui.DecoratorService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.actions.shared.AbstractUIAction; @@ -75,6 +76,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import static org.nuiton.i18n.I18n.t; @@ -834,9 +836,9 @@ public abstract class ContentUIHandler<E extends IdDto> { if (formDto != null && ReferentialDto.class.isAssignableFrom(dtoClass)) { //FIXME Bien vérifier que cela fonctionne - ReferenceSetDto<R> referenceSetDto = formDto.getReferenceSetDto(dtoClass, list.getModel().getProperty()); + Set<ReferentialDto> referenceSetDto = getModel().getReferentialReferences((Class) dtoClass, list.getModel().getProperty()); - data = new ArrayList<>(referenceSetDto.getReference()); + data = new ArrayList(referenceSetDto); } else { @@ -928,7 +930,12 @@ public abstract class ContentUIHandler<E extends IdDto> { } protected <R extends IdDto> Decorator<ReferenceDto<R>> getReferenceDecorator(Class<R> dtoType) { - Decorator<ReferenceDto<R>> decorator = ObserveSwingApplicationContext.get().getReferenceDecorator(dtoType); + Decorator<ReferenceDto<R>> decorator = getDecoratorService().getReferenceDecorator(dtoType); + return decorator; + } + + protected <R extends ReferentialDto> Decorator<ReferentialReferenceDto<R>> getReferentialReferenceDecorator(Class<R> dtoType) { + Decorator<ReferentialReferenceDto<R>> decorator = getDecoratorService().getReferentialReferenceDecorator(dtoType); return decorator; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java index 14bfd19..cbc63b3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java @@ -234,7 +234,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E } if (o instanceof BeanListHeader<?>) { - init((BeanListHeader<?>) o); + init((BeanListHeader) o); continue; } @@ -361,8 +361,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E prepareBeanComboBox(beanComboBox); } - @SuppressWarnings("unchecked") - protected void init(BeanListHeader beanList) { + protected <E extends IdDto> void init(BeanListHeader<ReferenceDto<E>> beanList) { beanList.setI18nPrefix("observe.common."); @@ -382,7 +381,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E log.debug("addDecorator to list " + jlist.getName()); } - Decorator<? extends IdDto> decorator = ObserveSwingApplicationContext.get().getDecorator(klass); + Decorator<? extends IdDto> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(klass); jlist.putClientProperty("decorator", decorator); } @@ -609,13 +608,13 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E * des entités * @since 1.5 */ - protected <E extends IdDto> void prepareEntityList(FilterableDoubleList<ReferenceDto> list) { + protected <E extends IdDto> void prepareEntityList(FilterableDoubleList<ReferenceDto<E>> list) { ObserveSwingApplicationContext tx = ObserveSwingApplicationContext.get(); Class<E> dtoClass = (Class<E>) list.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_ENTITY_CLASS); // init list - Decorator<ReferenceDto> decorator = tx.getDecorator(ReferenceDto.class, dtoClass.getSimpleName()); + Decorator<ReferenceDto<E>> decorator = tx.getDecoratorService().getReferenceDecorator(dtoClass); if (log.isDebugEnabled()) { log.debug("Will use decorator " + decorator); } @@ -623,7 +622,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E list.putClientProperty("decorator", decorator); // set datas to list and init renderer - list.init((JXPathDecorator<ReferenceDto>) decorator, new ArrayList<ReferenceDto>(), new ArrayList<ReferenceDto>()); + list.init((JXPathDecorator<ReferenceDto<E>>) decorator, new ArrayList<ReferenceDto<E>>(), new ArrayList<ReferenceDto<E>>()); // get the renderer initialized ListCellRenderer renderer = list.getSelectedList().getCellRenderer(); @@ -650,12 +649,12 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E * @since 1.5 */ protected <E extends IdDto> void prepareEntityList(Class<E> dtoClass, - BeanListHeader<ReferenceDto> list) { + BeanListHeader<ReferenceDto<E>> list) { ObserveSwingApplicationContext tx = ObserveSwingApplicationContext.get(); // init list - Decorator<ReferenceDto> decorator = tx.getDecorator(ReferenceDto.class, dtoClass.getSimpleName()); + Decorator<ReferenceDto<E>> decorator = tx.getDecoratorService().getReferenceDecorator(dtoClass); if (log.isDebugEnabled()) { log.debug("Will use decorator " + decorator); } @@ -663,7 +662,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E list.putClientProperty("decorator", decorator); // set datas to list and init renderer - list.init((JXPathDecorator<ReferenceDto>) decorator, Collections.<ReferenceDto>emptyList()); + list.init((JXPathDecorator<ReferenceDto<E>>) decorator, Collections.<ReferenceDto<E>>emptyList()); // get the renderer initialized ListCellRenderer renderer = list.getList().getCellRenderer(); @@ -688,16 +687,16 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E * @si un pb pendant la récupération des * entités */ - protected <E extends IdDto> void prepareBeanComboBox(BeanComboBox<ReferenceDto> comboBox) { + protected <E extends IdDto> void prepareBeanComboBox(BeanComboBox<ReferenceDto<E>> comboBox) { ObserveSwingApplicationContext context = ObserveSwingApplicationContext.get(); // init combobox Class<E> dtoClass = (Class<E>) comboBox.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_ENTITY_CLASS); - Decorator<ReferenceDto> decorator = context.getDecorator(ReferenceDto.class, dtoClass.getSimpleName()); + Decorator<ReferenceDto<E>> decorator = context.getDecoratorService().getReferenceDecorator(dtoClass); // add data list to combo box - comboBox.init((JXPathDecorator<ReferenceDto>) decorator, Collections.<ReferenceDto>emptyList()); + comboBox.init((JXPathDecorator<ReferenceDto<E>>) decorator, Collections.<ReferenceDto<E>>emptyList()); final ListCellRenderer renderer = comboBox.getCombobox().getRenderer(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java index 7a7da5e..e6a47de 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIModel.java @@ -24,6 +24,7 @@ package fr.ird.observe.ui.content; import fr.ird.observe.ObserveSwingTechnicalException; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; @@ -253,6 +254,27 @@ public abstract class ContentUIModel<E extends IdDto> extends AbstractSerializab } + public <D extends IdDto> ReferenceSetDto<D> getReferenceSet(Class<D> type, String name) { + + ReferenceSetDto<D> referenceSetDto = formDto.getReferenceSetDto(type, name); + return referenceSetDto; + + } + + public <D extends ReferentialDto> ReferentialReferenceDto<D> getReferentialReferenceById(Class<D> type, String name, String id) { + + ReferentialReferenceDto<D> referenceSetDto = (ReferentialReferenceDto<D>) formDto.getReferenceById(type, name, id); + return referenceSetDto; + + } + + public <D extends IdDto> ReferenceDto<D> getReferenceById(Class<D> type, String name, String id) { + + ReferenceDto<D> referenceSetDto = formDto.getReferenceById(type, name, id); + return referenceSetDto; + + } + protected void firePropertyChange(String propertyName, Object newValue) { firePropertyChange(propertyName, null, newValue); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java index d449680..6ac234a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java @@ -183,6 +183,9 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { } + // utilisation du mode requis + setContentMode(mode); + getModel().setFormDto(formDto); SetSeineDtos.copySetSeineDto(formDto.getForm(), bean); @@ -199,9 +202,6 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { getUi().getStartTime().setDate(dateAndTime); - // utilisation du mode requis - setContentMode(mode); - SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); computeTabValidState(errorTableModel); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java index 30c032c..f27eb03 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java @@ -469,6 +469,10 @@ public abstract class ContentTableModel<P extends IdDto, B extends IdDto> extend return model == null ? null : model.getTableEditBean(); } + public boolean isNewRow() { + return getRowBean().getId() == null; + } + public boolean isCreate() { return create; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java index dd10b91..0e164ea 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java @@ -21,11 +21,18 @@ */ package fr.ird.observe.ui.content.table; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; +import fr.ird.observe.services.dto.referential.SpeciesDto; +import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; +import fr.ird.observe.services.dto.seine.TargetCatchDto; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ContentUIModel; @@ -42,7 +49,9 @@ import javax.swing.table.DefaultTableCellRenderer; import java.awt.Rectangle; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.io.Serializable; import java.util.List; +import java.util.Set; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -189,12 +198,8 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex E editBean = getBean(); // preparation du bean d'édition - loadEditBean(id); - - getModel().setMode(mode); - // initialisation du modèle du tableau getUi().getTableModel().attachModel(); @@ -246,6 +251,7 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex uiInitializer.initUI(); getModel().addPropertyChangeListener(ContentUIModel.PROPERTY_FORM_DTO, new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { updateReferenceSets(true); @@ -268,6 +274,8 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex ui.getTableModel().dettachModel(); + getModel().setMode(mode); + // chargement du bean d'édition loadEditBean(mode); @@ -439,4 +447,50 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex getTableModel().resetEditBean(); } + /** + * @param weightCategory la catégorie de poids + * @return la référence sur l'espèce de la catégorie de poids + */ + protected ReferentialReferenceDto<SpeciesDto> getWeightCategorySpecies(ReferentialReferenceDto<WeightCategoryDto> weightCategory) { + + //FIXME Il faut que les références dans les dto du form remontés soient les même que ceux remontés par les ensembles de références + //FIXME i.e pas de référence de référence + Serializable ref = weightCategory.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES); + + String speciesId; + if (ref instanceof String) { + speciesId = (String) ref; + } else { + speciesId = ((ReferentialReferenceDto<?>) ref).getId(); + } + return getModel().getReferentialReferenceById(SpeciesDto.class, TargetCatchDto.PROPERTY_SPECIES, speciesId); + } + + /** + * @param speciesId l'identifiant de l'espèce + * @return la liste de toutes les catégories de poids de l'espèce + */ + protected List<ReferentialReferenceDto<WeightCategoryDto>> getSpeciesWeightCategories(String speciesId) { + + Set<ReferentialReferenceDto<WeightCategoryDto>> allCategories = getModel().getReferentialReferences(WeightCategoryDto.class, TargetCatchDto.PROPERTY_WEIGHT_CATEGORY); + + return Lists.newArrayList(Iterables.filter(allCategories, new WeightCategorySpeciesPredicate(speciesId))); + + } + + private static class WeightCategorySpeciesPredicate implements Predicate<ReferentialReferenceDto<WeightCategoryDto>> { + + private final String speciesId; + + public WeightCategorySpeciesPredicate(String speciesId) { + this.speciesId = speciesId; + } + + @Override + public boolean apply(ReferentialReferenceDto<WeightCategoryDto> input) { + return speciesId.equals(input.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES)); + } + + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java index 077d1cd..9b55b32 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.content.table.impl.longline; */ import fr.ird.observe.db.constants.DataContextType; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.BaitsCompositionDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto; @@ -90,14 +89,15 @@ public class BaitsCompositionUIHandler extends ContentTableUIHandler<SetLongline n("observe.baitsComposition.table.proportion"), n("observe.baitsComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, BaitTypeDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, BaitSettingStatusDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, BaitTypeDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, BaitSettingStatusDto.class)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum table.getModel().addTableModelListener(new TableModelListener() { + @Override public void tableChanged(TableModelEvent e) { int proportionSum = getBean().getBaitsCompositionProportionSum(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java index 8e63600..98d6423 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.content.table.impl.longline; */ import fr.ird.observe.db.constants.DataContextType; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.BranchlinesCompositionDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.services.dto.referential.longline.HookSizeDto; @@ -88,8 +87,8 @@ public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLo n("observe.branchlinesComposition.table.proportion"), n("observe.branchlinesComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookTypeDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookSizeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HookTypeDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HookSizeDto.class)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java index 2c984f7..0848a00 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java @@ -349,12 +349,12 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, BasketDto.class.getSimpleName() + DecoratorService.HAULING_IDENTIFIER)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, BranchlineDto.class.getSimpleName() + DecoratorService.HAULING_IDENTIFIER)); - UIHelper.setTableColumnRenderer(table, 3, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 3, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newEnumTableCellRenderer(renderer, CatchAcquisitionModeEnum.class)); UIHelper.setTableColumnRenderer(table, 5, UIHelper.newEmptyNumberTableCellRenderer(renderer)); - UIHelper.setTableColumnRenderer(table, 6, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HealthnessDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 7, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, CatchFateLonglineDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 8, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HealthnessDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 6, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HealthnessDto.class)); + UIHelper.setTableColumnRenderer(table, 7, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, CatchFateLonglineDto.class)); + UIHelper.setTableColumnRenderer(table, 8, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HealthnessDto.class)); UIHelper.setTableColumnRenderer(table, 9, UIHelper.newBooleanTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 10, UIHelper.newStringTableCellRenderer(renderer, 10, true)); @@ -370,7 +370,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat n("observe.catchlongline.table.size"), n("observe.catchlongline.table.size.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SizeMeasureTypeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SizeMeasureTypeDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); Decorator<ReferenceDto<SizeMeasureTypeDto>> decorator = getReferenceDecorator(SizeMeasureTypeDto.class); @@ -400,7 +400,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat n("observe.catchlongline.table.weight"), n("observe.catchlongline.table.weight.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, WeightMeasureTypeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, WeightMeasureTypeDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); Decorator<ReferenceDto<WeightMeasureTypeDto>> decorator = getReferenceDecorator(WeightMeasureTypeDto.class); @@ -511,14 +511,17 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat @Override protected void loadEditBean(String beanId) { + FormDto<SetLonglineCatchDto> formDto = getSetLonglineCatchService().loadForm(beanId); - getModel().setFormDto(formDto); + + CatchLonglineUIModel model = getModel(); + model.setFormDto(formDto); LonglinePositionHelper<CatchLonglineDto> positionHelper = POSITION_HELPER_ENTRY.getContextValue(getUi()); - positionHelper.initSections(formDto.getReferenceSetDto(SectionDto.class, CatchLonglineDto.PROPERTY_SECTION), - formDto.getReferenceSetDto(BasketDto.class, CatchLonglineDto.PROPERTY_BASKET), - formDto.getReferenceSetDto(BranchlineDto.class, CatchLonglineDto.PROPERTY_BRANCHLINE), + positionHelper.initSections(model.getReferenceSet(SectionDto.class, CatchLonglineDto.PROPERTY_SECTION), + model.getReferenceSet(BasketDto.class, CatchLonglineDto.PROPERTY_BASKET), + model.getReferenceSet(BranchlineDto.class, CatchLonglineDto.PROPERTY_BRANCHLINE), formDto.getForm().getCatchLongline()); SetLonglineCatchDtos.copySetLonglineCatchDto(formDto.getForm(), getBean()); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java index 1f373fc..88641f0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java @@ -25,7 +25,6 @@ package fr.ird.observe.ui.content.table.impl.longline; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.ActivityLonglineEncouterDto; import fr.ird.observe.services.dto.longline.ActivityLonglineEncouterDtos; import fr.ird.observe.services.dto.longline.EncounterDto; @@ -87,8 +86,8 @@ public class EncounterUIHandler extends ContentTableUIHandler<ActivityLonglineEn n("observe.encounter.table.count"), n("observe.encounter.table.count.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, EncounterTypeDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, EncounterTypeDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java index ec431e7..1ad8a3d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.content.table.impl.longline; */ import fr.ird.observe.db.constants.DataContextType; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.FloatlinesCompositionDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.services.dto.referential.longline.LineTypeDto; @@ -85,12 +84,13 @@ public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLon n("observe.floatlinesComposition.table.proportion"), n("observe.floatlinesComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, LineTypeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, LineTypeDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum table.getModel().addTableModelListener(new TableModelListener() { + @Override public void tableChanged(TableModelEvent e) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java index b7d0938..4e66bd5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java @@ -223,7 +223,7 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip n("observe.gearUseFeaturesLongline.table.comment"), n("observe.gearUseFeaturesLongline.table.comment.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, GearDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, GearDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newBooleanTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newStringTableCellRenderer(renderer, 10, true)); @@ -239,7 +239,7 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip n("observe.gearUseFeaturesLongline.table.value"), n("observe.gearUseFeaturesLongline.table.value.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, GearCaracteristicDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, GearCaracteristicDto.class)); UIHelper.setTableColumnRenderer(table, 1, new GearUseFeatureMeasurementCellRenderer(0, renderer)); table.getTableHeader().setReorderingAllowed(false); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java index 6faa103..4e51701 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.content.table.impl.longline; */ import fr.ird.observe.db.constants.DataContextType; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.HooksCompositionDto; import fr.ird.observe.services.dto.longline.SetLonglineGlobalCompositionDto; import fr.ird.observe.services.dto.referential.longline.HookSizeDto; @@ -88,8 +87,8 @@ public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLongline n("observe.hooksComposition.table.proportion"), n("observe.hooksComposition.table.proportion.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookTypeDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, HookSizeDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HookTypeDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HookSizeDto.class)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java index 6bebad1..21b7bf1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java @@ -306,7 +306,7 @@ public class LonglinePositionHelper<D extends LonglinePositionAwareDto> { protected List<ReferenceDto<BasketDto>> getBaskets(ReferenceDto<SectionDto> section) { ArrayList<ReferenceDto<BasketDto>> baskets = Lists.newArrayList(Iterables.filter( - (Set) basketUniverse.getReference(), + basketUniverse.getReference(), ReferenceDtos.newLabelValuePredicate(BasketDto.PROPERTY_SECTION, section.getId()))); return baskets; @@ -315,7 +315,7 @@ public class LonglinePositionHelper<D extends LonglinePositionAwareDto> { protected List<ReferenceDto<BranchlineDto>> getBranchlines(ReferenceDto<BasketDto> basket) { ArrayList<ReferenceDto<BranchlineDto>> branchlines = Lists.newArrayList(Iterables.filter( - (Set) branchlineUniverse.getReference(), + branchlineUniverse.getReference(), ReferenceDtos.newLabelValuePredicate(BranchlineDto.PROPERTY_BASKET, basket.getId()))); return branchlines; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java index b37c9a6..26d45f6 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java @@ -29,7 +29,6 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.ObserveSwingTechnicalException; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.ActivityLonglineSensorUsedDto; import fr.ird.observe.services.dto.longline.ActivityLonglineSensorUsedDtos; import fr.ird.observe.services.dto.longline.SensorUsedDto; @@ -108,9 +107,9 @@ public class SensorUsedUIHandler extends ContentTableUIHandler<ActivityLonglineS n("observe.sensorUsed.table.dataLocation"), n("observe.sensorUsed.table.dataLocation.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SensorTypeDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SensorBrandDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 2, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SensorDataFormatDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SensorTypeDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SensorBrandDto.class)); + UIHelper.setTableColumnRenderer(table, 2, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SensorDataFormatDto.class)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newStringTableCellRenderer(renderer, 10, true)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newBooleanTableCellRenderer(renderer, new Predicate<Object>() { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java index 20625b7..9ee21a1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java @@ -29,7 +29,6 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.ObserveSwingTechnicalException; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.BasketDto; import fr.ird.observe.services.dto.longline.BranchlineDto; import fr.ird.observe.services.dto.longline.SectionDto; @@ -43,6 +42,7 @@ import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIHandler; +import fr.ird.observe.ui.content.table.ContentTableUIModel; import jaxx.runtime.context.JAXXContextEntryDef; import jaxx.runtime.swing.HidorButton; import jaxx.runtime.validator.swing.SwingValidatorMessage; @@ -89,6 +89,7 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener = new TableModelListener() { + @Override public void tableChanged(TableModelEvent e) { @@ -100,6 +101,7 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt // Change toogle target visible on all TimeEditors protected final PropertyChangeListener onToogleTimeEditorSliderChangedListener = new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { Boolean newValue = (Boolean) evt.getNewValue(); @@ -188,8 +190,9 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt UIHelper.setTableColumnRenderer(table, 0, UIHelper.newStringTableCellRenderer(renderer, 10, true)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newStringTableCellRenderer(renderer, 10, true)); - UIHelper.setTableColumnRenderer(table, 2, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SensorBrandDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 2, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SensorBrandDto.class)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newBooleanTableCellRenderer(renderer, new Predicate<Object>() { + @Override public boolean apply(Object input) { return input != null; @@ -327,7 +330,7 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt t("observe.tdr.delete.data.message"), JOptionPane.WARNING_MESSAGE, new Object[]{t("observe.choice.confirm.delete"), - t("observe.choice.cancel")}, + t("observe.choice.cancel")}, 1); boolean doDelete = response == 0; @@ -465,17 +468,21 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt @Override protected void loadEditBean(String beanId) { + FormDto<SetLonglineTdrDto> formDto = getTdrService().loadForm(beanId); - getModel().setFormDto(formDto); + + ContentTableUIModel<SetLonglineTdrDto, TdrDto> model = getModel(); + model.setFormDto(formDto); LonglinePositionHelper<TdrDto> positionHelper = POSITION_HELPER_ENTRY.getContextValue(getUi()); - positionHelper.initSections(formDto.getReferenceSetDto(SectionDto.class, TdrDto.PROPERTY_SECTION), - formDto.getReferenceSetDto(BasketDto.class, TdrDto.PROPERTY_BASKET), - formDto.getReferenceSetDto(BranchlineDto.class, TdrDto.PROPERTY_BRANCHLINE), - formDto.getForm().getTdr()); + positionHelper.initSections(model.getReferenceSet(SectionDto.class, TdrDto.PROPERTY_SECTION), + model.getReferenceSet(BasketDto.class, TdrDto.PROPERTY_BASKET), + model.getReferenceSet(BranchlineDto.class, TdrDto.PROPERTY_BRANCHLINE), + formDto.getForm().getTdr()); SetLonglineTdrDtos.copySetLonglineTdrDto(formDto.getForm(), getBean()); + } protected TdrService getTdrService() { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java index b0f80b2..3fb1e1f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java @@ -219,7 +219,7 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei n("observe.gearUseFeaturesSeine.table.comment"), n("observe.gearUseFeaturesSeine.table.comment.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, GearDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, GearDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newBooleanTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newStringTableCellRenderer(renderer, 10, true)); @@ -235,7 +235,7 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei n("observe.gearUseFeaturesSeine.table.value"), n("observe.gearUseFeaturesSeine.table.value.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, GearCaracteristicDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, GearCaracteristicDto.class)); UIHelper.setTableColumnRenderer(table, 1, new GearUseFeatureMeasurementCellRenderer(0, renderer)); table.getTableHeader().setReorderingAllowed(false); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java index 2e6102a..c734463 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java @@ -284,9 +284,9 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeineNonTa n("observe.nonTargetCatch.table.comment"), n("observe.nonTargetCatch.table.comment.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesFateDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 2, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, ReasonForDiscardDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesFateDto.class)); + UIHelper.setTableColumnRenderer(table, 2, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, ReasonForDiscardDto.class)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 5, UIHelper.newEmptyNumberTableCellRenderer(renderer)); @@ -294,6 +294,7 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeineNonTa UIHelper.setTableColumnRenderer(table, 7, UIHelper.newStringTableCellRenderer(renderer, 10, true)); } + @SuppressWarnings("Duplicates") @Override protected boolean prepareSave(SetSeineNonTargetCatchDto editBean, List<NonTargetCatchDto> objets) throws Exception { super.prepareSave(editBean, objets); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java index 54e7e1f..d0c5935 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java @@ -26,7 +26,6 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.SexDto; import fr.ird.observe.services.dto.referential.SpeciesDto; @@ -71,6 +70,7 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam * @since 3.0 */ protected final PropertyChangeListener weightChanged = new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { NonTargetLengthDto source = (NonTargetLengthDto) evt.getSource(); @@ -86,6 +86,7 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam * @since 3.0 */ protected final PropertyChangeListener lengthChanged = new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { NonTargetLengthDto source = (NonTargetLengthDto) evt.getSource(); @@ -196,11 +197,11 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam n("observe.nonTargetSample.table.picturesReferences"), n("observe.nonTargetSample.table.picturesReferences.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); - UIHelper.setTableColumnRenderer(table, 4, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SexDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 4, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SexDto.class)); UIHelper.setTableColumnRenderer(table, 5, renderer); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java index 37d5e2a..f6e2c7c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java @@ -24,7 +24,6 @@ package fr.ird.observe.ui.content.table.impl.seine; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto; import fr.ird.observe.services.dto.seine.FloatingObjectObservedSpeciesDto; @@ -87,8 +86,8 @@ public class ObjectObservedSpeciesUIHandler extends ContentTableUIHandler<Floati n("observe.objectObservedSpecies.table.count"), n("observe.objectObservedSpecies.table.count.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesStatusDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesStatusDto.class)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java index d80cebd..99dc5b0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java @@ -24,7 +24,6 @@ package fr.ird.observe.ui.content.table.impl.seine; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.seine.FloatingObjectSchoolEstimateDto; import fr.ird.observe.services.dto.seine.FloatingObjectSchoolEstimateDtos; @@ -84,7 +83,7 @@ public class ObjectSchoolEstimateUIHandler extends ContentTableUIHandler<Floatin n("observe.schoolEstimate.table.weight"), n("observe.schoolEstimate.table.weight.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java index 50a9bc8..e6f0b37 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java @@ -29,7 +29,6 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.IdDtos; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.seine.SchoolEstimateDto; @@ -122,7 +121,7 @@ public class SchoolEstimateUIHandler extends ContentTableUIHandler<SetSeineSchoo n("observe.schoolEstimate.table.meanWeight"), n("observe.schoolEstimate.table.meanWeight.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java index dc16e4e..9e1ccfa 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java @@ -21,14 +21,11 @@ */ package fr.ird.observe.ui.content.table.impl.seine; -import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; @@ -92,17 +89,13 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa @Override public void propertyChange(PropertyChangeEvent evt) { - ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model; - model = getTableModel(); - - if (model.getRowBean().getId() == null) { - - // en mode creation , on doit recalculer la liste - // des categories + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + if (model.isNewRow()) { + // en mode creation , on doit recalculer la liste des categories ReferentialReferenceDto<SpeciesDto> species = (ReferentialReferenceDto<SpeciesDto>) evt.getNewValue(); + onSpeciesChanged(species); - onEspeceChanged(species); } } } @@ -114,6 +107,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa return getDataContext().getSelectedSetId(); } + @SuppressWarnings("Duplicates") @Override protected boolean prepareSave(SetSeineTargetCatchDto bean, List<TargetCatchDto> objets) { @@ -144,8 +138,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa // il existe des echantillons thon a supprimer on demande une confirmation StringBuilder sb = new StringBuilder(512); - Decorator<ReferenceDto> decorator = - getDecoratorService().getDecoratorByType(ReferenceDto.class, SpeciesDto.class.getSimpleName()); + Decorator<ReferentialReferenceDto<SpeciesDto>> decorator = getReferentialReferenceDecorator(SpeciesDto.class); for (ReferentialReferenceDto<SpeciesDto> species : speciesToDelete) { sb.append(" - ").append(decorator.toString(species)).append('\n'); @@ -183,11 +176,11 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa TargetCatchUI ui = getUi(); - ReferentialReferenceDto<WeightCategoryDto> beanWeightCategory = bean.getWeightCategory(); + ReferentialReferenceDto<WeightCategoryDto> weightCategory = bean.getWeightCategory(); - ReferentialReferenceDto<SpeciesDto> beanSpecies = null; - if (beanWeightCategory != null) { - beanSpecies = (ReferentialReferenceDto<SpeciesDto>) beanWeightCategory.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES); + ReferentialReferenceDto<SpeciesDto> species = null; + if (weightCategory != null) { + species = getWeightCategorySpecies(weightCategory); } JComponent requestFocus; @@ -198,9 +191,9 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa if (!getTableModel().isCreate()) { // on repositionne l'espèce (cela reconstruira la liste des categories) - ui.getSpecies().setSelectedItem(beanSpecies); + ui.getSpecies().setSelectedItem(species); // on repositionne la categorie - ui.getWeightCategory().setSelectedItem(beanWeightCategory); + ui.getWeightCategory().setSelectedItem(weightCategory); } requestFocus = ui.getSpecies(); @@ -211,16 +204,16 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa // au singleton de sa valeur correspondante dans le bean // puisque dans ce mode, pas possibilite de modifier de cette // valeur (clef metier) - ui.getSpecies().setSelectedItem(beanSpecies); - ui.getWeightCategory().setData(Collections.singletonList(beanWeightCategory)); - ui.getWeightCategory().setSelectedItem(beanWeightCategory); + ui.getSpecies().setSelectedItem(species); + ui.getWeightCategory().setData(Collections.singletonList(weightCategory)); + ui.getWeightCategory().setSelectedItem(weightCategory); requestFocus = ui.getCatchWeight(); } if (log.isDebugEnabled()) { - log.debug("selected categoriePoid " + beanWeightCategory); - log.debug("selected species " + beanSpecies); + log.debug("selected weightcategory " + weightCategory); + log.debug("selected species " + species); } requestFocus.requestFocus(); } @@ -247,40 +240,30 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa n("observe.targetCatch.table.comment"), n("observe.targetCatch.table.comment.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, WeightCategoryDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, WeightCategoryDto.class)); UIHelper.setTableColumnRenderer(table, 2, renderer); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newStringTableCellRenderer(renderer, 10, true)); } @SuppressWarnings("unchecked") - protected void onEspeceChanged(final ReferentialReferenceDto<SpeciesDto> species) { + protected void onSpeciesChanged(ReferentialReferenceDto<SpeciesDto> species) { List<ReferentialReferenceDto<WeightCategoryDto>> availableCategories; if (species == null) { - // aucune espèce selectionnee, on vide simplement - // la liste des categories car il faut d'abord choisir une - // espèce puis une categorie - + // aucune espèce selectionnee, on vide simplement la liste des categories + // car il faut d'abord choisir une espèce puis une categorie availableCategories = Collections.emptyList(); - } else { - - // un species est selectionnee, - // on calcule les categories pour cette espèce - Set<ReferentialReferenceDto<WeightCategoryDto>> allCategories = getModel().getReferentialReferences(WeightCategoryDto.class, TargetCatchDto.PROPERTY_SPECIES); + } else { + // un espèce est selectionnee, on calcule les categories pour cette espèce // on ne conserve que les categories de l'espèce - availableCategories = Lists.newArrayList(Iterables.filter(allCategories, new Predicate<ReferentialReferenceDto<WeightCategoryDto>>() { + availableCategories = getSpeciesWeightCategories(species.getId()); - @Override - public boolean apply(ReferentialReferenceDto<WeightCategoryDto> input) { - return species.equals(input.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES)); - } - })); } // on met a jour la liste des categories disponibles @@ -289,6 +272,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa // on reinitialise toujours la categorie selectionnee combo.setSelectedItem(null); + } @Override @@ -312,4 +296,5 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa protected TargetCatchService getTargetCatchService() { return ObserveSwingApplicationContext.get().newService(TargetCatchService.class); } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java index f56b866..2934fde 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java @@ -27,7 +27,6 @@ import com.google.common.collect.Sets; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto; @@ -54,7 +53,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -91,9 +89,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT if (weightCategory != null) { for (int i = 0; i < model.getRowCount(); i++) { TargetCatchDto c = model.getValueAt(i); - if (c != null && - weightCategory.equals(c.getWeightCategory()) && - c.getReasonForDiscard() != null) { + if (c != null && weightCategory.equals(c.getWeightCategory()) && c.getReasonForDiscard() != null) { set.add(c.getReasonForDiscard()); } } @@ -124,16 +120,16 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT @Override public void propertyChange(PropertyChangeEvent evt) { - ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = - getTableModel(); - TargetCatchDto bean = model.getRowBean(); + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); - if (bean.getId() == null) { - // en mode creation , on doit recalculer la liste des categories + if (model.isNewRow()) { + // en mode creation , on doit recalculer la liste des categories ReferentialReferenceDto<SpeciesDto> species = (ReferentialReferenceDto<SpeciesDto>) evt.getNewValue(); - onEspeceChanged(bean, species); + onSpeciesChanged(model.getRowBean(), species); + } + } } ); @@ -149,15 +145,14 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT @Override public void propertyChange(PropertyChangeEvent evt) { - ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = - getTableModel(); - TargetCatchDto bean = model.getRowBean(); - if (bean.getId() == null) { - // en mode creation , on doit recalculer la liste - // des raison rejet + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + if (model.isNewRow()) { + + // en mode creation , on doit recalculer la liste des raison rejet ReferentialReferenceDto<WeightCategoryDto> weightCategory = (ReferentialReferenceDto<WeightCategoryDto>) evt.getNewValue(); - onCategorieChanged(bean, weightCategory); + onWeightCategoryChanged(model.getRowBean(), weightCategory); + } } @@ -171,6 +166,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT return getDataContext().getSelectedSetId(); } + @SuppressWarnings("Duplicates") @Override protected boolean prepareSave(SetSeineTargetCatchDto bean, List<TargetCatchDto> objets) { @@ -201,7 +197,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT // il existe des echantillon thon a supprimer on demande une confirmation StringBuilder sb = new StringBuilder(512); Decorator<ReferentialReferenceDto<SpeciesDto>> decorator = - getDecoratorService().getReferenceDecorator(SpeciesDto.class); + getReferentialReferenceDecorator(SpeciesDto.class); for (ReferentialReferenceDto<SpeciesDto> species : speciesToDelete) { sb.append(" - ").append(decorator.toString(species)).append('\n'); @@ -235,22 +231,23 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT return true; } + @SuppressWarnings("Duplicates") @Override protected void onSelectedRowChanged(int editingRow, TargetCatchDto bean, boolean create) { TargetDiscardCatchUI ui = getUi(); - ReferentialReferenceDto<WeightCategoryDto> beanWeightCategory = bean.getWeightCategory(); + ReferentialReferenceDto<WeightCategoryDto> weightCategory = bean.getWeightCategory(); - ReferentialReferenceDto<SpeciesDto> beanSpecies = null; - if (beanWeightCategory != null) { - beanSpecies = (ReferentialReferenceDto<SpeciesDto>) beanWeightCategory.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES); + ReferentialReferenceDto<SpeciesDto> species = null; + if (weightCategory != null) { + species = getWeightCategorySpecies(weightCategory); } - ReferentialReferenceDto<ReasonForDiscardDto> beanReasonForDiscard = bean.getReasonForDiscard(); + ReferentialReferenceDto<ReasonForDiscardDto> reasonForDiscard = bean.getReasonForDiscard(); if (log.isDebugEnabled()) { - log.debug("selected categoriePoid " + beanWeightCategory); - log.debug("selected species " + beanSpecies); - log.debug("selected reasonForDiscard " + beanReasonForDiscard); + log.debug("selected categoriePoid " + weightCategory); + log.debug("selected species " + species); + log.debug("selected reasonForDiscard " + reasonForDiscard); } JComponent requestFocus; @@ -264,7 +261,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT } // on recalcule la liste des speciess disponibles - List<ReferentialReferenceDto<SpeciesDto>> availableSpecies = buildEspeceList(beanSpecies, beanWeightCategory); + List<ReferentialReferenceDto<SpeciesDto>> availableSpecies = buildSpeciesList(species, weightCategory); ui.getSpecies().setData(availableSpecies); // on reinitilise toujours l'species (pour reinitialiser la liste des categories) @@ -272,10 +269,10 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT if (!model.isCreate()) { // on repositionne l'espèce (cela reconstruira la liste des categories) - ui.getSpecies().setSelectedItem(beanSpecies); + ui.getSpecies().setSelectedItem(species); // on repositionne la categorie - ui.getWeightCategory().setSelectedItem(beanWeightCategory); - ui.getReasonForDiscard().setSelectedItem(beanReasonForDiscard); + ui.getWeightCategory().setSelectedItem(weightCategory); + ui.getReasonForDiscard().setSelectedItem(reasonForDiscard); } requestFocus = ui.getSpecies(); @@ -284,11 +281,11 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT // au singleton de sa valeur correspondante dans le bean // puisque dans ce mode, pas possibilite de modifier de cette // valeur (clef metier) - ui.getSpecies().setSelectedItem(beanSpecies); - ui.getWeightCategory().setData(Collections.singletonList(beanWeightCategory)); - ui.getWeightCategory().setSelectedItem(beanWeightCategory); - ui.getReasonForDiscard().setData(Collections.singletonList(beanReasonForDiscard)); - ui.getReasonForDiscard().setSelectedItem(beanReasonForDiscard); + ui.getSpecies().setSelectedItem(species); + ui.getWeightCategory().setData(Collections.singletonList(weightCategory)); + ui.getWeightCategory().setSelectedItem(weightCategory); + ui.getReasonForDiscard().setData(Collections.singletonList(reasonForDiscard)); + ui.getReasonForDiscard().setSelectedItem(reasonForDiscard); requestFocus = ui.getCatchWeight(); } @@ -318,15 +315,15 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT n("observe.targetDiscarded.table.comment"), n("observe.targetDiscarded.table.comment.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, WeightCategoryDto.class.getSimpleName())); - UIHelper.setTableColumnRenderer(table, 2, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, ReasonForDiscardDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, WeightCategoryDto.class)); + UIHelper.setTableColumnRenderer(table, 2, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, ReasonForDiscardDto.class)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newStringTableCellRenderer(renderer, 20, false)); UIHelper.setTableColumnRenderer(table, 5, UIHelper.newStringTableCellRenderer(renderer, 10, true)); } - protected void onEspeceChanged(TargetCatchDto bean, ReferentialReferenceDto<SpeciesDto> species) { + protected void onSpeciesChanged(TargetCatchDto bean, ReferentialReferenceDto<SpeciesDto> species) { ReferentialReferenceDto<WeightCategoryDto> weightCategory = null; @@ -334,23 +331,20 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT if (species == null) { - // aucune espèce selectionnee, on vide simplement - // la liste des categories car il faut d'abord choisir une espèce puis une categorie + // aucune espèce selectionnee, on vide simplement la liste des categories + // car il faut d'abord choisir une espèce puis une categorie data = Collections.emptyList(); } else { - // un species est selectionne, on met a jour la liste des categories - // disponibles pour cette espèce - + // un espèce est selectionnee, on met a jour la liste des categories disponibles pour cette espèce List<ReferentialReferenceDto<WeightCategoryDto>> availableCategories = buildWeightCategoryList(species); data = availableCategories; weightCategory = bean.getWeightCategory(); - if (weightCategory != null && - !availableCategories.contains(weightCategory)) { + if (weightCategory != null && !availableCategories.contains(weightCategory)) { weightCategory = null; } } @@ -363,7 +357,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT combo.setSelectedItem(weightCategory); } - protected void onCategorieChanged(TargetCatchDto bean, ReferentialReferenceDto<WeightCategoryDto> weightCategory) { + protected void onWeightCategoryChanged(TargetCatchDto bean, ReferentialReferenceDto<WeightCategoryDto> weightCategory) { TargetDiscardCatchUI ui = getUi(); ReferentialReferenceDto<ReasonForDiscardDto> reasonForDiscard = null; @@ -390,9 +384,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT data = reasonForDiscardList; - - if (reasonForDiscard != null && - !reasonForDiscardList.contains(reasonForDiscard)) { + if (reasonForDiscard != null && !reasonForDiscardList.contains(reasonForDiscard)) { // on sélectionne la première raison rejet disponible reasonForDiscard = null; } @@ -407,62 +399,54 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT combo.setSelectedItem(reasonForDiscard); } - protected List<ReferentialReferenceDto<SpeciesDto>> buildEspeceList(ReferentialReferenceDto<SpeciesDto> species, - ReferentialReferenceDto<WeightCategoryDto> weightCategory) { + protected List<ReferentialReferenceDto<SpeciesDto>> buildSpeciesList(ReferentialReferenceDto<SpeciesDto> species, + ReferentialReferenceDto<WeightCategoryDto> weightCategory) { - List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryList = getAllCategories(); + List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryList = getAllWeightCategories(); - removeFullyUsedCategories(weightCategoryList); + removeFullyUsedWeightCategories(weightCategoryList); if (weightCategory != null) { weightCategoryList.add(weightCategory); } - Collection<ReferentialReferenceDto<SpeciesDto>> usedEspeces = Sets.newHashSet(); + Collection<ReferentialReferenceDto<SpeciesDto>> usedSpecies = Sets.newHashSet(); for (ReferentialReferenceDto<WeightCategoryDto> cat : weightCategoryList) { - usedEspeces.add((ReferentialReferenceDto<SpeciesDto>) cat.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES)); + usedSpecies.add(getWeightCategorySpecies(cat)); } - List<ReferentialReferenceDto<SpeciesDto>> result = Lists.newArrayList(usedEspeces); + List<ReferentialReferenceDto<SpeciesDto>> result = Lists.newArrayList(usedSpecies); weightCategoryList.clear(); - usedEspeces.clear(); + usedSpecies.clear(); return result; + } protected List<ReferentialReferenceDto<WeightCategoryDto>> buildWeightCategoryList(ReferentialReferenceDto<SpeciesDto> species) { - List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryList = getAllCategories(); + List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryList = getSpeciesWeightCategories(species.getId()); - // on filtre les categories sur l'espèce donnée - for (Iterator<ReferentialReferenceDto<WeightCategoryDto>> it = weightCategoryList.iterator(); - it.hasNext(); ) { - ReferentialReferenceDto<WeightCategoryDto> weighte = it.next(); - if (!species.equals(weighte.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES))) { - it.remove(); - } - } - - // on filtre toutes les weightCategory qui ont deja references - // toutes les raison rejets - removeFullyUsedCategories(weightCategoryList); + // on filtre toutes les categories qui ont deja references sur toutes les raisons de rejet + removeFullyUsedWeightCategories(weightCategoryList); return weightCategoryList; } @SuppressWarnings("unchecked") - protected List<ReferentialReferenceDto<ReasonForDiscardDto>> buildReasonFordiscardList(ReferentialReferenceDto<WeightCategoryDto> weightCategory, ReferentialReferenceDto<ReasonForDiscardDto> currentReason) { + protected List<ReferentialReferenceDto<ReasonForDiscardDto>> buildReasonFordiscardList(ReferentialReferenceDto<WeightCategoryDto> weightCategory, + ReferentialReferenceDto<ReasonForDiscardDto> reasonForDiscard) { ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); - Set<ReferentialReferenceDto<ReasonForDiscardDto>> reasonForDiscardSetDto = getModel().getReferentialReferences(ReasonForDiscardDto.class, TargetCatchDto.PROPERTY_REASON_FOR_DISCARD); + Set<ReferentialReferenceDto<ReasonForDiscardDto>> reasonForDiscardSet = getModel().getReferentialReferences(ReasonForDiscardDto.class, TargetCatchDto.PROPERTY_REASON_FOR_DISCARD); - List<ReferentialReferenceDto<ReasonForDiscardDto>> reasonForDiscardList = Lists.newArrayList(reasonForDiscardSetDto); + List<ReferentialReferenceDto<ReasonForDiscardDto>> reasonForDiscardList = Lists.newArrayList(reasonForDiscardSet); // on filtre les raison rejet sur la categorie for (int i = 0; i < model.getRowCount(); i++) { TargetCatchDto c = model.getValueAt(i); if (c != null && c.getReasonForDiscard() != null - && (currentReason == null || !currentReason.equals(c.getReasonForDiscard())) + && (reasonForDiscard == null || !reasonForDiscard.equals(c.getReasonForDiscard())) && weightCategory.equals(c.getWeightCategory())) { reasonForDiscardList.remove(c.getReasonForDiscard()); } @@ -471,30 +455,28 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT return reasonForDiscardList; } - protected List<ReferentialReferenceDto<WeightCategoryDto>> getAllCategories() { - Set<ReferentialReferenceDto<WeightCategoryDto>> weightCategorySetDto = getModel().getReferentialReferences(WeightCategoryDto.class, TargetCatchDto.PROPERTY_WEIGHT_CATEGORY); - - List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryList = Lists.newArrayList(weightCategorySetDto); + protected List<ReferentialReferenceDto<WeightCategoryDto>> getAllWeightCategories() { + Set<ReferentialReferenceDto<WeightCategoryDto>> weightCategorySet = getModel().getReferentialReferences(WeightCategoryDto.class, TargetCatchDto.PROPERTY_WEIGHT_CATEGORY); + List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryList = Lists.newArrayList(weightCategorySet); return weightCategoryList; + } - protected void removeFullyUsedCategories( - List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryAvaillable) { + protected void removeFullyUsedWeightCategories(List<ReferentialReferenceDto<WeightCategoryDto>> weightCategoryAvaillables) { ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); - Set<ReferentialReferenceDto<ReasonForDiscardDto>> reasonForDiscardSetDto = getModel().getReferentialReferences(ReasonForDiscardDto.class, TargetCatchDto.PROPERTY_REASON_FOR_DISCARD); + Set<ReferentialReferenceDto<ReasonForDiscardDto>> reasonForDiscardSet = getModel().getReferentialReferences(ReasonForDiscardDto.class, TargetCatchDto.PROPERTY_REASON_FOR_DISCARD); - int nbReasonForDiscard = reasonForDiscardSetDto.size(); + int nbReasonForDiscard = reasonForDiscardSet.size(); - // on filtre toutes les weightCategory qui ont deja references toutes - // les raisons rejets + // on filtre toutes les weightCategory qui ont deja references toutes les raisons rejets for (ReferentialReferenceDto<WeightCategoryDto> c : getWeightCategoryUsed(model)) { Collection<ReferentialReferenceDto<ReasonForDiscardDto>> raisonUsed = getReasonForDiscardUsed(model, c); if (raisonUsed.size() == nbReasonForDiscard) { // toutes les raison de rejet epuisé pour cette categorie - weightCategoryAvaillable.remove(c); + weightCategoryAvaillables.remove(c); } } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java index 9dfab19..18b1f93 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java @@ -25,7 +25,6 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; -import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.result.SaveResultDto; @@ -77,6 +76,7 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSampleDto * @since 3.0 */ protected final PropertyChangeListener weightChanged = new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { TargetLengthDto source = (TargetLengthDto) evt.getSource(); @@ -92,6 +92,7 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSampleDto * @since 3.0 */ protected final PropertyChangeListener lengthChanged = new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { TargetLengthDto source = (TargetLengthDto) evt.getSource(); @@ -211,7 +212,7 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSampleDto n("observe.targetSample.table.totalWeight"), n("observe.targetSample.table.totalWeight.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesDto.class)); UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEnumTableCellRenderer(renderer, CodeMesureEnum.class)); UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java index 3d8197b..e532c88 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java @@ -543,7 +543,7 @@ public class ObserveTreeHelper extends NavTreeHelper<ObserveNode> { Collections.sort(data, new Comparator<ReferenceDto<ProgramDto>>() { Decorator<ReferentialReferenceDto<ProgramDto>> decorator = - ObserveSwingApplicationContext.get().getDecoratorService().getReferenceDecorator(ProgramDto.class); + ObserveSwingApplicationContext.get().getDecoratorService().getReferentialReferenceDecorator(ProgramDto.class); @Override public int compare(ReferenceDto<ProgramDto> o1, ReferenceDto<ProgramDto> o2) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivityLonglineNodeMenuPopulator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivityLonglineNodeMenuPopulator.java index 4697333..83cfce2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivityLonglineNodeMenuPopulator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivityLonglineNodeMenuPopulator.java @@ -5,9 +5,9 @@ import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.ui.DecoratorService; -import fr.ird.observe.ui.tree.DtoNodeSupport; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.TripLonglineNode; import fr.ird.observe.ui.tree.actions.ChangeActivityTripActionListener; import fr.ird.observe.ui.tree.actions.NodeChangeActionListener; import fr.ird.observe.ui.util.DecoratedNodeEntity; @@ -43,21 +43,19 @@ public class MoveActivityLonglineNodeMenuPopulator extends MoveNodeMenuPopulator ObserveNode programNode = parentNode.getParent(); DecoratorService decoratorService = treeHelper.getTreeCellRenderer().getDecoratorService(); - Decorator<ReferenceDto> tripDecorator = - decoratorService.getDecoratorByType(ReferenceDto.class, TripLonglineDto.class.getSimpleName()); + Decorator<ReferenceDto<TripLonglineDto>> tripDecorator = decoratorService.getReferenceDecorator(TripLonglineDto.class); - for (int i = 0, n = programNode.getChildCount() ; i < n ; i++) { + for (int i = 0, n = programNode.getChildCount(); i < n; i++) { - ObserveNode tripNode = programNode.getChildAt(i); + TripLonglineNode tripNode = (TripLonglineNode) programNode.getChildAt(i); String tripId = tripNode.getId(); // si le noeud de marée n'est pas le même que le parent actuel - if (!parentNode.equals(tripNode) - // si le noeud est bien un noeud de marée longline - && IdDtos.isTripLonglineId(tripId)) { + // si le noeud est bien un noeud de marée longline + if (!parentNode.equals(tripNode) && IdDtos.isTripLonglineId(tripId)) { + + possibleParents.add(DecoratedNodeEntity.newDecoratedNodeEntity(tripNode, tripDecorator)); - String decoratedTrip = tripDecorator.toString(((DtoNodeSupport) tripNode).getEntity()); - possibleParents.add(new DecoratedNodeEntity(tripId, decoratedTrip)); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivitySeineNodeMenuPopulator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivitySeineNodeMenuPopulator.java index 719c393..909203b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivitySeineNodeMenuPopulator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveActivitySeineNodeMenuPopulator.java @@ -5,9 +5,9 @@ import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.ui.DecoratorService; -import fr.ird.observe.ui.tree.DtoNodeSupport; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.RouteSeineNode; import fr.ird.observe.ui.tree.actions.ChangeActivityRouteActionListener; import fr.ird.observe.ui.tree.actions.NodeChangeActionListener; import fr.ird.observe.ui.util.DecoratedNodeEntity; @@ -43,21 +43,19 @@ public class MoveActivitySeineNodeMenuPopulator extends MoveNodeMenuPopulator { ObserveNode routesNode = parentNode.getParent(); DecoratorService decoratorService = treeHelper.getTreeCellRenderer().getDecoratorService(); - Decorator<ReferenceDto> routeDecorator = - decoratorService.getDecoratorByType(ReferenceDto.class, RouteDto.class.getSimpleName()); + Decorator<ReferenceDto<RouteDto>> routeDecorator = decoratorService.getReferenceDecorator(RouteDto.class); - for (int i = 0, n = routesNode.getChildCount() ; i < n ; i++) { + for (int i = 0, n = routesNode.getChildCount(); i < n; i++) { - ObserveNode routeNode = routesNode.getChildAt(i); + RouteSeineNode routeNode = (RouteSeineNode) routesNode.getChildAt(i); String routeId = routeNode.getId(); // si le noeud de marée n'est pas le même que le parent actuel - if (!parentNode.equals(routeNode) - // si le noeud est bien un noeud de marée seine - && IdDtos.isRouteId(routeId)) { + // si le noeud est bien un noeud de marée seine + if (!parentNode.equals(routeNode) && IdDtos.isRouteId(routeId)) { + + possibleParents.add(DecoratedNodeEntity.newDecoratedNodeEntity(routeNode, routeDecorator)); - String decoratedRoute = routeDecorator.toString(((DtoNodeSupport) routeNode).getEntity()); - possibleParents.add(new DecoratedNodeEntity(routeId, decoratedRoute)); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveRouteNodeMenuPopulator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveRouteNodeMenuPopulator.java index b9ea140..5158e8c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveRouteNodeMenuPopulator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveRouteNodeMenuPopulator.java @@ -5,9 +5,9 @@ import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.ui.DecoratorService; -import fr.ird.observe.ui.tree.DtoNodeSupport; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.TripSeineNode; import fr.ird.observe.ui.tree.actions.ChangeRouteTripActionListener; import fr.ird.observe.ui.tree.actions.NodeChangeActionListener; import fr.ird.observe.ui.util.DecoratedNodeEntity; @@ -43,21 +43,19 @@ public class MoveRouteNodeMenuPopulator extends MoveNodeMenuPopulator { ObserveNode programNode = parentNode.getParent(); DecoratorService decoratorService = treeHelper.getTreeCellRenderer().getDecoratorService(); - Decorator<ReferenceDto> tripDecorator = - decoratorService.getDecoratorByType(ReferenceDto.class, TripSeineDto.class.getSimpleName()); + Decorator<ReferenceDto<TripSeineDto>> tripDecorator = decoratorService.getReferenceDecorator(TripSeineDto.class); - for (int i = 0, n = programNode.getChildCount() ; i < n ; i++) { + for (int i = 0, n = programNode.getChildCount(); i < n; i++) { - ObserveNode tripNode = programNode.getChildAt(i); + TripSeineNode tripNode = (TripSeineNode) programNode.getChildAt(i); String tripId = tripNode.getId(); // si le noeud de marée n'est pas le même que le parent actuel - if (!parentNode.equals(tripNode) - // si le noeud est bien un noeud de marée seine - && IdDtos.isTripSeineId(tripId)) { + // si le noeud est bien un noeud de marée seine + if (!parentNode.equals(tripNode) && IdDtos.isTripSeineId(tripId)) { + + possibleParents.add(DecoratedNodeEntity.newDecoratedNodeEntity(tripNode, tripDecorator)); - String decoratedTrip = tripDecorator.toString(((DtoNodeSupport) tripNode).getEntity()); - possibleParents.add(new DecoratedNodeEntity(tripId, decoratedTrip)); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveTripNodeMenuPopulator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveTripNodeMenuPopulator.java index be084c7..c6586fb 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveTripNodeMenuPopulator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/menu/MoveTripNodeMenuPopulator.java @@ -1,14 +1,15 @@ package fr.ird.observe.ui.tree.menu; +import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.constants.GearType; import fr.ird.observe.services.dto.referential.ProgramDto; -import fr.ird.observe.ui.DecoratorService; -import fr.ird.observe.ui.tree.DtoNodeSupport; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; +import fr.ird.observe.ui.tree.ProgramLonglineNode; +import fr.ird.observe.ui.tree.ProgramSeineNode; import fr.ird.observe.ui.tree.actions.ChangeTripProgramActionListener; import fr.ird.observe.ui.tree.actions.NodeChangeActionListener; import fr.ird.observe.ui.util.DecoratedNodeEntity; @@ -19,7 +20,7 @@ import java.util.List; /** * @author Kevin Morin (Code Lutin) - * @since x.x + * @since 5.0 */ public class MoveTripNodeMenuPopulator extends MoveNodeMenuPopulator { @@ -41,36 +42,43 @@ public class MoveTripNodeMenuPopulator extends MoveNodeMenuPopulator { List<DecoratedNodeEntity> possibleParents = new ArrayList<>(); // noeud longline ? - GearType geartype = IdDtos.isLonglineId(tripNode.getId()) ? GearType.longline : GearType.seine; + GearType gearType = IdDtos.isLonglineId(tripNode.getId()) ? GearType.longline : GearType.seine; // racine ObserveNode rootNode = treeHelper.getRootNode(); - DecoratorService decoratorService = treeHelper.getTreeCellRenderer().getDecoratorService(); - Decorator<ReferenceDto> programDecorator = - decoratorService.getDecoratorByType(ReferenceDto.class, ProgramDto.class.getSimpleName()); + createPossibleParents(parentNode.getId(), possibleParents, gearType, rootNode); - for (int i = 0, n = rootNode.getChildCount() ; i < n ; i++) { + return possibleParents; + } + + public static void createPossibleParents(String oldProgramId, List<DecoratedNodeEntity> possibleParents, GearType gearType, ObserveNode rootNode) { + + Decorator<ReferenceDto<ProgramDto>> programDecorator = ObserveSwingApplicationContext.get().getDecoratorService().getReferenceDecorator(ProgramDto.class); + + for (int i = 0, n = rootNode.getChildCount(); i < n; i++) { ObserveNode programNode = rootNode.getChildAt(i); String programId = programNode.getId(); // si le noeud programme n'est pas le même que le parent actuel - if (!parentNode.equals(programNode) - // si le noeud est bien un noeud de programme - && IdDtos.isProgramId(programId)) { + // si le noeud est bien un noeud de programme + if (IdDtos.isProgramId(programId) && !oldProgramId.equals(programId)) { + + if (programNode instanceof ProgramSeineNode && GearType.seine == gearType) { - ReferenceDto<ProgramDto> program = ((DtoNodeSupport) programNode).getEntity(); + ProgramSeineNode node = (ProgramSeineNode) programNode; + possibleParents.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator)); - // si le type de marée et le type de prgramme sont les même - if (geartype.equals(program.getPropertyValue(ProgramDto.PROPERTY_GEAR_TYPE))) { + } else if (programNode instanceof ProgramLonglineNode && GearType.longline == gearType) { + + ProgramLonglineNode node = (ProgramLonglineNode) programNode; + possibleParents.add(DecoratedNodeEntity.newDecoratedNodeEntity(node, programDecorator)); - String decoratedProgram = programDecorator.toString(program); - possibleParents.add(new DecoratedNodeEntity(programId, decoratedProgram)); } + } } - - return possibleParents; } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java index 8538cb2..0affb51 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java @@ -123,7 +123,7 @@ public class UsagesUIHandler { typetitle = t(typetitle, typeTitle, size); pane.setColumnHeaderView(new JLabel(typetitle)); List<String> data = new ArrayList<String>(size); - Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecorator(type); + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(type); if (decorator == null) { throw new NullPointerException( "could not find decorator for type " + type); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/DecoratedNodeEntity.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/DecoratedNodeEntity.java index 0b61312..d34b546 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/DecoratedNodeEntity.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/DecoratedNodeEntity.java @@ -1,6 +1,7 @@ package fr.ird.observe.ui.util; import com.google.common.base.Preconditions; +import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.ui.tree.DtoNodeSupport; import org.nuiton.decorator.Decorator; @@ -12,19 +13,13 @@ import org.nuiton.decorator.Decorator; public class DecoratedNodeEntity { private final String id; - private final String label; - public DecoratedNodeEntity(String id, String label) { - this.id = id; - this.label = label; - } + private final String label; - public DecoratedNodeEntity(DtoNodeSupport node, Decorator<ReferenceDto> decorator) { + public static <E extends IdDto> DecoratedNodeEntity newDecoratedNodeEntity(DtoNodeSupport<E> node, Decorator<ReferenceDto<E>> decorator) { Preconditions.checkNotNull(node); Preconditions.checkNotNull(decorator); - - this.id = node.getId(); - this.label = decorator.toString(node.getEntity()); + return new DecoratedNodeEntity(node.getId(), decorator.toString(node.getEntity())); } public String getId() { @@ -36,4 +31,9 @@ public class DecoratedNodeEntity { return label; } + protected DecoratedNodeEntity(String id, String label) { + this.id = id; + this.label = label; + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TargetCatchDecorator.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TargetCatchDecorator.java new file mode 100644 index 0000000..3a3ee5c --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/decorator/TargetCatchDecorator.java @@ -0,0 +1,53 @@ +/* + * #%L + * ObServe :: Business + * %% + * Copyright (C) 2008 - 2011 IRD, Codelutin, Tony Chemit + * %% + * 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% + */ +package fr.ird.observe.ui.util.decorator; + +import fr.ird.observe.services.dto.seine.TargetCatchDto; +import org.apache.commons.jxpath.JXPathContext; + +/** + * Decorator of {@link TargetCatchDto}. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.4 + */ +public class TargetCatchDecorator extends ObserveDecorator<TargetCatchDto> { + + private static final long serialVersionUID = 1L; + + public TargetCatchDecorator() { + super(TargetCatchDto.class, + "${species/scientificLabel}$s##${weightCategory/label}$s##${catchWeight}$f" + ); + } + + @Override + protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, + String token) { + Comparable<Comparable<?>> value = super.getTokenValue(jxcontext, token); + if (token.equals("species/scientificLabel") && + "xx".equals(String.valueOf(value))) { + value = super.getTokenValue(jxcontext, "species/label"); + } + return value; + } +} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySimpleSpeedDtoValidator.java b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySimpleSpeedDtoValidator.java index 389e461..005df01 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySimpleSpeedDtoValidator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySimpleSpeedDtoValidator.java @@ -172,15 +172,15 @@ public class ActivitySimpleSpeedDtoValidator extends FieldValidatorSupport { } protected String decorate(ActivitySeineDto activitySeine) { - return ObserveSwingApplicationContext.get().getDecorator(ActivitySeineDto.class).toString(activitySeine); + return ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(ActivitySeineDto.class).toString(activitySeine); } protected String decorate(ActivitySeineStubDto activitySeine) { - return ObserveSwingApplicationContext.get().getDecorator(ActivitySeineStubDto.class).toString(activitySeine); + return ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(ActivitySeineStubDto.class).toString(activitySeine); } protected String decorate(GPSPoint currentPoint) { - return ObserveSwingApplicationContext.get().getDecorator(GPSPoint.class).toString(currentPoint); + return ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(GPSPoint.class).toString(currentPoint); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySpeedDtoValidator.java b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySpeedDtoValidator.java index 530b548..5c69c48 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySpeedDtoValidator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/ActivitySpeedDtoValidator.java @@ -98,11 +98,11 @@ public class ActivitySpeedDtoValidator extends FieldValidatorSupport { } protected String decorate(ActivitySeineStubDto activitySeine) { - return ObserveSwingApplicationContext.get().getDecorator(ActivitySeineStubDto.class).toString(activitySeine); + return ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(ActivitySeineStubDto.class).toString(activitySeine); } protected String decorate(GPSPoint currentPoint) { - return ObserveSwingApplicationContext.get().getDecorator(GPSPoint.class).toString(currentPoint); + return ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(GPSPoint.class).toString(currentPoint); } public CollectionFieldExpressionValidator getDelegate(final RouteDto route) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueHomeIdDtoValidator.java b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueHomeIdDtoValidator.java index f79007a..cffadf5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueHomeIdDtoValidator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueHomeIdDtoValidator.java @@ -63,7 +63,7 @@ public class SetLonglineUniqueHomeIdDtoValidator extends FieldValidatorSupport { ReferenceDto<ActivityLonglineDto> activityLonglineRef = sameHomeIdSetLonglineOptional.get().getActivityLongline(); - Decorator<ReferenceDto> decorator = ObserveSwingApplicationContext.get().getDecorator(ReferenceDto.class, ActivityLonglineDto.class.getSimpleName()); + Decorator<ReferenceDto<ActivityLonglineDto>> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getReferenceDecorator(ActivityLonglineDto.class); stack.set("duplicatedActivity", decorator.toString(activityLonglineRef)); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueNumberDtoValidator.java b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueNumberDtoValidator.java index 8b1502b..147bed8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueNumberDtoValidator.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/validation/validator/dto/SetLonglineUniqueNumberDtoValidator.java @@ -63,7 +63,7 @@ public class SetLonglineUniqueNumberDtoValidator extends FieldValidatorSupport { ReferenceDto<ActivityLonglineDto> activityLonglineRef = sameNumberSetLonglineOptional.get().getActivityLongline(); - Decorator<ReferenceDto> decorator = ObserveSwingApplicationContext.get().getDecorator(ReferenceDto.class, ActivityLonglineDto.class.getSimpleName()); + Decorator<Class<ActivityLonglineDto>> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecorator(ActivityLonglineDto.class); stack.set("duplicatedActivity", decorator.toString(activityLonglineRef)); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm