[Git][ultreiaio/ird-observe][develop] Deleted 4 commits: Ajout de la donnée observe_longline.ActivityLogbook (See #907) Maquettage
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below. Deleted commits: 30fedc4d by Tony CHEMIT at 2018-04-03T20:13:33Z Ajout de la donnée observe_longline.ActivityLogbook (See #907) Maquettage - - - - - e6646c3e by Tony CHEMIT at 2018-04-03T20:13:33Z Ajout de la donnée observe_longline.SetLogbook (See #909) - - - - - 018ebdbf by Tony CHEMIT at 2018-04-03T20:13:33Z Ajout de la donnée observe_longline.CatchLogbook (See #911) Maquettage - - - - - 355b9469 by Tony CHEMIT at 2018-04-03T20:13:33Z update i18n (see #911, see #907, see #909) - - - - - 15 changed files: - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUI.jaxx - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUI.jcss - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUIHandler.java - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUIModel.java - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUI.jaxx - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUI.jcss - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUIHandler.java - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUIModel.java - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUI.jaxx - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUI.jcss - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUIHandler.java - + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUIModel.java - client/src/main/resources/i18n/client_en_GB.properties - client/src/main/resources/i18n/client_es_ES.properties - client/src/main/resources/i18n/client_fr_FR.properties Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUI.jaxx ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUI.jaxx @@ -0,0 +1,192 @@ +<!-- + #%L + ObServe :: Client + %% + Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + %% + 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% + --> + +<fr.ird.observe.client.ui.content.open.ContentOpenableUI + i18nFormat="observe.common.ActivityLonglineDto.%s" + superGenericType='ActivityLonglineDto, ActivityLonglineLogbookUI' + contentTitle='{n("observe.common.ActivityLonglineDto.title")}'> + + <style source="../../Common.jcss"/> + + <import> + fr.ird.observe.dto.data.longline.ActivityLonglineDto + fr.ird.observe.dto.data.longline.ActivityLonglineReference + fr.ird.observe.dto.data.longline.SetLonglineDto + fr.ird.observe.dto.referential.FpaZoneReference + fr.ird.observe.dto.referential.longline.VesselActivityLonglineReference + fr.ird.observe.dto.referential.seine.WindReference + fr.ird.observe.dto.referential.DataQualityReference + + fr.ird.observe.client.ui.actions.content.AddActivityLonglineSetUIAction + fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.main.global.DeleteDataGlobalUIAction + fr.ird.observe.client.ui.actions.main.global.OpenDataGlobalUIAction + fr.ird.observe.client.ui.actions.main.global.CloseDataGlobalUIAction + fr.ird.observe.client.ui.actions.main.global.NewNextDataGlobalUIAction + fr.ird.observe.client.ui.util.JComment + + org.nuiton.jaxx.widgets.temperature.TemperatureFormat + org.nuiton.jaxx.widgets.temperature.TemperatureEditor + org.nuiton.jaxx.widgets.temperature.TemperatureEditorConfig + + org.nuiton.jaxx.widgets.number.NumberEditor + org.nuiton.jaxx.widgets.select.BeanComboBox + + org.nuiton.jaxx.widgets.datetime.DateTimeEditor + org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor + + java.awt.Dimension + + static fr.ird.observe.client.ui.util.UIHelper.getStringValue + static org.nuiton.i18n.I18n.n + </import> + + <!-- model --> + <ActivityLonglineLogbookUIModel id='model'/> + + <!-- edit bean --> + <ActivityLonglineDto id='bean'/> + + <!-- validator --> + <BeanValidator id='validator' autoField='true' beanClass='fr.ird.observe.dto.data.longline.ActivityLonglineDto' + errorTableModel='{getErrorTableModel()}' context='create'> + + <field name='longitude' component='coordinatesEditor'/> + <field name='latitude' component='coordinatesEditor'/> + <field name='quadrant' component='coordinatesEditor'/> + + </BeanValidator> + + <!-- formulaire --> + <JPanel id="body"> + <Table fill='both' constraints="BorderLayout.CENTER"> + + <!-- date - time --> + <row> + <cell columns="2" weightx="1"> + <DateTimeEditor id='timeStamp' constructorParams='this'/> + </cell> + </row> + + <!-- position --> + <row> + <cell columns="2" weightx="1"> + <CoordinatesEditor id='coordinatesEditor' constructorParams='this'/> + </cell> + </row> + + <!-- activity vessel --> + <row> + <cell anchor='west'> + <JLabel id='vesselActivityLonglineLabel'/> + </cell> + <cell anchor='east' fill="both"> + <BeanComboBox id='vesselActivityLongline' genericType='VesselActivityLonglineReference' + constructorParams='this'/> + </cell> + </row> + + <!--zone FPA--> + <row> + <cell anchor='west'> + <JLabel id='fpaZoneLabel'/> + </cell> + <cell anchor='east' fill="both"> + <BeanComboBox id='fpaZone' genericType='FpaZoneReference' constructorParams='this'/> + </cell> + </row> + + <!-- vitesse vessel --> + <row> + <cell anchor='west'> + <JLabel id='vesselSpeedLabel'/> + </cell> + <cell anchor='east' weightx="1" fill="both"> + <NumberEditor id='vesselSpeed' constructorParams='this' styleClass="float2"/> + </cell> + </row> + + <!-- température de surface --> + <row> + <cell anchor='west'> + <JLabel id='seaSurfaceTemperatureLabel'/> + </cell> + <cell anchor='east' fill="both"> + <TemperatureEditor id='seaSurfaceTemperature' constructorParams='this'/> + </cell> + </row> + + <!-- vent beaufort --> + <row> + <cell anchor='west'> + <JLabel id='windLabel'/> + </cell> + <cell anchor='east' fill="both"> + <BeanComboBox id='wind' genericType='WindReference' constructorParams='this'/> + </cell> + </row> + + <!-- dataQuality --> + <row> + <cell anchor='west'> + <JLabel id='dataQualityLabel'/> + </cell> + <cell anchor='east' weightx="1" fill="both"> + <BeanComboBox id='dataQuality' genericType='DataQualityReference' constructorParams='this'/> + </cell> + </row> + + <!-- activité observation --> + <row> + <cell anchor='west'> + <JLabel id='relatedObservedActivityLabel'/> + </cell> + <cell anchor='east' fill="both"> + <BeanComboBox id='relatedObservedActivity' genericType='ActivityLonglineReference' constructorParams='this'/> + </cell> + </row> + + <!-- comment --> + <row> + <cell columns='2' weighty="1"> + <JComment id="comment"/> + </cell> + </row> + </Table> + </JPanel> + + <!-- surcharge des actions (pour appliquer la css specifique) --> + <JButton id='delete'/> + <JButton id='reopen'/> + <JButton id='close'/> + <JButton id='closeAndCreate'/> + <JButton id='actionDown'/> + + <Table id='extraActions' fill="both" weightx="1" insets='2'> + <row> + <cell weightx="0.5" fill="both"> + <JButton id='addSet'/> + </cell> + </row> + </Table> + +</fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUI.jcss ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUI.jcss @@ -0,0 +1,99 @@ +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * 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% + */ + +#model { + editable:true; + modified:{validator.isChanged()}; + valid:{validator.isValid()}; +} + +#body { + layout:{new BorderLayout()}; +} + +#extraActions { + visible:{model.isUpdatingMode()}; +} + +#timeStamp { + propertyDate:{ActivityLonglineDto.PROPERTY_TIME_STAMP}; + propertyDayDate:{ActivityLonglineUIModel.PROPERTY_DATE}; + propertyTimeDate:{ActivityLonglineUIModel.PROPERTY_TIME}; + date:{bean.getTimeStamp()}; +} + +#coordinatesEditor { + propertyLatitude:{ActivityLonglineDto.PROPERTY_LATITUDE}; + propertyLongitude:{ActivityLonglineDto.PROPERTY_LONGITUDE}; + propertyQuadrant:{ActivityLonglineDto.PROPERTY_QUADRANT}; +} + +#vesselActivityLongline { + property:{ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE}; + selectedItem:{bean.getVesselActivityLongline()}; + enabled:{!model.isUpdatingMode()}; +} + +#fpaZone { + property:{ActivityLonglineDto.PROPERTY_FPA_ZONE}; + selectedItem:{bean.getFpaZone()}; +} + +#seaSurfaceTemperature { + format:{TemperatureFormat.C}; + storageTemperature:{bean.getSeaSurfaceTemperature()}; +} + +#dataQuality { + property:{ActivityLonglineDto.PROPERTY_DATA_QUALITY}; + selectedItem:{bean.getDataQuality()}; +} + +#reopen { + _toolTipText:{t("observe.common.ActivityDto.action.reopen.tip")}; +} + +#close { + enabled:{!model.isModified() && (model.isHistoricalData() || model.isValid())}; + _toolTipText:{t("observe.common.ActivityDto.action.close.tip")}; +} + +#closeAndCreate { + _globalAction:{NewNextDataGlobalUIAction.ACTION_NAME}; + enabled:{!model.isModified() && (model.isHistoricalData() || model.isValid())}; + _text:{t("observe.common.ActivityDto.action.closeAndCreate")}; + _toolTipText:{t("observe.common.ActivityDto.action.closeAndCreate.tip")}; +} + +#delete { + _globalAction:{DeleteDataGlobalUIAction.ACTION_NAME}; + _toolTipText:{t("observe.common.ActivityDto.action.delete.tip")}; +} + +#addSet { + actionIcon:add; + text:"observe.common.ActivityLonglineDto.action.addSet"; + toolTipText:"observe.common.ActivityLonglineDto.action.addSet.tip"; + enabled:{!model.isModified() && model.isValid() && model.isSetOperation() && ! bean.isHasSetLongline()}; + _observeAction:{AddActivityLonglineSetUIAction.ACTION_NAME}; + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUIHandler.java ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUIHandler.java @@ -0,0 +1,306 @@ +package fr.ird.observe.client.ui.content.data.longline; + +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ird.observe.client.ObserveSwingApplicationContext; +import fr.ird.observe.client.db.ClientDataContext; +import fr.ird.observe.client.db.constants.DataContextType; +import fr.ird.observe.client.ui.content.ContentMode; +import fr.ird.observe.client.ui.content.ContentUIModel; +import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler; +import fr.ird.observe.client.validation.ClientValidationContext; +import fr.ird.observe.dto.data.longline.ActivityLonglineDto; +import fr.ird.observe.dto.data.longline.ActivityLonglineHelper; +import fr.ird.observe.dto.data.longline.TripLonglineDto; +import fr.ird.observe.dto.form.Form; +import fr.ird.observe.dto.reference.DataDtoReference; +import fr.ird.observe.dto.result.TripChildSaveResultDto; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.runtime.spi.UIHandler; +import org.nuiton.validator.NuitonValidatorScope; + +import javax.swing.SwingUtilities; +import java.util.Optional; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +/** + * Created on 8/29/14. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 3.7 + */ +class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<ActivityLonglineDto, ActivityLonglineLogbookUI> implements UIHandler<ActivityLonglineLogbookUI> { + + /** Logger */ + private static final Log log = LogFactory.getLog(ActivityLonglineLogbookUIHandler.class); + + ActivityLonglineLogbookUIHandler() { + super(DataContextType.TripLongline, DataContextType.ActivityLongline, n("observe.common.ActivityLonglineDto.message.not.open")); + } + + @Override + protected boolean doOpenData() { + boolean result = getOpenDataManager().canOpenActivityLongline(getSelectedParentId()); + if (result) { + String setLonglineId = Optional.ofNullable(getBean().getSetLongline()).map(DataDtoReference::getId).orElse(null); + getOpenDataManager().openActivityLongline(getSelectedParentId(), getSelectedId(), setLonglineId); + + } + return result; + } + + @Override + public boolean doCloseData() { + boolean result = getOpenDataManager().isOpenActivityLongline(getSelectedId()); + if (result) { + getOpenDataManager().closeActivityLongline(getSelectedId()); + } + return result; + } + + @Override + protected ContentMode getContentMode(ClientDataContext dataContext) { + + String activityId = getSelectedId(); + + if (activityId == null) { + + // mode creation + return ContentMode.CREATE; + } + + // l'activity existe en base + if (getOpenDataManager().isOpenActivityLongline(getSelectedId())) { + + // l'activity est ouverte, donc modifiable + return ContentMode.UPDATE; + } + + ActivityLonglineLogbookUI ui = getUi(); + + // l'activity n'est pas ouverte, donc pas éditable + if (!getOpenDataManager().isOpenTripLongline(getSelectedParentId())) { + + // la marée n'est pas ouverte + addMessage(ui, + NuitonValidatorScope.INFO, + getTypeI18nKey(TripLonglineDto.class), + t("observe.common.TripLonglineDto.message.not.open")); + + if (getModel().isHistoricalData()) { + + addInfoMessage(t("observe.common.DataDto.message.historical.data")); + } + + } else { + + // seule l'activity n'est pas ouverte + addInfoMessage(t(closeMessage)); + } + + return ContentMode.READ; + } + + @Override + public void openUI() { + super.openUI(); + + getUi().getCoordinatesEditor().resetModel(); + + String tripId = getSelectedParentId(); + String activityId = getSelectedId(); + + if (log.isInfoEnabled()) { + log.info(prefix + "tripId = " + tripId); + log.info(prefix + "activityId = " + activityId); + } + + ContentMode mode = computeContentMode(); + if (log.isInfoEnabled()) { + log.info(prefix + "content mode " + mode); + } + ActivityLonglineDto bean = getBean(); + + boolean create = activityId == null; + + Form<ActivityLonglineDto> form; + if (create) { + + // create mode + form = getActivityLonglineService().preCreate(tripId); + + } else { + + // update mode + form = getActivityLonglineService().loadForm(activityId); + + } + + setContentMode(mode); + + loadReferentialReferenceSetsInModel(form); + + getModel().setForm(form); + ActivityLonglineHelper.copyActivityLonglineDto(form.getObject(), bean); + + if (log.isDebugEnabled()) { + log.debug(" long - lat = " + bean.getLongitude() + " - " + bean.getLatitude()); + } + finalizeOpenUI(mode, create); + + // Mise à jour du composant de coordonnées + // 1. Mise à jour latitude/longitude: + getUi().getCoordinatesEditor().setLatitudeAndLongitude(bean.getLatitude(), bean.getLongitude()); + + // 2. Mise à jour du quadrant : + // Si le bean de données contient un quadrant, on met simplement à jour le composant de coordonnées pour sélectionner le quadrant voulu + // sinon, on réinitialise les quadrants du composant afin qu'aucun d'eux ne soit sélectionné (par exemple dans le cas de la création de la première activité d'une marée) + if (bean.getQuadrant() == null) { + getUi().getCoordinatesEditor().resetQuadrant(); + } else { + getUi().getCoordinatesEditor().setQuadrant(bean.getQuadrant()); + } + + // on annule la modification engendree par ce binding + getModel().setModified(create); + } + + @Override + public void startEditUI(String... binding) { + ActivityLonglineLogbookUI ui = getUi(); + + ContentUIModel<ActivityLonglineDto> model = getModel(); + + boolean create = model.getMode() == ContentMode.CREATE; + String contextName = getValidatorContextName(model.getMode()); + ui.getValidator().setContext(contextName); + if (create) { + addMessage(ui, + NuitonValidatorScope.INFO, + getTypeI18nKey(ActivityLonglineDto.class), + t("observe.common.ActivityLonglineDto.message.creating")); + } else { + addMessage(ui, + NuitonValidatorScope.INFO, + getTypeI18nKey(ActivityLonglineDto.class), + t("observe.common.ActivityLonglineDto.message.updating")); + } + + super.startEditUI( + ActivityLonglineLogbookUI.BINDING_TIME_STAMP_DATE, + ActivityLonglineLogbookUI.BINDING_SEA_SURFACE_TEMPERATURE_STORAGE_TEMPERATURE, + ActivityLonglineLogbookUI.BINDING_COMMENT_MODEL, + ActivityLonglineLogbookUI.BINDING_VESSEL_ACTIVITY_LONGLINE_SELECTED_ITEM, + ActivityLonglineLogbookUI.BINDING_FPA_ZONE_SELECTED_ITEM, + ActivityLonglineLogbookUI.BINDING_CLOSE_ENABLED, + ActivityLonglineLogbookUI.BINDING_CLOSE_AND_CREATE_ENABLED); + model.setModified(create); + } + + @Override + protected void prepareValidationContext() { + super.prepareValidationContext(); + + ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); + validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor()); + + } + + @Override + protected boolean doSave(ActivityLonglineDto bean) { + + boolean notPersisted = bean.isNotPersisted(); + + String tripId = getSelectedParentId(); + + TripChildSaveResultDto saveResult = getActivityLonglineService().save(tripId, getModel().getBean()); + saveResult.toDto(bean); + + setUpdateMareeNodeTag(saveResult.isTripEndDateUpdated()); + + obtainChildPosition(bean); + + if (notPersisted) { + // ouverture de l'activité après création + getOpenDataManager().openActivityLongline(getSelectedParentId(), bean.getId(), null); + + if (ActivityLonglineHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId())) { + + // création de l'opération de pêche + SwingUtilities.invokeLater(() -> getUi().getAddSet().doClick()); + } + } + + return true; + } + + @Override + protected int getOpenablePosition(String parentId, ActivityLonglineDto bean) { + return getActivityLonglineService().getActivityLonglinePositionInTripLongline(parentId, bean.getId()); + } + + @Override + protected boolean doDelete(ActivityLonglineDto bean) { + + if (askToDelete(bean)) { + return false; + } + if (log.isInfoEnabled()) { + log.info("Will delete Activity " + bean.getId()); + } + + String tripId = getSelectedParentId(); + boolean wasTripEndDateUpdated = getActivityLonglineService().delete(tripId, bean.getId()); + if (log.isInfoEnabled()) { + log.info("Delete done for Activity " + bean.getId()); + } + getOpenDataManager().closeActivityLongline(bean.getId()); + + setUpdateMareeNodeTag(wasTripEndDateUpdated); + return true; + + } + + @Override + protected void afterSave(boolean refresh) { + super.afterSave(refresh); + repaintTripNode(); + } + + @Override + protected void afterDelete() { + super.afterDelete(); + repaintTripNode(); + } + + @Override + protected boolean obtainCanReopen(boolean create) { + + return !create && getOpenDataManager().canOpenActivityLongline(getSelectedParentId()); + + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUIModel.java ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineLogbookUIModel.java @@ -0,0 +1,88 @@ +package fr.ird.observe.client.ui.content.data.longline; + +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ird.observe.client.ui.content.open.ContentOpenableUIModel; +import fr.ird.observe.dto.data.longline.ActivityLonglineDto; +import fr.ird.observe.dto.referential.longline.VesselActivityLonglineHelper; +import fr.ird.observe.dto.referential.longline.VesselActivityLonglineReference; +import org.nuiton.util.DateUtil; + +import java.util.Date; + +/** + * Created on 9/26/14. + * + * @author Tony Chemit - dev@tchemit.fr + * @since XXX + */ +public class ActivityLonglineLogbookUIModel extends ContentOpenableUIModel<ActivityLonglineDto> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_SET_OPERATION = "setOperation"; + + public static final String PROPERTY_DATE = "date"; + + public static final String PROPERTY_TIME = "time"; + + public ActivityLonglineLogbookUIModel() { + super(ActivityLonglineDto.class); + + getBean().addPropertyChangeListener(ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, evt -> { + boolean oldValue = VesselActivityLonglineHelper.isSetOperation((VesselActivityLonglineReference) evt.getOldValue()); + boolean newValue = VesselActivityLonglineHelper.isSetOperation((VesselActivityLonglineReference) evt.getNewValue()); + firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue); + }); + } + + public boolean isSetOperation() { + return VesselActivityLonglineHelper.isSetOperation(bean.getVesselActivityLongline()); + } + + public Date getDate() { + Date timeStamp = bean.getTimeStamp(); + return timeStamp == null ? null : DateUtil.getDay(timeStamp); + } + + public Date getTime() { + Date timeStamp = bean.getTimeStamp(); + return timeStamp == null ? null : DateUtil.getTime(timeStamp, false, false); + } + + public void setDate(Date date) { + Date timeStamp = bean.getTimeStamp(); + if (timeStamp != null) { + Date dateAndTime = date == null ? timeStamp : DateUtil.getDateAndTime(date, timeStamp, true, false); + bean.setTimeStamp(dateAndTime); + } + } + + public void setTime(Date time) { + Date timeStamp = bean.getTimeStamp(); + if (timeStamp != null) { + Date dateAndTime = time == null ? timeStamp : DateUtil.getDateAndTime(timeStamp, time, false, false); + bean.setTimeStamp(dateAndTime); + } + } +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUI.jaxx ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUI.jaxx @@ -0,0 +1,282 @@ +<!-- + #%L + ObServe :: Client + %% + Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + %% + 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% + --> + +<fr.ird.observe.client.ui.content.table.ContentTableUI + i18nFormat="observe.common.CatchLonglineDto.%s" + superGenericType='SetLonglineCatchDto, CatchLonglineDto, CatchLonglineLogbookUI' + contentTitle='{n("observe.common.CatchLonglineDto.title")}' + newEntryText='{n("observe.common.CatchLonglineDto.action.new")}' + newEntryTip='{n("observe.common.CatchLonglineDto.action.new.tip")}' + saveNewEntryText='{n("observe.common.CatchLonglineDto.action.create")}' + saveNewEntryTip='{n("observe.common.CatchLonglineDto.action.create.tip")}'> + + <style source="../CommonTable.jcss"/> + + <import> + fr.ird.observe.dto.data.longline.BasketReference + fr.ird.observe.dto.data.longline.BranchlineDto + fr.ird.observe.dto.data.longline.BranchlineReference + fr.ird.observe.dto.data.longline.CatchLonglineDto + fr.ird.observe.dto.data.longline.SectionReference + fr.ird.observe.dto.data.longline.SetLonglineCatchDto + fr.ird.observe.dto.referential.SpeciesReference + fr.ird.observe.dto.referential.SexReference + fr.ird.observe.dto.referential.longline.BaitHaulingStatusReference + fr.ird.observe.dto.referential.longline.CatchFateLonglineReference + fr.ird.observe.dto.referential.longline.HealthnessReference + fr.ird.observe.dto.referential.longline.HookPositionReference + fr.ird.observe.dto.referential.longline.MaturityStatusReference + fr.ird.observe.dto.referential.longline.StomacFullnessReference + fr.ird.observe.client.constants.CatchAcquisitionMode + fr.ird.observe.client.ui.content.table.* + fr.ird.observe.client.ui.util.BooleanEditor + fr.ird.observe.client.ui.util.JComment + + org.nuiton.jaxx.widgets.number.NumberEditor + org.nuiton.jaxx.widgets.select.BeanComboBox + org.nuiton.jaxx.widgets.select.FilterableDoubleList + org.nuiton.jaxx.widgets.datetime.DateTimeEditor + org.nuiton.jaxx.widgets.datetime.TimeEditor + + java.awt.Dimension + + java.util.Collection + + org.apache.commons.lang3.BooleanUtils + + static fr.ird.observe.client.ui.util.UIHelper.getStringValue + static org.nuiton.i18n.I18n.n + </import> + + <!-- model --> + <CatchLonglineLogbookUIModel id='model'/> + + <!-- edit bean --> + <SetLonglineCatchDto id='bean'/> + + <!-- table edit bean --> + <CatchLonglineDto id='tableEditBean'/> + + <!-- table model --> + <ContentTableModel id='tableModel' genericType='SetLonglineCatchDto, CatchLonglineDto'/> + + <!-- edit branchline --> + <BranchlineDto id='branchlineBean' initializer='new BranchlineDto()'/> + + <!-- le validateur de l'écran --> + <BeanValidator id='validator' context='update' + beanClass='fr.ird.observe.dto.data.longline.SetLonglineCatchDto' + errorTableModel='{getErrorTableModel()}'> + </BeanValidator> + + <!-- le validateur d'une entrée de tableau --> + <BeanValidator id='validatorTable' autoField='true' context='update' + beanClass='fr.ird.observe.dto.data.longline.CatchLonglineDto' + errorTableModel='{getErrorTableModel()}' + parentValidator='{validator}'/> + + <JPopupMenu id='catchLonglinesPopup'> + <JMenuItem id='moveCatchLonglineUp' onActionPerformed='getHandler().moveCatchLonglineUp()'/> + <JMenuItem id='moveCatchLonglineDown' onActionPerformed='getHandler().moveCatchLonglineDown()'/> + </JPopupMenu> + + <ButtonGroup id='acquisitionModeGroup' + onStateChanged='getHandler().updateCatchAcquisitionMode((CatchAcquisitionMode) acquisitionModeGroup.getSelectedValue())'/> + + <Table id='editorPanel' fill='both' insets='0'> + <row> + <cell weightx="1" weighty="1"> + <JTabbedPane id='mainTabbedPane'> + <tab id='caracteristicTab' computeI18n=""> + <Table id='editForm' fill='both' insets='1'> + + <row> + <cell columns="4"> + <JPanel layout="{new GridLayout()}"> + + <!-- acquisition Mode --> + <JPanel id='acquisitionModePanel'> + <JRadioButton id='acquisitionModeIndividual'/> + <JRadioButton id='acquisitionModeGrouped'/> + </JPanel> + + </JPanel> + </cell> + </row> + + <!-- speciesCatch --> + <!-- tagNumber --> + <row> + <cell> + <JLabel id='speciesCatchLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <BeanComboBox id='speciesCatch' genericType='SpeciesReference' constructorParams='this'/> + </cell> + <cell anchor='west'> + <JLabel id='tagNumberLabel'/> + </cell> + <cell anchor='east' weightx="1" fill="both"> + <JPanel layout='{new BorderLayout()}'> + <JToolBar id='tagNumberToolbar' constraints='BorderLayout.WEST'> + <JButton id='resetTagNumber' styleClass='resetButton'/> + </JToolBar> + <JTextField id='tagNumber' constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> + + <!-- count --> + <row> + <cell> + <JLabel id='countLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <NumberEditor id='count' constructorParams='this' styleClass="int6"/> + </cell> + </row> + + <!-- count --> + <!-- total weight --> + <row> + <cell> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <NumberEditor id='totalWeight' constructorParams='this' styleClass="float3"/> + </cell> + <cell> + <JLabel id='weightDeterminationMethodLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <BeanComboBox id='weightDeterminationMethod' constructorParams='this' genericType='HealthnessReference'/> + </cell> + </row> + + + <!-- catch healthness --> + <row> + <cell> + <JLabel id='catchHealthnessLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <BeanComboBox id='catchHealthness' constructorParams='this' genericType='HealthnessReference'/> + </cell> + </row> + + <!-- catch fate --> + <!-- discard healthness --> + <row> + <cell> + <JLabel id='catchFateLonglineLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <BeanComboBox id='catchFateLongline' constructorParams='this' genericType='CatchFateLonglineReference'/> + </cell> + <cell> + <JLabel id='discardHealthnessLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <BeanComboBox id='discardHealthness' constructorParams='this' genericType='HealthnessReference'/> + </cell> + </row> + + <!-- onBordDataProcessing --> + <row> + <cell> + <JLabel id='onBordDataProcessingLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <BeanComboBox id='onBordDataProcessing' constructorParams='this' genericType='CatchFateLonglineReference'/> + </cell> + <cell anchor='east' weightx="1" fill="both"> + <JPanel layout='{new BorderLayout()}'> + <JToolBar id='photoReferencesToolbar' constraints='BorderLayout.WEST'> + <JButton id='resetPhotoReferences' styleClass='resetButton'/> + </JToolBar> + <JTextField id='photoReferences' constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> + </Table> + </tab> + + <tab id='depredatedTab' computeI18n=""> + + <Table id='depredatedForm' fill='both' insets='1'> + + <!-- depredated --> + <row> + <cell anchor='west' fill="both"> + <JCheckBox id='depredated' styleClass="i18n"/> + </cell> + </row> + + <!-- beatDiameter --> + <row> + <cell> + <JLabel id='beatDiameterLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <NumberEditor id='beatDiameter' constructorParams='this' styleClass="float3"/> + </cell> + </row> + <!-- countDepredated --> + <row> + <cell> + <JLabel id='countDepredatedLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <NumberEditor id='countDepredated' constructorParams='this' styleClass="float3"/> + </cell> + </row> + <!-- depredatedProportion --> + <row> + <cell> + <JLabel id='depredatedProportionLabel'/> + </cell> + <cell weightx='1' anchor='east'> + <NumberEditor id='depredatedProportion' constructorParams='this' styleClass="float3"/> + </cell> + </row> + + <!-- predator --> + <row> + <cell columns="2" fill="both" weighty="0.7"> + <JScrollPane id='predatorPane'> + <FilterableDoubleList id='predator' genericType='SpeciesReference'/> + </JScrollPane> + </cell> + </row> + + </Table> + </tab> + </JTabbedPane> + </cell> + </row> + <row> + <cell weighty='1'> + <JComment id="comment"/> + </cell> + </row> + </Table> +</fr.ird.observe.client.ui.content.table.ContentTableUI> \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUI.jcss ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUI.jcss @@ -0,0 +1,360 @@ +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * 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% + */ + +.i18nBranchline { + computeI18n:"observe.common.BranchlineDto.%s" +} + +#model { + valid:{validator.isValid() && validatorTable.isValid()}; + canSaveRow:{validatorTable.isChanged() && validatorTable.isValid() }; + canResetRow:{validatorTable.isChanged()}; +} + +#moveCatchLonglineUp { + text: "observe.common.CatchLonglineDto.action.moveCatchLonglineUp"; + toolTipText: "observe.common.CatchLonglineDto.action.moveCatchLonglineUp.tip"; + actionIcon: go-up; +} + +#moveCatchLonglineDown { + text: "observe.common.CatchLonglineDto.action.moveCatchLonglineDown"; + toolTipText: "observe.common.CatchLonglineDto.action.moveCatchLonglineDown.tip"; + actionIcon: go-down; +} + + +/* ***************************************************************************** */ +/* CARACTERISTIC TAB ********************************************************** */ +/* ***************************************************************************** */ + +#caracteristicTab { + icon:{handler.getErrorIconIfFalse(model.isCaracteristicsTabValid())}; +} + +#acquisitionModeGroup { + selectedValue:{CatchAcquisitionMode.valueOf(tableEditBean.getAcquisitionMode())}; +} + +#acquisitionModePanel { + border:{new TitledBorder(t("observe.common.CatchLonglineDto.acquisitionMode"))}; + layout:{new GridLayout(0,1)}; +} + +#acquisitionModeIndividual { + buttonGroup:acquisitionModeGroup; + value:{CatchAcquisitionMode.INDIVIDUAL}; + text:{CatchAcquisitionMode.INDIVIDUAL.toString()}; + selected:{tableEditBean.getAcquisitionMode() == 0}; + enabled:{!tableModel.isEditable() || tableModel.isCreate()}; +} + +#acquisitionModeGrouped { + buttonGroup:acquisitionModeGroup; + value:{CatchAcquisitionMode.GROUPED}; + text:{CatchAcquisitionMode.GROUPED.toString()}; + selected:{tableEditBean.getAcquisitionMode() == 1}; + enabled:{!tableModel.isEditable() || tableModel.isCreate()}; +} + +#locationOnLonglinePanel { + border:{new TitledBorder(t("observe.common.CatchLonglineDto.locationOnLongline"))}; +} + +#section { + property:{CatchLonglineDto.PROPERTY_SECTION}; + selectedItem:{tableEditBean.getSection()}; + force:true; + _listNoLoad:{true}; +} + +#basket { + property:{CatchLonglineDto.PROPERTY_BASKET}; + selectedItem:{tableEditBean.getBasket()}; + _listNoLoad:{true}; +} + +#branchline { + property:{CatchLonglineDto.PROPERTY_BRANCHLINE}; + selectedItem:{tableEditBean.getBranchline()}; + _listNoLoad:{true}; +} + +#speciesCatch { + property:{CatchLonglineDto.PROPERTY_SPECIES_CATCH}; + selectedItem:{tableEditBean.getSpeciesCatch()}; +} + +#resetPhotoReferences { + toolTipText:"observe.common.CatchLonglineDto.action.reset.photoReferences.tip"; + _resetTablePropertyName:{CatchLonglineDto.PROPERTY_PHOTO_REFERENCES}; +} + +#photoReferences { + text:{getStringValue(tableEditBean.getPhotoReferences())}; + _tablePropertyName:{CatchLonglineDto.PROPERTY_PHOTO_REFERENCES}; +} + +#resetTagNumber { + toolTipText:"observe.common.DataDto.action.resetTagNumber"; + _resetTablePropertyName:{CatchLonglineDto.PROPERTY_TAG_NUMBER}; + enabled:{tableEditBean.getAcquisitionMode() == 0}; +} + +#tagNumber { + text:{getStringValue(tableEditBean.getTagNumber())}; + _tablePropertyName:{CatchLonglineDto.PROPERTY_TAG_NUMBER}; + enabled:{tableEditBean.getAcquisitionMode() == 0}; +} + +#count { + property:{CatchLonglineDto.PROPERTY_COUNT}; + numberValue:{tableEditBean.getCount()}; +} + +#totalWeight { + property:{CatchLonglineDto.PROPERTY_TOTAL_WEIGHT}; + numberValue:{tableEditBean.getTotalWeight()}; +} + +#hookWhenDiscarded { + _tablePropertyName:{CatchLonglineDto.PROPERTY_HOOK_WHEN_DISCARDED}; + booleanValue:{tableEditBean.getHookWhenDiscarded()}; +} + +#catchFateLongline { + property:{CatchLonglineDto.PROPERTY_CATCH_FATE_LONGLINE}; + selectedItem:{tableEditBean.getCatchFateLongline()}; +} + +#catchHealthness { + property:{CatchLonglineDto.PROPERTY_CATCH_HEALTHNESS}; + selectedItem:{tableEditBean.getCatchHealthness()}; +} + +#discardHealthness { + property:{CatchLonglineDto.PROPERTY_DISCARD_HEALTHNESS}; + selectedItem:{tableEditBean.getDiscardHealthness()}; +} + +#catchFateLongline { + property:{CatchLonglineDto.PROPERTY_CATCH_FATE_LONGLINE}; + selectedItem:{tableEditBean.getCatchFateLongline()}; +} + +#hookPosition { + property:{CatchLonglineDto.PROPERTY_HOOK_POSITION}; + selectedItem:{tableEditBean.getHookPosition()}; +} + +#comment { + title:"observe.common.CatchLonglineDto.comment"; +} + +/* ***************************************************************************** */ +/* DEPREDATED TAB ************************************************************* */ +/* ***************************************************************************** */ + +#depredatedFormTab { + icon:{handler.getErrorIconIfFalse(model.isDepredatedTabValid())}; +} + +#beatDiameter { + property:{CatchLonglineDto.PROPERTY_BEAT_DIAMETER}; + numberValue:{tableEditBean.getBeatDiameter()}; +} + +#depredated { + horizontalTextPosition:{JCheckBox.LEFT}; + _tablePropertyName:{CatchLonglineDto.PROPERTY_DEPREDATED}; + selected:{BooleanUtils.isTrue(tableEditBean.getDepredated())}; +} + +#predatorPane { + minimumSize:{new Dimension(10,150)}; +} + +#predator { + property: predator; + selected:{(Collection)tableEditBean.getPredator()}; + showListLabel: true; + universeLabel:{t("observe.common.CatchLonglineDto.availablePredator")}; + selectedLabel:{t("observe.common.CatchLonglineDto.selectedPredator")}; +} + +/* ***************************************************************************** */ +/* FOOD AND SEXUAL TAB ******************************************************** */ +/* ***************************************************************************** */ + +#foodAndSexualFormTab { + icon:{handler.getErrorIconIfFalse(model.isFoodAndSexualTabValid())}; +} + +#foodAndSexualForm { + border:{new TitledBorder( (String) null)}; +} + +#sex { + property:{CatchLonglineDto.PROPERTY_SEX}; + selectedItem:{tableEditBean.getSex()}; +} + +#stomacFullness { + property:{CatchLonglineDto.PROPERTY_STOMAC_FULLNESS}; + selectedItem:{tableEditBean.getStomacFullness()}; +} + +#maturityStatus { + property:{CatchLonglineDto.PROPERTY_MATURITY_STATUS}; + selectedItem:{tableEditBean.getMaturityStatus()}; +} + +#gonadeWeight { + property:{CatchLonglineDto.PROPERTY_GONADE_WEIGHT}; + numberValue:{tableEditBean.getGonadeWeight()}; +} + +/* ***************************************************************************** */ +/* SIZE MEASURES TAB ********************************************************** */ +/* ***************************************************************************** */ + +#sizeMeasuresFormTab { + icon:{handler.getErrorIconIfFalse(sizeMeasuresTableModel.isValid())}; +} + +#sizeMeasuresTable { + model: {sizeMeasuresTableModel}; +} + +#addSizeMeasure { + text: "observe.common.CatchLonglineDto.action.addSizeMeasure"; + toolTipText: "observe.common.CatchLonglineDto.action.addSizeMeasure.tip"; + actionIcon: add; +} + +#deleteSelectedSizeMeasure { + text: "observe.common.CatchLonglineDto.action.deleteSelectedSizeMeasure"; + toolTipText: "observe.common.CatchLonglineDto.action.deleteSelectedSizeMeasure.tip"; + actionIcon: delete; +} + +/* ***************************************************************************** */ +/* WEIGHT MEASURES TAB ******************************************************** */ +/* ***************************************************************************** */ + +#weightMeasuresFormTab { + icon:{handler.getErrorIconIfFalse(weightMeasuresTableModel.isValid())}; +} + +#weightMeasuresTable { + model: {weightMeasuresTableModel}; +} + +#addWeightMeasure { + text: "observe.common.CatchLonglineDto.action.addWeightMeasure"; + toolTipText: "observe.common.CatchLonglineDto.action.addWeightMeasure.tip"; + actionIcon: add; +} + +#deleteSelectedWeightMeasure { + text: "observe.common.CatchLonglineDto.action.deleteSelectedWeightMeasure"; + toolTipText: "observe.common.CatchLonglineDto.action.deleteSelectedWeightMeasure.tip"; + actionIcon: delete; +} + +/* ***************************************************************************** */ +/* BRANCHLINE TAB ************************************************************* */ +/* ***************************************************************************** */ + +#branchlineFormTab { + icon:{handler.getErrorIconIfFalse(model.isBranchlineTabValid())}; + enabled:{!tableModel.isCreate() && tableEditBean.getBranchline() != null}; +} + +#branchlineForm { + border:{new TitledBorder( (String) null)}; + visible:{!tableModel.isCreate() && tableEditBean.getBranchline() != null}; +} + +#depthRecorder { + horizontalTextPosition:{JCheckBox.LEFT}; + _branchlineBeanPropertyName:{BranchlineDto.PROPERTY_DEPTH_RECORDER}; + selected:{BooleanUtils.isTrue(branchlineBean.getDepthRecorder())}; +} + +#hookLost { + horizontalTextPosition:{JCheckBox.LEFT}; + _branchlineBeanPropertyName:{BranchlineDto.PROPERTY_HOOK_LOST}; + selected:{BooleanUtils.isTrue(branchlineBean.getHookLost())}; +} + +#traceCutOff { + horizontalTextPosition:{JCheckBox.LEFT}; + _branchlineBeanPropertyName:{BranchlineDto.PROPERTY_TRACE_CUT_OFF}; + selected:{BooleanUtils.isTrue(branchlineBean.getTraceCutOff())}; +} + +#timer { + horizontalTextPosition:{JCheckBox.LEFT}; + _branchlineBeanPropertyName:{BranchlineDto.PROPERTY_TIMER}; + selected:{BooleanUtils.isTrue(branchlineBean.getTimer())}; +} + +#timeSinceContact { + propertyTime:{CatchLonglineUIModel.PROPERTY_BRANCHLINE_TIME_SINCE_CONTACT}; + bean:{model}; + enabled:{BooleanUtils.isTrue(branchlineBean.getTimer())}; + time:{model.getBranchlineTimeSinceContact()}; + showTimeEditorSlider:false; +} + +#timerTimeOnBoard { + date:{branchlineBean.getTimerTimeOnBoard()}; + propertyDate: {BranchlineDto.PROPERTY_TIMER_TIME_ON_BOARD}; + bean:{branchlineBean}; + showTimeEditorSlider:false; + enabled:{BooleanUtils.isTrue(branchlineBean.getTimer())}; +} + +#baitHaulingStatus { + property:{BranchlineDto.PROPERTY_BAIT_HAULING_STATUS}; + bean:{branchlineBean}; + selectedItem:{branchlineBean.getBaitHaulingStatus()}; +} + +#branchlineActions { + visible:{tableModel.isEditable()}; +} + +#resetBranchline { + text:"observe.common.CatchLonglineDto.resetBranchline"; + toolTipText:"observe.common.CatchLonglineDto.resetBranchline.tip"; + actionIcon:"revert"; + enabled:{branchlineValidator.isChanged()}; +} + +#saveBranchline{ + text:"observe.common.CatchLonglineDto.saveBranchline"; + toolTipText:"observe.common.CatchLonglineDto.saveBranchline.tip"; + actionIcon:"save"; + enabled:{branchlineValidator.isChanged() && branchlineValidator.isValid()}; +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUIHandler.java ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUIHandler.java @@ -0,0 +1,508 @@ +package fr.ird.observe.client.ui.content.data.longline; + +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ird.observe.client.ObserveSwingApplicationContext; +import fr.ird.observe.client.constants.CatchAcquisitionMode; +import fr.ird.observe.client.db.constants.DataContextType; +import fr.ird.observe.client.ui.content.ContentUIModel; +import fr.ird.observe.client.ui.content.table.ContentTableModel; +import fr.ird.observe.client.ui.content.table.ContentTableUIHandler; +import fr.ird.observe.client.ui.content.table.ContentTableUIInitializer; +import fr.ird.observe.client.ui.tree.navigation.NavigationTree; +import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; +import fr.ird.observe.client.ui.tree.navigation.nodes.longline.TripLonglineNavigationTreeNode; +import fr.ird.observe.client.ui.util.UIHelper; +import fr.ird.observe.client.ui.util.table.AutotSelectRowAndShowPopupActionSupport; +import fr.ird.observe.dto.data.longline.BranchlineDto; +import fr.ird.observe.dto.data.longline.CatchLonglineDto; +import fr.ird.observe.dto.data.longline.SetLonglineCatchDto; +import fr.ird.observe.dto.data.longline.TripLonglineReference; +import fr.ird.observe.dto.form.Form; +import fr.ird.observe.dto.form.FormDefinition; +import fr.ird.observe.dto.reference.DtoReferenceCollection; +import fr.ird.observe.dto.referential.SpeciesDto; +import fr.ird.observe.dto.referential.SpeciesReference; +import fr.ird.observe.dto.referential.longline.CatchFateLonglineReference; +import fr.ird.observe.dto.referential.longline.HealthnessReference; +import fr.ird.observe.dto.result.SaveResultDto; +import fr.ird.observe.spi.DtoModelHelper; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.runtime.spi.UIHandler; +import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; +import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; +import org.nuiton.validator.NuitonValidatorScope; + +import javax.swing.JComponent; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableCellRenderer; +import java.beans.PropertyChangeListener; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +/** + * Created on 9/11/14. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 3.7 + */ +public class CatchLonglineLogbookUIHandler extends ContentTableUIHandler<SetLonglineCatchDto, CatchLonglineDto, CatchLonglineLogbookUI> implements UIHandler<CatchLonglineLogbookUI> { + + /** Logger */ + private static final Log log = LogFactory.getLog(CatchLonglineLogbookUIHandler.class); + private static final String GROUPED_TRIP_TYPE_ID = "fr.ird.observe.entities.referentiel.longline.TripType#1239832686136#0.1"; + // Compute valid state of tab from the error table + protected final TableModelListener computeTabValidStateListener; + private final PropertyChangeListener catchFateChanged; + private final PropertyChangeListener depredatedChanged; + + CatchLonglineLogbookUIHandler() { + super(DataContextType.SetLongline); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; + catchFateChanged = evt -> onCatchFateChanged((CatchFateLonglineReference) evt.getNewValue()); + depredatedChanged = evt -> onDepredatedChanged((Boolean) evt.getNewValue(), (CatchLonglineDto) evt.getSource()); + + addReferentialFilter(CatchLonglineDto.PROPERTY_SPECIES_CATCH, (ReferentialReferencesFilter<SpeciesDto, SpeciesReference>) incomingReferences -> { + String speciesListId = ObserveSwingApplicationContext.get().getConfig().getSpeciesListLonglineCatchId(); + String tripLonglineId = getDataContext().getSelectedTripLonglineId(); + List<SpeciesReference> result = getTripLonglineService().getSpeciesByListAndTrip(tripLonglineId, speciesListId).toList(); + return DtoReferenceCollection.filterEnabled(result); + }); + + addReferentialFilter(CatchLonglineDto.PROPERTY_PREDATOR, (ReferentialReferencesFilter<SpeciesDto, SpeciesReference>) incomingReferences -> { + String speciesListId = ObserveSwingApplicationContext.get().getConfig().getSpeciesListLonglineDepredatorId(); + String tripLonglineId = getDataContext().getSelectedTripLonglineId(); + List<SpeciesReference> result = getTripLonglineService().getSpeciesByListAndTrip(tripLonglineId, speciesListId).toList(); + return DtoReferenceCollection.filterEnabled(result); + }); + } + + @Override + public CatchLonglineLogbookUIModel getModel() { + return (CatchLonglineLogbookUIModel) super.getModel(); + } + + @Override + public void afterInit(CatchLonglineLogbookUI ui) { + + ContentTableUIInitializer<SetLonglineCatchDto, CatchLonglineDto, CatchLonglineLogbookUI> uiInitializer = new ContentTableUIInitializer<>(ui); + uiInitializer.initUI(); + + ui.setTitle(t(updateTitle(ui.getContentTitle()))); + updateTitle(getModel().getMode()); + + installFocusTraversalPolicy(); + + CatchLonglineLogbookUIModel model = ui.getModel(); + + model.addPropertyChangeListener(ContentUIModel.PROPERTY_FORM, evt -> updateUiWithReferenceSetsFromModel()); + } + + @Override + public void openUI() { + + if (log.isInfoEnabled()) { + log.info("OpenUI: " + getModel()); + } + + super.openUI(); + + // To be sure always remove listener (could prevent some leaks) + getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener); + // listen messages to see if required to add + getUi().getErrorTableModel().addTableModelListener(computeTabValidStateListener); + + SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); + computeTabValidState(errorTableModel); + + } + + void updateCatchAcquisitionMode(CatchAcquisitionMode newMode) { + + if (log.isDebugEnabled()) { + log.debug("Change CatchAcquisitionMode " + newMode); + } + if (newMode == null) { + + // mode null (cela peut arriver avec les bindings) + return; + } + + CatchLonglineLogbookUI ui = getUi(); + + boolean createMode = ui.getTableModel().isCreate(); + + CatchLonglineDto editBean = ui.getTableEditBean(); + + switch (newMode) { + + case GROUPED: + + if (createMode) { + + editBean.setTotalWeight(null); + editBean.setCount(null); + editBean.setHookPosition(null); + + } + + break; + + case INDIVIDUAL: + + if (createMode) { + + // on positionne le count à 1 (seule valeur possible) + editBean.setCount(1); + + } + + break; + } + + boolean isGrouped = CatchAcquisitionMode.GROUPED.equals(newMode); + + ui.getTotalWeight().setEnabled(isGrouped); + ui.getCount().setEnabled(isGrouped); + + if (createMode) { + + // on propage le mode de saisie dans le bean + editBean.setAcquisitionMode(newMode.ordinal()); + + } + } + + @Override + protected void onSelectedRowChanged(int editingRow, CatchLonglineDto bean, boolean create) { + + if (log.isInfoEnabled()) { + log.info("Selected row changed: " + editingRow + ", create? " + create); + } + + CatchLonglineLogbookUI ui = getUi(); + + CatchLonglineTableModel tableModel = getTableModel(); + + if (!tableModel.isEditable()) { + return; + } + + JComponent requestFocus; + + CatchAcquisitionMode acquisitionModeEnum; + + if (tableModel.isCreate()) { + + // go back to first pane + ui.getMainTabbedPane().setSelectedIndex(0); + + NavigationTree treeHelper = getNavigationTree(); + NavigationTreeNodeSupport selectedNode = treeHelper.getSelectedNode(); + while (!(selectedNode instanceof TripLonglineNavigationTreeNode)) { + selectedNode = selectedNode.getParent(); + } + TripLonglineReference tripReference = ((TripLonglineNavigationTreeNode) selectedNode).getData(); + String tripTypeId = tripReference.getTripTypeId(); + if (log.isInfoEnabled()) { + log.info("Use tripId: " + tripTypeId); + } + acquisitionModeEnum = GROUPED_TRIP_TYPE_ID.equals(tripTypeId) ? CatchAcquisitionMode.GROUPED : CatchAcquisitionMode.INDIVIDUAL; + + ui.getPredator().setEnabled(false); + ui.getDiscardHealthness().setEnabled(false); + ui.getBeatDiameter().setEnabled(false); + + requestFocus = ui.getSpeciesCatch(); + + } else { + + int acquisitionMode = bean.getAcquisitionMode(); + + acquisitionModeEnum = CatchAcquisitionMode.valueOf(acquisitionMode); + + if (acquisitionModeEnum.equals(CatchAcquisitionMode.GROUPED)) { + + requestFocus = ui.getCount(); + + } else { + + requestFocus = ui.getCatchHealthness(); + + } + + //FIXME Voir si pas besoin aussi de relancer les binding (catchFateChanged, branchlineChanged) ? + onDepredatedChanged(bean.getDepredated(), bean); + + } + + ui.getAcquisitionModeGroup().setSelectedValue(null); + ui.getAcquisitionModeGroup().setSelectedValue(acquisitionModeEnum); + + bean.removePropertyChangeListener(CatchLonglineDto.PROPERTY_CATCH_FATE_LONGLINE, catchFateChanged); + bean.addPropertyChangeListener(CatchLonglineDto.PROPERTY_CATCH_FATE_LONGLINE, catchFateChanged); + + bean.removePropertyChangeListener(CatchLonglineDto.PROPERTY_DEPREDATED, depredatedChanged); + bean.addPropertyChangeListener(CatchLonglineDto.PROPERTY_DEPREDATED, depredatedChanged); + + UIHelper.askFocus(requestFocus); + + } + + @Override + protected void initTableUI(DefaultTableCellRenderer renderer) { + + CatchLonglineLogbookUI ui = getUi(); + { + // init main table + + JTable table = ui.getTable(); + + UIHelper.setI18nTableHeaderRenderer( + table, + + n("observe.common.CatchLonglineDto.table.speciesCatch"), + n("observe.common.CatchLonglineDto.table.speciesCatch.tip"), + n("observe.common.CatchLonglineDto.table.acquisitionMode"), + n("observe.common.CatchLonglineDto.table.acquisitionMode.tip"), + n("observe.common.CatchLonglineDto.table.count"), + n("observe.common.CatchLonglineDto.table.count.tip"), + n("observe.common.CatchLonglineDto.table.catchHealthness"), + n("observe.common.CatchLonglineDto.table.catchHealthness.tip"), + n("observe.common.CatchLonglineDto.table.catchFateLongline"), + n("observe.common.CatchLonglineDto.table.catchFateLongline.tip"), + n("observe.common.CatchLonglineDto.table.discardHealthness"), + n("observe.common.CatchLonglineDto.table.discardHealthness.tip"), + n("observe.common.CatchLonglineDto.table.depredated"), + n("observe.common.CatchLonglineDto.table.depredated.tip"), + n("observe.common.CatchLonglineDto.table.comment"), + n("observe.common.CatchLonglineDto.table.comment.tip")); + + + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesReference.class)); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEnumTableCellRenderer(renderer, CatchAcquisitionMode.class)); + UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); + UIHelper.setTableColumnRenderer(table, 3, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HealthnessReference.class)); + UIHelper.setTableColumnRenderer(table, 4, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, CatchFateLonglineReference.class)); + UIHelper.setTableColumnRenderer(table, 5, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, HealthnessReference.class)); + UIHelper.setTableColumnRenderer(table, 6, UIHelper.newBooleanTableCellRenderer(renderer)); + UIHelper.setTableColumnRenderer(table, 7, UIHelper.newStringTableCellRenderer(renderer, 10, true)); + + new CatchLonglinesAutotSelectRowAndShowPopupAction(ui, ui.getTableScrollPane(), table, ui.getCatchLonglinesPopup()); + + } + + getTableModel().addPropertyChangeListener(ContentTableModel.CREATE_PROPERTY, evt -> { + Boolean oldValue = (Boolean) evt.getOldValue(); + Boolean newValue = (Boolean) evt.getNewValue(); + setTableModelCreate(oldValue, newValue); + }); + } + + @Override + protected String getEditBeanIdToLoad() { + return getDataContext().getSelectedSetLonglineId(); + } + + @Override + protected void doPersist(SetLonglineCatchDto bean) { + SaveResultDto saveResult = getSetLonglineCatchService().save(bean); + bean.setLastUpdateDate(saveResult.getLastUpdateDate()); + } + + @Override + protected boolean prepareSave(SetLonglineCatchDto editBean, List<CatchLonglineDto> objets) throws Exception { + boolean doSave = super.prepareSave(editBean, objets); + if (doSave) { + editBean.setCatchLongline(objets); + } + return doSave; + } + + @Override + protected void loadEditBean(String beanId) { + + Form<SetLonglineCatchDto> form = getSetLonglineCatchService().loadForm(beanId); + + CatchLonglineLogbookUIModel model = getModel(); + + // On supprime l'entrée sélectionnée dans le tableau + getTableModel().setSelectedRow(-1); + + loadReferentialReferenceSetsInModel(form); + + Optional<FormDefinition<BranchlineDto>> optionalFormDefinition = DtoModelHelper.getOptionalFormDefinition(BranchlineDto.class); + optionalFormDefinition.ifPresent(branchlineDtoFormDefinition -> loadReferentialReferenceSetsInModel(branchlineDtoFormDefinition, false)); + + model.setForm(form); + } + + @Override + protected void closeSafeUI() { + + if (log.isInfoEnabled()) { + log.info("CloseUI: " + getModel()); + } + super.closeSafeUI(); + + // remove listener + getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener); + + } + + private void setTableModelCreate(Boolean oldValue, Boolean newValue) { + + if (BooleanUtils.isTrue(oldValue) && BooleanUtils.isFalse(newValue)) { + + // just save a row + // reload acquisition mode (will rebind some stuff) + + CatchAcquisitionMode acquisitionModeEnum = (CatchAcquisitionMode) getUi().getAcquisitionModeGroup().getSelectedValue(); + + getUi().getAcquisitionModeGroup().setSelectedValue(null); + getUi().getAcquisitionModeGroup().setSelectedValue(acquisitionModeEnum); + + } + + } + + private void onCatchFateChanged(CatchFateLonglineReference newValue) { + + CatchLonglineLogbookUI ui = getUi(); + + if (newValue == null || !"fr.ird.observe.entities.referentiel.longline.CatchFateLongline#1239832686125#0.3".equals(newValue.getId())) { + + // not discarded + ui.getDiscardHealthness().setEnabled(false); + + getTableEditBean().setHookWhenDiscarded(null); + getTableEditBean().setDiscardHealthness(null); + + } else { + + // discarded + ui.getDiscardHealthness().setEnabled(true); + } + + } + + private void onDepredatedChanged(Boolean newValue, CatchLonglineDto tableEditBean) { + + CatchLonglineLogbookUI ui = getUi(); + + if (BooleanUtils.isTrue(newValue)) { + + // depredated + ui.getBeatDiameter().setEnabled(true); + ui.getPredator().setEnabled(true); + + } else { + + // not depredated + ui.getBeatDiameter().setEnabled(false); + ui.getPredator().setEnabled(false); + tableEditBean.setBeatDiameter(null); + tableEditBean.setPredator(null); + + } + + } + + protected void computeTabValidState(SwingValidatorMessageTableModel errorTableModel) { + + Set<String> errorProperties = new HashSet<>(); + int rowCount = errorTableModel.getRowCount(); + for (int i = 0; i < rowCount; i++) { + + SwingValidatorMessage row = errorTableModel.getRow(i); + if (NuitonValidatorScope.ERROR.equals(row.getScope())) { + errorProperties.add(row.getField()); + } + } + + boolean caracteristicsTabValid = !errorProperties.removeAll(CatchLonglineLogbookUIModel.CARACTERISTIC_TAB_PROPERTIES); + boolean depredatedTabValid = !errorProperties.removeAll(CatchLonglineLogbookUIModel.DEPREDATED_TAB_PROPERTIES); + + CatchLonglineLogbookUIModel model = getModel(); + + model.setCaracteristicsTabValid(caracteristicsTabValid); + model.setDepredatedTabValid(depredatedTabValid); + } + + @Override + protected CatchLonglineTableModel getTableModel() { + return (CatchLonglineTableModel) super.getTableModel(); + } + + public void moveCatchLonglineUp() { + int selectedRow = getUi().getTable().getSelectedRow(); + getTableModel().moveUp(selectedRow); + } + + public void moveCatchLonglineDown() { + int selectedRow = getUi().getTable().getSelectedRow(); + getTableModel().moveDown(selectedRow); + } + + static class CatchLonglinesAutotSelectRowAndShowPopupAction extends AutotSelectRowAndShowPopupActionSupport { + + private final CatchLonglineLogbookUI ui; + + CatchLonglinesAutotSelectRowAndShowPopupAction(CatchLonglineLogbookUI ui, + JScrollPane pane, + JTable table, + JPopupMenu popup) { + super(pane, table, popup); + this.ui = ui; + } + + @Override + protected void beforeOpenPopup(int modelRowIndex, int modelColumnIndex) { + + CatchLonglineTableModel model = (CatchLonglineTableModel) getTable().getModel(); + + boolean canMoveUp = !ui.getModel().isCanSaveRow() && modelRowIndex > 0; + boolean canMoveDown = !ui.getModel().isCanSaveRow() && modelRowIndex < model.getRowCount() - 1; + + ui.getMoveCatchLonglineUp().setEnabled(canMoveUp); + ui.getMoveCatchLonglineDown().setEnabled(canMoveDown); + + } + + } +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUIModel.java ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/CatchLonglineLogbookUIModel.java @@ -0,0 +1,152 @@ +package fr.ird.observe.client.ui.content.data.longline; + +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.ImmutableSet; +import fr.ird.observe.client.ui.content.table.ContentTableMeta; +import fr.ird.observe.client.ui.content.table.ContentTableModel; +import fr.ird.observe.client.ui.content.table.ContentTableUIModel; +import fr.ird.observe.client.ui.content.table.ObserveContentTableUI; +import fr.ird.observe.dto.data.longline.CatchLonglineDto; +import fr.ird.observe.dto.data.longline.SetLonglineCatchDto; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +/** + * Created on 9/26/14. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 3.7 + */ +public class CatchLonglineLogbookUIModel extends ContentTableUIModel<SetLonglineCatchDto, CatchLonglineDto> { + + public static final String PROPERTY_CARACTERISTICS_TAB_VALID = "caracteristicsTabValid"; + + public static final String PROPERTY_DEPREDATED_TAB_VALID = "depredatedTabValid"; + + public static final Set<String> CARACTERISTIC_TAB_PROPERTIES = + ImmutableSet.<String>builder().add(CatchLonglineDto.PROPERTY_SPECIES_CATCH, + CatchLonglineDto.PROPERTY_PHOTO_REFERENCES, + CatchLonglineDto.PROPERTY_COUNT, + CatchLonglineDto.PROPERTY_TOTAL_WEIGHT, + CatchLonglineDto.PROPERTY_CATCH_HEALTHNESS, + CatchLonglineDto.PROPERTY_HOOK_POSITION, + CatchLonglineDto.PROPERTY_CATCH_FATE_LONGLINE, + CatchLonglineDto.PROPERTY_DISCARD_HEALTHNESS, + CatchLonglineDto.PROPERTY_TAG_NUMBER, + CatchLonglineDto.PROPERTY_HOOK_WHEN_DISCARDED).build(); + + public static final Set<String> DEPREDATED_TAB_PROPERTIES = + ImmutableSet.<String>builder().add(CatchLonglineDto.PROPERTY_DEPREDATED, + CatchLonglineDto.PROPERTY_BEAT_DIAMETER, + CatchLonglineDto.PROPERTY_PREDATOR).build(); + + + private static final long serialVersionUID = 1L; + + protected boolean caracteristicsTabValid; + + protected boolean depredatedTabValid; + + public CatchLonglineLogbookUIModel(CatchLonglineUI ui) { + super(SetLonglineCatchDto.class, + CatchLonglineDto.class, + new String[]{ + SetLonglineCatchDto.PROPERTY_CATCH_LONGLINE + }, + new String[]{CatchLonglineDto.PROPERTY_SPECIES_CATCH, + CatchLonglineDto.PROPERTY_ACQUISITION_MODE, + CatchLonglineDto.PROPERTY_COUNT, + CatchLonglineDto.PROPERTY_CATCH_HEALTHNESS, + CatchLonglineDto.PROPERTY_CATCH_FATE_LONGLINE, + CatchLonglineDto.PROPERTY_DISCARD_HEALTHNESS, + CatchLonglineDto.PROPERTY_DEPREDATED, + CatchLonglineDto.PROPERTY_NUMBER, + CatchLonglineDto.PROPERTY_HOME_ID, + CatchLonglineDto.PROPERTY_HOOK_POSITION, + CatchLonglineDto.PROPERTY_HOOK_WHEN_DISCARDED, + CatchLonglineDto.PROPERTY_MATURITY_STATUS, + CatchLonglineDto.PROPERTY_PHOTO_REFERENCES, + CatchLonglineDto.PROPERTY_SEX, + CatchLonglineDto.PROPERTY_PREDATOR, + CatchLonglineDto.PROPERTY_STOMAC_FULLNESS, + CatchLonglineDto.PROPERTY_TOTAL_WEIGHT, + CatchLonglineDto.PROPERTY_BEAT_DIAMETER, + CatchLonglineDto.PROPERTY_GONADE_WEIGHT, + CatchLonglineDto.PROPERTY_TAG_NUMBER, + CatchLonglineDto.PROPERTY_COMMENT + }); + + List<ContentTableMeta<CatchLonglineDto>> metas = Arrays.asList( + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_SPECIES_CATCH, false), + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_ACQUISITION_MODE, false), + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_COUNT, false), + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_CATCH_HEALTHNESS, false), + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_CATCH_FATE_LONGLINE, false), + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_DISCARD_HEALTHNESS, false), + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_DEPREDATED, false), + ContentTableModel.newTableMeta(CatchLonglineDto.class, CatchLonglineDto.PROPERTY_COMMENT, false)); + + initModel(ui, metas); + + } + + public boolean isCaracteristicsTabValid() { + return caracteristicsTabValid; + } + + public void setCaracteristicsTabValid(boolean caracteristicsTabValid) { + this.caracteristicsTabValid = caracteristicsTabValid; + firePropertyChange(PROPERTY_CARACTERISTICS_TAB_VALID, null, caracteristicsTabValid); + } + + public boolean isDepredatedTabValid() { + return depredatedTabValid; + } + + public void setDepredatedTabValid(boolean depredatedTabValid) { + this.depredatedTabValid = depredatedTabValid; + firePropertyChange(PROPERTY_DEPREDATED_TAB_VALID, null, depredatedTabValid); + } + + @Override + protected CatchLonglineTableModel createTableModel(ObserveContentTableUI<SetLonglineCatchDto, CatchLonglineDto, ?> ui, List<ContentTableMeta<CatchLonglineDto>> contentTableMetas) { + return new CatchLonglineTableModel(ui, contentTableMetas); + } + + @Override + protected BinderModelBuilder<CatchLonglineDto, CatchLonglineDto> prepareChildLoador(String binderName) { + + BinderModelBuilder<CatchLonglineDto, CatchLonglineDto> builder = super.prepareChildLoador(binderName); + + builder.addCollectionStrategy(Binder.CollectionStrategy.duplicate, CatchLonglineDto.PROPERTY_PREDATOR); + + return builder; + + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUI.jaxx ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUI.jaxx @@ -0,0 +1,452 @@ +<!-- + #%L + ObServe :: Client + %% + Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + %% + 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% + --> + +<fr.ird.observe.client.ui.content.ContentUI + i18nFormat="observe.common.SetLonglineDto.%s" + superGenericType='SetLonglineDto, SetLonglineLogbookUI' + contentTitle='{n("observe.common.SetLonglineDto.title")}'> + + <import> + fr.ird.observe.dto.data.longline.SetLonglineDto + fr.ird.observe.dto.referential.longline.SettingShapeReference + fr.ird.observe.dto.referential.longline.LineTypeReference + fr.ird.observe.dto.referential.longline.LightsticksTypeReference + fr.ird.observe.dto.referential.longline.LightsticksColorReference + + fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.ResetEditUIAction + fr.ird.observe.client.ui.actions.content.SaveEditUIAction + fr.ird.observe.client.ui.actions.main.global.DeleteDataGlobalUIAction + fr.ird.observe.client.ui.actions.main.global.NewNextDataGlobalUIAction + fr.ird.observe.client.ui.actions.main.global.ResetDataGlobalUIAction + fr.ird.observe.client.ui.actions.main.global.SaveDataGlobalUIAction + + fr.ird.observe.client.ui.content.ContentUIModel + fr.ird.observe.client.ui.util.BooleanEditor + fr.ird.observe.client.ui.util.JComment + + org.nuiton.jaxx.widgets.number.NumberEditor + org.nuiton.jaxx.widgets.select.BeanComboBox + org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor + org.nuiton.jaxx.widgets.datetime.DateTimeEditor + + org.apache.commons.lang3.BooleanUtils + + java.awt.Dimension + + static fr.ird.observe.client.ui.util.UIHelper.getStringValue + static org.nuiton.i18n.I18n.n + </import> + + <style source="../../Common.jcss"/> + + <!-- model --> + <SetLonglineLogbookUIModel id='model'/> + + <!-- edit bean --> + <SetLonglineDto id='bean'/> + + <!-- validator --> + <BeanValidator id='validator' autoField='true' context='update' + beanClass='fr.ird.observe.dto.data.longline.SetLonglineDto' + errorTableModel='{getErrorTableModel()}'> + + <field name='settingStartLongitude' component='settingStartCoordinates'/> + <field name='settingStartLatitude' component='settingStartCoordinates'/> + <field name='settingStartQuadrant' component='settingStartCoordinates'/> + + <field name='settingEndLongitude' component='settingEndCoordinates'/> + <field name='settingEndLatitude' component='settingEndCoordinates'/> + <field name='settingEndQuadrant' component='settingEndCoordinates'/> + + <field name='haulingStartLongitude' component='haulingStartCoordinates'/> + <field name='haulingStartLatitude' component='haulingStartCoordinates'/> + <field name='haulingStartQuadrant' component='haulingStartCoordinates'/> + + <field name='haulingEndLongitude' component='haulingEndCoordinates'/> + <field name='haulingEndLatitude' component='haulingEndCoordinates'/> + <field name='haulingEndQuadrant' component='haulingEndCoordinates'/> + + </BeanValidator> + + <!-- formulaire --> + <JPanel id="body" layout='{new BorderLayout()}'> + + <Table insets="0" fill="both" constraints='BorderLayout.CENTER'> + <row> + <cell anchor="north"> + <JTabbedPane id='mainTabbedPane'> + <tab id='settingTab' computeI18n=""> + <JPanel layout='{new BorderLayout()}'> + <Table fill='both' constraints='BorderLayout.NORTH'> + + <!-- homeId --> + <row> + <cell anchor='west'> + <JLabel id='homeIdLabel'/> + </cell> + <cell anchor='east' weightx="1" fill="both"> + <JPanel layout='{new BorderLayout()}'> + <JToolBar id='homeIdToolbar' constraints='BorderLayout.WEST'> + <JButton id='resetHomeId' constraints='BorderLayout.WEST' styleClass='resetButton'/> + </JToolBar> + <JTextField id='homeId' constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> + <!-- number --> + <row> + <cell anchor='west'> + <JLabel id='numberLabel'/> + </cell> + <cell columns="2" weightx="1" fill="both"> + <NumberEditor id='number' constructorParams='this' styleClass="int6"/> + </cell> + </row> + <!-- setting shape --> + <row> + <cell anchor='west'> + <JLabel id='settingShapeLabel'/> + </cell> + <cell columns="3" fill="both"> + <BeanComboBox id='settingShape' constructorParams='this' genericType='SettingShapeReference'/> + </cell> + </row> + <row> + <cell columns="2"> + <Table insets="0" fill='both'> + <!-- setting start timeStamp --> + <row> + <cell weightx="1"> + <DateTimeEditor id='settingStartTimeStamp' constructorParams='this'/> + </cell> + </row> + + <!-- setting start position --> + <row> + <cell anchor="east"> + <CoordinatesEditor id='settingStartCoordinates' constructorParams='this'/> + </cell> + </row> + + <!-- setting end timeStamp --> + <row> + <cell> + <DateTimeEditor id='settingEndTimeStamp' constructorParams='this'/> + </cell> + </row> + + <!-- setting end position --> + <row> + <cell anchor="east"> + <CoordinatesEditor id='settingEndCoordinates' constructorParams='this'/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> + </JPanel> + + </tab> + + <tab id='settingCaracteristicsTab' computeI18n=""> + <Table fill='both'> + + <!-- setting vessel speed --> + <row> + <cell> + <JLabel id='settingVesselSpeedLabel'/> + </cell> + <cell columns="3"> + <NumberEditor id='settingVesselSpeed' constructorParams='this' styleClass="float3"/> + </cell> + </row> + <!-- time between hooks --> + <row> + <cell anchor='west'> + <JLabel id='timeBetweenHooksLabel'/> + </cell> + <cell fill='both' weightx="1" columns="3"> + <NumberEditor id='timeBetweenHooks' constructorParams='this' styleClass="long10"/> + </cell> + </row> + <!-- total line length --> + <row> + <cell anchor='west'> + <JLabel id='totalLineLengthLabel'/> + </cell> + <cell fill='both' weightx="1" columns="3"> + <NumberEditor id='totalLineLength' constructorParams='this' styleClass="long10"/> + </cell> + </row> + <!-- basket line length --> + <row> + <cell anchor='west'> + <JLabel id='basketLineLengthLabel'/> + </cell> + <cell fill='both' weightx="1" columns="3"> + <NumberEditor id='basketLineLength' constructorParams='this' styleClass="long10"/> + </cell> + </row> + <!-- lengthBetweenBranchlines --> + <row> + <cell anchor='west'> + <JLabel id='lengthBetweenBranchlinesLabel'/> + </cell> + <cell fill='both' weightx="1" columns="3"> + <NumberEditor id='lengthBetweenBranchlines' constructorParams='this' styleClass="long10"/> + </cell> + </row> + + <!-- shooter used --> + <!-- shooter speed --> + <row> + <cell anchor="east"> + <JCheckBox id='shooterUsed' styleClass="i18n"/> + </cell> + <cell> + <JLabel id='shooterSpeedLabel'/> + </cell> + <cell columns="2"> + <NumberEditor id='shooterSpeed' constructorParams='this' styleClass="float3"/> + </cell> + </row> + <!-- max depth targeted (m) --> + <row> + <cell> + <JLabel id='maxDepthTargetedLabel'/> + </cell> + <cell columns="3"> + <NumberEditor id='maxDepthTargeted' constructorParams='this' styleClass="int6"/> + </cell> + </row> + <!-- total section count --> + <row> + <cell anchor='west'> + <JLabel id='totalSectionsCountLabel'/> + </cell> + <cell fill='both' weightx="1" columns="3"> + <NumberEditor id='totalSectionsCount' constructorParams='this' styleClass="int6"/> + </cell> + </row> + <!-- basket per section count --> + <!-- total basket count --> + <row> + <cell anchor='west'> + <JLabel id='basketsPerSectionCountLabel'/> + </cell> + <cell fill='both' weightx="1"> + <NumberEditor id='basketsPerSectionCount' constructorParams='this' styleClass="int6"/> + </cell> + <cell anchor='west'> + <JLabel id='totalBasketsCountLabel'/> + </cell> + <cell fill='both' weightx="1"> + <NumberEditor id='totalBasketsCount' constructorParams='this' styleClass="int6"/> + </cell> + </row> + <!-- branchlines per basket count --> + <!-- total hooks count --> + <row> + <cell anchor='west'> + <JLabel id='branchlinesPerBasketCountLabel'/> + </cell> + <cell fill='both' weightx="1"> + <NumberEditor id='branchlinesPerBasketCount' constructorParams='this' styleClass="int6"/> + </cell> + <cell anchor='west'> + <JLabel id='totalHooksCountLabel'/> + </cell> + <cell fill='both' weightx="1"> + <NumberEditor id='totalHooksCount' constructorParams='this' styleClass="int6"/> + </cell> + </row> + <!-- line type --> + <row> + <cell anchor='west'> + <JLabel id='lineTypeLabel'/> + </cell> + <cell columns="3"> + <BeanComboBox id='lineType' constructorParams='this' genericType='LineTypeReference'/> + </cell> + </row> + <!-- weighted swivels --> + <!-- swivels weights --> + <row> + <cell anchor="east"> + <JCheckBox id='weightedSwivel' styleClass="i18n"/> + </cell> + <cell anchor="west"> + <JLabel id='swivelWeightLabel'/> + </cell> + <cell columns="2"> + <NumberEditor id='swivelWeight' constructorParams='this' styleClass="float3"/> + </cell> + </row> + + <!-- weighted snaps --> + <!-- snap weights --> + <row> + <cell anchor='east'> + <JCheckBox id='weightedSnap' styleClass="i18n"/> + </cell> + <cell> + <JLabel id='snapWeightLabel'/> + </cell> + <cell columns="2"> + <NumberEditor id='snapWeight' constructorParams='this' styleClass="float3"/> + </cell> + </row> + <!-- monitored --> + <row> + <cell anchor='east'> + <JCheckBox id='monitored' styleClass="i18n"/> + </cell> + </row> + </Table> + </tab> + + <tab id='lightstickssTab' computeI18n=""> + <JPanel layout='{new BorderLayout()}'> + <Table fill='both' constraints='BorderLayout.NORTH'> + <!-- lightsticksUsed --> + <row> + <cell anchor='east'> + <JCheckBox id='lightsticksUsed' styleClass="i18n"/> + </cell> + </row> + <!-- lightsticks per basket count --> + <row> + <cell anchor='west'> + <JLabel id='lightsticksPerBasketCountLabel'/> + </cell> + <cell fill='both' weightx="1" columns="3"> + <NumberEditor id='lightsticksPerBasketCount' constructorParams='this' styleClass="int6"/> + </cell> + </row> + <!-- lightsticks type --> + <row> + <cell anchor='west'> + <JLabel id='lightsticksTypeLabel'/> + </cell> + <cell columns="3"> + <BeanComboBox id='lightsticksType' constructorParams='this' genericType='LightsticksTypeReference'/> + </cell> + </row> + <!-- lightsticks color --> + <row> + <cell anchor='west'> + <JLabel id='lightsticksColorLabel'/> + </cell> + <cell columns="3"> + <BeanComboBox id='lightsticksColor' constructorParams='this' genericType='LightsticksColorReference'/> + </cell> + </row> + </Table> + </JPanel> + </tab> + + <tab id='haulingTab' computeI18n=""> + + <JPanel layout='{new BorderLayout()}'> + <Table fill='both' constraints='BorderLayout.NORTH'> + + <!-- hauling same direction as setting --> + <row> + <cell> + <JLabel id='haulingDirectionSameAsSettingLabel'/> + </cell> + <cell> + <BooleanEditor id='haulingDirectionSameAsSetting'/> + </cell> + </row> + + <!-- hauling start timeStamp --> + <row> + <cell columns="2" weightx="1"> + <DateTimeEditor id='haulingStartTimeStamp' constructorParams='this'/> + </cell> + </row> + + <!-- hauling start position --> + <row> + <cell columns="2" anchor='east'> + <CoordinatesEditor id='haulingStartCoordinates' constructorParams='this'/> + </cell> + </row> + + <!-- hauling end timeStamp --> + <row> + <cell columns="2" weightx="1"> + <DateTimeEditor id='haulingEndTimeStamp' constructorParams='this'/> + </cell> + </row> + + <!-- hauling end position --> + <row> + <cell columns="2" anchor='east'> + <CoordinatesEditor id='haulingEndCoordinates' constructorParams='this'/> + </cell> + </row> + + <row> + <!-- hauling breaks --> + <cell anchor="west"> + <JLabel id='haulingBreaksLabel'/> + </cell> + <cell weightx="1" fill="both"> + <NumberEditor id='haulingBreaks' constructorParams='this' styleClass="int6"/> + </cell> + </row> + </Table> + </JPanel> + </tab> + </JTabbedPane> + </cell> + </row> + + <row> + <cell fill="both" weighty="1" weightx="1"> + <JComment id="comment"/> + </cell> + </row> + + </Table> + </JPanel> + + <!-- actions --> + <Table id="actions" fill='both' weightx='1' insets='0'> + <row> + <cell weightx="0.5" fill="both"> + <JButton id='reset'/> + </cell> + <cell weightx="0.5"> + <JButton id='save'/> + </cell> + <cell weightx="0.5"> + <JButton id='delete'/> + </cell> + </row> + </Table> + +</fr.ird.observe.client.ui.content.ContentUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUI.jcss ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUI.jcss @@ -0,0 +1,254 @@ +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * 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% + */ + +#model { + editable:true; + modified:{validator.isChanged()}; + valid:{validator.isValid()}; + enabled:{!model.isReadingMode()}; +} + +/* ***************************************************************************** */ +/* SETTING TAB **************************************************************** */ +/* ***************************************************************************** */ + +#settingTab { + icon:{handler.getErrorIconIfFalse(model.isSettingTabValid())}; +} + +#homeId { + text: {getStringValue(bean.getHomeId())}; + _propertyName: {SetLonglineDto.PROPERTY_HOME_ID}; +} + +#resetHomeId { + _resetPropertyName: {SetLonglineDto.PROPERTY_HOME_ID}; + toolTipText:"observe.common.SetLonglineDto.action.reset.homeId.tip"; +} + +#number { + property: {SetLonglineDto.PROPERTY_NUMBER}; + numberValue:{bean.getNumber()}; +} + +#settingStartTimeStamp { + date:{bean.getSettingStartTimeStamp()}; + propertyDate: {SetLonglineDto.PROPERTY_SETTING_START_TIME_STAMP}; +} + +#settingStartCoordinates { + propertyLatitude:{SetLonglineDto.PROPERTY_SETTING_START_LATITUDE}; + propertyLongitude:{SetLonglineDto.PROPERTY_SETTING_START_LONGITUDE}; + propertyQuadrant:{SetLonglineDto.PROPERTY_SETTING_START_QUADRANT}; + latitude:{bean.getSettingStartLatitude()}; + longitude:{bean.getSettingStartLongitude()}; + quadrant:{bean.getSettingStartQuadrant()}; +} + +#settingEndTimeStamp { + date:{bean.getSettingEndTimeStamp()}; + propertyDate: {SetLonglineDto.PROPERTY_SETTING_END_TIME_STAMP}; +} + +#settingEndCoordinates { + propertyLatitude:{SetLonglineDto.PROPERTY_SETTING_END_LATITUDE}; + propertyLongitude:{SetLonglineDto.PROPERTY_SETTING_END_LONGITUDE}; + propertyQuadrant:{SetLonglineDto.PROPERTY_SETTING_END_QUADRANT}; + latitude:{bean.getSettingEndLatitude()}; + longitude:{bean.getSettingEndLongitude()}; + quadrant:{bean.getSettingEndQuadrant()}; +} + +/* ***************************************************************************** */ +/* SETTING CARACTERISTICS TAB ************************************************* */ +/* ***************************************************************************** */ + +#settingCaracteristicsTab { + icon:{handler.getErrorIconIfFalse(model.isSettingCaracteristicsTabValid())}; +} + +#settingVesselSpeed { + property:{SetLonglineDto.PROPERTY_SETTING_VESSEL_SPEED}; + numberValue:{bean.getSettingVesselSpeed()}; +} + +#shooterUsed { + horizontalTextPosition:{JCheckBox.LEFT}; + _propertyName:{SetLonglineDto.PROPERTY_SHOOTER_USED}; + selected:{BooleanUtils.isTrue(bean.getShooterUsed())}; +} + +#shooterSpeed { + enabled:{BooleanUtils.isTrue(bean.getShooterUsed())}; + property:{SetLonglineDto.PROPERTY_SHOOTER_SPEED}; + numberValue:{bean.getShooterSpeed()}; +} + +#settingShape { + property:{SetLonglineDto.PROPERTY_SETTING_SHAPE}; + selectedItem:{bean.getSettingShape()}; +} + +#weightedSwivel { + horizontalTextPosition:{JCheckBox.LEFT}; + _propertyName:{SetLonglineDto.PROPERTY_WEIGHTED_SWIVEL}; + selected:{BooleanUtils.isTrue(bean.getWeightedSwivel())}; +} + +#swivelWeight { + enabled:{BooleanUtils.isTrue(bean.getWeightedSwivel())}; + property:{SetLonglineDto.PROPERTY_SWIVEL_WEIGHT}; + numberValue:{bean.getSwivelWeight()}; +} + +#weightedSnap { + horizontalTextPosition:{JCheckBox.LEFT}; + _propertyName:{SetLonglineDto.PROPERTY_WEIGHTED_SNAP}; + selected:{BooleanUtils.isTrue(bean.getWeightedSnap())}; +} + +#snapWeight { + enabled:{BooleanUtils.isTrue(bean.getWeightedSnap())}; + property:{SetLonglineDto.PROPERTY_SNAP_WEIGHT}; + numberValue:{bean.getSnapWeight()}; +} + +#lineType { + property:{SetLonglineDto.PROPERTY_LINE_TYPE}; + selectedItem:{bean.getLineType()}; +} + +#maxDepthTargeted { + property:{SetLonglineDto.PROPERTY_MAX_DEPTH_TARGETED}; + numberValue:{bean.getMaxDepthTargeted()}; +} + +#monitored { + horizontalTextPosition:{JCheckBox.LEFT}; + _propertyName:{SetLonglineDto.PROPERTY_MONITORED}; + selected:{BooleanUtils.isTrue(bean.getMonitored())}; +} + +#lightsticksType { + property:{SetLonglineDto.PROPERTY_LIGHTSTICKS_TYPE}; + selectedItem:{bean.getLightsticksType()}; + enabled:{bean.getLightsticksPerBasketCount() !=null && bean.getLightsticksPerBasketCount() > 0}; +} + +#lightsticksColor { + property:{SetLonglineDto.PROPERTY_LIGHTSTICKS_COLOR}; + selectedItem:{bean.getLightsticksColor()}; + enabled:{bean.getLightsticksPerBasketCount() !=null && bean.getLightsticksPerBasketCount() > 0}; +} + +#timeBetweenHooks { + property:{SetLonglineDto.PROPERTY_TIME_BETWEEN_HOOKS}; + numberValue:{bean.getTimeBetweenHooks()}; +} + +#lightsticksPerBasketCount { + property:{SetLonglineDto.PROPERTY_LIGHTSTICKS_PER_BASKET_COUNT}; + numberValue:{bean.getLightsticksPerBasketCount()}; +} + +#basketsPerSectionCount { + property:{SetLonglineDto.PROPERTY_BASKETS_PER_SECTION_COUNT}; + numberValue:{bean.getBasketsPerSectionCount()}; +} + +#totalBasketsCount { + property:{SetLonglineDto.PROPERTY_TOTAL_BASKETS_COUNT}; + numberValue:{bean.getTotalBasketsCount()}; +} + +#branchlinesPerBasketCount { + property:{SetLonglineDto.PROPERTY_BRANCHLINES_PER_BASKET_COUNT}; + numberValue:{bean.getBranchlinesPerBasketCount()}; +} + +#totalSectionsCount { + property:{SetLonglineDto.PROPERTY_TOTAL_SECTIONS_COUNT}; + numberValue:{bean.getTotalSectionsCount()}; +} + +#totalHooksCount { + property:{SetLonglineDto.PROPERTY_TOTAL_HOOKS_COUNT}; + numberValue:{bean.getTotalHooksCount()}; +} + +/* ***************************************************************************** */ +/* HAULING TAB **************************************************************** */ +/* ***************************************************************************** */ + +#haulingTab { + icon:{handler.getErrorIconIfFalse(model.isHaulingTabValid())}; +} + +#haulingDirectionSameAsSetting { + booleanValue:{bean.getHaulingDirectionSameAsSetting()}; + _propertyName: {SetLonglineDto.PROPERTY_HAULING_DIRECTION_SAME_AS_SETTING}; +} + +#haulingStartTimeStamp { + date:{bean.getHaulingStartTimeStamp()}; + propertyDate: {SetLonglineDto.PROPERTY_HAULING_START_TIME_STAMP}; +} + +#haulingStartCoordinates { + propertyLatitude:{SetLonglineDto.PROPERTY_HAULING_START_LATITUDE}; + propertyLongitude:{SetLonglineDto.PROPERTY_HAULING_START_LONGITUDE}; + propertyQuadrant:{SetLonglineDto.PROPERTY_HAULING_START_QUADRANT}; + latitude:{bean.getHaulingStartLatitude()}; + longitude:{bean.getHaulingStartLongitude()}; + quadrant:{bean.getHaulingStartQuadrant()}; +} + +#haulingEndTimeStamp { + date:{bean.getHaulingEndTimeStamp()}; + propertyDate: {SetLonglineDto.PROPERTY_HAULING_END_TIME_STAMP}; +} + +#haulingEndCoordinates { + propertyLatitude:{SetLonglineDto.PROPERTY_HAULING_END_LATITUDE}; + propertyLongitude:{SetLonglineDto.PROPERTY_HAULING_END_LONGITUDE}; + propertyQuadrant:{SetLonglineDto.PROPERTY_HAULING_END_QUADRANT}; + latitude:{bean.getHaulingEndLatitude()}; + longitude:{bean.getHaulingEndLongitude()}; + quadrant:{bean.getHaulingEndQuadrant()}; +} + +#haulingBreaks { + property:{SetLonglineDto.PROPERTY_HAULING_BREAKS}; + numberValue:{bean.getHaulingBreaks()}; +} + +#delete { + _globalAction:{DeleteDataGlobalUIAction.ACTION_NAME}; +} + +#save { + _globalAction:{SaveDataGlobalUIAction.ACTION_NAME}; +} + +#reset { + _globalAction:{ResetDataGlobalUIAction.ACTION_NAME}; +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUIHandler.java ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUIHandler.java @@ -0,0 +1,495 @@ +package fr.ird.observe.client.ui.content.data.longline; + +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ird.observe.client.ObserveSwingApplicationContext; +import fr.ird.observe.client.db.ClientDataContext; +import fr.ird.observe.client.db.ObserveSwingDataSource; +import fr.ird.observe.client.db.constants.DataContextType; +import fr.ird.observe.client.ui.content.ContentMode; +import fr.ird.observe.client.ui.content.ContentUIHandler; +import fr.ird.observe.client.ui.content.ContentUIModel; +import fr.ird.observe.client.ui.tree.navigation.NavigationTree; +import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; +import fr.ird.observe.client.validation.ClientValidationContext; +import fr.ird.observe.dto.data.longline.ActivityLonglineDto; +import fr.ird.observe.dto.data.longline.SetLonglineDto; +import fr.ird.observe.dto.data.longline.SetLonglineHelper; +import fr.ird.observe.dto.data.longline.SetLonglineReference; +import fr.ird.observe.dto.form.Form; +import fr.ird.observe.dto.result.SaveResultDto; +import fr.ird.observe.spi.DtoModelHelper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.runtime.spi.UIHandler; +import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; +import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; +import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; +import org.nuiton.jaxx.widgets.gis.CoordinateFormat; +import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditorModel; +import org.nuiton.jaxx.widgets.hidor.HidorButton; +import org.nuiton.validator.NuitonValidatorScope; + +import javax.swing.event.TableModelListener; +import java.beans.PropertyChangeListener; +import java.util.HashSet; +import java.util.Set; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created on 9/1/14. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 3.7 + */ +public class SetLonglineLogbookUIHandler extends ContentUIHandler<SetLonglineDto, SetLonglineLogbookUI> implements UIHandler<SetLonglineLogbookUI> { + + /** Logger */ + private static final Log log = LogFactory.getLog(SetLonglineLogbookUIHandler.class); + + // Compute valid state of tab from the error table + protected final TableModelListener computeTabValidStateListener; + + // Change toogle target visible on all TimeEditors + private final PropertyChangeListener onToogleTimeEditorSliderChangedListener; + + // Change toogle target visible on all TimeEditors + private final PropertyChangeListener onCoordinateFormatChangedListener; + + private boolean toogleTimeEditorSliderIsChanging; + + private boolean coordinateFormatChangedIsChanging; + + SetLonglineLogbookUIHandler() { + super(DataContextType.ActivityLongline, DataContextType.SetLongline); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; + onToogleTimeEditorSliderChangedListener = evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + onToogleTimeEditorSliderChanged(newValue); + }; + onCoordinateFormatChangedListener = evt -> { + CoordinateFormat newValue = (CoordinateFormat) evt.getNewValue(); + onCoordinateFormatChanged(newValue); + }; + } + + @Override + protected boolean computeCanWrite(ObserveSwingDataSource source) { + return source.canWriteData(); + } + + @Override + protected ContentMode getContentMode(ClientDataContext dataContext) { + + String setId = getSelectedId(); + + if (setId == null) { + + // mode creation + return ContentMode.CREATE; + + } + + if (getOpenDataManager().isOpenActivityLongline(dataContext.getSelectedActivityLonglineId())) { + + // l'activité est ouverte, mode édition + return ContentMode.UPDATE; + + } + + // l'activité n'est pas ouverte, mode lecture + addMessage(getUi(), + NuitonValidatorScope.INFO, + getTypeI18nKey(ActivityLonglineDto.class), + t("observe.common.ActivityLonglineDto.message.not.open")); + + return ContentMode.READ; + + } + + @Override + public void afterInit(SetLonglineLogbookUI ui) { + super.afterInit(ui); + + ui.getSettingStartTimeStamp().getSliderHidor().addPropertyChangeListener(HidorButton.PROPERTY_TARGET_VISIBLE, onToogleTimeEditorSliderChangedListener); + ui.getSettingEndTimeStamp().getSliderHidor().addPropertyChangeListener(HidorButton.PROPERTY_TARGET_VISIBLE, onToogleTimeEditorSliderChangedListener); + ui.getHaulingStartTimeStamp().getSliderHidor().addPropertyChangeListener(HidorButton.PROPERTY_TARGET_VISIBLE, onToogleTimeEditorSliderChangedListener); + ui.getHaulingEndTimeStamp().getSliderHidor().addPropertyChangeListener(HidorButton.PROPERTY_TARGET_VISIBLE, onToogleTimeEditorSliderChangedListener); + + ui.getSettingStartCoordinates().getModel().addPropertyChangeListener(CoordinatesEditorModel.PROPERTY_FORMAT, onCoordinateFormatChangedListener); + ui.getSettingEndCoordinates().getModel().addPropertyChangeListener(CoordinatesEditorModel.PROPERTY_FORMAT, onCoordinateFormatChangedListener); + ui.getHaulingStartCoordinates().getModel().addPropertyChangeListener(CoordinatesEditorModel.PROPERTY_FORMAT, onCoordinateFormatChangedListener); + ui.getHaulingEndCoordinates().getModel().addPropertyChangeListener(CoordinatesEditorModel.PROPERTY_FORMAT, onCoordinateFormatChangedListener); + + } + + @Override + public void openUI() { + + getUi().getSettingStartCoordinates().resetModel(); + getUi().getSettingEndCoordinates().resetModel(); + getUi().getHaulingStartCoordinates().resetModel(); + getUi().getHaulingEndCoordinates().resetModel(); + + if (log.isInfoEnabled()) { + log.info("OpenUI: " + getModel()); + } + super.openUI(); + + String activityId = getSelectedParentId(); + String setId = getSelectedId(); + + if (log.isInfoEnabled()) { + log.info("activityId = " + activityId); + log.info("setId = " + setId); + } + ContentMode mode = computeContentMode(); + + SetLonglineDto bean = getBean(); + + Form<SetLonglineDto> form; + if (setId == null) { + + // create mode + form = getSetLonglineService().preCreate(activityId); + + } else { + + // update mode + form = getSetLonglineService().loadForm(setId); + + } + + loadReferentialReferenceSetsInModel(form); + + getModel().setForm(form); + SetLonglineHelper.copySetLonglineDto(form.getObject(), bean); + + // 1. Mise à jour latitude/longitude: + getUi().getSettingStartCoordinates().setLatitudeAndLongitude(bean.getSettingStartLatitude(), bean.getSettingStartLongitude()); + // 2. Mise à jour du quadrant : + // Si le bean de données contient un quadrant, on met simplement à jour le composant de coordonnées pour sélectionner le quadrant voulu + // sinon, on réinitialise les quadrants du composant afin qu'aucun d'eux ne soit sélectionné (par exemple dans le cas de la création de la première activité d'une route) + if (bean.getSettingStartQuadrant() == null) { + getUi().getSettingStartCoordinates().resetQuadrant(); + } else { + getUi().getSettingStartCoordinates().setQuadrant(bean.getSettingStartQuadrant()); + } + + // 1. Mise à jour latitude/longitude: + getUi().getSettingEndCoordinates().setLatitudeAndLongitude(bean.getSettingEndLatitude(), bean.getSettingEndLongitude()); + // 2. Mise à jour du quadrant : + // Si le bean de données contient un quadrant, on met simplement à jour le composant de coordonnées pour sélectionner le quadrant voulu + // sinon, on réinitialise les quadrants du composant afin qu'aucun d'eux ne soit sélectionné (par exemple dans le cas de la création de la première activité d'une route) + if (bean.getSettingEndQuadrant() == null) { + getUi().getSettingEndCoordinates().resetQuadrant(); + } else { + getUi().getSettingEndCoordinates().setQuadrant(bean.getSettingEndQuadrant()); + } + + // 1. Mise à jour latitude/longitude: + getUi().getHaulingStartCoordinates().setLatitudeAndLongitude(bean.getHaulingStartLatitude(), bean.getHaulingStartLongitude()); + // 2. Mise à jour du quadrant : + // Si le bean de données contient un quadrant, on met simplement à jour le composant de coordonnées pour sélectionner le quadrant voulu + // sinon, on réinitialise les quadrants du composant afin qu'aucun d'eux ne soit sélectionné (par exemple dans le cas de la création de la première activité d'une route) + if (bean.getHaulingStartQuadrant() == null) { + getUi().getHaulingStartCoordinates().resetQuadrant(); + } else { + getUi().getHaulingStartCoordinates().setQuadrant(bean.getHaulingStartQuadrant()); + } + + // 1. Mise à jour latitude/longitude: + getUi().getHaulingEndCoordinates().setLatitudeAndLongitude(bean.getHaulingEndLatitude(), bean.getHaulingEndLongitude()); + // 2. Mise à jour du quadrant : + // Si le bean de données contient un quadrant, on met simplement à jour le composant de coordonnées pour sélectionner le quadrant voulu + // sinon, on réinitialise les quadrants du composant afin qu'aucun d'eux ne soit sélectionné (par exemple dans le cas de la création de la première activité d'une route) + if (bean.getHaulingEndQuadrant() == null) { + getUi().getHaulingEndCoordinates().resetQuadrant(); + } else { + getUi().getHaulingEndCoordinates().setQuadrant(bean.getHaulingEndQuadrant()); + } + + // utilisation du mode requis + setContentMode(mode); + + // To be sure always remove listener (could prevent some leaks) + getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener); + // listen messages to see if required to add + getUi().getErrorTableModel().addTableModelListener(computeTabValidStateListener); + + SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel(); + computeTabValidState(errorTableModel); + + if (mode != ContentMode.READ) { + getUi().startEdit(null); + } + + } + + @Override + protected void closeSafeUI() { + + if (log.isInfoEnabled()) { + log.info("CloseUI: " + getModel()); + } + super.closeSafeUI(); + + // remove listener + getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener); + + } + + @Override + public void startEditUI(String... binding) { + + ContentUIModel<SetLonglineDto> model = getModel(); + boolean create = model.getMode() == ContentMode.CREATE; + String contextName = getValidatorContextName(model.getMode()); + getUi().getValidator().setContext(contextName); + if (create) { + addInfoMessage(t("observe.common.SetLonglineDto.message.creating")); + } else { + addInfoMessage(t("observe.common.SetLonglineDto.message.updating")); + } + + super.startEditUI(SetLonglineLogbookUI.BINDING_COMMENT_MODEL, + + // setting tab + SetLonglineLogbookUI.BINDING_HOME_ID_TEXT, + SetLonglineLogbookUI.BINDING_NUMBER_NUMBER_VALUE, + + SetLonglineLogbookUI.BINDING_SETTING_START_TIME_STAMP_DATE, + SetLonglineLogbookUI.BINDING_SETTING_START_COORDINATES_LATITUDE, + SetLonglineLogbookUI.BINDING_SETTING_START_COORDINATES_LONGITUDE, + + SetLonglineLogbookUI.BINDING_SETTING_END_TIME_STAMP_DATE, + SetLonglineLogbookUI.BINDING_SETTING_END_COORDINATES_LATITUDE, + SetLonglineLogbookUI.BINDING_SETTING_END_COORDINATES_LONGITUDE, + + // setting caracteristics tab + SetLonglineLogbookUI.BINDING_SETTING_VESSEL_SPEED_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_SHOOTER_USED_SELECTED, + SetLonglineLogbookUI.BINDING_SHOOTER_SPEED_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_TIME_BETWEEN_HOOKS_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_SETTING_SHAPE_SELECTED_ITEM, + SetLonglineLogbookUI.BINDING_WEIGHTED_SWIVEL_SELECTED, + SetLonglineLogbookUI.BINDING_SWIVEL_WEIGHT_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_WEIGHTED_SNAP_SELECTED, + SetLonglineLogbookUI.BINDING_SNAP_WEIGHT_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_LINE_TYPE_SELECTED_ITEM, + SetLonglineLogbookUI.BINDING_MAX_DEPTH_TARGETED_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_MONITORED_SELECTED, + SetLonglineLogbookUI.BINDING_LIGHTSTICKS_TYPE_SELECTED_ITEM, + SetLonglineLogbookUI.BINDING_LIGHTSTICKS_COLOR_SELECTED_ITEM, + SetLonglineLogbookUI.BINDING_LIGHTSTICKS_PER_BASKET_COUNT_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_BASKETS_PER_SECTION_COUNT_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_TOTAL_BASKETS_COUNT_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_BRANCHLINES_PER_BASKET_COUNT_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_TOTAL_SECTIONS_COUNT_NUMBER_VALUE, + SetLonglineLogbookUI.BINDING_TOTAL_HOOKS_COUNT_NUMBER_VALUE, + + // hauling tab + SetLonglineLogbookUI.BINDING_HAULING_DIRECTION_SAME_AS_SETTING_BOOLEAN_VALUE, + + SetLonglineLogbookUI.BINDING_HAULING_START_TIME_STAMP_DATE, + SetLonglineLogbookUI.BINDING_HAULING_START_COORDINATES_LATITUDE, + SetLonglineLogbookUI.BINDING_HAULING_START_COORDINATES_LONGITUDE, + + SetLonglineLogbookUI.BINDING_HAULING_END_TIME_STAMP_DATE, + SetLonglineLogbookUI.BINDING_HAULING_END_COORDINATES_LATITUDE, + SetLonglineLogbookUI.BINDING_HAULING_END_COORDINATES_LONGITUDE, + + SetLonglineLogbookUI.BINDING_HAULING_BREAKS_NUMBER_VALUE); + + model.setModified(create); + + } + + @Override + protected boolean doSave(SetLonglineDto bean) { + + String activityId = getSelectedParentId(); + + boolean notPersisted = bean.isNotPersisted(); + + SaveResultDto saveResult = getSetLonglineService().save(activityId, bean); + saveResult.toDto(bean); + + if (notPersisted) { + getOpenDataManager().openSetLongline(activityId, bean.getId()); + } + + return true; + + } + + @Override + protected void afterSave(boolean refresh) { + + super.afterSave(refresh); + + SetLonglineDto bean = getBean(); + + SwingValidatorUtil.setValidatorChanged(getUi(), false); + + NavigationTree treeHelper = getNavigationTree(); + + NavigationTreeNodeSupport node = treeHelper.getSelectedNode(); + boolean create = node.getId() == null; + + if (create) { + + getModel().setMode(ContentMode.UPDATE); + + // remove old node and recreate new node + NavigationTreeNodeSupport parentNode = node.getParent(); + treeHelper.removeNode(node); + + SetLonglineReference reference = DtoModelHelper.fromDataDto(SetLonglineDto.class).toReference(getDecoratorService().getReferentialLocale(), bean); + node = treeHelper.addSetLongline(parentNode, reference); + + stopEditUI(); + treeHelper.selectNode(node); + + } else { + + // select ancestor node + treeHelper.reloadSelectedNode(false, false); + + } + + } + + @Override + protected boolean doDelete(SetLonglineDto bean) { + + if (askToDelete(bean)) { + return false; + } + + String activityId = getSelectedParentId(); + getSetLonglineService().delete(activityId, bean.getId()); + + return true; + + } + + @Override + protected void prepareValidationContext() { + super.prepareValidationContext(); + + ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); + validationContext.setCoordinatesEditor("haulingStart", getUi().getHaulingStartCoordinates()); + validationContext.setCoordinatesEditor("haulingEnd", getUi().getHaulingEndCoordinates()); + validationContext.setCoordinatesEditor("settingStart", getUi().getSettingStartCoordinates()); + validationContext.setCoordinatesEditor("settingEnd", getUi().getSettingEndCoordinates()); + + } + + + protected void computeTabValidState(SwingValidatorMessageTableModel errorTableModel) { + + Set<String> errorProperties = new HashSet<>(); + int rowCount = errorTableModel.getRowCount(); + for (int i = 0; i < rowCount; i++) { + + SwingValidatorMessage row = errorTableModel.getRow(i); + if (NuitonValidatorScope.ERROR.equals(row.getScope())) { + errorProperties.add(row.getField()); + } + } + + boolean settingTabValid = !errorProperties.removeAll(SetLonglineLogbookUIModel.SETTING_TAB_PROPERTIES); + boolean settingCaracteristicsTabValid = !errorProperties.removeAll(SetLonglineLogbookUIModel.SETTING_CARACTERISTICS_TAB_PROPERTIES); + boolean haulingTabValid = !errorProperties.removeAll(SetLonglineLogbookUIModel.HAULING_TAB_PROPERTIES); + + SetLonglineLogbookUIModel model = (SetLonglineLogbookUIModel) getModel(); + model.setSettingTabValid(settingTabValid); + model.setSettingCaracteristicsTabValid(settingCaracteristicsTabValid); + model.setHaulingTabValid(haulingTabValid); + + } + + private void onToogleTimeEditorSliderChanged(boolean newValue) { + + if (!toogleTimeEditorSliderIsChanging) { + + toogleTimeEditorSliderIsChanging = true; + + boolean selected = !newValue; + + try { + + getUi().getSettingStartTimeStamp().getSliderHidor().setSelected(selected); + getUi().getSettingStartTimeStamp().getSliderHidor().setTargetVisible(newValue); + + getUi().getSettingEndTimeStamp().getSliderHidor().setSelected(selected); + getUi().getSettingEndTimeStamp().getSliderHidor().setTargetVisible(newValue); + + getUi().getHaulingStartTimeStamp().getSliderHidor().setSelected(selected); + getUi().getHaulingStartTimeStamp().getSliderHidor().setTargetVisible(newValue); + + getUi().getHaulingEndTimeStamp().getSliderHidor().setSelected(selected); + getUi().getHaulingEndTimeStamp().getSliderHidor().setTargetVisible(newValue); + + } finally { + + toogleTimeEditorSliderIsChanging = false; + + } + + } + + } + + private synchronized void onCoordinateFormatChanged(CoordinateFormat newValue) { + + if (!coordinateFormatChangedIsChanging) { + + coordinateFormatChangedIsChanging = true; + + try { + + getUi().getSettingStartCoordinates().setFormat(newValue); + getUi().getSettingEndCoordinates().setFormat(newValue); + + getUi().getHaulingStartCoordinates().setFormat(newValue); + getUi().getHaulingEndCoordinates().setFormat(newValue); + + } finally { + + coordinateFormatChangedIsChanging = false; + + } + + } + + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUIModel.java ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineLogbookUIModel.java @@ -0,0 +1,132 @@ +package fr.ird.observe.client.ui.content.data.longline; + +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.ImmutableSet; +import fr.ird.observe.client.ui.content.ContentUIModel; +import fr.ird.observe.dto.data.longline.SetLonglineDto; + +import java.util.Set; + +/** + * Created on 9/28/14. + * + * @author Tony Chemit - dev@tchemit.fr + * @since XXX + */ +public class SetLonglineLogbookUIModel extends ContentUIModel<SetLonglineDto> { + + public static final String PROPERTY_SETTING_TAB_VALID = "settingTabValid"; + + public static final String PROPERTY_SETTING_CARACTERISTICS_TAB_VALID = "settingCaracteristicsTabValid"; + + public static final String PROPERTY_HAULING_TAB_VALID = "haulingTabValid"; + + public static final Set<String> SETTING_TAB_PROPERTIES = + ImmutableSet.<String>builder().add( + SetLonglineDto.PROPERTY_HOME_ID, + SetLonglineDto.PROPERTY_NUMBER, + SetLonglineDto.PROPERTY_SETTING_START_TIME_STAMP, + SetLonglineDto.PROPERTY_SETTING_START_LATITUDE, + SetLonglineDto.PROPERTY_SETTING_START_LONGITUDE, + SetLonglineDto.PROPERTY_SETTING_END_TIME_STAMP, + SetLonglineDto.PROPERTY_SETTING_END_LATITUDE, + SetLonglineDto.PROPERTY_SETTING_END_LONGITUDE + ).build(); + + public static final Set<String> SETTING_CARACTERISTICS_TAB_PROPERTIES = + ImmutableSet.<String>builder().add( + SetLonglineDto.PROPERTY_SETTING_SHAPE, + SetLonglineDto.PROPERTY_LINE_TYPE, + SetLonglineDto.PROPERTY_LIGHTSTICKS_TYPE, + SetLonglineDto.PROPERTY_LIGHTSTICKS_COLOR, + SetLonglineDto.PROPERTY_SETTING_VESSEL_SPEED, + SetLonglineDto.PROPERTY_MAX_DEPTH_TARGETED, + SetLonglineDto.PROPERTY_SHOOTER_USED, + SetLonglineDto.PROPERTY_SHOOTER_SPEED, + SetLonglineDto.PROPERTY_WEIGHTED_SWIVEL, + SetLonglineDto.PROPERTY_SWIVEL_WEIGHT, + SetLonglineDto.PROPERTY_WEIGHTED_SNAP, + SetLonglineDto.PROPERTY_SNAP_WEIGHT, + SetLonglineDto.PROPERTY_MONITORED, + SetLonglineDto.PROPERTY_TIME_BETWEEN_HOOKS, + SetLonglineDto.PROPERTY_BASKETS_PER_SECTION_COUNT, + SetLonglineDto.PROPERTY_BRANCHLINES_PER_BASKET_COUNT, + SetLonglineDto.PROPERTY_LIGHTSTICKS_PER_BASKET_COUNT, + SetLonglineDto.PROPERTY_TOTAL_SECTIONS_COUNT, + SetLonglineDto.PROPERTY_TOTAL_BASKETS_COUNT, + SetLonglineDto.PROPERTY_TOTAL_HOOKS_COUNT + ).build(); + + public static final Set<String> HAULING_TAB_PROPERTIES = + ImmutableSet.<String>builder().add( + SetLonglineDto.PROPERTY_HAULING_DIRECTION_SAME_AS_SETTING, + SetLonglineDto.PROPERTY_HAULING_START_LATITUDE, + SetLonglineDto.PROPERTY_HAULING_START_LONGITUDE, + SetLonglineDto.PROPERTY_HAULING_START_TIME_STAMP, + SetLonglineDto.PROPERTY_HAULING_END_LATITUDE, + SetLonglineDto.PROPERTY_HAULING_END_LONGITUDE, + SetLonglineDto.PROPERTY_HAULING_END_TIME_STAMP, + SetLonglineDto.PROPERTY_HAULING_BREAKS + ).build(); + + private static final long serialVersionUID = 1L; + + protected boolean settingTabValid; + + protected boolean settingCaracteristicsTabValid; + + protected boolean haulingTabValid; + + public SetLonglineLogbookUIModel() { + super(SetLonglineDto.class); + } + + public boolean isHaulingTabValid() { + return haulingTabValid; + } + + public void setHaulingTabValid(boolean haulingTabValid) { + this.haulingTabValid = haulingTabValid; + firePropertyChange(PROPERTY_HAULING_TAB_VALID, null, haulingTabValid); + } + + public boolean isSettingCaracteristicsTabValid() { + return settingCaracteristicsTabValid; + } + + public void setSettingCaracteristicsTabValid(boolean settingCaracteristicsTabValid) { + this.settingCaracteristicsTabValid = settingCaracteristicsTabValid; + firePropertyChange(PROPERTY_SETTING_CARACTERISTICS_TAB_VALID, null, settingCaracteristicsTabValid); + } + + public boolean isSettingTabValid() { + return settingTabValid; + } + + public void setSettingTabValid(boolean settingTabValid) { + this.settingTabValid = settingTabValid; + firePropertyChange(PROPERTY_SETTING_TAB_VALID, null, settingTabValid); + } + +} ===================================== client/src/main/resources/i18n/client_en_GB.properties ===================================== --- a/client/src/main/resources/i18n/client_en_GB.properties +++ b/client/src/main/resources/i18n/client_en_GB.properties @@ -364,8 +364,11 @@ observe.common.ActivityLonglineDto.message.no.active.found.for.other.trip=No ope observe.common.ActivityLonglineDto.message.nonForTrip=< No activity for current trip > observe.common.ActivityLonglineDto.message.not.open=Activity is not opened, no edit possible. observe.common.ActivityLonglineDto.message.updating=Updating an activity +observe.common.ActivityLonglineDto.relatedObservedActivity=Observed activity observe.common.ActivityLonglineDto.timeStamp=timestamp observe.common.ActivityLonglineDto.titles=Activities +observe.common.ActivityLonglineDto.vesselSpeed=Speed +observe.common.ActivityLonglineDto.wind=Wind observe.common.ActivitySeineDto.action.addFloatingObject=Add FAD observe.common.ActivitySeineDto.action.addFloatingObject.tip=Add a FAD to the activity observe.common.ActivitySeineDto.action.addSet=Add a Set @@ -454,11 +457,14 @@ observe.common.CatchLonglineDto.availablePredator=Avaiable predators observe.common.CatchLonglineDto.beatDiameter=Beat diameter observe.common.CatchLonglineDto.branchlineTab=Branchline observe.common.CatchLonglineDto.caracteristicTab=Caracteristics +observe.common.CatchLonglineDto.countDepredated=\#TODO observe.common.CatchLonglineDto.depredated=Depredated +observe.common.CatchLonglineDto.depredatedProportion=\#TODO observe.common.CatchLonglineDto.depredatedTab=Depredation observe.common.CatchLonglineDto.foodAndSexualTab=Food and sexual maturity observe.common.CatchLonglineDto.hookWhenDiscarded=Discarded with hook observe.common.CatchLonglineDto.locationOnLongline=Location on longline +observe.common.CatchLonglineDto.onBordDataProcessing=On bord data processing observe.common.CatchLonglineDto.photoReferences=Photo references observe.common.CatchLonglineDto.resetBranchline=Cancel observe.common.CatchLonglineDto.resetBranchline.tip=Cancel any modification @@ -490,6 +496,7 @@ observe.common.CatchLonglineDto.table.speciesCatch=Species observe.common.CatchLonglineDto.table.speciesCatch.tip=Species observe.common.CatchLonglineDto.tagNumber=Tag number observe.common.CatchLonglineDto.totalWeight=Total weight (kg) +observe.common.CatchLonglineDto.weightDeterminationMethod=Weight Determination method observe.common.CatchLonglineDto.weightMeasuresTab=Weights observe.common.DataDto.action.createEntry.tip=Create a new entry observe.common.DataDto.action.deleteEntry.tip=Delete entry in edition @@ -912,14 +919,20 @@ observe.common.SensorUsedDto.table.sensorType.tip=Sensor type observe.common.SetDto.action.goToOpen.short=Open set observe.common.SetDto.action.goToOpen.tip=Open set observe.common.SetLonglineDto.action.reset.homeId.tip=Reset home id +observe.common.SetLonglineDto.basketLineLength=\#TODO observe.common.SetLonglineDto.haulingTab=Hauling +observe.common.SetLonglineDto.lengthBetweenBranchlines=\#TODO +observe.common.SetLonglineDto.lightsticksUsed=\#TODO +observe.common.SetLonglineDto.lightstickssTab=\#TODO observe.common.SetLonglineDto.message.creating=Creating fishing operation observe.common.SetLonglineDto.message.updating=Updating fishing operation observe.common.SetLonglineDto.monitored=Monitored observe.common.SetLonglineDto.settingCaracteristicsTab=Caracteristics observe.common.SetLonglineDto.settingTab=Setting +observe.common.SetLonglineDto.shooterUsed=Shooter used observe.common.SetLonglineDto.targetCatchCompositionEstimatedByObserver=Composition estimated by observer? observe.common.SetLonglineDto.targetDiscardCatchCompositionEstimatedByObserver=Composition estimated by observer? +observe.common.SetLonglineDto.totalLineLength=\#TODO observe.common.SetLonglineDto.weightedSnap=Weighted snap observe.common.SetLonglineDto.weightedSwivel=Weighted swivel observe.common.SetLonglineGlobalCompositionDto.availableMitigationType=Available mitigations ===================================== client/src/main/resources/i18n/client_es_ES.properties ===================================== --- a/client/src/main/resources/i18n/client_es_ES.properties +++ b/client/src/main/resources/i18n/client_es_ES.properties @@ -364,8 +364,11 @@ observe.common.ActivityLonglineDto.message.no.active.found.for.other.trip=Ningun observe.common.ActivityLonglineDto.message.nonForTrip=< Ninguna actividad por la marea actual > observe.common.ActivityLonglineDto.message.not.open=La actividad no está abierta, imposible modificar. observe.common.ActivityLonglineDto.message.updating=Se está modificando la actividad actual. +observe.common.ActivityLonglineDto.relatedObservedActivity=\#TODO observe.common.ActivityLonglineDto.timeStamp=Timestamp observe.common.ActivityLonglineDto.titles=Actividades +observe.common.ActivityLonglineDto.vesselSpeed=\#TODO +observe.common.ActivityLonglineDto.wind=\#TODO observe.common.ActivitySeineDto.action.addFloatingObject=Añadir un DCP observe.common.ActivitySeineDto.action.addFloatingObject.tip=Añadir un objeto flotante a la actividad observe.common.ActivitySeineDto.action.addSet=Añadir un lance @@ -454,11 +457,14 @@ observe.common.CatchLonglineDto.availablePredator=Deprepadaores disponibles observe.common.CatchLonglineDto.beatDiameter=Diametro de la mordedura observe.common.CatchLonglineDto.branchlineTab=Arponcillo observe.common.CatchLonglineDto.caracteristicTab=Características +observe.common.CatchLonglineDto.countDepredated=\#TODO observe.common.CatchLonglineDto.depredated=Victima de depredación +observe.common.CatchLonglineDto.depredatedProportion=\#TODO observe.common.CatchLonglineDto.depredatedTab=Depredación observe.common.CatchLonglineDto.foodAndSexualTab=Alimentación y maturidad sexual observe.common.CatchLonglineDto.hookWhenDiscarded=Echazado con el anzuelo observe.common.CatchLonglineDto.locationOnLongline=Posición sobre la línea +observe.common.CatchLonglineDto.onBordDataProcessing=On bord data processing \#TODO observe.common.CatchLonglineDto.photoReferences=Referencias foto observe.common.CatchLonglineDto.resetBranchline=Cancelar observe.common.CatchLonglineDto.resetBranchline.tip=Cancelar las modificaciones sobre el arponcillo @@ -490,6 +496,7 @@ observe.common.CatchLonglineDto.table.speciesCatch=Especie observe.common.CatchLonglineDto.table.speciesCatch.tip=Especie observe.common.CatchLonglineDto.tagNumber=Numéro d'échantillon \#TODO observe.common.CatchLonglineDto.totalWeight=Peso total (kg) +observe.common.CatchLonglineDto.weightDeterminationMethod=\#TODO observe.common.CatchLonglineDto.weightMeasuresTab=Pesos (kg) observe.common.DataDto.action.createEntry.tip=Crear una nueva entrada observe.common.DataDto.action.deleteEntry.tip=Cancelar la edición de la entrada actual @@ -912,14 +919,20 @@ observe.common.SensorUsedDto.table.sensorType.tip=Tipo de sensor observe.common.SetDto.action.goToOpen.short=Lance abierto observe.common.SetDto.action.goToOpen.tip=Acceder al lance abierto observe.common.SetLonglineDto.action.reset.homeId.tip=Reiniciar el id de negocio +observe.common.SetLonglineDto.basketLineLength=\#TODO observe.common.SetLonglineDto.haulingTab=Arrastre +observe.common.SetLonglineDto.lengthBetweenBranchlines=\#TODO +observe.common.SetLonglineDto.lightsticksUsed=\#TODO +observe.common.SetLonglineDto.lightstickssTab=\#TODO observe.common.SetLonglineDto.message.creating=Lance en proceso de creación. observe.common.SetLonglineDto.message.updating=La operación de pesca está en proceso de modificación. observe.common.SetLonglineDto.monitored=Instrumentada observe.common.SetLonglineDto.settingCaracteristicsTab=Características observe.common.SetLonglineDto.settingTab=Calada +observe.common.SetLonglineDto.shooterUsed=Shooter used \#TODO observe.common.SetLonglineDto.targetCatchCompositionEstimatedByObserver=Composition estimée par l'observateur ? \#TODO observe.common.SetLonglineDto.targetDiscardCatchCompositionEstimatedByObserver=Composition estimée par l'observateur ? \#TODO +observe.common.SetLonglineDto.totalLineLength=Total line length (m) \#TODO observe.common.SetLonglineDto.weightedSnap=Snap lesté observe.common.SetLonglineDto.weightedSwivel=Émerillon lesté observe.common.SetLonglineGlobalCompositionDto.availableMitigationType=Atenuaciónes disponibles ===================================== client/src/main/resources/i18n/client_fr_FR.properties ===================================== --- a/client/src/main/resources/i18n/client_fr_FR.properties +++ b/client/src/main/resources/i18n/client_fr_FR.properties @@ -364,8 +364,11 @@ observe.common.ActivityLonglineDto.message.no.active.found.for.other.trip=Aucune observe.common.ActivityLonglineDto.message.nonForTrip=< Aucune activité pour la marée courante > observe.common.ActivityLonglineDto.message.not.open=L'opération de pêche n'est pas ouverte, aucune modification possible. observe.common.ActivityLonglineDto.message.updating=L'activité est en cours de modification. +observe.common.ActivityLonglineDto.relatedObservedActivity=Activité observée observe.common.ActivityLonglineDto.timeStamp=Horodatage observe.common.ActivityLonglineDto.titles=Activités +observe.common.ActivityLonglineDto.vesselSpeed=Vitesse du courant (nd) +observe.common.ActivityLonglineDto.wind=Vent Beaufort observe.common.ActivitySeineDto.action.addFloatingObject=Ajouter un DCP observe.common.ActivitySeineDto.action.addFloatingObject.tip=Ajouter un objet flottant à l'activité observe.common.ActivitySeineDto.action.addSet=Ajouter la calée @@ -454,11 +457,14 @@ observe.common.CatchLonglineDto.availablePredator=Prédateurs disponibles observe.common.CatchLonglineDto.beatDiameter=Diamètre de la morsure observe.common.CatchLonglineDto.branchlineTab=Avançon observe.common.CatchLonglineDto.caracteristicTab=Caractéristiques +observe.common.CatchLonglineDto.countDepredated=Nombre déprédaté observe.common.CatchLonglineDto.depredated=Victime de déprédation +observe.common.CatchLonglineDto.depredatedProportion=Proportion déprédaté observe.common.CatchLonglineDto.depredatedTab=Déprédation observe.common.CatchLonglineDto.foodAndSexualTab=Alimentation et maturité sexuelle observe.common.CatchLonglineDto.hookWhenDiscarded=Rejeté avec hameçon observe.common.CatchLonglineDto.locationOnLongline=Position sur la ligne +observe.common.CatchLonglineDto.onBordDataProcessing=Traitement effectué à bord observe.common.CatchLonglineDto.photoReferences=Références photo observe.common.CatchLonglineDto.resetBranchline=Annuler observe.common.CatchLonglineDto.resetBranchline.tip=Annuler les modifications sur l'avançon @@ -490,6 +496,7 @@ observe.common.CatchLonglineDto.table.speciesCatch=Espèce observe.common.CatchLonglineDto.table.speciesCatch.tip=Espèce observe.common.CatchLonglineDto.tagNumber=Id marque observe.common.CatchLonglineDto.totalWeight=Poids total (kg) +observe.common.CatchLonglineDto.weightDeterminationMethod=Méthode d'estimation observe.common.CatchLonglineDto.weightMeasuresTab=Poids (kg) observe.common.DataDto.action.createEntry.tip=Créer une nouvelle entrée observe.common.DataDto.action.deleteEntry.tip=Supprimer l'entrée en cours d'édition @@ -912,14 +919,20 @@ observe.common.SensorUsedDto.table.sensorType.tip=Type de capteur observe.common.SetDto.action.goToOpen.short=Calée ouverte observe.common.SetDto.action.goToOpen.tip=Accéder à la calée ouverte observe.common.SetLonglineDto.action.reset.homeId.tip=Réinitialiser l'id métier +observe.common.SetLonglineDto.basketLineLength=Longueur de la ligne par panier (m) observe.common.SetLonglineDto.haulingTab=Virage +observe.common.SetLonglineDto.lengthBetweenBranchlines=Distance entre avançons (m) +observe.common.SetLonglineDto.lightsticksUsed=Utilisation des cyalumes ? +observe.common.SetLonglineDto.lightstickssTab=Cyalumes observe.common.SetLonglineDto.message.creating=L'opération de pêche est en cours de création. observe.common.SetLonglineDto.message.updating=L'opération de pêche est en cours de modification. observe.common.SetLonglineDto.monitored=Instrumentée observe.common.SetLonglineDto.settingCaracteristicsTab=Caractéristiques observe.common.SetLonglineDto.settingTab=Filage +observe.common.SetLonglineDto.shooterUsed=Utilisation du shooter observe.common.SetLonglineDto.targetCatchCompositionEstimatedByObserver=Composition estimée par l'observateur ? observe.common.SetLonglineDto.targetDiscardCatchCompositionEstimatedByObserver=Composition estimée par l'observateur ? +observe.common.SetLonglineDto.totalLineLength=Longueur totale de la ligne (m) observe.common.SetLonglineDto.weightedSnap=Snap lesté observe.common.SetLonglineDto.weightedSwivel=Émerillon lesté observe.common.SetLonglineGlobalCompositionDto.availableMitigationType=Atténuations disponibles View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/0fb8cb2d7fde3846a306b71857a... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/0fb8cb2d7fde3846a306b71857a... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT