This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 287ca4198fee469327bd3e3bdc6806be63528c51 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 27 15:25:09 2016 +0200 Bien libérer les listener quand on quitte l'écran --- .../frequency/SpeciesFrequencyUIHandler.java | 63 +++++++++++----------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index f27ddab..c89c608 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -163,6 +163,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci protected Decorator<Caracteristic> caracteristicTipDecorator; protected Decorator<CaracteristicQualitativeValue> caracteristicQualitativeDecorator; protected SoundEngine soundEngine; + protected PropertyChangeListener listenFishingOperationReloadInDataContext; public SpeciesFrequencyUIHandler() { @@ -236,6 +237,19 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } }; + // pour recharger l'opération dans le modèle quand celle ci a changée (après une sauvegarde de l'opération par exemple) + this.listenFishingOperationReloadInDataContext = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + TuttiDataContext source = (TuttiDataContext) event.getSource(); + FishingOperation fishingOperation = source.getFishingOperation(); + if (log.isInfoEnabled()) { + log.info("Reloading fishing operation in model: " + fishingOperation); + } + SpeciesFrequencyUIHandler.this.getModel().setFishingOperation(fishingOperation); + } + }; + } //------------------------------------------------------------------------// @@ -356,15 +370,9 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci TuttiDataContext dataContext = getDataContext(); SampleCategoryModel sampleCategoryModel = dataContext.getSampleCategoryModel(); - // get the default caracteristics + // get the default caracteristics from protocol List<Caracteristic> protocolIndividualObservationCaracteristics = new ArrayList<>(dataContext.getDefaultIndividualObservationCaracteristics()); - -// // on ajoute toujours la colonne sex -// if (!protocolCaracteristic.contains(sexCaracteristic)) { -// protocolCaracteristic.add(0, sexCaracteristic); -// } - Optional<CruiseCache> optionalCruiseCache = dataContext.getOptionalCruiseCache(); if (!optionalCruiseCache.isPresent()) { throw new IllegalStateException("Can't find cruise cache"); @@ -389,15 +397,8 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci // listen when caliper is connected or not and adjust the listener getContext().addPropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperIsConnected); - // pour recharger l'opération dans le modèle quand celle ci a changée (après une sauvegarde de l'opération par exemple) - getDataContext().addPropertyChangeListener(TuttiDataContext.PROPERTY_FISHING_OPERATION_ID, event -> { - TuttiDataContext source = (TuttiDataContext) event.getSource(); - FishingOperation fishingOperation = source.getFishingOperation(); - if (log.isInfoEnabled()) { - log.info("Reloading fishing operation in model: " + fishingOperation); - } - model.setFishingOperation(fishingOperation); - }); + // listen when fishing operation reloaded in data context to propagate it to our model + getDataContext().addPropertyChangeListener(TuttiDataContext.PROPERTY_FISHING_OPERATION_ID, listenFishingOperationReloadInDataContext); } @@ -590,6 +591,22 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci log.debug("closing: " + ui); } + getDataContext().removePropertyChangeListener(TuttiDataContext.PROPERTY_FISHING_OPERATION_ID, listenFishingOperationReloadInDataContext); + + TuttiUIContext context = getContext(); + context.removePropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, listenIchtyomerIsConnected); + context.removePropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperIsConnected); + + if (context.isIchtyometerConnected()) { + + context.getIchtyometerReader().removeFeedModeReaderListener(ichtyometerFeedReaderListener); + } + + if (context.isCaliperConnected()) { + + context.getCaliperReader().removeFeedModeReaderListener(caliperFeedReaderListener); + } + SpeciesFrequencyUIModel model = getModel(); IOUtils.closeQuietly(individualObservationBatchTableHandler); @@ -608,20 +625,6 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci model.setSimpleCount(null); model.setModify(false); - TuttiUIContext context = getContext(); - context.removePropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, listenIchtyomerIsConnected); - context.removePropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperIsConnected); - - if (context.isIchtyometerConnected()) { - - context.getIchtyometerReader().removeFeedModeReaderListener(ichtyometerFeedReaderListener); - } - - if (context.isCaliperConnected()) { - - context.getCaliperReader().removeFeedModeReaderListener(caliperFeedReaderListener); - } - EditSpeciesBatchPanelUI parent = getParentContainer(EditSpeciesBatchPanelUI.class); parent.switchToEditBatch(); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.