branch feature/refactor_external_devices created (now 839a37c)
This is an automated email from the git hooks/post-receive script. New change to branch feature/refactor_external_devices in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git at 839a37c Ajout d'un nouveau handler dédié aux external devices This branch includes the following new commits: new 839a37c Ajout d'un nouveau handler dédié aux external devices The 1 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 839a37cf2518fc591613321017023ee77c35ae95 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 22 15:26:28 2016 +0200 Ajout d'un nouveau handler dédié aux external devices -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/refactor_external_devices in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 839a37cf2518fc591613321017023ee77c35ae95 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Apr 22 15:26:28 2016 +0200 Ajout d'un nouveau handler dédié aux external devices --- .../species/frequency/ExternalDevicesHandler.java | 237 ++++++++++++ .../frequency/SpeciesFrequencyUIHandler.java | 407 +++++++++++---------- .../species/frequency/SpeciesFrequencyUIModel.java | 22 ++ 3 files changed, 477 insertions(+), 189 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/ExternalDevicesHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/ExternalDevicesHandler.java new file mode 100644 index 0000000..c325375 --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/ExternalDevicesHandler.java @@ -0,0 +1,237 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; + +import com.google.common.base.Preconditions; +import fr.ifremer.tutti.caliper.feed.CaliperFeedReader; +import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderListener; +import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderMeasureRecord; +import fr.ifremer.tutti.ichtyometer.feed.IchtyometerFeedReader; +import fr.ifremer.tutti.ichtyometer.feed.event.IchtyometerFeedReaderListener; +import fr.ifremer.tutti.ichtyometer.feed.record.IchtyometerFeedReaderMeasureRecord; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.actions.ApplySpeciesFrequencyRafaleAction; +import fr.ifremer.tutti.ui.swing.util.SoundEngine; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.application.ApplicationBusinessException; + +import javax.swing.SwingUtilities; +import java.beans.PropertyChangeListener; +import java.io.Closeable; +import java.io.IOException; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created on 22/04/16. + * + * @author Tony Chemit - chemit@codelutin.com + */ +public class ExternalDevicesHandler implements Closeable { + + /** Logger. */ + private static final Log log = LogFactory.getLog(ExternalDevicesHandler.class); + + private final SoundEngine soundEngine; + private final SpeciesFrequencyUIModel model; + /** + * To consume measures when they arrive from the ichtyometer. + */ + private final IchtyometerFeedReaderListener ichtyometerFeedReaderListener; + /** + * To consume measures when they arrive from the caliper. + */ + private final CaliperFeedReaderListener caliperFeedReaderListener; + + private final ApplySpeciesFrequencyRafaleAction applySpeciesFrequencyRafaleAction; + protected final TuttiUIContext tuttiUIContext; + protected final PropertyChangeListener listenIchtyometerConnected; + protected final PropertyChangeListener listenCaliperConnected; + + public ExternalDevicesHandler(SpeciesFrequencyUI ui, ApplySpeciesFrequencyRafaleAction applySpeciesFrequencyRafaleAction) { + + this.model = ui.getModel(); + this.tuttiUIContext = ui.getHandler().getContext(); + this.soundEngine = tuttiUIContext.getSoundEngine(); + this.applySpeciesFrequencyRafaleAction = applySpeciesFrequencyRafaleAction; + + this.ichtyometerFeedReaderListener = event -> SwingUtilities.invokeLater( + () -> { + if (!model.isSimpleCountingMode()) { + + // can try to consume value + IchtyometerFeedReaderMeasureRecord record = event.getRecord(); + consumeIchtyometerFeedRecord(record); + } + } + ); + + this.caliperFeedReaderListener = event -> SwingUtilities.invokeLater( + () -> { + if (!model.isSimpleCountingMode()) { + + // can try to consume value + CaliperFeedReaderMeasureRecord record = event.getRecord(); + consumeCaliperFeedRecord(record); + } + } + ); + + // listen when ichtyometer is connected or not and adjust the listener + this.listenIchtyometerConnected = event -> { + boolean connected = (boolean) event.getNewValue(); + + if (connected) { + + // listen when itchtyometer is connected and this ui is showing + listenItchtyometer(); + } + + boolean rafaleMode = model.isRafaleMode(); + boolean caliperConnected = tuttiUIContext.isCaliperConnected(); + model.recomputeLogTableIsvisible(rafaleMode, connected, caliperConnected); + + }; + tuttiUIContext.addPropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, listenIchtyometerConnected); + + // listen when calipter is connected or not and adjust the listener + this.listenCaliperConnected = event -> { + boolean connected = (boolean) event.getNewValue(); + + if (connected) { + + // listen when calipser is connected and this ui is showing + listenCaliper(); + } + + boolean rafaleMode = model.isRafaleMode(); + boolean ichtyometerConnected = tuttiUIContext.isIchtyometerConnected(); + model.recomputeLogTableIsvisible(rafaleMode, ichtyometerConnected, connected); + + }; + tuttiUIContext.addPropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperConnected); + + } + + public void editBatch(SpeciesBatchRowModel speciesBatch) { + + if (tuttiUIContext.isIchtyometerConnected()) { + + // let's listen the ichtyometer + listenItchtyometer(); + + } + + if (tuttiUIContext.isCaliperConnected()) { + + // let's listen the caliper + listenCaliper(); + + } + } + + @Override + public void close() throws IOException { + + tuttiUIContext.removePropertyChangeListener(TuttiUIContext.PROPERTY_ICHTYOMETER_CONNECTED, listenIchtyometerConnected); + tuttiUIContext.removePropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperConnected); + + if (tuttiUIContext.isIchtyometerConnected()) { + tuttiUIContext.getIchtyometerReader().removeFeedModeReaderListener(ichtyometerFeedReaderListener); + } + + if (tuttiUIContext.isCaliperConnected()) { + tuttiUIContext.getCaliperReader().removeFeedModeReaderListener(caliperFeedReaderListener); + } + + } + + protected void consumeIchtyometerFeedRecord(IchtyometerFeedReaderMeasureRecord record) { + if (record.isValid()) { + + String unit = model.getLengthStepCaracteristicUnit(); + + // board measurements are in mm + + float length; + + if ("mm".equals(unit)) { + + // measurement in mm asked + length = record.getMeasure(); + + } else { + + // measurement in cm asked + length = record.getMeasure() / 10f; + + } + + applySpeciesFrequencyRafaleAction.applyRafaleStep(length, true); + + } else { + + soundEngine.beepOnExternalDeviceErrorReception(); + + throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.itchyometer.bad.record", record.getRecord())); + } + } + + protected void consumeCaliperFeedRecord(CaliperFeedReaderMeasureRecord record) { + if (record.isValid()) { + + String unit = model.getLengthStepCaracteristicUnit(); + + // board measurements are in mm + + float length; + + if ("mm".equals(unit)) { + + // measurement in mm asked + length = record.getMeasure(); + + } else { + + // measurement in cm asked + length = record.getMeasure() / 10f; + + } + + applySpeciesFrequencyRafaleAction.applyRafaleStep(length, true); + + } else { + + soundEngine.beepOnExternalDeviceErrorReception(); + + throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.caliper.bad.record", record.getRecord())); + } + } + + protected void listenItchtyometer() { + + Preconditions.checkState(tuttiUIContext.isIchtyometerConnected()); + + IchtyometerFeedReader ichtyometerReader = tuttiUIContext.getIchtyometerReader(); + + // always remove the listener before adding it to be sure it will not be there twice + ichtyometerReader.removeAllFeedModeReaderListeners(); + if (log.isInfoEnabled()) { + log.info("Start listen ichtyometer"); + } + ichtyometerReader.addFeedModeReaderListener(ichtyometerFeedReaderListener); + } + + protected void listenCaliper() { + + Preconditions.checkState(tuttiUIContext.isCaliperConnected()); + + CaliperFeedReader caliperReader = tuttiUIContext.getCaliperReader(); + // always remove the listener before adding it to be sure it will not be there twice + caliperReader.removeAllFeedModeReaderListeners(); + if (log.isInfoEnabled()) { + log.info("Start listen caliper"); + } + caliperReader.addFeedModeReaderListener(caliperFeedReaderListener); + } +} 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..615d442 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 @@ -22,12 +22,6 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; * #L% */ -import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderEvent; -import fr.ifremer.tutti.caliper.feed.event.CaliperFeedReaderListener; -import fr.ifremer.tutti.caliper.feed.record.CaliperFeedReaderMeasureRecord; -import fr.ifremer.tutti.ichtyometer.feed.event.IchtyometerFeedReaderEvent; -import fr.ifremer.tutti.ichtyometer.feed.event.IchtyometerFeedReaderListener; -import fr.ifremer.tutti.ichtyometer.feed.record.IchtyometerFeedReaderMeasureRecord; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.CopyIndividualObservationMode; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; @@ -41,13 +35,11 @@ import fr.ifremer.tutti.persistence.entities.referential.TaxonCache; import fr.ifremer.tutti.persistence.entities.referential.TaxonCaches; import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.type.WeightUnit; -import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.EditSpeciesBatchPanelUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesOrBenthosBatchUISupport; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyCellComponent.FrequencyCellEditor; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.actions.ApplySpeciesFrequencyRafaleAction; -import fr.ifremer.tutti.ui.swing.util.SoundEngine; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; @@ -72,7 +64,6 @@ import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.jdesktop.swingx.table.TableColumnExt; import org.jdesktop.swingx.table.TableColumnModelExt; import org.nuiton.decorator.Decorator; -import org.nuiton.jaxx.application.ApplicationBusinessException; import org.nuiton.jaxx.application.swing.AbstractApplicationUIHandler; import org.nuiton.jaxx.application.swing.table.ColumnIdentifier; @@ -128,14 +119,14 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci */ protected WeightUnit weightUnit; - /** - * To consume measures when they arrive from the ichtyometer. - */ - protected final IchtyometerFeedReaderListener ichtyometerFeedReaderListener; - /** - * To consume measures when they arrive from the caliper. - */ - protected final CaliperFeedReaderListener caliperFeedReaderListener; +// /** +// * To consume measures when they arrive from the ichtyometer. +// */ +// protected final IchtyometerFeedReaderListener ichtyometerFeedReaderListener; +// /** +// * To consume measures when they arrive from the caliper. +// */ +// protected final CaliperFeedReaderListener caliperFeedReaderListener; protected ApplySpeciesFrequencyRafaleAction applySpeciesFrequencyRafaleAction; @@ -145,6 +136,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci protected AverageWeightsHistogramHandler averageWeightsHistogramHandler; protected FrequenciesHistogramHandler frequenciesHistogramHandler; protected SamplingNotificationZoneHandler samplingNotificationZoneHandler; + protected ExternalDevicesHandler externalDevicesHandler; protected Decorator<Caracteristic> caracteristicDecorator; protected Decorator<Caracteristic> caracteristicTipDecorator; @@ -156,41 +148,41 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci SpeciesFrequencyRowModel.PROPERTY_NUMBER, SpeciesFrequencyRowModel.PROPERTY_WEIGHT); - this.ichtyometerFeedReaderListener = new IchtyometerFeedReaderListener() { - - @Override - public void recordRead(IchtyometerFeedReaderEvent event) { - final IchtyometerFeedReaderMeasureRecord record = event.getRecord(); - - SwingUtilities.invokeLater( - () -> { - if (!getModel().isSimpleCountingMode()) { - - // can try to consume value - consumeIchtyometerFeedRecord(record); - } - } - ); - } - }; - - this.caliperFeedReaderListener = new CaliperFeedReaderListener() { - - @Override - public void recordRead(CaliperFeedReaderEvent event) { - final CaliperFeedReaderMeasureRecord record = event.getRecord(); - - SwingUtilities.invokeLater( - () -> { - if (!getModel().isSimpleCountingMode()) { - - // can try to consume value - consumeCaliperFeedRecord(record); - } - } - ); - } - }; +// this.ichtyometerFeedReaderListener = new IchtyometerFeedReaderListener() { +// +// @Override +// public void recordRead(IchtyometerFeedReaderEvent event) { +// final IchtyometerFeedReaderMeasureRecord record = event.getRecord(); +// +// SwingUtilities.invokeLater( +// () -> { +// if (!getModel().isSimpleCountingMode()) { +// +// // can try to consume value +// consumeIchtyometerFeedRecord(record); +// } +// } +// ); +// } +// }; +// +// this.caliperFeedReaderListener = new CaliperFeedReaderListener() { +// +// @Override +// public void recordRead(CaliperFeedReaderEvent event) { +// final CaliperFeedReaderMeasureRecord record = event.getRecord(); +// +// SwingUtilities.invokeLater( +// () -> { +// if (!getModel().isSimpleCountingMode()) { +// +// // can try to consume value +// consumeCaliperFeedRecord(record); +// } +// } +// ); +// } +// }; } @@ -326,18 +318,18 @@ 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) { - - // listen when itchtyometer is connected and this ui is showing - listenItchtyometer(); - } - - SwingUtilities.invokeLater(this::updateLogVisibility); - }); +// // 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) { +// +// // listen when itchtyometer is connected and this ui is showing +// listenItchtyometer(); +// } +// +// SwingUtilities.invokeLater(this::updateLogVisibility); +// }); } @@ -438,6 +430,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci // when configuration mode change, let's focus the best component (see http://forge.codelutin.com/issues/4035) model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_FREQUENCIES_CONFIGURATION_MODE, evt -> { + SpeciesFrequencyUIModel source = (SpeciesFrequencyUIModel) evt.getSource(); FrequencyConfigurationMode newValue = (FrequencyConfigurationMode) evt.getNewValue(); SwingUtilities.invokeLater( () -> { @@ -445,11 +438,41 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci if (componentToFocus != null) { componentToFocus.grabFocus(); } - updateLogVisibility(); + //FIXME Pourquoi ceic est fait dans ce listener ? + boolean rafaleMode = source.isRafaleMode(); + boolean ichtyometerConnected = getContext().isIchtyometerConnected(); + boolean caliperConnected = getContext().isCaliperConnected(); + model.recomputeLogTableIsvisible(rafaleMode, ichtyometerConnected, caliperConnected); +// updateLogVisibility(); } ); }); + // Pour recalculer la visibilité du tableau des logs + model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_RAFALE_MODE, evt -> { + boolean newRafaleMode = (boolean) evt.getNewValue(); + boolean ichtyometerConnected = getContext().isIchtyometerConnected(); + boolean caliperConnected = getContext().isCaliperConnected(); + model.recomputeLogTableIsvisible(newRafaleMode, ichtyometerConnected, caliperConnected); + }); + + // Pour afficher ou non le tableau des logs + model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LOG_TABLE_VISIBLE, evt -> { + boolean logTableIsVisible = (boolean) evt.getNewValue(); + JSplitPane firstSplitPane = ui.getFirstSplitPane(); + JSplitPane secondSplitPane = ui.getSecondSplitPane(); + + int lastDividerLocation = secondSplitPane.getLastDividerLocation(); + if (lastDividerLocation == 0) { + lastDividerLocation = 200; + } + secondSplitPane.setDividerLocation(logTableIsVisible ? lastDividerLocation : 0); + secondSplitPane.setDividerSize(logTableIsVisible ? firstSplitPane.getDividerSize() : 0); + + ui.getLogsScrollPane().setVisible(logTableIsVisible); + }); + + // Pour bloquer le changement de copie des poids rtp s'il y a deja des poids model.addVetoableChangeListener(SpeciesFrequencyUIModel.PROPERTY_COPY_RTP_WEIGHTS, evt -> { @@ -479,6 +502,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci } }); + // Pour recalculer les poids des mensurations quand l'utilisation des poids rtp change model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_COPY_RTP_WEIGHTS, evt -> { getModel().getRows().forEach(row -> getModel().computeRowWeightWithRtp(row)); getModel().reloadRows(); @@ -506,6 +530,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci this.averageWeightsHistogramHandler = new AverageWeightsHistogramHandler(ui); this.frequenciesHistogramHandler = new FrequenciesHistogramHandler(ui); this.samplingNotificationZoneHandler = new SamplingNotificationZoneHandler(ui, model.getIndividualObservationModel().getSamplingNotificationZoneModel()); + this.externalDevicesHandler = new ExternalDevicesHandler(ui, applySpeciesFrequencyRafaleAction); listenValidatorValid(ui.getValidator(), model); @@ -533,6 +558,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci IOUtils.closeQuietly(averageWeightsHistogramHandler); IOUtils.closeQuietly(frequenciesHistogramHandler); IOUtils.closeQuietly(samplingNotificationZoneHandler); + IOUtils.closeQuietly(externalDevicesHandler); frequencyEditor = null; @@ -545,17 +571,17 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci model.setSimpleCount(null); model.setModify(false); - TuttiUIContext context = getContext(); - - if (context.isIchtyometerConnected()) { - - context.getIchtyometerReader().removeFeedModeReaderListener(ichtyometerFeedReaderListener); - } - - if (context.isCaliperConnected()) { - - context.getCaliperReader().removeFeedModeReaderListener(caliperFeedReaderListener); - } +// TuttiUIContext context = getContext(); +// +// if (context.isIchtyometerConnected()) { +// +// context.getIchtyometerReader().removeFeedModeReaderListener(ichtyometerFeedReaderListener); +// } +// +// if (context.isCaliperConnected()) { +// +// context.getCaliperReader().removeFeedModeReaderListener(caliperFeedReaderListener); +// } EditSpeciesBatchPanelUI parent = getParentContainer(EditSpeciesBatchPanelUI.class); parent.switchToEditBatch(); @@ -631,20 +657,21 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci loadFrequenciesAndObservations(frequency, individualObservations); samplingNotificationZoneHandler.editBatch(speciesBatch); - - if (getContext().isIchtyometerConnected()) { - - // let's listen the ichtyometer - listenItchtyometer(); - - } - - if (getContext().isCaliperConnected()) { - - // let's listen the caliper - listenCaliper(); - - } + externalDevicesHandler.editBatch(speciesBatch); + +// if (getContext().isIchtyometerConnected()) { +// +// // let's listen the ichtyometer +// listenItchtyometer(); +// +// } +// +// if (getContext().isCaliperConnected()) { +// +// // let's listen the caliper +// listenCaliper(); +// +// } model.setModify(false); @@ -721,7 +748,7 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci // on repositionne sur le bon radio-bouton // le code n'est pas optimal mais est moins dangeureux que de relancer des fires je pense - switch(model.getCopyIndividualObservationMode()) { + switch (model.getCopyIndividualObservationMode()) { case ALL: ui.getCopyAllButton().setSelected(true); break; @@ -951,89 +978,91 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci return col; } - protected void consumeIchtyometerFeedRecord(IchtyometerFeedReaderMeasureRecord record) { - if (record.isValid()) { - - String unit = getModel().getLengthStepCaracteristicUnit(); - - // board measurements are in mm - - float length; - - if ("mm".equals(unit)) { - - // measurement in mm asked - length = record.getMeasure(); - - } else { - - // measurement in cm asked - length = record.getMeasure() / 10f; - - } - - applySpeciesFrequencyRafaleAction.applyRafaleStep(length, true); - - } else { - - SoundEngine soundEngine = getContext().getSoundEngine(); - soundEngine.beepOnExternalDeviceErrorReception(); - - throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.itchyometer.bad.record", record.getRecord())); - } - } - - protected void consumeCaliperFeedRecord(CaliperFeedReaderMeasureRecord record) { - if (record.isValid()) { - - String unit = getModel().getLengthStepCaracteristicUnit(); - - // board measurements are in mm - - float length; - - if ("mm".equals(unit)) { - - // measurement in mm asked - length = record.getMeasure(); - - } else { - - // measurement in cm asked - length = record.getMeasure() / 10f; - - } - - applySpeciesFrequencyRafaleAction.applyRafaleStep(length, true); - - } else { - - SoundEngine soundEngine = getContext().getSoundEngine(); - soundEngine.beepOnExternalDeviceErrorReception(); - - throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.caliper.bad.record", record.getRecord())); - } - } - - protected void listenItchtyometer() { - - // always remove the listener before adding it to be sure it will not be there twice - getContext().getIchtyometerReader().removeAllFeedModeReaderListeners(); - if (log.isInfoEnabled()) { - log.info("Start listen ichtyometer"); - } - getContext().getIchtyometerReader().addFeedModeReaderListener(ichtyometerFeedReaderListener); - } - - protected void listenCaliper() { - - // always remove the listener before adding it to be sure it will not be there twice - getContext().getCaliperReader().removeAllFeedModeReaderListeners(); - if (log.isInfoEnabled()) { - log.info("Start listen caliper"); - } - getContext().getCaliperReader().addFeedModeReaderListener(caliperFeedReaderListener); - } +// protected void consumeIchtyometerFeedRecord(IchtyometerFeedReaderMeasureRecord record) { +// if (record.isValid()) { +// +// String unit = getModel().getLengthStepCaracteristicUnit(); +// +// // board measurements are in mm +// +// float length; +// +// if ("mm".equals(unit)) { +// +// // measurement in mm asked +// length = record.getMeasure(); +// +// } else { +// +// // measurement in cm asked +// length = record.getMeasure() / 10f; +// +// } +// +// applySpeciesFrequencyRafaleAction.applyRafaleStep(length, true); +// +// } else { +// +// SoundEngine soundEngine = getContext().getSoundEngine(); +// soundEngine.beepOnExternalDeviceErrorReception(); +// +// throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.itchyometer.bad.record", record.getRecord())); +// } +// } + +// protected void consumeCaliperFeedRecord(CaliperFeedReaderMeasureRecord record) { +// if (record.isValid()) { +// +// String unit = getModel().getLengthStepCaracteristicUnit(); +// +// // board measurements are in mm +// +// float length; +// +// if ("mm".equals(unit)) { +// +// // measurement in mm asked +// length = record.getMeasure(); +// +// } else { +// +// // measurement in cm asked +// length = record.getMeasure() / 10f; +// +// } +// +// applySpeciesFrequencyRafaleAction.applyRafaleStep(length, true); +// +// } else { +// +// SoundEngine soundEngine = getContext().getSoundEngine(); +// soundEngine.beepOnExternalDeviceErrorReception(); +// +// throw new ApplicationBusinessException(t("tutti.editSpeciesFrequencies.error.caliper.bad.record", record.getRecord())); +// } +// } + +// protected void listenItchtyometer() { +// +// // always remove the listener before adding it to be sure it will not be there twice +// IchtyometerFeedReader ichtyometerReader = getContext().getIchtyometerReader(); +// ichtyometerReader.removeAllFeedModeReaderListeners(); +// if (log.isInfoEnabled()) { +// log.info("Start listen ichtyometer"); +// } +// ichtyometerReader.addFeedModeReaderListener(ichtyometerFeedReaderListener); +// } +// +// protected void listenCaliper() { +// +// // always remove the listener before adding it to be sure it will not be there twice +// CaliperFeedReader caliperReader = getContext().getCaliperReader(); +// caliperReader.removeAllFeedModeReaderListeners(); +// if (log.isInfoEnabled()) { +// log.info("Start listen caliper"); +// } +// caliperReader.addFeedModeReaderListener(caliperFeedReaderListener); +// } protected JComponent getComponentToFocus(FrequencyConfigurationMode mode) { JComponent componentToFocus = null; @@ -1069,21 +1098,21 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci return componentToFocus; } - protected void updateLogVisibility() { - - boolean logVisible = getModel().isRafaleMode() || getContext().isIchtyometerConnected() || getContext().isCaliperConnected(); - JSplitPane firstSplitPane = ui.getFirstSplitPane(); - JSplitPane secondSplitPane = ui.getSecondSplitPane(); - - int lastDividerLocation = secondSplitPane.getLastDividerLocation(); - if (lastDividerLocation == 0) { - lastDividerLocation = 200; - } - secondSplitPane.setDividerLocation(logVisible ? lastDividerLocation : 0); - secondSplitPane.setDividerSize(logVisible ? firstSplitPane.getDividerSize() : 0); - - ui.getLogsScrollPane().setVisible(logVisible); - } +// protected void updateLogVisibility() { +// +// boolean logVisible = getModel().isRafaleMode() || getContext().isIchtyometerConnected() || getContext().isCaliperConnected(); +// JSplitPane firstSplitPane = ui.getFirstSplitPane(); +// JSplitPane secondSplitPane = ui.getSecondSplitPane(); +// +// int lastDividerLocation = secondSplitPane.getLastDividerLocation(); +// if (lastDividerLocation == 0) { +// lastDividerLocation = 200; +// } +// secondSplitPane.setDividerLocation(logVisible ? lastDividerLocation : 0); +// secondSplitPane.setDividerSize(logVisible ? firstSplitPane.getDividerSize() : 0); +// +// ui.getLogsScrollPane().setVisible(logVisible); +// } protected void reloadRowsFromIndividualObservations() { SpeciesFrequencyUIModel model = getModel(); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java index a2e0251..b6cb6b2 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java @@ -112,6 +112,8 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa public static final String PROPERTY_NON_EMPTY_INDIVIDUAL_OBSERVATION_ROWS_IN_ERROR = "nonEmptyIndividualObservationRowsInError"; + public static final String PROPERTY_LOG_TABLE_VISIBLE = "logTableVisible"; + private final SpeciesOrBenthosBatchUISupport speciesOrBenthosBatchUISupport; /** @@ -264,6 +266,11 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa */ private boolean initBatchEdition; + /** + * Can we show the log table ? + */ + private boolean logTableVisible = true; + private final AverageWeightsHistogramModel averageWeightsHistogramModel; private final FrequenciesHistogramModel frequenciesHistogramModel; private final IndividualObservationBatchUIModel individualObservationModel; @@ -854,4 +861,19 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa getRows().clear(); getRowsInError().clear(); } + + public boolean isLogTableVisible() { + return logTableVisible; + } + + public void setLogTableVisible(boolean logTableVisible) { + Object oldValue = isLogTableVisible(); + this.logTableVisible = logTableVisible; + firePropertyChange(PROPERTY_LOG_TABLE_VISIBLE, oldValue, logTableVisible); + } + + public void recomputeLogTableIsvisible(boolean rafaleMode, boolean ichtyometerConnected, boolean caliperConnected) { + boolean logTableVisible = rafaleMode || ichtyometerConnected || caliperConnected; + setLogTableVisible(logTableVisible); + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm