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 f1d0845df1a27e41c404a6c1e649aba25c39f88f Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 22 15:31:50 2016 +0200 libération de listeners quand on quitte l'écran --- .../frequency/SpeciesFrequencyUIHandler.java | 55 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 10 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 7914bae..1a9f751 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 @@ -91,6 +91,8 @@ import java.awt.Component; import java.awt.Font; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; import java.io.Serializable; import java.util.ArrayList; @@ -136,6 +138,14 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci * To consume measures when they arrive from the caliper. */ protected final CaliperFeedReaderListener caliperFeedReaderListener; + /** + * Pour écouter quand le big fin se connecte. + */ + protected final PropertyChangeListener listenIchtyomerIsConnected; + /** + * Pour écouter quand le pied à coulisse se connecte. + */ + protected final PropertyChangeListener listenCaliperIsConnected; protected ApplySpeciesFrequencyRafaleAction applySpeciesFrequencyRafaleAction; @@ -192,6 +202,36 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } }; + this.listenIchtyomerIsConnected = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + boolean connected = (boolean) evt.getNewValue(); + + if (connected && SpeciesFrequencyUIHandler.this.frequencyEditor != null) { + + // listen when itchtyometer is connected and this ui is showing + SpeciesFrequencyUIHandler.this.listenItchtyometer(); + } + + SwingUtilities.invokeLater(SpeciesFrequencyUIHandler.this::updateLogVisibility); + } + }; + + this.listenCaliperIsConnected = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + boolean connected = (boolean) evt.getNewValue(); + + if (connected && SpeciesFrequencyUIHandler.this.frequencyEditor != null) { + + // listen when caliper is connected and this ui is showing + SpeciesFrequencyUIHandler.this.listenCaliper(); + } + + SwingUtilities.invokeLater(SpeciesFrequencyUIHandler.this::updateLogVisibility); + } + }; + } //------------------------------------------------------------------------// @@ -327,17 +367,10 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci this.ui.setContextValue(model); // listen when ichtyometer is connected or not and adjust the listener - getContext().addPropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, evt -> { - boolean connected = (boolean) evt.getNewValue(); - - if (connected && SpeciesFrequencyUIHandler.this.frequencyEditor != null) { + getContext().addPropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, listenIchtyomerIsConnected); - // listen when itchtyometer is connected and this ui is showing - listenItchtyometer(); - } - - SwingUtilities.invokeLater(this::updateLogVisibility); - }); + // listen when caliper is connected or not and adjust the listener + getContext().addPropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperIsConnected); } @@ -546,6 +579,8 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci model.setModify(false); TuttiUIContext context = getContext(); + context.removePropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, listenIchtyomerIsConnected); + context.removePropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperIsConnected); if (context.isIchtyometerConnected()) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.