mailman.cloud.codelutin.com
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

Observe-commits

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2018 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2017 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2016 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2015 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2014 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2013 -----
  • December
  • November
  • October
  • September
observe-commits@list.forge.codelutin.com

September 2018

  • 1 participants
  • 147 discussions
[Git][ultreiaio/ird-observe][develop-7.x] [jgitflow-maven-plugin]updating poms for 7.0-RC-23-SNAPSHOT development[skip ci]
by Tony CHEMIT 23 Sep '18

23 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 6a01a724 by Tony CHEMIT at 2018-09-23T09:43:15Z [jgitflow-maven-plugin]updating poms for 7.0-RC-23-SNAPSHOT development[skip ci] - - - - - 13 changed files: - client-configuration/pom.xml - client/pom.xml - dto/pom.xml - observe/pom.xml - persistence/pom.xml - pom.xml - server-configuration/pom.xml - server/pom.xml - services-client/pom.xml - services-local/pom.xml - services/pom.xml - test/pom.xml - validation/pom.xml Changes: ===================================== client-configuration/pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>client-configuration</artifactId> ===================================== client/pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>client</artifactId> ===================================== dto/pom.xml ===================================== @@ -27,7 +27,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>dto</artifactId> ===================================== observe/pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>observe</artifactId> ===================================== persistence/pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>persistence</artifactId> ===================================== pom.xml ===================================== @@ -31,7 +31,7 @@ <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> <packaging>pom</packaging> <name>ObServe :: Pom</name> ===================================== server-configuration/pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>server-configuration</artifactId> ===================================== server/pom.xml ===================================== @@ -27,7 +27,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>server</artifactId> ===================================== services-client/pom.xml ===================================== @@ -27,7 +27,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>services-client</artifactId> ===================================== services-local/pom.xml ===================================== @@ -27,7 +27,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>services-local</artifactId> ===================================== services/pom.xml ===================================== @@ -27,7 +27,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>services</artifactId> ===================================== test/pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>test</artifactId> ===================================== validation/pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> - <version>7.0-RC-22-SNAPSHOT</version> + <version>7.0-RC-23-SNAPSHOT</version> </parent> <artifactId>validation</artifactId> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/6a01a724cd1b921bd952795c25d… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/6a01a724cd1b921bd952795c25d… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe] Pushed new branch release/7.0-RC-22
by Tony CHEMIT 23 Sep '18

23 Sep '18
Tony CHEMIT pushed new branch release/7.0-RC-22 at ultreiaio / ird-observe -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/tree/release/7.0-RC-22 You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Widget température °C/°F : message de validation perfectible - Closes #960
by Tony CHEMIT 22 Sep '18

22 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 5a2cb9fb by Tony CHEMIT at 2018-09-22T18:50:56Z Widget température °C/°F : message de validation perfectible - Closes #960 - - - - - 21 changed files: - client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUIHandler.java - client/src/main/java/fr/ird/observe/client/validation/ClientValidationContext.java - + dto/src/main/java/fr/ird/observe/dto/data/longline/TripLonglineDto.java - dto/src/main/models/Observe.model - persistence/src/main/java/fr/ird/observe/binder/data/longline/TripLonglineActivityEntityDtoBinder.java - persistence/src/main/java/fr/ird/observe/binder/data/seine/ActivitySeineStubEntityDtoBinder.java - services/pom.xml - + services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureBoundFieldValidator.java - + services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureCompareFieldValidator.java - validation/pom.xml - validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-create-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-update-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml - validation/src/main/resources/i18n/validation_en_GB.properties - validation/src/main/resources/i18n/validation_es_ES.properties - validation/src/main/resources/i18n/validation_fr_FR.properties - validation/src/main/resources/validators.xml Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java ===================================== @@ -1,5 +1,27 @@ package fr.ird.observe.client.ui.actions.content; +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; import fr.ird.observe.client.ui.ObserveMainUI; ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java ===================================== @@ -52,8 +52,8 @@ import fr.ird.observe.dto.reference.DataDtoReference; import fr.ird.observe.dto.reference.ReferentialDtoReference; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jdesktop.swingx.JXDatePicker; import org.jdesktop.swingx.JXMonthView; import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor; @@ -63,6 +63,7 @@ import org.nuiton.jaxx.runtime.swing.editor.EnumEditor; import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer; import org.nuiton.jaxx.runtime.swing.renderer.EnumEditorRenderer; import org.nuiton.jaxx.validator.JAXXValidator; +import org.nuiton.jaxx.validator.swing.SwingValidator; import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; import org.nuiton.jaxx.widgets.datetime.DateTimeEditor; import org.nuiton.jaxx.widgets.datetime.TimeEditor; @@ -346,6 +347,10 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> editor.setConfig(new TemperatureEditorConfig(TemperatureFormat.C, getBean(), label.getText(), propertyName)); editor.init(label); + editor.getModel().addPropertyChangeListener("format", e -> { + ((SwingValidator<?>) ui.getObjectById("validator")).doValidate(); + }); + } private void init(JLabel editor) { ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUIHandler.java ===================================== @@ -251,7 +251,7 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor()); - + validationContext.setTemperatureEditorModel("seaSurfaceTemperature", getUi().getSeaSurfaceTemperature().getModel()); } @Override ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUIHandler.java ===================================== @@ -140,7 +140,7 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor()); - + validationContext.setTemperatureEditorModel("seaSurfaceTemperature", getUi().getSeaSurfaceTemperature().getModel()); } @Override ===================================== client/src/main/java/fr/ird/observe/client/validation/ClientValidationContext.java ===================================== @@ -8,12 +8,12 @@ * 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>. @@ -39,6 +39,7 @@ import fr.ird.observe.services.ObserveServicesProvider; import fr.ird.observe.services.validation.ValidationContext; import fr.ird.observe.services.validation.ValidationDataContext; import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor; +import org.nuiton.jaxx.widgets.temperature.TemperatureEditorModel; import java.util.List; import java.util.Map; @@ -52,6 +53,9 @@ import java.util.function.Supplier; */ public class ClientValidationContext extends ValidationContext { + private Map<String, CoordinatesEditor> coordinatesEditors = new TreeMap<>(); + private Map<String, TemperatureEditorModel> temperatureEditorModels = new TreeMap<>(); + public ClientValidationContext(ClientConfig config, ValidationDataContext validationDataContext) { super(validationDataContext, ObserveSwingApplicationContext.get().getDecoratorService(), @@ -118,14 +122,13 @@ public class ClientValidationContext extends ValidationContext { public void reset() { super.reset(); coordinatesEditors.clear(); + temperatureEditorModels.clear(); } public ObserveOpenDataManager getOpenDataManager() { return ObserveSwingApplicationContext.get().getOpenDataManager(); } - private Map<String, CoordinatesEditor> coordinatesEditors = new TreeMap<>(); - public Map<String, CoordinatesEditor> getCoordinatesEditors() { return coordinatesEditors; } @@ -138,4 +141,16 @@ public class ClientValidationContext extends ValidationContext { coordinatesEditors.put(name, editor); } + public Map<String, TemperatureEditorModel> getTemperatureEditorModels() { + return temperatureEditorModels; + } + + public TemperatureEditorModel getTemperatureEditorModel(String name) { + return temperatureEditorModels.get(name); + } + + public void setTemperatureEditorModel(String name, TemperatureEditorModel editor) { + temperatureEditorModels.put(name, editor); + } + } ===================================== dto/src/main/java/fr/ird/observe/dto/data/longline/TripLonglineDto.java ===================================== @@ -0,0 +1,56 @@ +package fr.ird.observe.dto.data.longline; + +/*- + * #%L + * ObServe :: Dto + * %% + * Copyright (C) 2008 - 2018 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.Iterables; +import fr.ird.observe.dto.IdHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class TripLonglineDto extends GeneratedTripLonglineDto { + + private static final Logger log = LogManager.getLogger(TripLonglineDto.class); + private static final long serialVersionUID = 3977866185675257699L; + + public TripLonglineActivityDto getPreviousActivity(String activitySeineId) { + + TripLonglineActivityDto previous = null; + + if (activitySeineId != null) { + + int currentPosition = Iterables.indexOf(getActivityLongline(), IdHelper.newIdPredicate(activitySeineId)::test); + if (currentPosition >= 1) { + previous = Iterables.get(getActivityLongline(), currentPosition - 1); + } + } + + if (previous != null) { + log.debug("previous activity " + previous.getTimeStamp()); + + } else { + log.debug("no previous activity for " + activityLongline); + } + + return previous; + } +} ===================================== dto/src/main/models/Observe.model ===================================== @@ -348,6 +348,7 @@ activityLongline + {*} data.longline.TripLonglineActivity | ordered unique data.longline.TripLonglineActivity > data.Data timeStamp + {*:1} Date +seaSurfaceTemperature + {*:1} Float data.longline.TripLonglineGearUse > data.Data | form=data.longline.GearUseFeaturesLongline gearUseFeaturesLongline + {*} data.longline.GearUseFeaturesLongline | ordered ===================================== persistence/src/main/java/fr/ird/observe/binder/data/longline/TripLonglineActivityEntityDtoBinder.java ===================================== @@ -53,6 +53,6 @@ public class TripLonglineActivityEntityDtoBinder extends DataEntityDtoBinderSupp copyEntityDataFieldsToDto(entity, dto); dto.setTimeStamp(entity.getTimeStamp()); - + dto.setSeaSurfaceTemperature(entity.getSeaSurfaceTemperature()); } } ===================================== persistence/src/main/java/fr/ird/observe/binder/data/seine/ActivitySeineStubEntityDtoBinder.java ===================================== @@ -52,6 +52,7 @@ public class ActivitySeineStubEntityDtoBinder extends DataEntityDtoBinderSupport dto.setLastUpdateDate(entity.getLastUpdateDate()); dto.setLatitude(entity.getLatitude()); dto.setLongitude(entity.getLongitude()); + dto.setSeaSurfaceTemperature(entity.getSeaSurfaceTemperature()); boolean isFindeVeille = entity.getVesselActivitySeine() != null && ActivitySeineImpl.ACTIVITY_FIN_DE_VEILLE.equals(entity.getVesselActivitySeine().getCode()); ===================================== services/pom.xml ===================================== @@ -88,6 +88,10 @@ <groupId>io.ultreia.java4all.http</groupId> <artifactId>http-api</artifactId> </dependency> + <dependency> + <groupId>io.ultreia.java4all</groupId> + <artifactId>java-lang</artifactId> + </dependency> <dependency> <groupId>io.ultreia.java4all.jaxx</groupId> @@ -157,6 +161,10 @@ <groupId>io.ultreia.java4all.topia</groupId> <artifactId>service-script</artifactId> </dependency> + <dependency> + <groupId>io.ultreia.java4all.jaxx</groupId> + <artifactId>jaxx-widgets-temperature</artifactId> + </dependency> </dependencies> ===================================== services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureBoundFieldValidator.java ===================================== @@ -0,0 +1,149 @@ +package fr.ird.observe.services.validation.validators; + +/*- + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2018 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.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; +import org.nuiton.jaxx.widgets.temperature.I18nEnumHelper; +import org.nuiton.jaxx.widgets.temperature.TemperatureEditorModel; +import org.nuiton.jaxx.widgets.temperature.TemperatureFormat; + +import java.util.Map; + +/** + * To validate that the temperature is in correct bound. + * <p> + * Created by tchemit on 22/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class TemperatureBoundFieldValidator extends FieldValidatorSupport { + + /** + * Default temperature format (min and max are based on this format). + */ + private TemperatureFormat defaultTemperatureFormat; + /** + * Min temperature. + */ + private Float min; + /** + * Max temperature. + */ + private Float max; + + public void setDefaultTemperatureFormat(String defaultTemperatureFormat) { + this.defaultTemperatureFormat = TemperatureFormat.valueOf(defaultTemperatureFormat); + } + + public void setMin(String min) { + this.min = Float.valueOf(min); + } + + public void setMax(String max) { + this.max = Float.valueOf(max); + } + + @Override + public void validate(Object object) throws ValidationException { + + if (min == null) { + throw new ValidationException("No parameter 'min' filled"); + } + if (max == null) { + throw new ValidationException("No parameter 'max' filled"); + } + if (min >= max) { + throw new ValidationException(String.format("No parameter 'min' (%s) is greater than 'max' (%s)", min, max)); + } + String fieldName = getFieldName(); + if (fieldName == null) { + throw new ValidationException("No parameter 'fieldName' filled"); + } + Float temperature = (Float) getFieldValue(fieldName, object); + if (temperature == null) { + return; + } + + @SuppressWarnings("unchecked") Map<String, TemperatureEditorModel> map = (Map<String, TemperatureEditorModel>) getFieldValue("temperatureEditorModels", object); + TemperatureFormat temperatureFormat = defaultTemperatureFormat; + if (map != null) { + + TemperatureEditorModel temperatureEditorModel = map.get(fieldName); + //FIXME une validation est lancé dans l'ui alors que l'on ne devrait pas et on a pas ce composant alors + if (temperatureEditorModel != null) { + temperatureFormat = temperatureEditorModel.getFormat(); + } + } + + if (temperature < min || temperature > max) { + float min; + float max; + if (temperatureFormat.equals(defaultTemperatureFormat)) { + min = this.min; + max = this.max; + } else { + min = defaultTemperatureFormat.convert(this.min, temperatureFormat); + max = defaultTemperatureFormat.convert(this.max, temperatureFormat); + } + stack.set(fieldName + "Bound", new TemperatureResult(min, max, I18nEnumHelper.getLabel(temperatureFormat))); + try { + addFieldError(fieldName, object); + } finally { + stack.pop(); + } + } + + } + + @Override + public String getValidatorType() { + return "temperatureBound"; + } + + static class TemperatureResult { + private final float min; + private final float max; + private final String format; + + TemperatureResult(float min, float max, String format) { + this.min = min; + this.max = max; + this.format = format; + } + + public float getMin() { + return min; + } + + public float getMax() { + return max; + } + + public String getFormat() { + return format; + } + } + +} + ===================================== services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureCompareFieldValidator.java ===================================== @@ -0,0 +1,196 @@ +package fr.ird.observe.services.validation.validators; + +/*- + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2018 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.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; +import io.ultreia.java4all.lang.Numbers; +import org.nuiton.jaxx.widgets.temperature.I18nEnumHelper; +import org.nuiton.jaxx.widgets.temperature.TemperatureEditorModel; +import org.nuiton.jaxx.widgets.temperature.TemperatureFormat; + +import java.util.Map; + +/** + * To validate that the temperature is in correct bound. + * <p> + * Created by tchemit on 22/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class TemperatureCompareFieldValidator extends FieldValidatorSupport { + + /** + * Name of the field to compare against. + */ + private String compareFieldName; + + /** + * Default temperature format (bottom are based on this format). + */ + private TemperatureFormat defaultTemperatureFormat; + /** + * Compare temperature format (compare temperature is base on this format). + */ + private TemperatureFormat compareTemperatureFormat; + /** + * Delta authorized. + */ + private Float delta; + + /** + * Min temperature. + */ + private Float min; + /** + * Max temperature. + */ + private Float max; + + public void setDefaultTemperatureFormat(String defaultTemperatureFormat) { + this.defaultTemperatureFormat = TemperatureFormat.valueOf(defaultTemperatureFormat); + } + + public void setCompareTemperatureFormat(String compareTemperatureFormat) { + this.compareTemperatureFormat = TemperatureFormat.valueOf(compareTemperatureFormat); + } + + public void setMin(String min) { + this.min = Float.valueOf(min); + } + + public void setMax(String max) { + this.max = Float.valueOf(max); + } + + public void setDelta(String delta) { + this.delta = Float.valueOf(delta); + } + + public void setCompareFieldName(String compareFieldName) { + this.compareFieldName = compareFieldName; + } + + @Override + public void validate(Object object) throws ValidationException { + if (min == null) { + throw new ValidationException("No parameter 'min' filled"); + } + if (max == null) { + throw new ValidationException("No parameter 'max' filled"); + } + if (min >= max) { + throw new ValidationException(String.format("No parameter 'min' (%s) is greater than 'max' (%s)", min, max)); + } + String fieldName = getFieldName(); + if (fieldName == null) { + throw new ValidationException("No parameter 'fieldName' filled"); + } + if (compareFieldName == null) { + throw new ValidationException("No parameter 'compareFieldName' filled"); + } + if (delta == null) { + throw new ValidationException("No parameter 'bottom' filled"); + } + Float temperature = (Float) getFieldValue(fieldName, object); + if (temperature == null) { + return; + } + Float againstTemperature = (Float) getFieldValue(compareFieldName, object); + if (againstTemperature == null) { + return; + } + @SuppressWarnings("unchecked") Map<String, TemperatureEditorModel> map = (Map<String, TemperatureEditorModel>) getFieldValue("temperatureEditorModels", object); + TemperatureFormat temperatureFormat = defaultTemperatureFormat; + if (map != null) { + + TemperatureEditorModel temperatureEditorModel = map.get(fieldName); + //FIXME une validation est lancé dans l'ui alors que l'on ne devrait pas et on a pas ce composant alors + if (temperatureEditorModel != null) { + temperatureFormat = temperatureEditorModel.getFormat(); + } + } + + float bottom = againstTemperature - delta; + if (bottom < min) { + bottom = min; + } + float top = againstTemperature + delta; + if (top > max) { + top = max; + } + if (temperature < bottom || temperature > top) { + if (!temperatureFormat.equals(defaultTemperatureFormat)) { + bottom = Numbers.roundOneDigit(defaultTemperatureFormat.convert(bottom, temperatureFormat)); + top = Numbers.roundOneDigit(defaultTemperatureFormat.convert(top, temperatureFormat)); + } + if (!temperatureFormat.equals(compareTemperatureFormat)) { + againstTemperature = compareTemperatureFormat.convert(againstTemperature, temperatureFormat); + } + stack.set(fieldName + "Compare", new TemperatureResult(bottom, top, againstTemperature, I18nEnumHelper.getLabel(temperatureFormat))); + try { + addFieldError(fieldName, object); + } finally { + stack.pop(); + } + } + + } + + @Override + public String getValidatorType() { + return "temperatureCompare"; + } + + static class TemperatureResult { + private final float bottom; + private final float top; + private final Float againstTemperature; + private final String format; + + TemperatureResult(float bottom, float top, Float againstTemperature, String format) { + this.bottom = bottom; + this.top = top; + this.againstTemperature = againstTemperature; + this.format = format; + } + + public Float getAgainstTemperature() { + return againstTemperature; + } + + public float getBottom() { + return bottom; + } + + public float getTop() { + return top; + } + + public String getFormat() { + return format; + } + } + +} + ===================================== validation/pom.xml ===================================== @@ -191,6 +191,11 @@ <artifactId>jaxx-widgets-gis</artifactId> <version>${lib.version.java4all.jaxx}</version> </dependency> + <dependency> + <groupId>io.ultreia.java4all.jaxx</groupId> + <artifactId>jaxx-widgets-temperature</artifactId> + <version>${lib.version.java4all.jaxx}</version> + </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-create-error-validation.xml ===================================== @@ -77,16 +77,14 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} </message> </field-validator> - </field> <field name="quadrant"> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-update-error-validation.xml ===================================== @@ -62,13 +62,24 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> + <message> + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} + </message> + </field-validator> + <!-- coherence temperature surface (delta de 12° par rapport a celle de l'activity precedente) --> + <field-validator type="temperatureCompare" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="delta">12.0</param> + <param name="defaultTemperatureFormat">C</param> + <param name="compareTemperatureFormat">C</param> + <param name="compareFieldName">currentTrip.getPreviousActivity(id).seaSurfaceTemperature</param> <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} + observe.validation.activity.invalid.seaSurfaceTemperature##${currentTrip.getPreviousActivity(id).timeStamp}##${seaSurfaceTemperatureCompare.againstTemperature}##${seaSurfaceTemperatureCompare.bottom}##${seaSurfaceTemperatureCompare.top}##${seaSurfaceTemperatureCompare.format} </message> </field-validator> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml ===================================== @@ -251,28 +251,12 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> - <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} - </message> - </field-validator> - - <!-- coherence temperature surface (delta de 12° par rapport a celle de l'activity precedente) --> - <field-validator type="fieldexpression"> - <param name="expression"><![CDATA[ - seaSurfaceTemperature == null || previousActivity == null || previousActivity.seaSurfaceTemperature == null || - (previousActivity.seaSurfaceTemperature > seaSurfaceTemperature ? - previousActivity.seaSurfaceTemperature - seaSurfaceTemperature <= 12.0 - : seaSurfaceTemperature - previousActivity.seaSurfaceTemperature <= 12.0 - ) - ]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> <message> - observe.validation.activity.invalid.seaSurfaceTemperature##${seaSurfaceTemperature}##${previousActivity.seaSurfaceTemperature}##${previousActivity.time} + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} </message> </field-validator> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml ===================================== @@ -180,28 +180,24 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} </message> </field-validator> - <!-- coherence temperature surface (delta de 12° par rapport a celle de l'activity precedente) --> - <field-validator type="fieldexpression"> - <param name="expression"><![CDATA[ - seaSurfaceTemperature == null || previousActivity == null || previousActivity.seaSurfaceTemperature == null || - (previousActivity.seaSurfaceTemperature > seaSurfaceTemperature ? - previousActivity.seaSurfaceTemperature - seaSurfaceTemperature <= 12.0 - : seaSurfaceTemperature - previousActivity.seaSurfaceTemperature <= 12.0 - ) - ]]> - </param> + <field-validator type="temperatureCompare" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="delta">12.0</param> + <param name="defaultTemperatureFormat">C</param> + <param name="compareTemperatureFormat">C</param> + <param name="compareFieldName">currentRoute.getPreviousActivity(id).seaSurfaceTemperature</param> <message> - observe.validation.activity.invalid.seaSurfaceTemperature##${seaSurfaceTemperature}##${previousActivity.seaSurfaceTemperature}##${previousActivity.time} + observe.validation.activity.invalid.seaSurfaceTemperature##${currentRoute.getPreviousActivity(id).time}##${seaSurfaceTemperatureCompare.againstTemperature}##${seaSurfaceTemperatureCompare.bottom}##${seaSurfaceTemperatureCompare.top}##${seaSurfaceTemperatureCompare.format} </message> </field-validator> ===================================== validation/src/main/resources/i18n/validation_en_GB.properties ===================================== @@ -325,7 +325,7 @@ observe.common.WindDto.speedRange=Speed range observe.common.WindDto.waveHeight=Wave weight observe.validation.activity.bound.latitude=Latitude must be between %1$s and %2$s. observe.validation.activity.bound.longitude=Longitude must be between %1$s and %2$s. -observe.validation.activity.bound.seaSurfaceTemperature=Temperature must be between %1$s and %2$s. +observe.validation.activity.bound.seaSurfaceTemperature=Temperature must be between %1$s%3$s and %2$s%3$s. observe.validation.activity.bound.vesselSpeed=Vessel speed must be between %1$s and %2$s. observe.validation.activity.comment.tobig=Comment size is bound to 1024 characters. observe.validation.activity.desactivated.currentFpaZone=Selected current Fpa zone is disabled. @@ -340,7 +340,7 @@ observe.validation.activity.desactivated.vesselActivity=Selected vessel activity observe.validation.activity.desactivated.wind=Selected wind is disabled. observe.validation.activity.duplicated.time=There is already another activity at this time. observe.validation.activity.invalid.quadrant=Quadrant is not coherent with ocean (%1$s) of trip (indian\: 1,2, atlantic 1,2,3,4). -observe.validation.activity.invalid.seaSurfaceTemperature=Sea temperature (%1$s) can't vary to more than 12° from surface temperature (%2$s) of the previous activity %3$s. +observe.validation.activity.invalid.seaSurfaceTemperature=Previous activity (%1$s) sea temperature was %2$s%5$s, current temperature must be between %3$s%5$s and %4$s%5$s. observe.validation.activity.invalid.speed=Activity speed is %s nb, which is more than the maximum authorized which is %s nd. observe.validation.activity.null.dcp=No floating object selected. observe.validation.activity.null.fpaZone=Fpa zone is not filled. ===================================== validation/src/main/resources/i18n/validation_es_ES.properties ===================================== @@ -327,7 +327,7 @@ observe.common.WindDto.speedRange=Texto velocidad del viento observe.common.WindDto.waveHeight=Texto descriptivo de «altura media de la ola» observe.validation.activity.bound.latitude=La latitud dada debe estar comprendida entre %1$s y %2$s. observe.validation.activity.bound.longitude=La longitud dada debe estar comprendida entre %1$s y %2$s. -observe.validation.activity.bound.seaSurfaceTemperature=La temperatura debe estar comprendida entre %1$s y %2$s. +observe.validation.activity.bound.seaSurfaceTemperature=La temperatura debe estar comprendida entre %1$s%3$s y %2$s%3$s. observe.validation.activity.bound.vesselSpeed=La Velocidad del viento estar comprendida entre %1$s y %2$s. observe.validation.activity.comment.tobig=La longitud del campo comentarios está limitada a 1024 carácteres. observe.validation.activity.desactivated.currentFpaZone=La zona actual debe ser desactivada @@ -342,7 +342,7 @@ observe.validation.activity.desactivated.vesselActivity=Actividad del barco sele observe.validation.activity.desactivated.wind=La fuerza del viento seleccionada está desactivada. observe.validation.activity.duplicated.time=Ya existe una actividad a esa hora. observe.validation.activity.invalid.quadrant=El cuadrante no es coherente con el informe del oceano (%1$s) de la marea (indico \: 1,2, atlantico \: 1, 2, 3, 4) -observe.validation.activity.invalid.seaSurfaceTemperature=La temperatura superficial (%1$s) no puede variar mas de 12° con respecto a la temperatura superficial (%2$s) de la actividad anterio %3$s. +observe.validation.activity.invalid.seaSurfaceTemperature=Previous activity (%1$s) sea temperature was %2$s%5$s, current temperature must be between %3$s%5$s and %4$s%5$s. \#TODO observe.validation.activity.invalid.speed=La velocidad de la actividad actual es %s nudos, mientras que la velocidad máxima es %s nudos. observe.validation.activity.null.dcp=No se ha introducido objeto flotante. observe.validation.activity.null.fpaZone=La selección de una zona FPA es obligatoria. ===================================== validation/src/main/resources/i18n/validation_fr_FR.properties ===================================== @@ -325,7 +325,7 @@ observe.common.WindDto.speedRange=Libellé vitesse vent observe.common.WindDto.waveHeight=Libellé Hauteur moyenne vagues observe.validation.activity.bound.latitude=La latitude doit être comprise entre %1$s et %2$s. observe.validation.activity.bound.longitude=La longitude doit être comprise entre %1$s et %2$s. -observe.validation.activity.bound.seaSurfaceTemperature=La température doit être comprise entre %1$s et %2$s. +observe.validation.activity.bound.seaSurfaceTemperature=La température doit être comprise entre %1$s%3$s et %2$s%3$s. observe.validation.activity.bound.vesselSpeed=La vitesse navire doit être comprise entre %1$s et %2$s. observe.validation.activity.comment.tobig=La taille du commentaire est limitée à 1024 caractères. observe.validation.activity.desactivated.currentFpaZone=La zone courante est désactivée. @@ -340,7 +340,7 @@ observe.validation.activity.desactivated.vesselActivity=L'activité bateau séle observe.validation.activity.desactivated.wind=Le vent Beaufort sélectionné est désactivé. observe.validation.activity.duplicated.time=Il existe déjà une autre activité à cette heure. observe.validation.activity.invalid.quadrant=Le quadrant n'est pas cohérent par rapport à l'océan (%1$s) de la marée (indien \: 1 -observe.validation.activity.invalid.seaSurfaceTemperature=La température surface (%1$s) ne peut pas varier de plus de 12° par rapport à la température surface (%2$s) de l'activité précédente %3$s. +observe.validation.activity.invalid.seaSurfaceTemperature=La température surface de l'activité précédente (%1$s) est de %2$s%5$s, la température doit être comprise entre %3$s%5$s et %4$s%5$s. observe.validation.activity.invalid.speed=La vitesse de l'activité courante est de %s nd, alors que la vitesse maximale autorisée est %s nd observe.validation.activity.null.dcp=Aucun objet flottant saisi. observe.validation.activity.null.fpaZone=La sélection d'une zone FPA est obligatoire. ===================================== validation/src/main/resources/validators.xml ===================================== @@ -69,5 +69,7 @@ <validator name="referentialCode" class="fr.ird.observe.services.validation.validators.ReferentialCodeValidator"/> <validator name="nonTargetCatchObservedSystem" class="fr.ird.observe.services.validation.validators.NonTargetCatchObservedSystemValidator"/> <validator name="activitySeine_observedSystem" class="fr.ird.observe.services.validation.validators.ActivitySeineObservedSystemValidator"/> + <validator name="temperatureBound" class="fr.ird.observe.services.validation.validators.TemperatureBoundFieldValidator"/> + <validator name="temperatureCompare" class="fr.ird.observe.services.validation.validators.TemperatureCompareFieldValidator"/> </validators> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/5a2cb9fb46a202038eddcd3bd16… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/5a2cb9fb46a202038eddcd3bd16… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Widget température °C/°F : message de validation perfectible - Closes #960
by Tony CHEMIT 22 Sep '18

22 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: d22c04d4 by Tony CHEMIT at 2018-09-22T17:54:27Z Widget température °C/°F : message de validation perfectible - Closes #960 - - - - - 21 changed files: - client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUIHandler.java - client/src/main/java/fr/ird/observe/client/validation/ClientValidationContext.java - + dto/src/main/java/fr/ird/observe/dto/data/longline/TripLonglineDto.java - dto/src/main/models/Observe.model - persistence/src/main/java/fr/ird/observe/binder/data/longline/TripLonglineActivityEntityDtoBinder.java - persistence/src/main/java/fr/ird/observe/binder/data/seine/ActivitySeineStubEntityDtoBinder.java - services/pom.xml - + services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureBoundFieldValidator.java - + services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureCompareFieldValidator.java - validation/pom.xml - validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-create-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-update-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml - validation/src/main/resources/i18n/validation_en_GB.properties - validation/src/main/resources/i18n/validation_es_ES.properties - validation/src/main/resources/i18n/validation_fr_FR.properties - validation/src/main/resources/validators.xml Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java ===================================== @@ -1,5 +1,27 @@ package fr.ird.observe.client.ui.actions.content; +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; import fr.ird.observe.client.ui.ObserveMainUI; ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java ===================================== @@ -52,8 +52,8 @@ import fr.ird.observe.dto.reference.DataDtoReference; import fr.ird.observe.dto.reference.ReferentialDtoReference; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jdesktop.swingx.JXDatePicker; import org.jdesktop.swingx.JXMonthView; import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor; @@ -63,6 +63,7 @@ import org.nuiton.jaxx.runtime.swing.editor.EnumEditor; import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer; import org.nuiton.jaxx.runtime.swing.renderer.EnumEditorRenderer; import org.nuiton.jaxx.validator.JAXXValidator; +import org.nuiton.jaxx.validator.swing.SwingValidator; import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; import org.nuiton.jaxx.widgets.datetime.DateTimeEditor; import org.nuiton.jaxx.widgets.datetime.TimeEditor; @@ -346,6 +347,10 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> editor.setConfig(new TemperatureEditorConfig(TemperatureFormat.C, getBean(), label.getText(), propertyName)); editor.init(label); + editor.getModel().addPropertyChangeListener("format", e -> { + ((SwingValidator<?>) ui.getObjectById("validator")).doValidate(); + }); + } private void init(JLabel editor) { ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUIHandler.java ===================================== @@ -251,7 +251,7 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor()); - + validationContext.setTemperatureEditorModel("seaSurfaceTemperature", getUi().getSeaSurfaceTemperature().getModel()); } @Override ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUIHandler.java ===================================== @@ -140,7 +140,7 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor()); - + validationContext.setTemperatureEditorModel("seaSurfaceTemperature", getUi().getSeaSurfaceTemperature().getModel()); } @Override ===================================== client/src/main/java/fr/ird/observe/client/validation/ClientValidationContext.java ===================================== @@ -8,12 +8,12 @@ * 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>. @@ -39,6 +39,7 @@ import fr.ird.observe.services.ObserveServicesProvider; import fr.ird.observe.services.validation.ValidationContext; import fr.ird.observe.services.validation.ValidationDataContext; import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor; +import org.nuiton.jaxx.widgets.temperature.TemperatureEditorModel; import java.util.List; import java.util.Map; @@ -52,6 +53,9 @@ import java.util.function.Supplier; */ public class ClientValidationContext extends ValidationContext { + private Map<String, CoordinatesEditor> coordinatesEditors = new TreeMap<>(); + private Map<String, TemperatureEditorModel> temperatureEditorModels = new TreeMap<>(); + public ClientValidationContext(ClientConfig config, ValidationDataContext validationDataContext) { super(validationDataContext, ObserveSwingApplicationContext.get().getDecoratorService(), @@ -118,14 +122,13 @@ public class ClientValidationContext extends ValidationContext { public void reset() { super.reset(); coordinatesEditors.clear(); + temperatureEditorModels.clear(); } public ObserveOpenDataManager getOpenDataManager() { return ObserveSwingApplicationContext.get().getOpenDataManager(); } - private Map<String, CoordinatesEditor> coordinatesEditors = new TreeMap<>(); - public Map<String, CoordinatesEditor> getCoordinatesEditors() { return coordinatesEditors; } @@ -138,4 +141,16 @@ public class ClientValidationContext extends ValidationContext { coordinatesEditors.put(name, editor); } + public Map<String, TemperatureEditorModel> getTemperatureEditorModels() { + return temperatureEditorModels; + } + + public TemperatureEditorModel getTemperatureEditorModel(String name) { + return temperatureEditorModels.get(name); + } + + public void setTemperatureEditorModel(String name, TemperatureEditorModel editor) { + temperatureEditorModels.put(name, editor); + } + } ===================================== dto/src/main/java/fr/ird/observe/dto/data/longline/TripLonglineDto.java ===================================== @@ -0,0 +1,56 @@ +package fr.ird.observe.dto.data.longline; + +/*- + * #%L + * ObServe :: Dto + * %% + * Copyright (C) 2008 - 2018 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.Iterables; +import fr.ird.observe.dto.IdHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class TripLonglineDto extends GeneratedTripLonglineDto { + + private static final Logger log = LogManager.getLogger(TripLonglineDto.class); + private static final long serialVersionUID = 3977866185675257699L; + + public TripLonglineActivityDto getPreviousActivity(String activitySeineId) { + + TripLonglineActivityDto previous = null; + + if (activitySeineId != null) { + + int currentPosition = Iterables.indexOf(getActivityLongline(), IdHelper.newIdPredicate(activitySeineId)::test); + if (currentPosition >= 1) { + previous = Iterables.get(getActivityLongline(), currentPosition - 1); + } + } + + if (previous != null) { + log.debug("previous activity " + previous.getTimeStamp()); + + } else { + log.debug("no previous activity for " + activityLongline); + } + + return previous; + } +} ===================================== dto/src/main/models/Observe.model ===================================== @@ -348,6 +348,7 @@ activityLongline + {*} data.longline.TripLonglineActivity | ordered unique data.longline.TripLonglineActivity > data.Data timeStamp + {*:1} Date +seaSurfaceTemperature + {*:1} Float data.longline.TripLonglineGearUse > data.Data | form=data.longline.GearUseFeaturesLongline gearUseFeaturesLongline + {*} data.longline.GearUseFeaturesLongline | ordered ===================================== persistence/src/main/java/fr/ird/observe/binder/data/longline/TripLonglineActivityEntityDtoBinder.java ===================================== @@ -53,6 +53,6 @@ public class TripLonglineActivityEntityDtoBinder extends DataEntityDtoBinderSupp copyEntityDataFieldsToDto(entity, dto); dto.setTimeStamp(entity.getTimeStamp()); - + dto.setSeaSurfaceTemperature(entity.getSeaSurfaceTemperature()); } } ===================================== persistence/src/main/java/fr/ird/observe/binder/data/seine/ActivitySeineStubEntityDtoBinder.java ===================================== @@ -52,6 +52,7 @@ public class ActivitySeineStubEntityDtoBinder extends DataEntityDtoBinderSupport dto.setLastUpdateDate(entity.getLastUpdateDate()); dto.setLatitude(entity.getLatitude()); dto.setLongitude(entity.getLongitude()); + dto.setSeaSurfaceTemperature(entity.getSeaSurfaceTemperature()); boolean isFindeVeille = entity.getVesselActivitySeine() != null && ActivitySeineImpl.ACTIVITY_FIN_DE_VEILLE.equals(entity.getVesselActivitySeine().getCode()); ===================================== services/pom.xml ===================================== @@ -157,6 +157,10 @@ <groupId>io.ultreia.java4all.topia</groupId> <artifactId>service-script</artifactId> </dependency> + <dependency> + <groupId>io.ultreia.java4all.jaxx</groupId> + <artifactId>jaxx-widgets-temperature</artifactId> + </dependency> </dependencies> ===================================== services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureBoundFieldValidator.java ===================================== @@ -0,0 +1,149 @@ +package fr.ird.observe.services.validation.validators; + +/*- + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2018 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.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; +import org.nuiton.jaxx.widgets.temperature.I18nEnumHelper; +import org.nuiton.jaxx.widgets.temperature.TemperatureEditorModel; +import org.nuiton.jaxx.widgets.temperature.TemperatureFormat; + +import java.util.Map; + +/** + * To validate that the temperature is in correct bound. + * <p> + * Created by tchemit on 22/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class TemperatureBoundFieldValidator extends FieldValidatorSupport { + + /** + * Default temperature format (min and max are based on this format). + */ + private TemperatureFormat defaultTemperatureFormat; + /** + * Min temperature. + */ + private Float min; + /** + * Max temperature. + */ + private Float max; + + public void setDefaultTemperatureFormat(String defaultTemperatureFormat) { + this.defaultTemperatureFormat = TemperatureFormat.valueOf(defaultTemperatureFormat); + } + + public void setMin(String min) { + this.min = Float.valueOf(min); + } + + public void setMax(String max) { + this.max = Float.valueOf(max); + } + + @Override + public void validate(Object object) throws ValidationException { + + if (min == null) { + throw new ValidationException("No parameter 'min' filled"); + } + if (max == null) { + throw new ValidationException("No parameter 'max' filled"); + } + if (min >= max) { + throw new ValidationException(String.format("No parameter 'min' (%s) is greater than 'max' (%s)", min, max)); + } + String fieldName = getFieldName(); + if (fieldName == null) { + throw new ValidationException("No parameter 'fieldName' filled"); + } + Float temperature = (Float) getFieldValue(fieldName, object); + if (temperature == null) { + return; + } + + @SuppressWarnings("unchecked") Map<String, TemperatureEditorModel> map = (Map<String, TemperatureEditorModel>) getFieldValue("temperatureEditorModels", object); + TemperatureFormat temperatureFormat = defaultTemperatureFormat; + if (map != null) { + + TemperatureEditorModel temperatureEditorModel = map.get(fieldName); + //FIXME une validation est lancé dans l'ui alors que l'on ne devrait pas et on a pas ce composant alors + if (temperatureEditorModel != null) { + temperatureFormat = temperatureEditorModel.getFormat(); + } + } + + if (temperature < min || temperature > max) { + float min; + float max; + if (temperatureFormat.equals(defaultTemperatureFormat)) { + min = this.min; + max = this.max; + } else { + min = defaultTemperatureFormat.convert(this.min, temperatureFormat); + max = defaultTemperatureFormat.convert(this.max, temperatureFormat); + } + stack.set(fieldName + "Bound", new TemperatureResult(min, max, I18nEnumHelper.getLabel(temperatureFormat))); + try { + addFieldError(fieldName, object); + } finally { + stack.pop(); + } + } + + } + + @Override + public String getValidatorType() { + return "temperatureBound"; + } + + static class TemperatureResult { + private final float min; + private final float max; + private final String format; + + TemperatureResult(float min, float max, String format) { + this.min = min; + this.max = max; + this.format = format; + } + + public float getMin() { + return min; + } + + public float getMax() { + return max; + } + + public String getFormat() { + return format; + } + } + +} + ===================================== services/src/main/java/fr/ird/observe/services/validation/validators/TemperatureCompareFieldValidator.java ===================================== @@ -0,0 +1,159 @@ +package fr.ird.observe.services.validation.validators; + +/*- + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2018 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.opensymphony.xwork2.validator.ValidationException; +import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; +import io.ultreia.java4all.lang.Numbers; +import org.nuiton.jaxx.widgets.temperature.I18nEnumHelper; +import org.nuiton.jaxx.widgets.temperature.TemperatureEditorModel; +import org.nuiton.jaxx.widgets.temperature.TemperatureFormat; + +import java.util.Map; + +/** + * To validate that the temperature is in correct bound. + * <p> + * Created by tchemit on 22/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class TemperatureCompareFieldValidator extends FieldValidatorSupport { + + /** + * Name of the field to compare against. + */ + private String compareFieldName; + + /** + * Default temperature format (max are based on this format). + */ + private TemperatureFormat defaultTemperatureFormat; + /** + * Compare temperature format (compare temperature is base on this format). + */ + private TemperatureFormat compareTemperatureFormat; + /** + * Max temperature. + */ + private Float max; + + public void setDefaultTemperatureFormat(String defaultTemperatureFormat) { + this.defaultTemperatureFormat = TemperatureFormat.valueOf(defaultTemperatureFormat); + } + + public void setCompareTemperatureFormat(String compareTemperatureFormat) { + this.compareTemperatureFormat = TemperatureFormat.valueOf(compareTemperatureFormat); + } + + public void setMax(String max) { + this.max = Float.valueOf(max); + } + + public void setCompareFieldName(String compareFieldName) { + this.compareFieldName = compareFieldName; + } + + @Override + public void validate(Object object) throws ValidationException { + + String fieldName = getFieldName(); + if (fieldName == null) { + throw new ValidationException("No parameter 'fieldName' filled"); + } + if (compareFieldName == null) { + throw new ValidationException("No parameter 'compareFieldName' filled"); + } + if (max == null) { + throw new ValidationException("No parameter 'max' filled"); + } + Float temperature = (Float) getFieldValue(fieldName, object); + if (temperature == null) { + return; + } + Float againstTemperature = (Float) getFieldValue(compareFieldName, object); + if (againstTemperature == null) { + return; + } + @SuppressWarnings("unchecked") Map<String, TemperatureEditorModel> map = (Map<String, TemperatureEditorModel>) getFieldValue("temperatureEditorModels", object); + TemperatureFormat temperatureFormat = defaultTemperatureFormat; + if (map != null) { + + TemperatureEditorModel temperatureEditorModel = map.get(fieldName); + //FIXME une validation est lancé dans l'ui alors que l'on ne devrait pas et on a pas ce composant alors + if (temperatureEditorModel != null) { + temperatureFormat = temperatureEditorModel.getFormat(); + } + } + + if (Math.abs(temperature - againstTemperature) > max) { + float max; + if (temperatureFormat.equals(defaultTemperatureFormat)) { + max = this.max; + } else { + max = Numbers.roundOneDigit(defaultTemperatureFormat.convert(this.max, temperatureFormat) - 32); + } + if (!temperatureFormat.equals(compareTemperatureFormat)) { + againstTemperature = compareTemperatureFormat.convert(againstTemperature, temperatureFormat); + } + stack.set(fieldName + "Compare", new TemperatureResult(max, againstTemperature, I18nEnumHelper.getLabel(temperatureFormat))); + try { + addFieldError(fieldName, object); + } finally { + stack.pop(); + } + } + + } + + @Override + public String getValidatorType() { + return "temperatureCompare"; + } + + static class TemperatureResult { + private final float max; + private final Float againstTemperature; + private final String format; + + TemperatureResult(float max, Float againstTemperature, String format) { + this.max = max; + this.againstTemperature = againstTemperature; + this.format = format; + } + + public Float getAgainstTemperature() { + return againstTemperature; + } + + public float getMax() { + return max; + } + + public String getFormat() { + return format; + } + } + +} + ===================================== validation/pom.xml ===================================== @@ -191,6 +191,11 @@ <artifactId>jaxx-widgets-gis</artifactId> <version>${lib.version.java4all.jaxx}</version> </dependency> + <dependency> + <groupId>io.ultreia.java4all.jaxx</groupId> + <artifactId>jaxx-widgets-temperature</artifactId> + <version>${lib.version.java4all.jaxx}</version> + </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-create-error-validation.xml ===================================== @@ -77,16 +77,14 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} </message> </field-validator> - </field> <field name="quadrant"> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/longline/ActivityLonglineDto-update-error-validation.xml ===================================== @@ -62,13 +62,22 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> + <message> + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} + </message> + </field-validator> + <!-- coherence temperature surface (delta de 12° par rapport a celle de l'activity precedente) --> + <field-validator type="temperatureCompare" short-circuit="true"> + <param name="max">12.0</param> + <param name="defaultTemperatureFormat">C</param> + <param name="compareTemperatureFormat">C</param> + <param name="compareFieldName">currentTrip.getPreviousActivity(id).seaSurfaceTemperature</param> <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} + observe.validation.activity.invalid.seaSurfaceTemperature##${seaSurfaceTemperatureCompare.againstTemperature}##${currentTrip.getPreviousActivity(id).timeStamp}##${seaSurfaceTemperatureCompare.max}##${seaSurfaceTemperatureCompare.format} </message> </field-validator> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml ===================================== @@ -251,28 +251,12 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> - <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} - </message> - </field-validator> - - <!-- coherence temperature surface (delta de 12° par rapport a celle de l'activity precedente) --> - <field-validator type="fieldexpression"> - <param name="expression"><![CDATA[ - seaSurfaceTemperature == null || previousActivity == null || previousActivity.seaSurfaceTemperature == null || - (previousActivity.seaSurfaceTemperature > seaSurfaceTemperature ? - previousActivity.seaSurfaceTemperature - seaSurfaceTemperature <= 12.0 - : seaSurfaceTemperature - previousActivity.seaSurfaceTemperature <= 12.0 - ) - ]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> <message> - observe.validation.activity.invalid.seaSurfaceTemperature##${seaSurfaceTemperature}##${previousActivity.seaSurfaceTemperature}##${previousActivity.time} + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} </message> </field-validator> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml ===================================== @@ -180,28 +180,22 @@ <field name="seaSurfaceTemperature"> <!-- temperature surface non saisie || 12.0 <= temperature surface <= 35.0 --> - <field-validator type="fieldexpressionwithparams" short-circuit="true"> - <param name="doubleParams">min:12.0|max:35.0</param> - <param name="expression"> - <![CDATA[ seaSurfaceTemperature == null || (doubles.min <= seaSurfaceTemperature && seaSurfaceTemperature <= doubles.max)]]> - </param> + <field-validator type="temperatureBound" short-circuit="true"> + <param name="min">12.0</param> + <param name="max">35.0</param> + <param name="defaultTemperatureFormat">C</param> <message> - observe.validation.activity.bound.seaSurfaceTemperature##${doubles.min}##${doubles.max} + observe.validation.activity.bound.seaSurfaceTemperature##${seaSurfaceTemperatureBound.min}##${seaSurfaceTemperatureBound.max}##${seaSurfaceTemperatureBound.format} </message> </field-validator> - <!-- coherence temperature surface (delta de 12° par rapport a celle de l'activity precedente) --> - <field-validator type="fieldexpression"> - <param name="expression"><![CDATA[ - seaSurfaceTemperature == null || previousActivity == null || previousActivity.seaSurfaceTemperature == null || - (previousActivity.seaSurfaceTemperature > seaSurfaceTemperature ? - previousActivity.seaSurfaceTemperature - seaSurfaceTemperature <= 12.0 - : seaSurfaceTemperature - previousActivity.seaSurfaceTemperature <= 12.0 - ) - ]]> - </param> + <field-validator type="temperatureCompare" short-circuit="true"> + <param name="max">12.0</param> + <param name="defaultTemperatureFormat">C</param> + <param name="compareTemperatureFormat">C</param> + <param name="compareFieldName">currentRoute.getPreviousActivity(id).seaSurfaceTemperature</param> <message> - observe.validation.activity.invalid.seaSurfaceTemperature##${seaSurfaceTemperature}##${previousActivity.seaSurfaceTemperature}##${previousActivity.time} + observe.validation.activity.invalid.seaSurfaceTemperature##${seaSurfaceTemperatureCompare.againstTemperature}##${currentRoute.getPreviousActivity(id).time}##${seaSurfaceTemperatureCompare.max}##${seaSurfaceTemperatureCompare.format} </message> </field-validator> ===================================== validation/src/main/resources/i18n/validation_en_GB.properties ===================================== @@ -325,7 +325,7 @@ observe.common.WindDto.speedRange=Speed range observe.common.WindDto.waveHeight=Wave weight observe.validation.activity.bound.latitude=Latitude must be between %1$s and %2$s. observe.validation.activity.bound.longitude=Longitude must be between %1$s and %2$s. -observe.validation.activity.bound.seaSurfaceTemperature=Temperature must be between %1$s and %2$s. +observe.validation.activity.bound.seaSurfaceTemperature=Temperature must be between %1$s%3$s and %2$s%3$s. observe.validation.activity.bound.vesselSpeed=Vessel speed must be between %1$s and %2$s. observe.validation.activity.comment.tobig=Comment size is bound to 1024 characters. observe.validation.activity.desactivated.currentFpaZone=Selected current Fpa zone is disabled. @@ -340,7 +340,7 @@ observe.validation.activity.desactivated.vesselActivity=Selected vessel activity observe.validation.activity.desactivated.wind=Selected wind is disabled. observe.validation.activity.duplicated.time=There is already another activity at this time. observe.validation.activity.invalid.quadrant=Quadrant is not coherent with ocean (%1$s) of trip (indian\: 1,2, atlantic 1,2,3,4). -observe.validation.activity.invalid.seaSurfaceTemperature=Sea temperature (%1$s) can't vary to more than 12° from surface temperature (%2$s) of the previous activity %3$s. +observe.validation.activity.invalid.seaSurfaceTemperature=Sea temperature can't vary to more than %3$s%4$s from surface temperature (%1$s%4$s) of the previous activity %2$s. observe.validation.activity.invalid.speed=Activity speed is %s nb, which is more than the maximum authorized which is %s nd. observe.validation.activity.null.dcp=No floating object selected. observe.validation.activity.null.fpaZone=Fpa zone is not filled. ===================================== validation/src/main/resources/i18n/validation_es_ES.properties ===================================== @@ -327,7 +327,7 @@ observe.common.WindDto.speedRange=Texto velocidad del viento observe.common.WindDto.waveHeight=Texto descriptivo de «altura media de la ola» observe.validation.activity.bound.latitude=La latitud dada debe estar comprendida entre %1$s y %2$s. observe.validation.activity.bound.longitude=La longitud dada debe estar comprendida entre %1$s y %2$s. -observe.validation.activity.bound.seaSurfaceTemperature=La temperatura debe estar comprendida entre %1$s y %2$s. +observe.validation.activity.bound.seaSurfaceTemperature=La temperatura debe estar comprendida entre %1$s%3$s y %2$s%3$s. observe.validation.activity.bound.vesselSpeed=La Velocidad del viento estar comprendida entre %1$s y %2$s. observe.validation.activity.comment.tobig=La longitud del campo comentarios está limitada a 1024 carácteres. observe.validation.activity.desactivated.currentFpaZone=La zona actual debe ser desactivada @@ -342,7 +342,7 @@ observe.validation.activity.desactivated.vesselActivity=Actividad del barco sele observe.validation.activity.desactivated.wind=La fuerza del viento seleccionada está desactivada. observe.validation.activity.duplicated.time=Ya existe una actividad a esa hora. observe.validation.activity.invalid.quadrant=El cuadrante no es coherente con el informe del oceano (%1$s) de la marea (indico \: 1,2, atlantico \: 1, 2, 3, 4) -observe.validation.activity.invalid.seaSurfaceTemperature=La temperatura superficial (%1$s) no puede variar mas de 12° con respecto a la temperatura superficial (%2$s) de la actividad anterio %3$s. +observe.validation.activity.invalid.seaSurfaceTemperature=La temperatura superficial no puede variar mas de %3$s%4$s con respecto a la temperatura superficial (%1$s%4$s) de la actividad anterio %2$s. observe.validation.activity.invalid.speed=La velocidad de la actividad actual es %s nudos, mientras que la velocidad máxima es %s nudos. observe.validation.activity.null.dcp=No se ha introducido objeto flotante. observe.validation.activity.null.fpaZone=La selección de una zona FPA es obligatoria. ===================================== validation/src/main/resources/i18n/validation_fr_FR.properties ===================================== @@ -325,7 +325,7 @@ observe.common.WindDto.speedRange=Libellé vitesse vent observe.common.WindDto.waveHeight=Libellé Hauteur moyenne vagues observe.validation.activity.bound.latitude=La latitude doit être comprise entre %1$s et %2$s. observe.validation.activity.bound.longitude=La longitude doit être comprise entre %1$s et %2$s. -observe.validation.activity.bound.seaSurfaceTemperature=La température doit être comprise entre %1$s et %2$s. +observe.validation.activity.bound.seaSurfaceTemperature=La température doit être comprise entre %1$s%3$s et %2$s%3$s. observe.validation.activity.bound.vesselSpeed=La vitesse navire doit être comprise entre %1$s et %2$s. observe.validation.activity.comment.tobig=La taille du commentaire est limitée à 1024 caractères. observe.validation.activity.desactivated.currentFpaZone=La zone courante est désactivée. @@ -340,7 +340,7 @@ observe.validation.activity.desactivated.vesselActivity=L'activité bateau séle observe.validation.activity.desactivated.wind=Le vent Beaufort sélectionné est désactivé. observe.validation.activity.duplicated.time=Il existe déjà une autre activité à cette heure. observe.validation.activity.invalid.quadrant=Le quadrant n'est pas cohérent par rapport à l'océan (%1$s) de la marée (indien \: 1 -observe.validation.activity.invalid.seaSurfaceTemperature=La température surface (%1$s) ne peut pas varier de plus de 12° par rapport à la température surface (%2$s) de l'activité précédente %3$s. +observe.validation.activity.invalid.seaSurfaceTemperature=La température surface ne peut pas varier de plus de %3$s%4$s par rapport à la température surface (%1$s%4$s) de l'activité précédente %2$s. observe.validation.activity.invalid.speed=La vitesse de l'activité courante est de %s nd, alors que la vitesse maximale autorisée est %s nd observe.validation.activity.null.dcp=Aucun objet flottant saisi. observe.validation.activity.null.fpaZone=La sélection d'une zone FPA est obligatoire. ===================================== validation/src/main/resources/validators.xml ===================================== @@ -69,5 +69,7 @@ <validator name="referentialCode" class="fr.ird.observe.services.validation.validators.ReferentialCodeValidator"/> <validator name="nonTargetCatchObservedSystem" class="fr.ird.observe.services.validation.validators.NonTargetCatchObservedSystemValidator"/> <validator name="activitySeine_observedSystem" class="fr.ird.observe.services.validation.validators.ActivitySeineObservedSystemValidator"/> + <validator name="temperatureBound" class="fr.ird.observe.services.validation.validators.TemperatureBoundFieldValidator"/> + <validator name="temperatureCompare" class="fr.ird.observe.services.validation.validators.TemperatureCompareFieldValidator"/> </validators> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/d22c04d46aa280dcd0a276df0c3… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/d22c04d46aa280dcd0a276df0c3… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] [PS] La création automatique d'une calée ne fonctionne plus (Closes #1075)
by Tony CHEMIT 22 Sep '18

22 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: b24c2861 by Tony CHEMIT at 2018-09-22T11:54:43Z [PS] La création automatique d&#39;une calée ne fonctionne plus (Closes #1075) - Add a NavigationTree.selectSafeNode method to skip any check on selected screen - Review the flow of OpenableUI to do afterSave extra code at the right place - - - - - 23 changed files: - client/src/main/java/fr/ird/observe/client/ui/actions/content/CloseAndCreateUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/CloseOpenUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveActivityLonglinesUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveActivitySeinesUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveRoutesUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveSingleDataUIActionSupport.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveTripsUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/ReOpenUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/ResetEditUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/SelectNodeUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/SelectOpenNodeUIAction.java - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/SetSeineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/ref/ReferenceHomeUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTree.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/CloseAndCreateUIAction.java ===================================== @@ -88,7 +88,7 @@ public class CloseAndCreateUIAction extends AbstractContentUIAction { NavigationTreeNodeSupport selectedNode = tree.getSelectedNode(); selectedNode = tree.getActivitySeineNode(selectedNode, dataContext.getOpenActivitySeineId()); - tree.selectNode(selectedNode); + tree.selectSafeNode(selectedNode); // on conserve le path de l'activité TreePath path = tree.getSelectionPath(); @@ -127,7 +127,7 @@ public class CloseAndCreateUIAction extends AbstractContentUIAction { // selection du noeud de l'activity ouverte NavigationTreeNodeSupport selectedNode = tree.getSelectedNode(); selectedNode = tree.getActivityLonglineNode(selectedNode, dataContext.getOpenActivitySeineId()); - tree.selectNode(selectedNode); + tree.selectSafeNode(selectedNode); // on conserve le path de l'activité TreePath path = tree.getSelectionPath(); ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/CloseOpenUIAction.java ===================================== @@ -107,7 +107,7 @@ public class CloseOpenUIAction extends AbstractContentUIAction { NavigationTreeNodeSupport node = tree.getChild(selectedNode, id); - tree.selectNode(node); + tree.selectSafeNode(node); ContentOpenableUI selectedUI = (ContentOpenableUI) applicationContext.getContentUIManager().getSelectedContentUI(); @@ -117,7 +117,7 @@ public class CloseOpenUIAction extends AbstractContentUIAction { SwingUtilities.invokeLater(() -> { // retour sur le noeud parent - tree.selectNode(selectedNode); + tree.selectSafeNode(selectedNode); }); ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveActivityLonglinesUIAction.java ===================================== @@ -96,7 +96,7 @@ public class MoveActivityLonglinesUIAction extends MoveMultipleDataUIActionSuppo treeHelper.reloadNodeSubTree(newActivitiesNode); // Let's put the focus on the activities node which received the activities - treeHelper.selectNode(newActivitiesNode); + treeHelper.selectSafeNode(newActivitiesNode); } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveActivitySeinesUIAction.java ===================================== @@ -96,7 +96,7 @@ public class MoveActivitySeinesUIAction extends MoveMultipleDataUIActionSupport< treeHelper.reloadNodeSubTree(newActivitiesNode); // Let's put the focus on the activities node which received the activities - treeHelper.selectNode(newActivitiesNode); + treeHelper.selectSafeNode(newActivitiesNode); } } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveRoutesUIAction.java ===================================== @@ -104,7 +104,7 @@ public class MoveRoutesUIAction extends MoveMultipleDataUIActionSupport<RoutesUI // // That's why, if we do this before the trip is opened, // we will end up with an incoherent list view (some buttons will be deactivated while they should be activated for instance) - treeHelper.selectNode(newRoutesNode); + treeHelper.selectSafeNode(newRoutesNode); } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveSingleDataUIActionSupport.java ===================================== @@ -73,7 +73,7 @@ public abstract class MoveSingleDataUIActionSupport extends UIActionSupport { int position = moveData(oldParentNode.getId(), newParentId, dataId); - treeHelper.selectNode(newParentNode); + treeHelper.selectSafeNode(newParentNode); treeHelper.removeNode(node); @@ -87,7 +87,7 @@ public abstract class MoveSingleDataUIActionSupport extends UIActionSupport { treeHelper.reloadNode(oldParentNode, false); treeHelper.reloadNode(newParentNode, false); - treeHelper.selectNode(newNode); + treeHelper.selectSafeNode(newNode); } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/MoveTripsUIAction.java ===================================== @@ -30,8 +30,8 @@ import fr.ird.observe.client.ui.content.list.ContentListUI; import fr.ird.observe.client.ui.tree.navigation.NavigationTree; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; import fr.ird.observe.dto.referential.GearType; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.List; import java.util.Optional; @@ -111,7 +111,7 @@ public abstract class MoveTripsUIAction<U extends ContentListUI<?, ?, ?, ?>> ext treeHelper.reloadNode(oldParentNode, true); treeHelper.reloadNode(newProgramNode, true); - treeHelper.selectNode(newProgramNode); + treeHelper.selectSafeNode(newProgramNode); } } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/ReOpenUIAction.java ===================================== @@ -73,7 +73,7 @@ public class ReOpenUIAction extends AbstractContentUIAction { NavigationTreeNodeSupport selectedNode = tree.getSelectedNode(); NavigationTreeNodeSupport node = tree.getChild(selectedNode, id); - tree.selectNode(node); + tree.selectSafeNode(node); openUI = (ContentOpenableUI<?, ?>) ObserveSwingApplicationContext.get().getContentUIManager().getSelectedContentUI(); ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/ResetEditUIAction.java ===================================== @@ -59,7 +59,7 @@ public class ResetEditUIAction extends AbstractContentUIAction { NavigationTree tree = getMainUI().getNavigationUI().getTree(); NavigationTreeNodeSupport parentNode = tree.getSelectedNode().getParent(); tree.removeNode(tree.getSelectedNode()); - tree.selectNode(parentNode); + tree.selectSafeNode(parentNode); } else { ui.resetEdit(); } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/SelectNodeUIAction.java ===================================== @@ -79,7 +79,7 @@ public class SelectNodeUIAction extends AbstractContentUIAction { NavigationTreeNodeSupport selectedNode = tree.getSelectedNode(); NavigationTreeNodeSupport nodeToSelect = tree.getChild(selectedNode, dataReference.getId()); - SwingUtilities.invokeLater(() -> tree.selectNode(nodeToSelect)); + SwingUtilities.invokeLater(() -> tree.selectSafeNode(nodeToSelect)); return; } @@ -92,6 +92,6 @@ public class SelectNodeUIAction extends AbstractContentUIAction { NavigationTreeNodeSupport node = (NavigationTreeNodeSupport) source.getClientProperty(NODE); Objects.requireNonNull(node); - SwingUtilities.invokeLater(() -> getMainUI().getNavigationUI().getTree().selectNode(node)); + SwingUtilities.invokeLater(() -> getMainUI().getNavigationUI().getTree().selectSafeNode(node)); } } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/SelectOpenNodeUIAction.java ===================================== @@ -58,7 +58,7 @@ public class SelectOpenNodeUIAction extends AbstractContentUIAction { NavigationTreeNodeSupport<?> node = contentListUI.getOpenNode(); NavigationTree tree = getNavigationTree(); - tree.selectNode(node); + tree.selectSafeNode(node); } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java ===================================== @@ -658,13 +658,11 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U String id = entity.getId(); NavigationTreeNodeSupport node = treeHelper.getChild(parentNode, id); log.debug("will go to node " + node + " for " + id); - treeHelper.selectNode(node); + treeHelper.selectSafeNode(node); } public void openLink(String url) { - try { - UIHelper.openLink(url); } catch (Exception e) { UIHelper.handlingError(e); @@ -683,13 +681,13 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U } - public <F extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<F> formDefinition) { + public <D extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<D> formDefinition) { loadReferentialReferenceSetsInModel(formDefinition, true); } - protected <F extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<F> formDefinition, boolean clear) { + protected <D extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<D> formDefinition, boolean clear) { - Class<F> dtoType = formDefinition.getType(); + Class<D> dtoType = formDefinition.getType(); ImmutableMap.Builder<String, ReferentialDtoReferenceSet<?>> modelReferentialReferenceSets = ImmutableMap.builder(); @@ -808,7 +806,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U if (parentNode != null) { // node still attached, so remove it treehelper.removeNode(node); - treehelper.selectNode(parentNode); + treehelper.selectSafeNode(parentNode); } } @@ -831,7 +829,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U NavigationTreeNodeSupport node = treeHelper.getSelectedNode(); NavigationTreeNodeSupport parentNode = node.getParent(); treeHelper.removeNode(node); - treeHelper.selectNode(parentNode); + treeHelper.selectSafeNode(parentNode); } } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUIHandler.java ===================================== @@ -29,6 +29,7 @@ import fr.ird.observe.client.ui.content.ContentMode; import fr.ird.observe.client.ui.content.ContentUIModel; import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy; import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler; +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.ActivityLonglineHelper; @@ -36,8 +37,8 @@ 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.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.validator.NuitonValidatorScope; @@ -254,9 +255,7 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin } @Override - protected boolean doSave(ActivityLonglineDto bean) { - - boolean notPersisted = bean.isNotPersisted(); + protected boolean doSave(ActivityLonglineDto bean, boolean notPersisted) { String tripId = getSelectedParentId(); @@ -270,15 +269,23 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin if (notPersisted) { // ouverture de l'activité après création getOpenDataManager().openActivityLongline(getSelectedParentId(), bean.getId(), null); + } + + return true; + } + + @Override + protected void afterSave(ActivityLonglineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) { + repaintTripNode(); + if (notPersisted) { if (ActivityLonglineHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId())) { - // création de l'opération de pêche - SwingUtilities.invokeLater(() -> getUi().getAddSet().doClick()); + // création de l'opération de pêche (sur le nouvel écran car l'action n'est pas accessible sur l'ancien écran) + ActivityLonglineUI content = ObserveSwingApplicationContext.get().getContentUIManager().getContent(); + SwingUtilities.invokeLater(() -> content.getAddSet().doClick()); } } - - return true; } @Override @@ -305,13 +312,6 @@ class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglin setUpdateMareeNodeTag(wasTripEndDateUpdated); return true; - - } - - @Override - protected void afterSave(boolean refresh) { - super.afterSave(refresh); - repaintTripNode(); } @Override ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/SetLonglineUIHandler.java ===================================== @@ -40,8 +40,8 @@ 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.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; @@ -380,7 +380,7 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto, SetLo node = treeHelper.addSetLongline(parentNode, reference); stopEditUI(); - treeHelper.selectNode(node); + treeHelper.selectSafeNode(node); } else { ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUIHandler.java ===================================== @@ -30,6 +30,7 @@ import fr.ird.observe.client.ui.content.ContentMode; import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy; import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler; import fr.ird.observe.client.ui.content.open.ContentOpenableUIModel; +import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; import fr.ird.observe.client.ui.util.tripMap.TripMapUI; import fr.ird.observe.dto.data.TripMapDto; import fr.ird.observe.dto.data.longline.TripLonglineDto; @@ -43,8 +44,8 @@ import fr.ird.observe.dto.referential.VesselDto; import fr.ird.observe.dto.referential.VesselHelper; import fr.ird.observe.dto.referential.VesselReference; import fr.ird.observe.dto.result.SaveResultDto; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.util.DateUtil; @@ -278,9 +279,7 @@ class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLonglineDto, Tr } @Override - protected boolean doSave(TripLonglineDto bean) { - - boolean notPersisted = bean.isNotPersisted(); + protected boolean doSave(TripLonglineDto bean, boolean notPersisted) { // on force toujours la date a etre sans heure, minute,... Date startDate = DateUtil.getDay(bean.getStartDate()); @@ -308,8 +307,11 @@ class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLonglineDto, Tr } @Override - protected int getOpenablePosition(String parentId, TripLonglineDto bean) { + protected void afterSave(TripLonglineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) { + } + @Override + protected int getOpenablePosition(String parentId, TripLonglineDto bean) { return getTripLonglineService().getTripLonglinePositionInProgram(parentId, bean.getId()); } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUIHandler.java ===================================== @@ -28,6 +28,7 @@ import fr.ird.observe.client.ui.content.ContentMode; import fr.ird.observe.client.ui.content.ContentUIModel; import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy; import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler; +import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; import fr.ird.observe.client.validation.ClientValidationContext; import fr.ird.observe.dto.data.seine.ActivitySeineDto; import fr.ird.observe.dto.data.seine.ActivitySeineHelper; @@ -38,8 +39,8 @@ import fr.ird.observe.dto.reference.DataDtoReference; import fr.ird.observe.dto.referential.seine.VesselActivitySeineHelper; import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference; import fr.ird.observe.dto.result.SaveResultDto; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; @@ -82,35 +83,6 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, }; } - @Override - protected void prepareValidationContext() { - super.prepareValidationContext(); - - ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); - validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor()); - - } - - @Override - protected boolean doOpenData() { - boolean result = getOpenDataManager().canOpenActivitySeine(getSelectedParentId()); - if (result) { - String setSeineId = Optional.ofNullable(getBean().getSetSeine()).map(DataDtoReference::getId).orElse(null); - - getOpenDataManager().openActivitySeine(getSelectedParentId(), getSelectedId(), setSeineId); - } - return result; - } - - @Override - public boolean doCloseData() { - boolean result = getOpenDataManager().isOpenActivitySeine(getSelectedId()); - if (result) { - getOpenDataManager().closeActivitySeine(getSelectedId()); - } - return result; - } - @Override protected ContentMode getContentMode(ClientDataContext dataContext) { @@ -163,38 +135,32 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, } @Override - protected ObserveLayoutFocusTraversalPolicy<ActivitySeineUI> creatFocusTraversalPolicy() { - return new ObserveLayoutFocusTraversalPolicy<ActivitySeineUI>() { + protected void prepareValidationContext() { + super.prepareValidationContext(); - @Override - protected Component getFirstComponentForEdit(Container aContainer) { - ActivitySeineUI ui = getUi(); - int selectedIndex = ui.getMainTabbedPane().getSelectedIndex(); - switch (selectedIndex) { - case 0: - JComponent editor = ui.getTime().getHourEditor().getEditor(); - return ((JSpinner.DateEditor) editor).getTextField(); - case 1: - return ui.getVesselSpeed(); - case 2: - return ui.getObservedSystem().getUniverseList(); - } - return super.getFirstComponent(aContainer); - } + ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext(); + validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinatesEditor()); - @Override - protected Component getLastComponentForEdit(Container aContainer) { - ActivitySeineUI ui = getUi(); - if (ui.getModel().isCreatingMode()) { - if (ui.getSave().isEnabled()) { - return ui.getSave(); - } - return ui.getReset(); - } else - return ui.getCloseAndCreate(); - } + } - }; + @Override + protected boolean doOpenData() { + boolean result = getOpenDataManager().canOpenActivitySeine(getSelectedParentId()); + if (result) { + String setSeineId = Optional.ofNullable(getBean().getSetSeine()).map(DataDtoReference::getId).orElse(null); + + getOpenDataManager().openActivitySeine(getSelectedParentId(), getSelectedId(), setSeineId); + } + return result; + } + + @Override + public boolean doCloseData() { + boolean result = getOpenDataManager().isOpenActivitySeine(getSelectedId()); + if (result) { + getOpenDataManager().closeActivitySeine(getSelectedId()); + } + return result; } @Override @@ -319,9 +285,42 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, } @Override - protected boolean doSave(ActivitySeineDto bean) { + protected ObserveLayoutFocusTraversalPolicy<ActivitySeineUI> creatFocusTraversalPolicy() { + return new ObserveLayoutFocusTraversalPolicy<ActivitySeineUI>() { - boolean notPersisted = bean.isNotPersisted(); + @Override + protected Component getFirstComponentForEdit(Container aContainer) { + ActivitySeineUI ui = getUi(); + int selectedIndex = ui.getMainTabbedPane().getSelectedIndex(); + switch (selectedIndex) { + case 0: + JComponent editor = ui.getTime().getHourEditor().getEditor(); + return ((JSpinner.DateEditor) editor).getTextField(); + case 1: + return ui.getVesselSpeed(); + case 2: + return ui.getObservedSystem().getUniverseList(); + } + return super.getFirstComponent(aContainer); + } + + @Override + protected Component getLastComponentForEdit(Container aContainer) { + ActivitySeineUI ui = getUi(); + if (ui.getModel().isCreatingMode()) { + if (ui.getSave().isEnabled()) { + return ui.getSave(); + } + return ui.getReset(); + } else + return ui.getCloseAndCreate(); + } + + }; + } + + @Override + protected boolean doSave(ActivitySeineDto bean, boolean notPersisted) { String routeId = getSelectedParentId(); @@ -335,17 +334,22 @@ class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto, if (notPersisted) { // ouverture de l'activité après création getOpenDataManager().openActivitySeine(getSelectedParentId(), bean.getId(), null); - - if (bean.getReasonForNoFishing() == null) { - // création de l'opération de pêche - SwingUtilities.invokeLater(() -> getUi().getAddSet().doClick()); - } - } return true; } + @Override + protected void afterSave(ActivitySeineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) { + if (notPersisted) { + if (bean.isSetOperation() && bean.getReasonForNoFishing() == null) { + // create set + ActivitySeineUI content = ObserveSwingApplicationContext.get().getContentUIManager().getContent(); + SwingUtilities.invokeLater(() -> content.getAddSet().doClick()); + } + } + } + @Override protected int getOpenablePosition(String parentId, ActivitySeineDto bean) { return getActivitySeineService().getActivitySeinePositionInRoute(parentId, bean.getId()); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java ===================================== @@ -264,7 +264,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, node = treeHelper.addFloatingObject(parentNode, reference); stopEditUI(); if (refresh) { - treeHelper.selectNode(node); + treeHelper.selectSafeNode(node); } } else { ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUIHandler.java ===================================== @@ -38,8 +38,8 @@ import fr.ird.observe.dto.form.Form; import fr.ird.observe.dto.referential.seine.VesselActivitySeineHelper; import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference; import fr.ird.observe.dto.result.TripChildSaveResultDto; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.util.DateUtil; import org.nuiton.validator.NuitonValidatorScope; @@ -185,9 +185,7 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme } @Override - protected boolean doSave(RouteDto bean) { - - boolean notPersisted = bean.isNotPersisted(); + protected boolean doSave(RouteDto bean, boolean notPersisted) { String tripId = getSelectedParentId(); @@ -217,14 +215,13 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme } @Override - protected int getOpenablePosition(String parentId, RouteDto bean) { - return getRouteService().getRoutePositionInTripSeine(parentId, bean.getId()); + protected void afterSave(RouteDto bean, NavigationTreeNodeSupport node, boolean notPersisted) { + repaintTripNode(); } @Override - protected void afterSave(boolean refresh) { - super.afterSave(refresh); - repaintTripNode(); + protected int getOpenablePosition(String parentId, RouteDto bean) { + return getRouteService().getRoutePositionInTripSeine(parentId, bean.getId()); } @Override @@ -347,7 +344,7 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme log.debug("PARENT NODE = " + parentNode); // select activities node before adding new node, otherwise, the new unsaved activity node may no more be selected // at the end of addUnsavedNode method (reloading sub node will empty selection...) - treeHelper.selectNode(parentNode); + treeHelper.selectSafeNode(parentNode); treeHelper.addUnsavedNode(parentNode, ActivitySeineDto.class); // on recupère l'écran d'édition ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/SetSeineUIHandler.java ===================================== @@ -40,8 +40,8 @@ import fr.ird.observe.dto.data.seine.SetSeineReference; import fr.ird.observe.dto.form.Form; import fr.ird.observe.dto.result.SaveResultDto; import fr.ird.observe.spi.DtoModelHelper; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; @@ -275,7 +275,7 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto, SetSeineUI> node = treeHelper.addSetSeine(parentNode, reference); stopEditUI(); - treeHelper.selectNode(node); + treeHelper.selectSafeNode(node); } else { // select ancestor node // treeHelper.refreshNode(node, false); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUIHandler.java ===================================== @@ -29,6 +29,7 @@ import fr.ird.observe.client.ui.content.ContentMode; import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy; import fr.ird.observe.client.ui.content.open.ContentOpenableUIHandler; import fr.ird.observe.client.ui.content.open.ContentOpenableUIModel; +import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; import fr.ird.observe.client.ui.util.tripMap.TripMapUI; import fr.ird.observe.dto.data.TripMapDto; import fr.ird.observe.dto.data.seine.TripSeineDto; @@ -42,8 +43,8 @@ import fr.ird.observe.dto.referential.VesselDto; import fr.ird.observe.dto.referential.VesselHelper; import fr.ird.observe.dto.referential.VesselReference; import fr.ird.observe.dto.result.SaveResultDto; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.util.DateUtil; @@ -273,9 +274,7 @@ class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto, TripSein } @Override - protected boolean doSave(TripSeineDto bean) { - - boolean notPersisted = bean.isNotPersisted(); + protected boolean doSave(TripSeineDto bean, boolean notPersisted) { // on force toujours la date a etre sans heure, minute,... Date startDate = DateUtil.getDay(bean.getStartDate()); @@ -303,8 +302,12 @@ class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto, TripSein return true; } - protected int getOpenablePosition(String parentId, TripSeineDto bean) { + @Override + protected void afterSave(TripSeineDto bean, NavigationTreeNodeSupport node, boolean notPersisted) { + + } + protected int getOpenablePosition(String parentId, TripSeineDto bean) { return getTripSeineService().getTripSeinePositionInProgram(parentId, bean.getId()); } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/open/ContentOpenableUIHandler.java ===================================== @@ -8,12 +8,12 @@ * 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>. @@ -50,10 +50,10 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont private static final String POSITION_OPENABLE = "positionOpenable"; - /** Logger */ static private final Logger log = LogManager.getLogger(ContentOpenableUIHandler.class); private static final String UPDATE_TRIP_NODE = "updateTripNode"; protected final String closeMessage; + private boolean notPersisted; public ContentOpenableUIHandler(DataContextType parentType, DataContextType type, String closeMessage) { super(parentType, type); @@ -62,6 +62,16 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont protected abstract boolean obtainCanReopen(boolean create); + protected abstract boolean doOpenData(); + + public abstract boolean doCloseData(); + + protected abstract boolean doSave(E bean, boolean notPersisted); + + protected abstract void afterSave(E bean, NavigationTreeNodeSupport node, boolean notPersisted); + + protected abstract int getOpenablePosition(String parentId, E bean); + @Override public ContentOpenableUIModel<E> getModel() { return (ContentOpenableUIModel<E>) super.getModel(); @@ -72,8 +82,6 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont return source.canWriteData(); } - protected abstract boolean doOpenData(); - public final void openDataUI() { boolean ok = false; try { @@ -132,8 +140,6 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont treeHelper.reloadNode(parent, false); } - public abstract boolean doCloseData(); - public final void afterCloseData() { U ui = getUi(); @@ -148,7 +154,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont removeAllMessages(ui); addMessage(ui, NuitonValidatorScope.INFO, - getTypeI18nKey(bean.getClass()), t(closeMessage)); + getTypeI18nKey(bean.getClass()), t(closeMessage)); NavigationTree treeHelper = getNavigationTree(); treeHelper.reloadSelectedNode(bean instanceof TripSeineDto || bean instanceof TripLonglineDto, true); @@ -157,8 +163,13 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont grabFocusOnForm(); } + protected final boolean doSave(E bean) { + notPersisted = bean.isNotPersisted(); + return doSave(bean, notPersisted); + } + @Override - protected void afterSave(boolean refresh) { + protected final void afterSave(boolean refresh) { super.afterSave(refresh); @@ -210,7 +221,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont } // on sélectionne le nouveau noeud - treeHelper.selectNode(node); + treeHelper.selectSafeNode(node); } else { if (oldPosition != position) { @@ -218,7 +229,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont treeHelper.moveNode(parentNode, node, position); // et le selectionner - treeHelper.selectNode(node); + treeHelper.selectSafeNode(node); } node.reload(); @@ -229,6 +240,7 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont // on repaint le noeud et ses enfants treeHelper.reloadSelectedNode(false, true); } + afterSave(bean, node, notPersisted); } /** @@ -271,8 +283,6 @@ public abstract class ContentOpenableUIHandler<E extends DataDto, U extends Cont getUi().setContextValue(position, POSITION_OPENABLE); } - protected abstract int getOpenablePosition(String parentId, E bean); - protected final void finalizeOpenUI(ContentMode mode, boolean create) { boolean historicalData = false; ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/ReferenceHomeUIHandler.java ===================================== @@ -37,7 +37,6 @@ import org.nuiton.jaxx.runtime.spi.UIHandler; import javax.swing.JButton; import javax.swing.JPanel; - import java.awt.Component; import java.awt.Container; @@ -95,7 +94,7 @@ public class ReferenceHomeUIHandler extends ContentUIHandler<ProgramDto, Referen String text = t(ObserveI18nDecoratorHelper.getTypePluralI18nKey(type)); JButton button = new JButton(text); - button.addActionListener(e -> navigation.selectNode(referentialNode.findChildByClass(type))); + button.addActionListener(e -> navigation.selectSafeNode(referentialNode.findChildByClass(type))); panel.add(button); } ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTree.java ===================================== @@ -64,8 +64,8 @@ import fr.ird.observe.dto.referential.ProgramReference; import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.spi.DtoModelHelper; import org.apache.commons.collections4.CollectionUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jdesktop.swingx.JXTree; import javax.swing.SwingUtilities; @@ -98,7 +98,7 @@ public class NavigationTree extends JXTree { setSelectionModel(new DefaultTreeSelectionModel() { @Override public void setSelectionPath(TreePath path) { - boolean canChange = !Objects.equals(path, getSelectionPath()) && ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI(); + boolean canChange = skipCheckPreviousContent || (!Objects.equals(path, getSelectionPath()) && ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI()); if (!canChange) { // cancel the change of node return; @@ -176,6 +176,29 @@ public class NavigationTree extends JXTree { return isSelectionEmpty() ? null : (NavigationTreeNodeSupport) getSelectionPath().getLastPathComponent(); } + private boolean skipCheckPreviousContent; + + /** + * Selects the given {@code node} in the tree without doing any check on previous content loaded. + * <p> + * This method should be used only programmatically. + * + * @param node the node to select + */ + public void selectSafeNode(NavigationTreeNodeSupport node) { + if (log.isInfoEnabled()) { + log.info("try to select node [" + node + "]"); + } + TreePath path = new TreePath(getTreeModel().getPathToRoot(node)); + + skipCheckPreviousContent = true; + try { + setSelectionPath(path); + } finally { + skipCheckPreviousContent = false; + } + SwingUtilities.invokeLater(() -> scrollPathToVisible(path)); + } /** * Selects the given {@code node} in the registred tree. * @@ -237,7 +260,7 @@ public class NavigationTree extends JXTree { try { - selectNode(selectedNode); + selectSafeNode(selectedNode); } finally { // nettoyage du context @@ -332,7 +355,7 @@ public class NavigationTree extends JXTree { log.debug("will selected open node: " + selectedNode); } - selectNode(selectedNode); + selectSafeNode(selectedNode); } } @@ -434,7 +457,7 @@ public class NavigationTree extends JXTree { fireTreeExpanded(new TreePath(result.getPath())); // Select new node - selectNode(result); + selectSafeNode(result); return result; } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/b24c286153ae0593fa4fd97ac0d… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/b24c286153ae0593fa4fd97ac0d… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] [PS] Utilisation d'un objet flottant de référence - Closes #1074
by Tony CHEMIT 21 Sep '18

21 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 09765ed1 by Tony CHEMIT at 2018-09-21T15:46:55Z [PS] Utilisation d&#39;un objet flottant de référence - Closes #1074 - - - - - 2 changed files: - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTable.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java ===================================== @@ -49,8 +49,8 @@ import fr.ird.observe.dto.result.SaveResultDto; import fr.ird.observe.services.service.actions.consolidate.dcp.ConsolidateFloatingObjectRequest; import fr.ird.observe.services.service.actions.consolidate.dcp.ConsolidateFloatingObjectResult; import fr.ird.observe.spi.DtoModelHelper; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.runtime.swing.SwingUtil; import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; @@ -147,6 +147,8 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, Set<FloatingObjectPartReference> partsSet; Form<FloatingObjectDto> form; Optional<FloatingObjectPreset> floatingObjectReference; + boolean useReference = false; + if (dcpId == null) { Optional<FloatingObjectPreset> ref = ObserveSwingApplicationContext.get().getFloatingObjectPresetsManager().getReferenceToUse(); @@ -155,6 +157,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, String floatingObjectReferenceId = ref.map(FloatingObjectPreset::getFloatingObjectId).orElse(null); form = getFloatingObjectService().preCreate(activityId, floatingObjectReferenceId); if (floatingObjectReferenceId != null) { + useReference = true; partsSet = getFloatingObjectService().getFloatingObjectPartByFloatingObject(floatingObjectReferenceId).toSet(); for (FloatingObjectPartReference floatingObjectPartDtoDataReference : partsSet) { floatingObjectPartDtoDataReference.setId(null); @@ -180,7 +183,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, model.reset(); - getUi().getTable().openTable(model, partsSet, bean.isPersisted()); + getUi().getTable().openTable(model, partsSet, bean.isPersisted() || useReference); setContentMode(mode); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTable.java ===================================== @@ -68,7 +68,7 @@ public class FloatingObjectPartsTreeTable extends JXTreeTable { return (FloatingObjectPartsTreeTableModel) super.getTreeTableModel(); } - public void openTable(FloatingObjectUIModel model, Set<FloatingObjectPartReference> partsSet, boolean persisted) { + public void openTable(FloatingObjectUIModel model, Set<FloatingObjectPartReference> partsSet, boolean expandTree) { for (FloatingObjectPartReference p : partsSet) { String objectMaterialId = p.getObjectMaterialId(); @@ -85,7 +85,7 @@ public class FloatingObjectPartsTreeTable extends JXTreeTable { FloatingObjectPartsTreeTableModel treeTableModel = getTreeTableModel(); treeTableModel.reset(); - if (persisted) { + if (expandTree) { expandAll(); } else { // expand first level nodes (except if they are disabled) View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/09765ed193a2c5859c399fbfa20… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/09765ed193a2c5859c399fbfa20… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] 7 commits: L'action de sauvegarde de la base locale est lancée automatiquement si on…
by Tony CHEMIT 21 Sep '18

21 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 9840f0cc by Tony CHEMIT at 2018-09-21T14:12:30Z L&#39;action de sauvegarde de la base locale est lancée automatiquement si on sélectionne une source connue - Closes #1072 - - - - - fe02c931 by Tony CHEMIT at 2018-09-21T14:12:31Z Fix some validation messages - - - - - da8ad35b by Tony CHEMIT at 2018-09-21T14:12:32Z start to improve navigation popup (but not use it now) - - - - - bdadf657 by Tony CHEMIT at 2018-09-21T14:12:32Z Introduce actions for admin tabs - - - - - a00adcff by Tony CHEMIT at 2018-09-21T14:12:32Z L&#39;assistant calcul de donnés demande abusivement (ou pas) de configurer une connexion - Closes #961 - - - - - 4cb8a860 by Tony CHEMIT at 2018-09-21T15:16:34Z La mise à jour des référentiels ne fonctionne pas si il y a des référentiels obsolètes! - Closes #1073 - - - - - e81af25e by Tony CHEMIT at 2018-09-21T15:19:32Z Après avoir réussit à effectuer les remplacements de référentiels obsolètes, la base source est toujours sauvegardé! - Closes #1074 - - - - - 30 changed files: - client/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss - client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java - client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java - + client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainLeftSourceUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainRightSourceUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/storage/UseRemoteConfigurationUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/storage/UseServerConfigurationUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/admin/AdminTabUIInitializer.java - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigModel.java - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jcss - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/admin/save/SaveLocalUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/legacy/ObsoleteReferentialReference.java - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/legacy/SynchronizeUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/ObserveActionMap.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss The diff was not included because it is too large. View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/d1918ddad1359cf2d45ad84c16… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/d1918ddad1359cf2d45ad84c16… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] 2 commits: Introduce actions for admin tabs
by Tony CHEMIT 21 Sep '18

21 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 061b5ecc by Tony CHEMIT at 2018-09-21T14:06:26Z Introduce actions for admin tabs - - - - - d1918dda by Tony CHEMIT at 2018-09-21T14:06:55Z L&#39;assistant calcul de donnés demande abusivement (ou pas) de configurer une connexion - Closes #961 - - - - - 9 changed files: - + client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainLeftSourceUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainRightSourceUIAction.java - + client/src/main/java/fr/ird/observe/client/ui/admin/AdminTabUIInitializer.java - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigModel.java - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jcss - client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/ObserveActionMap.java - client/src/main/java/fr/ird/observe/client/ui/storage/StorageUIModel.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainLeftSourceUIAction.java ===================================== @@ -0,0 +1,69 @@ +package fr.ird.observe.client.ui.actions.admin; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.actions.UIActionSupport; +import fr.ird.observe.client.ui.admin.AdminUIModel; +import fr.ird.observe.client.ui.admin.config.ConfigUI; +import fr.ird.observe.client.ui.storage.StorageUILauncher; +import fr.ird.observe.client.ui.storage.StorageUIModel; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.awt.Window; +import java.awt.event.ActionEvent; + +import static org.nuiton.i18n.I18n.n; + +/** + * Created by tchemit on 21/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class ObtainLeftSourceUIAction extends UIActionSupport { + + public static final String ACTION_NAME = ObtainLeftSourceUIAction.class.getName(); + private static final Logger log = LogManager.getLogger(ObtainLeftSourceUIAction.class); + + private final ConfigUI ui; + + public ObtainLeftSourceUIAction(ObserveMainUI mainUI, ConfigUI ui) { + super(mainUI, ACTION_NAME, n("observe.action.configure"), null, "config", ObserveKeyStrokes.KEY_STROKE_CONFIGURE_LOCAL_SOURCE, true); + this.ui = ui; + } + + @Override + public void actionPerformed(ActionEvent e) { + log.info("start obtain left connexion"); + StorageUIModel sourceModel = ui.getLocalSourceModel(); + StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel); + log.debug("After modifiy source model isValid : " + sourceModel.isValid() + " / " + sourceModel.isValidStep()); + + AdminUIModel model = ui.getModel(); + model.getConfigModel().removeLocalSource(); + model.getConfigModel().getLocalSourceModel().validate(); + model.validate(); + } +} ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/admin/ObtainRightSourceUIAction.java ===================================== @@ -0,0 +1,68 @@ +package fr.ird.observe.client.ui.actions.admin; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.actions.UIActionSupport; +import fr.ird.observe.client.ui.admin.AdminUIModel; +import fr.ird.observe.client.ui.admin.config.ConfigUI; +import fr.ird.observe.client.ui.storage.StorageStep; +import fr.ird.observe.client.ui.storage.StorageUILauncher; +import fr.ird.observe.client.ui.storage.StorageUIModel; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.awt.Window; +import java.awt.event.ActionEvent; + +import static org.nuiton.i18n.I18n.n; + +/** + * Created by tchemit on 21/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class ObtainRightSourceUIAction extends UIActionSupport { + + public static final String ACTION_NAME = ObtainRightSourceUIAction.class.getName(); + private static final Logger log = LogManager.getLogger(ObtainRightSourceUIAction.class); + + private final ConfigUI ui; + + public ObtainRightSourceUIAction(ObserveMainUI mainUI, ConfigUI ui) { + super(mainUI, ACTION_NAME, n("observe.action.configure"), null, "config", ObserveKeyStrokes.KEY_STROKE_CONFIGURE_REMOTE_SOURCE, true); + this.ui = ui; + } + + @Override + public void actionPerformed(ActionEvent e) { + log.info("start obtain right connexion"); + StorageUIModel sourceModel = ui.getCentralSourceModel(); + StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel); + AdminUIModel model = ui.getModel(); + model.getConfigModel().removeCentralSource(); + model.getConfigModel().getCentralSourceModel().validate(StorageStep.CONFIG); + model.validate(); + } +} ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/AdminTabUIInitializer.java ===================================== @@ -0,0 +1,442 @@ +package fr.ird.observe.client.ui.admin; + +/* + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ImmutableMap; +import fr.ird.observe.client.ObserveSwingApplicationContext; +import fr.ird.observe.client.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.actions.UIActionSupport; +import fr.ird.observe.client.ui.actions.content.GoToSubTab1UIAction; +import fr.ird.observe.client.ui.actions.content.GoToSubTab2UIAction; +import fr.ird.observe.client.ui.actions.content.GoToSubTab3UIAction; +import fr.ird.observe.client.ui.actions.content.GoToTab1UIAction; +import fr.ird.observe.client.ui.actions.content.GoToTab2UIAction; +import fr.ird.observe.client.ui.actions.content.GoToTab3UIAction; +import fr.ird.observe.client.ui.actions.content.GoToTab4UIAction; +import fr.ird.observe.client.ui.actions.content.GoToTab5UIAction; +import fr.ird.observe.client.ui.actions.content.GoToTab6UIAction; +import fr.ird.observe.client.ui.actions.content.GoToTabUIActionSupport; +import fr.ird.observe.client.ui.content.ObserveActionMap; +import fr.ird.observe.client.ui.util.UIHelper; +import fr.ird.observe.dto.I18nEnumHelper; +import fr.ird.observe.dto.decoration.DecoratorService; +import fr.ird.observe.dto.decoration.ObserveI18nLabelsBuilder; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.nuiton.jaxx.runtime.swing.editor.EnumEditor; +import org.nuiton.jaxx.runtime.swing.renderer.EnumEditorRenderer; +import org.nuiton.jaxx.widgets.datetime.DateTimeEditor; +import org.nuiton.jaxx.widgets.datetime.TimeEditor; +import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor; +import org.nuiton.jaxx.widgets.select.BeanComboBox; +import org.nuiton.jaxx.widgets.select.BeanFilterableComboBox; +import org.nuiton.jaxx.widgets.select.BeanListHeader; +import org.nuiton.jaxx.widgets.select.FilterableDoubleList; +import org.nuiton.jaxx.widgets.text.BigTextEditor; + +import javax.swing.AbstractButton; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JSpinner; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +/** + * To initialize ui. + * <p> + * Created on 9/26/14. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 3.7 + */ +public class AdminTabUIInitializer<UI extends AdminTabUI> { + + public static final String OBSERVE_ACTION = "observeAction"; + + public static final String GLOBAL_ACTION = "globalAction"; + + private static final String CLIENT_PROPERTY_PROPERTY_NAME = "propertyName"; + + private static final String CLIENT_PROPERTY_RESET_PROPERTY_NAME = "resetPropertyName"; + + private static final String CLIENT_PROPERTY_NOT_BLOCKING = "notBlocking"; + + /** Logger. */ + private static final Logger log = LogManager.getLogger(AdminTabUIInitializer.class); + + protected final UI ui; + + protected final DecoratorService decoratorService; + + public AdminTabUIInitializer(UI ui) { + this.ui = ui; + this.decoratorService = ObserveSwingApplicationContext.get().getDecoratorService(); + } + + public void initUI() { + + ObserveActionMap actionMap = ObserveSwingApplicationContext.get().getActionMap(); + InputMap inputMap = ObserveSwingApplicationContext.get().getMainUI().getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); + // initialisation des éditeurs + + Set<String> doNotBlockComponentIds = new HashSet<>(); + + ui.getActionMap().setParent(actionMap); + ui.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap); + + for (String name : ui.get$objectMap().keySet()) { + Object o = ui.getObjectById(name); + + if (o == null) { + continue; + } + +// if (o instanceof JComponent) { +// +// init((JComponent) o, doNotBlockComponentIds); +// } + + if (o instanceof AbstractButton) { + init(actionMap, (AbstractButton) o); + continue; + } + +// if (o instanceof BeanComboBox<?>) { +// init((BeanComboBox<?>) o); +// continue; +// } +// if (o instanceof BeanFilterableComboBox<?>) { +// init((BeanFilterableComboBox<?>) o); +// continue; +// } + +// if (o instanceof BeanListHeader<?>) { +// init((BeanListHeader) o); +// continue; +// } + +// if (o instanceof FilterableDoubleList<?>) { +// init((FilterableDoubleList<?>) o); +// continue; +// } + +// if (o instanceof TimeEditor) { +// init((TimeEditor) o); +// continue; +// } + +// if (o instanceof DateTimeEditor) { +// init((DateTimeEditor) o); +// continue; +// } + +// if (o instanceof CoordinatesEditor) { +// init((CoordinatesEditor) o); +// continue; +// } + +// if (o instanceof EnumEditor) { +// init((EnumEditor<?>) o); +// continue; +// } + +// if (o instanceof BigTextEditor) { +// init((BigTextEditor) o); +// continue; +// } +// if (o instanceof JTabbedPane) { +// init((JTabbedPane) o); +// continue; +// } +// if (o instanceof JLabel) { +// init((JLabel) o); +// continue; +// } + + } + + } + + private void init(JLabel editor) { + String editorName = StringUtils.removeEnd(editor.getName(), "Label"); + Object objectById = ui.getObjectById(editorName); + if (objectById instanceof JComponent) { + editor.setLabelFor((Component) objectById); + } + } + + protected void init(ObserveActionMap actionMap, AbstractButton editor) { + String actionId = (String) editor.getClientProperty(OBSERVE_ACTION); + if (actionId == null) { + return; + } + + // on a trouve une action commune + UIActionSupport action = actionMap.newAction(actionId, ui); + Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName()); + + log.debug("init common action " + actionId); + action.initAction(ui, editor); + +// actionId = (String) editor.getClientProperty(GLOBAL_ACTION); +// if (actionId != null) { +// action = (UIActionSupport) actionMap.get(actionId); +// Objects.requireNonNull(action, "action [" + actionId + "] not found for ui " + ui.getClass().getName()); +// KeyStroke acceleratorKey = action.getAcceleratorKey(); +// ObserveKeyStrokes.addKeyStroke(editor, acceleratorKey); +// } + + } + + @SuppressWarnings("unchecked") + protected void init(BeanComboBox beanComboBox) { + if (log.isDebugEnabled()) { + log.debug("init combobox for " + beanComboBox.getBeanType()); + } + Class referenceType = beanComboBox.getBeanType(); + beanComboBox.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType)); + beanComboBox.setI18nPrefix("observe.common."); + beanComboBox.setMinimumSize(new Dimension(0, 24)); + + if (StringUtils.isEmpty(beanComboBox.getProperty())) { + beanComboBox.setProperty(beanComboBox.getName()); + } + } + + @SuppressWarnings("unchecked") + protected void init(BeanFilterableComboBox BeanFilterableComboBox) { + if (log.isDebugEnabled()) { + log.debug("init combobox for " + BeanFilterableComboBox.getBeanType()); + } + BeanFilterableComboBox.getCombobox().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none"); + Class referenceType = BeanFilterableComboBox.getBeanType(); + BeanFilterableComboBox.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType)); + BeanFilterableComboBox.setI18nPrefix("observe.common."); + BeanFilterableComboBox.setMinimumSize(new Dimension(0, 24)); + + if (StringUtils.isEmpty(BeanFilterableComboBox.getProperty())) { + BeanFilterableComboBox.setProperty(BeanFilterableComboBox.getName()); + } + } + + @SuppressWarnings("unchecked") + protected void init(BeanListHeader beanList) { + + beanList.setI18nPrefix("observe.common."); + + log.debug("init list for " + beanList.getBeanType()); + + Class referenceType = beanList.getBeanType(); + beanList.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType)); + } + + @SuppressWarnings("unchecked") + protected void init(FilterableDoubleList beanList) { + + beanList.setI18nPrefix("observe.common."); + Class referenceType = beanList.getBeanType(); + beanList.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(referenceType)); + beanList.getAddButton().setFocusable(false); + beanList.getRemoveButton().setFocusable(false); + + log.debug("init list for " + beanList.getBeanType()); + } + + protected void init(BigTextEditor editor) { + log.debug("init big text editor " + editor.getName()); + if (editor.getProperty() == null) { + editor.setProperty(editor.getName()); + } + } + + protected void init(TimeEditor editor) { + log.debug("init time editor " + editor.getName()); + editor.init(); + if (isAutoSelectOnFocus(editor)) { + + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getHourEditor().getEditor()); + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getMinuteEditor().getEditor()); + + } + } + + protected void init(DateTimeEditor editor) { + log.debug("init date time editor " + editor.getName()); + editor.init(); + editor.getSliderHidor().setFocusable(false); + if (isAutoSelectOnFocus(editor)) { + + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getHourEditor().getEditor()); + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getMinuteEditor().getEditor()); + addAutoSelectOnFocus(editor.getDayDateEditor().getEditor()); + editor.getDayDateEditor().getEditor().addFocusListener(new FocusAdapter() { + + private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); + + @Override + public void focusLost(FocusEvent e) { + + JFormattedTextField source = (JFormattedTextField) e.getSource(); + if (source.isEditValid()) { + try { + Date newDate = simpleDateFormat.parse(editor.getDayDateEditor().getEditor().getText()); + Object oldValue = editor.getModel().getPropertyDayDate() == null ? null : UIHelper.getProperty(editor.getModel().getBean(), editor.getModel().getPropertyDayDate()); + if (!Objects.equals(oldValue, newDate)) { + editor.getDayDateEditor().commitEdit(); + log.debug("quit date editor, commit value: " + source.getValue()); + } + } catch (ParseException e1) { + // l'édition est valide donc pas de problème ici + } + } + super.focusLost(e); + } + }); + + } + } + + private void addAutoSelectOnFocus(JSpinner.DateEditor hourEditor) { + addAutoSelectOnFocus(hourEditor.getTextField()); + } + + protected void init(CoordinatesEditor editor) { + log.debug("init coordinates editor " + editor.getName()); + editor.setFormat(ObserveSwingApplicationContext.get().getConfig().getCoordinateFormat()); + editor.init(); + editor.getDmdFormat().setFocusable(false); + editor.getDmsFormat().setFocusable(false); + editor.getDdFormat().setFocusable(false); + + } + + protected void init(JTabbedPane tabbedPane) { + boolean mainTabbedPane = GoToTabUIActionSupport.MAIN_TABBED_PANE.equals(tabbedPane.getName()); + boolean subTabbedPane = GoToTabUIActionSupport.SUB_TABBED_PANE.equals(tabbedPane.getName()); + if (!mainTabbedPane && !subTabbedPane) { + return; + } + int tabCount = tabbedPane.getTabCount(); + InputMap inputMap = ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); + if (mainTabbedPane) { + ObserveKeyStrokes.addKeyStrokeToMainTabbedPane(tabbedPane); + if (tabCount > 0) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_1, GoToTab1UIAction.ACTION_NAME); + } + if (tabCount > 1) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_2, GoToTab2UIAction.ACTION_NAME); + } + if (tabCount > 2) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_3, GoToTab3UIAction.ACTION_NAME); + } + if (tabCount > 3) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_4, GoToTab4UIAction.ACTION_NAME); + } + if (tabCount > 4) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_5, GoToTab5UIAction.ACTION_NAME); + } + if (tabCount > 5) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_TAB_6, GoToTab6UIAction.ACTION_NAME); + } + } + if (subTabbedPane) { + ObserveKeyStrokes.addKeyStrokeToSubTabbedPane(tabbedPane); + if (tabCount > 0) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_1, GoToSubTab1UIAction.ACTION_NAME); + } + if (tabCount > 1) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_2, GoToSubTab2UIAction.ACTION_NAME); + } + if (tabCount > 2) { + inputMap.put(ObserveKeyStrokes.KEY_STROKE_GO_SUB_TAB_3, GoToSubTab3UIAction.ACTION_NAME); + } + } + + } + + protected void init(JComponent editor, Set<String> notBlockingComponents) { + final Boolean propertyName = (Boolean) editor.getClientProperty(CLIENT_PROPERTY_NOT_BLOCKING); + if (propertyName != null) { + + if (editor instanceof FilterableDoubleList) { + + notBlockingComponents.add("universeListPane"); + notBlockingComponents.add("selectedListPane"); + + } else { + + notBlockingComponents.add(editor.getName()); + + } + } + } + + protected <B extends Enum<B>> void init(EnumEditor<B> editor) { + log.debug("init enumEditor editor " + editor.getName()); + ImmutableMap.Builder<B, String> labelsBuilder = ImmutableMap.builder(); + for (B e : EnumSet.allOf(editor.getType())) { + String label = I18nEnumHelper.getLabel(e); + labelsBuilder.put(e, label); + } + editor.setRenderer(new EnumEditorRenderer<>(labelsBuilder.build())); + editor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none"); + } + + private boolean isAutoSelectOnFocus(JComponent comp) { + Boolean selectOnFocus = (Boolean) comp.getClientProperty("selectOnFocus"); + return BooleanUtils.isTrue(selectOnFocus); + } + + private void addAutoSelectOnFocus(JTextField jTextField) { + jTextField.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(final FocusEvent e) { + SwingUtilities.invokeLater(() -> { + JTextField source = (JTextField) e.getSource(); + source.selectAll(); + }); + + } + }); + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigModel.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.admin.config; * 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>. @@ -38,8 +38,8 @@ import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; import fr.ird.observe.services.service.DatabaseNotFoundException; import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.beans.PropertyChangeListener; import java.io.File; @@ -59,11 +59,15 @@ import static org.nuiton.i18n.I18n.t; */ public class ConfigModel extends AdminActionModel { - /** Logger */ - private static final Logger log = LogManager.getLogger(ConfigModel.class); public static final String PROPERTY_LOCAL_SOURCE_LABEL = "localSourceLabel"; public static final String PROPERTY_CENTRAL_SOURCE_LABEL = "centralSourceLabel"; - + public static final PropertyChangeListener LOG_PROPERTY_CHANGE_LISTENER = new AdminUIModel.LogPropertyChanged(); + /** Logger */ + private static final Logger log = LogManager.getLogger(ConfigModel.class); + /** la configuration de la base source */ + protected final StorageUIModel localSourceModel; + /** la configuration de la base central */ + protected final StorageUIModel centralSourceModel; /** la source de données en cours d'utilisation par l'application */ protected ObserveSwingDataSource previousSource; /** la source de données sur laquel on veut travailler */ @@ -72,10 +76,6 @@ public class ConfigModel extends AdminActionModel { protected ObserveDataSourceInformation localSourceInformation; /** la source de données dite central (contenant le référentiel valide) */ protected ObserveSwingDataSource centralSource; - /** la configuration de la base source */ - protected final StorageUIModel localSourceModel; - /** la configuration de la base central */ - protected final StorageUIModel centralSourceModel; private String localSourceLabel = t("observe.storage.config.source.storage"); private String centralSourceLabel = t("observe.storage.config.referentiel.storage"); @@ -158,7 +158,6 @@ public class ConfigModel extends AdminActionModel { } - public String getLocalSourceLabel() { return localSourceLabel; } @@ -179,7 +178,6 @@ public class ConfigModel extends AdminActionModel { firePropertyChange(PROPERTY_CENTRAL_SOURCE_LABEL, oldValue, centralSourceLabel); } - public boolean validate(AdminUIModel uiModel) { boolean validate = true; @@ -430,8 +428,6 @@ public class ConfigModel extends AdminActionModel { return validate; } - public static final PropertyChangeListener LOG_PROPERTY_CHANGE_LISTENER = new AdminUIModel.LogPropertyChanged(); - protected void startCentralSourceModel(AdminUI ui) { AdminUIModel uiModel = ui.getModel(); @@ -562,6 +558,9 @@ public class ConfigModel extends AdminActionModel { DbMode dbMode = localSourceModel.getDbMode(); localSourceModel.start(dbMode); +// if (previousSource != null && !previousSource.isLocal()) { +// localSourceModel.testRemote(); +// } if (log.isDebugEnabled()) { localSourceModel.removePropertyChangeListener(LOG_PROPERTY_CHANGE_LISTENER); ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jaxx ===================================== @@ -28,6 +28,8 @@ _failedIcon='SwingUtil.getUIManagerActionIcon("connect_no")'> <import> + fr.ird.observe.client.ui.actions.admin.ObtainLeftSourceUIAction + fr.ird.observe.client.ui.actions.admin.ObtainRightSourceUIAction fr.ird.observe.client.ui.admin.AdminActionModel fr.ird.observe.client.ui.admin.AdminUI fr.ird.observe.client.ui.admin.AdminStep @@ -121,7 +123,7 @@ public void addMessage(AdminStep step, String text) { <JLabel id='localSourceLabel'/> </cell> <cell> - <JButton id='configureLocalSource' onActionPerformed='handler.obtainIncomingConnexion()'/> + <JButton id='configureLocalSource'/> </cell> <cell anchor='east'> <JLabel id='localSourceStatus'/> @@ -145,7 +147,7 @@ public void addMessage(AdminStep step, String text) { <JLabel id='centralSourceLabel'/> </cell> <cell> - <JButton id='configureCentralSource' onActionPerformed='handler.obtainRemoteConnexion()'/> + <JButton id='configureCentralSource'/> </cell> <cell anchor='east'> <JLabel id='centralSourceStatus'/> ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUI.jcss ===================================== @@ -95,8 +95,7 @@ } #configureLocalSource { - text:"observe.action.configure"; - actionIcon:"config"; + _observeAction:{ObtainLeftSourceUIAction.ACTION_NAME}; } #localSourceStatus { @@ -118,8 +117,7 @@ } #configureCentralSource { - text:"observe.action.configure"; - actionIcon:"config"; + _observeAction:{ObtainRightSourceUIAction.ACTION_NAME}; } #centralSourceStatus { ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUIHandler.java ===================================== @@ -6,15 +6,15 @@ * %% * 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 + * 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 + * + * 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% @@ -23,25 +23,18 @@ package fr.ird.observe.client.ui.admin.config; import fr.ird.observe.client.ObserveSwingApplicationContext; import fr.ird.observe.client.ObserveTextGenerator; -import fr.ird.observe.client.ui.ObserveKeyStrokes; import fr.ird.observe.client.ui.admin.AdminStep; import fr.ird.observe.client.ui.admin.AdminTabUIHandler; -import fr.ird.observe.client.ui.admin.AdminUIModel; -import fr.ird.observe.client.ui.storage.StorageStep; -import fr.ird.observe.client.ui.storage.StorageUILauncher; +import fr.ird.observe.client.ui.admin.AdminTabUIInitializer; import fr.ird.observe.client.ui.storage.StorageUIModel; import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.services.configuration.ObserveDataSourceInformation; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.spi.UIHandler; -import javax.swing.AbstractAction; import javax.swing.JCheckBox; -import javax.swing.JComponent; import javax.swing.JLabel; -import java.awt.Window; -import java.awt.event.ActionEvent; import java.util.Set; import static org.nuiton.i18n.I18n.t; @@ -59,24 +52,7 @@ public class ConfigUIHandler extends AdminTabUIHandler<ConfigUI> implements UIHa @Override public void afterInit(ConfigUI ui) { - - ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ObserveKeyStrokes.KEY_STROKE_CONFIGURE_LOCAL_SOURCE, "obtainLocalSource"); - ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ObserveKeyStrokes.KEY_STROKE_CONFIGURE_REMOTE_SOURCE, "obtainRemoteSource"); - ui.getActionMap().put("obtainLocalSource", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - ui.doActionPerformed__on__configureLocalSource(e); - } - }); - ui.getActionMap().put("obtainRemoteSource", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - ui.doActionPerformed__on__configureCentralSource(e); - } - }); - - ObserveKeyStrokes.addKeyStroke(ui.getConfigureLocalSource(), ObserveKeyStrokes.KEY_STROKE_CONFIGURE_LOCAL_SOURCE); - ObserveKeyStrokes.addKeyStroke(ui.getConfigureCentralSource(), ObserveKeyStrokes.KEY_STROKE_CONFIGURE_REMOTE_SOURCE); + new AdminTabUIInitializer<>(ui).initUI(); super.afterInit(ui); UIHelper.setLayerUI(ui.getOperations(), parentUI.getOperationBlockLayerUI()); UIHelper.setLayerUI(ui.getConfig(), parentUI.getConfigBlockLayerUI()); @@ -121,29 +97,29 @@ public class ConfigUIHandler extends AdminTabUIHandler<ConfigUI> implements UIHa return operations.contains(scope); } - public void obtainIncomingConnexion() { - StorageUIModel sourceModel = ui.getLocalSourceModel(); - StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel); - if (log.isDebugEnabled()) { - log.debug("After modifiy source model isValid : " + sourceModel.isValid() + " / " + sourceModel.isValidStep()); - } - AdminUIModel model = ui.getModel(); - model.getConfigModel().removeLocalSource(); - model.getConfigModel().getLocalSourceModel().validate(); - model.validate(); - } - - public void obtainRemoteConnexion() { - if (log.isInfoEnabled()) { - log.info("start obtain remote connexion"); - } - StorageUIModel sourceModel = ui.getCentralSourceModel(); - StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel); - AdminUIModel model = ui.getModel(); - model.getConfigModel().removeCentralSource(); - model.getConfigModel().getCentralSourceModel().validate(StorageStep.CONFIG); - model.validate(); - } +// public void obtainIncomingConnexion() { +// StorageUIModel sourceModel = ui.getLocalSourceModel(); +// StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel); +// if (log.isDebugEnabled()) { +// log.debug("After modifiy source model isValid : " + sourceModel.isValid() + " / " + sourceModel.isValidStep()); +// } +// AdminUIModel model = ui.getModel(); +// model.getConfigModel().removeLocalSource(); +// model.getConfigModel().getLocalSourceModel().validate(); +// model.validate(); +// } +// +// public void obtainRemoteConnexion() { +// if (log.isInfoEnabled()) { +// log.info("start obtain remote connexion"); +// } +// StorageUIModel sourceModel = ui.getCentralSourceModel(); +// StorageUILauncher.obtainConnexion(ui, ui.getParentContainer(Window.class), sourceModel); +// AdminUIModel model = ui.getModel(); +// model.getConfigModel().removeCentralSource(); +// model.getConfigModel().getCentralSourceModel().validate(StorageStep.CONFIG); +// model.validate(); +// } protected String updateDataSourcePolicy(StorageUIModel sourceModel, boolean valid) { String text = null; ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ObserveActionMap.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.content; * 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>. @@ -30,8 +30,8 @@ import fr.ird.observe.client.ui.ObserveMainUI; import fr.ird.observe.client.ui.actions.UIActionSupport; import fr.ird.observe.client.ui.actions.main.global.GlobalUIActionSupport; import org.apache.commons.beanutils.ConstructorUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.reflections.Reflections; import javax.swing.AbstractButton; @@ -163,4 +163,16 @@ public class ObserveActionMap extends ActionMap { } + public <A extends UIActionSupport> A newAction(String key, Object args) { + + try { + @SuppressWarnings("unchecked") Class<A> actionType = (Class<A>) Class.forName(key); + log.debug("Create action: " + key + ", type: " + actionType.getName()); + return ConstructorUtils.invokeConstructor(actionType, new Object[]{ui, args}, new Class[]{ObserveMainUI.class, args.getClass()}); + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { + throw new ObserveSwingTechnicalException("Hum, can't creation action for type: " + key, e); + } + + } + } ===================================== client/src/main/java/fr/ird/observe/client/ui/storage/StorageUIModel.java ===================================== @@ -590,15 +590,17 @@ public class StorageUIModel extends WizardModel<StorageStep> { public void start(DbMode dbMode) { - if (log.isDebugEnabled()) { - log.debug("Will use dbMode : " + dbMode + " vs previous mode " + getDbMode()); - } + boolean testRemote = dataSourceInformation != null; + + log.debug("Will use dbMode : " + dbMode + " vs previous mode " + getDbMode()); setDbMode(dbMode); startCentralSourceModel(); startCentralDataSourceModel(); start(); + + firePropertyChange(DB_MODE_PROPERTY_NAME, getDbMode()); firePropertyChange(CREATION_MODE_PROPERTY_NAME, getCreationMode()); firePropertyChange(DUMP_FILE_PROPERTY_NAME, getDumpFile()); @@ -623,6 +625,11 @@ public class StorageUIModel extends WizardModel<StorageStep> { firePropertyChange(CAN_MIGRATE_PROPERTY_NAME, isCanMigrate()); firePropertyChange(SHOW_MIGRATION_SQL_PROPERTY_NAME, isShowMigrationSql()); firePropertyChange(SHOW_MIGRATION_PROGRESSION_PROPERTY_NAME, isShowMigrationProgression()); + + if (testRemote && !isLocal()) { + log.info("Test previous data source configuration..."); + testRemote(); + } } public boolean isCanUseLocalService() { @@ -1130,7 +1137,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { boolean oldValue = this.localStorageExist; this.localStorageExist = localStorageExist; firePropertyChange(LOCAL_STORAGE_EXIST_PROPERTY_NAME, oldValue, - localStorageExist); + localStorageExist); validate(); } @@ -1585,10 +1592,13 @@ public class StorageUIModel extends WizardModel<StorageStep> { config = pgConfig; } else if (isEditServerConfig()) { try { - URL url = new URL(serverUrl); + if (restConfig.getServerUrl() != null && serverUrl == null) { - restConfig.setServerUrl(url); + } else { + URL url = new URL(serverUrl); + restConfig.setServerUrl(url); + } config = restConfig; } catch (MalformedURLException e) { View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/049d8449d164655b7c54df4bcf… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/049d8449d164655b7c54df4bcf… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] 3 commits: L'action de sauvegarde de la base locale est lancée automatiquement si on…
by Tony CHEMIT 21 Sep '18

21 Sep '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: d0fa2a21 by Tony CHEMIT at 2018-09-21T10:18:39Z L&#39;action de sauvegarde de la base locale est lancée automatiquement si on sélectionne une source connue - Closes #1072 - - - - - 471a7f3e by Tony CHEMIT at 2018-09-21T11:39:14Z Fix some validation messages - - - - - 049d8449 by Tony CHEMIT at 2018-09-21T11:43:25Z start to improve navigation popup (but not use it now) - - - - - 22 changed files: - client/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss - client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java - client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/storage/UseRemoteConfigurationUIAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/storage/UseServerConfigurationUIAction.java - client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/ref/ContentReferenceUIHandler.java - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss ===================================== @@ -24,6 +24,10 @@ computeI18n:"skip" } +.forceNavigation { + _forceNavigation: true; +} + JToolBar { borderPainted:false; floatable:false; ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java ===================================== @@ -83,6 +83,7 @@ public abstract class ObserveKeyStrokes { public static final KeyStroke KEY_STROKE_CHANGE_FOCUS = KeyStroke.getKeyStroke("pressed F1"); public static final KeyStroke KEY_STROKE_SAVE = KeyStroke.getKeyStroke("ctrl pressed S"); public static final KeyStroke KEY_STROKE_SHIFT_ALT_ENTER = KeyStroke.getKeyStroke("alt shift pressed ENTER"); + public static final KeyStroke KEY_STROKE_SHOW_TECHNICAL_INFORMATIONS = KeyStroke.getKeyStroke("shift pressed F1"); public static final KeyStroke KEY_STROKE_GO_DOWN = KeyStroke.getKeyStroke("alt pressed D"); public static final KeyStroke KEY_STROKE_ADD_DCP = KeyStroke.getKeyStroke("ctrl pressed P"); public static final KeyStroke KEY_STROKE_ADD_SET_LONGLINE = KeyStroke.getKeyStroke("ctrl pressed L"); ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java ===================================== @@ -83,6 +83,18 @@ public abstract class UIActionSupport extends AbstractAction { } } + public String getText() { + return (String) getValue(SHORT_DESCRIPTION); + } + + public String getToolTipText() { + return (String) getValue(LONG_DESCRIPTION); + } + + public Icon getIcon() { + return (Icon) getValue(SMALL_ICON); + } + public KeyStroke getAcceleratorKey() { return (KeyStroke) getValue(ACCELERATOR_KEY); } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java ===================================== @@ -0,0 +1,140 @@ +package fr.ird.observe.client.ui.actions.content; + +import fr.ird.observe.client.ObserveSwingApplicationContext; +import fr.ird.observe.client.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.content.ContentUI; +import fr.ird.observe.client.ui.content.ContentUIModel; +import fr.ird.observe.client.ui.util.SpringUtilities; +import fr.ird.observe.dto.IdDto; +import fr.ird.observe.dto.referential.ReferentialDto; +import org.apache.commons.lang3.time.FastDateFormat; +import org.nuiton.decorator.Decorator; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTextField; +import javax.swing.SpringLayout; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.Locale; +import java.util.Objects; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +/** + * Created by tchemit on 21/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class ShowTechnicalInformationsAction extends AbstractContentUIAction { + + public static final String ACTION_NAME = ShowTechnicalInformationsAction.class.getName(); + private static final long serialVersionUID = 1L; + + private final FastDateFormat dateFormat; + + public ShowTechnicalInformationsAction(ObserveMainUI mainUI) { + super(mainUI, + ACTION_NAME, + null, + n("observe.action.show.technical.informations.tip"), + "show-informations", + ObserveKeyStrokes.KEY_STROKE_SHOW_TECHNICAL_INFORMATIONS); + putValue(NAME, null); + Locale locale = ObserveSwingApplicationContext.get().getConfig().getLocale(); + if (Locale.ENGLISH.equals(locale)) { + dateFormat = FastDateFormat.getInstance("yyyy-MM-ddZZ hh:mm:ss"); + } else { + dateFormat = FastDateFormat.getInstance("dd/MM/yyyy hh:mm:ss"); + } + } + + @Override + protected void actionPerformed(ContentUI<?, ?> contentUI) { + + JButton button = contentUI.getShowTechnicalInformations(); + + ContentUIModel<?> model = contentUI.getModel(); + IdDto bean = model.isEditing() ? model.getBean() : contentUI.getHandler().getSelectedBean(); + + if (bean.getLastUpdateDate() == null) { + return; + } + + JPanel content = new JPanel(new SpringLayout()); + + FocusListener l = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + JTextField source = (JTextField) e.getSource(); + source.setSelectionStart(0); + source.setSelectionEnd(source.getText().length()); + } + + @Override + public void focusLost(FocusEvent e) { + + } + }; + + { + content.add(new JLabel(t("observe.common.Dto.topiaId"))); + JTextField comp = new JTextField(bean.getId()); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + Class<?> beanType = model.getBeanType(); + boolean isReferential = ReferentialDto.class.isAssignableFrom(beanType); + if (isReferential) { + content.add(new JLabel(t("observe.common.Dto.topiaCreateDate"))); + JTextField comp = new JTextField(dateFormat.format(bean.getCreateDate())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + { + content.add(new JLabel(t("observe.common.Dto.lastUpdateDate"))); + JTextField comp = new JTextField(dateFormat.format(bean.getLastUpdateDate())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + if (isReferential) { + content.add(new JLabel(t("observe.common.Dto.topiaVersion"))); + JTextField comp = new JTextField(String.valueOf(bean.getVersion())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + SpringUtilities.makeCompactGrid(content, isReferential ? 4 : 2, 2, 5, 5, 5, 5); + + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(beanType); + Objects.requireNonNull(decorator, "Cant find decorator of type " + beanType); + String title = t("observe.common.Dto.technicalInformations", "\n" + decorator.toString(bean)); + + content.setBorder(new TitledBorder(title)); + + JPopupMenu popup = new JPopupMenu(); + popup.setBorderPainted(true); + popup.add(content); + popup.pack(); + + Dimension dim = popup.getPreferredSize(); + int x = (int) (button.getPreferredSize().getWidth() - dim.getWidth()); + int y = button.getHeight(); + popup.show(button, x, y); + + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/storage/UseRemoteConfigurationUIAction.java ===================================== @@ -29,8 +29,8 @@ import fr.ird.observe.client.ui.storage.StorageUI; import fr.ird.observe.client.ui.storage.StorageUIModel; import fr.ird.observe.client.ui.storage.tabs.ConfigUI; import fr.ird.observe.dto.presets.RemoteDataSourceConfiguration; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.swing.JMenuItem; import javax.swing.KeyStroke; @@ -84,8 +84,7 @@ public class UseRemoteConfigurationUIAction extends UIActionSupport { if (ConnexionStatus.SUCCESS == configUI.getModel().getConnexionStatus()) { if (parentContainer.getModel().getNextStep() != null) { parentContainer.getNextAction().doClick(); - } - if (getMainUI() != null) { + } else if (getMainUI() != null) { parentContainer.getApplyAction().doClick(); } } ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/storage/UseServerConfigurationUIAction.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.actions.storage; * 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>. @@ -29,8 +29,8 @@ import fr.ird.observe.client.ui.storage.StorageUI; import fr.ird.observe.client.ui.storage.StorageUIModel; import fr.ird.observe.client.ui.storage.tabs.ConfigUI; import fr.ird.observe.dto.presets.ServerDataSourceConfiguration; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.swing.JMenuItem; import javax.swing.KeyStroke; @@ -45,10 +45,9 @@ import java.awt.event.ActionEvent; */ public class UseServerConfigurationUIAction extends UIActionSupport { + public static final String ACTION_NAME = UseServerConfigurationUIAction.class.getName(); /** Logger */ private static final Logger log = LogManager.getLogger(UseServerConfigurationUIAction.class); - - public static final String ACTION_NAME = UseServerConfigurationUIAction.class.getName(); private final ConfigUI configUI; private final ServerDataSourceConfiguration configuration; private StorageUI parentContainer; @@ -84,8 +83,7 @@ public class UseServerConfigurationUIAction extends UIActionSupport { if (ConnexionStatus.SUCCESS == configUI.getModel().getConnexionStatus()) { if (parentContainer.getModel().getNextStep() != null) { parentContainer.getNextAction().doClick(); - } - if (getMainUI() != null) { + } else if (getMainUI() != null) { parentContainer.getApplyAction().doClick(); } } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jaxx ===================================== @@ -37,6 +37,7 @@ fr.ird.observe.client.configuration.ClientConfig fr.ird.observe.client.ui.actions.content.GoUpUIAction fr.ird.observe.client.ui.actions.content.GoDownUIAction + fr.ird.observe.client.ui.actions.content.ShowTechnicalInformationsAction fr.ird.observe.client.ui.content.ContentUIHandler fr.ird.observe.dto.IdDto @@ -48,6 +49,9 @@ javax.swing.JComboBox javax.swing.JList javax.swing.UIManager + javax.swing.AbstractButton + + static org.nuiton.i18n.I18n.t </import> <ClientConfig id='config' initializer='ObserveSwingApplicationContext.get().getConfig()'/> @@ -76,6 +80,8 @@ public abstract ContentUIHandler<E,U> getHandler(); + public List<AbstractButton> getNavigationPopupActions() { return getHandler().getNavigationPopupActions(); } + public Object getSelectedBean(JComboBox combo) { return combo.getSelectedItem(); } @@ -143,8 +149,7 @@ public void createData() { <JButton id='actionDown'/> </JXLayer> - <JButton id='showTechnicalInformations' - onActionPerformed='getHandler().showTechnicalInformations((JButton) event.getSource());'/> + <JButton id='showTechnicalInformations'/> <JLabel id='titleRight'/> </JToolBar> @@ -163,6 +168,9 @@ public void createData() { <JPanel id="invisible" visible='false'> + <JPanel id="navigationActions"> + <!--Place here all actions you want to see in navigation popup but not in the form--> + </JPanel> </JPanel> </org.jdesktop.swingx.JXTitledPanel> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jcss ===================================== @@ -37,6 +37,7 @@ #actionDown { _observeAction:{GoDownUIAction.ACTION_NAME}; _protectFocus:true; + _skipNavigation:true; } #actionUpPane { @@ -46,6 +47,7 @@ #actionUp { _observeAction:{GoUpUIAction.ACTION_NAME}; _protectFocus:true; + _skipNavigation:true; } @@ -59,8 +61,7 @@ #showTechnicalInformations { _original:true; - toolTipText:"observe.action.show.technical.informations.tip"; - actionIcon:"show-informations"; + _observeAction:{ShowTechnicalInformationsAction.ACTION_NAME}; enabled:{!model.isCreatingMode() && (model.getBean() != null)}; focusPainted:false; borderPainted:false; ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java ===================================== @@ -8,12 +8,12 @@ * 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>. @@ -35,7 +35,6 @@ import fr.ird.observe.client.ui.content.list.ContentListUIModel; import fr.ird.observe.client.ui.content.ref.ContentReferenceUIHandler; 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.util.SpringUtilities; import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.client.validation.ClientValidationContext; import fr.ird.observe.dto.IdDto; @@ -96,11 +95,10 @@ import fr.ird.observe.services.service.referential.ReferentialService; import fr.ird.observe.services.service.sql.SqlScriptProducerService; import fr.ird.observe.spi.map.ImmutableDtoMap; import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.time.FastDateFormat; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.nuiton.decorator.Decorator; import org.nuiton.decorator.DecoratorUtil; +import org.nuiton.jaxx.runtime.JAXXObject; import org.nuiton.jaxx.runtime.context.DefaultJAXXContext; import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; @@ -112,28 +110,17 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.AbstractButton; import javax.swing.ActionMap; import javax.swing.Icon; -import javax.swing.JButton; import javax.swing.JComponent; -import javax.swing.JLabel; import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; import javax.swing.JToolBar; -import javax.swing.SpringLayout; import javax.swing.SwingUtilities; import javax.swing.UIManager; -import javax.swing.border.TitledBorder; import java.awt.Component; -import java.awt.Dimension; import java.awt.FocusTraversalPolicy; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -158,13 +145,12 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U private final DataContextType type; private final Icon errorIcon; private final Map<String, ReferentialReferencesFilter> referentialsFilters = new TreeMap<>(); - private final FastDateFormat dateFormat; + private final ObserveLayoutFocusTraversalPolicy<U> focusTraversalPolicy; protected String prefix; /** l'interface graphique que le controleur utilise */ protected U ui; private boolean init; - private final ObserveLayoutFocusTraversalPolicy<U> focusTraversalPolicy; public ContentUIHandler(DataContextType parentType, DataContextType type) { this(null, parentType, type); } @@ -174,17 +160,9 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U this.parentType = parentType; this.type = type; this.errorIcon = UIManager.getIcon("action.error"); - Locale locale = ObserveSwingApplicationContext.get().getConfig().getLocale(); - if (Locale.ENGLISH.equals(locale)) { - dateFormat = FastDateFormat.getInstance("yyyy-MM-ddZZ hh:mm:ss"); - } else { - dateFormat = FastDateFormat.getInstance("dd/MM/yyyy hh:mm:ss"); - } this.focusTraversalPolicy = creatFocusTraversalPolicy(); } - protected abstract ObserveLayoutFocusTraversalPolicy<U> creatFocusTraversalPolicy(); - public static NavigationTree getNavigationTree() { return ObserveSwingApplicationContext.get().getMainUI().getNavigationUI().getTree(); } @@ -298,6 +276,63 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U model.removeMessages(ui, null); } + /** + * @return layout focus traversel policy used by the ui. + */ + protected abstract ObserveLayoutFocusTraversalPolicy<U> creatFocusTraversalPolicy(); + + /** + * @return actions usable in the navigation popup. + */ + public List<AbstractButton> getNavigationPopupActions() { + List<AbstractButton> result = new LinkedList<>(); + collectNavigationPopupActions(result, ui, "actions", "extraActions", "navigationActions", "titleRightToolBar"); + for (Object object : ui.get$objectMap().values()) { + if (object != ui && object instanceof ContentUI) { + collectNavigationPopupActions(result, (JAXXObject) object, "actions", "extraActions", "navigationActions"); + } + } + return result; + } + + protected void collectNavigationPopupActions(List<AbstractButton> result, JAXXObject jaxxObject, String... containers) { + for (Object object : jaxxObject.get$objectMap().values()) { + if (object instanceof AbstractButton) { + AbstractButton button = (AbstractButton) object; + boolean force = Objects.equals(true, button.getClientProperty("forceNavigation")); + if (!force) { + if (!button.isEnabled()) { + log.info("Reject (disabled) action: " + button.getName() + " - " + button.getText()); + continue; + } + if (!button.isShowing()) { + log.info("Reject (hidden) action: " + button.getName() + " - " + button.getText()); + continue; + } + if (Objects.equals(true, button.getClientProperty("skipNavigation"))) { + log.info("Reject (skip) action: " + button.getName() + " - " + button.getText()); + continue; + } + + boolean found = false; + for (String container : containers) { + found = SwingUtilities.getAncestorNamed(container, button) != null; + if (found) { + break; + } + } + if (!found) { + log.info("Reject (out of zone) action: " + button.getName() + " - " + button.getText()); + continue; + } + } + log.info("Keep action: " + button.getName() + " - " + button.getText()); + result.add(button); + } + } + + } + protected void addReferentialFilter(String propertyName, ReferentialReferencesFilter filter) { referentialsFilters.put(propertyName, filter); } @@ -802,9 +837,9 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U protected void addInfoMessage(String message) { addMessage(ui, - NuitonValidatorScope.INFO, - getTypeI18nKey(getModel().getBeanType()), - t(message) + NuitonValidatorScope.INFO, + getTypeI18nKey(getModel().getBeanType()), + t(message) ); } @@ -1159,92 +1194,11 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U } - protected E getSelectedBean() { + public E getSelectedBean() { return getModel().getBean(); } - /** - * Pour afficher une popup avec l'ensemble des informations techniques. - * - * @param button le boutton qui a declanche l'action - */ - void showTechnicalInformations(JButton button) { - - E bean = getModel().isEditing() ? getBean() : getSelectedBean(); - - if (bean.getLastUpdateDate() == null) { - return; - } - - JPanel content = new JPanel(new SpringLayout()); - - FocusListener l = new FocusListener() { - @Override - public void focusGained(FocusEvent e) { - JTextField source = (JTextField) e.getSource(); - source.setSelectionStart(0); - source.setSelectionEnd(source.getText().length()); - } - - @Override - public void focusLost(FocusEvent e) { - - } - }; - - { - content.add(new JLabel(t("observe.common.Dto.topiaId"))); - JTextField comp = new JTextField(bean.getId()); - comp.setEditable(false); - comp.addFocusListener(l); - content.add(comp); - } - - boolean isReferential = ReferentialDto.class.isAssignableFrom(getBeanType()); - if (isReferential) { - content.add(new JLabel(t("observe.common.Dto.topiaCreateDate"))); - JTextField comp = new JTextField(dateFormat.format(bean.getCreateDate())); - comp.setEditable(false); - comp.addFocusListener(l); - content.add(comp); - } - - { - content.add(new JLabel(t("observe.common.Dto.lastUpdateDate"))); - JTextField comp = new JTextField(dateFormat.format(bean.getLastUpdateDate())); - comp.setEditable(false); - comp.addFocusListener(l); - content.add(comp); - } - - if (isReferential) { - content.add(new JLabel(t("observe.common.Dto.topiaVersion"))); - JTextField comp = new JTextField(String.valueOf(bean.getVersion())); - comp.setEditable(false); - comp.addFocusListener(l); - content.add(comp); - } - - SpringUtilities.makeCompactGrid(content, isReferential ? 4 : 2, 2, 5, 5, 5, 5); - - Decorator<E> decorator = getDecoratorService().getDecoratorByType(getBeanType()); - Objects.requireNonNull(decorator, "Cant find decorator of type " + getBeanType()); - String title = t("observe.common.Dto.technicalInformations", "\n" + decorator.toString(bean)); - - content.setBorder(new TitledBorder(title)); - - JPopupMenu popup = new JPopupMenu(); - popup.setBorderPainted(true); - popup.add(content); - popup.pack(); - Dimension dim = popup.getPreferredSize(); - int x = (int) (button.getPreferredSize().getWidth() - dim.getWidth()); - int y = button.getHeight(); - popup.show(button, x, y); - } - void openedUI() { - SwingUtilities.invokeLater(this::forceGrabFocusOnForm); } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUI.jaxx ===================================== @@ -36,6 +36,7 @@ fr.ird.observe.client.ui.actions.content.AddActivityLonglineSetUIAction fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveActivityLonglineUIAction 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 @@ -156,5 +157,7 @@ </cell> </row> </Table> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/ActivityLonglineUI.jcss ===================================== @@ -97,3 +97,7 @@ _observeAction:{AddActivityLonglineSetUIAction.ACTION_NAME}; } + +#move { + _observeAction:{MoveActivityLonglineUIAction.ACTION_NAME}; +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jaxx ===================================== @@ -38,6 +38,7 @@ fr.ird.observe.dto.referential.DataQualityReference fr.ird.observe.dto.referential.longline.TripTypeReference fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveTripLonglineUIAction fr.ird.observe.client.ui.actions.main.global.DeleteDataGlobalUIAction fr.ird.observe.client.ui.actions.main.global.NewNextDataGlobalUIAction fr.ird.observe.client.ui.util.JComment @@ -238,4 +239,7 @@ protected boolean canEditOcean(java.util.LinkedHashSet<TripLonglineActivityDto> <JButton id='closeAndCreate'/> <JButton id='actionDown'/> + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jcss ===================================== @@ -118,3 +118,7 @@ _toolTipText:{t("observe.common.TripDto.action.delete.tip")}; _globalAction:{DeleteDataGlobalUIAction.ACTION_NAME}; } + +#move { + _observeAction:{MoveTripLonglineUIAction.ACTION_NAME}; +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jaxx ===================================== @@ -44,9 +44,10 @@ org.nuiton.jaxx.widgets.temperature.TemperatureEditor org.nuiton.jaxx.widgets.temperature.TemperatureEditorConfig - fr.ird.observe.client.ui.actions.content.DeleteDataUIAction fr.ird.observe.client.ui.actions.content.AddActivitySeineSetUIAction fr.ird.observe.client.ui.actions.content.AddActivitySeineFloatingObjectUIAction + fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveActivitySeineUIAction fr.ird.observe.client.ui.util.JComment org.nuiton.jaxx.widgets.number.NumberEditor @@ -303,5 +304,7 @@ </cell> </row> </Table> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jcss ===================================== @@ -181,3 +181,6 @@ visible:{bean.isDcpOperation()}; _observeAction:{AddActivitySeineFloatingObjectUIAction.ACTION_NAME}; } +#move { + _observeAction:{MoveActivitySeineUIAction.ACTION_NAME}; +} \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jaxx ===================================== @@ -30,6 +30,7 @@ <import> fr.ird.observe.dto.data.seine.RouteDto fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveRouteUIAction fr.ird.observe.client.ui.util.JComment org.jdesktop.swingx.JXDatePicker @@ -95,5 +96,7 @@ <JButton id='close'/> <JButton id='closeAndCreate'/> <JButton id='actionDown'/> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jcss ===================================== @@ -64,3 +64,6 @@ NumberEditor { #delete { _toolTipText:{t("observe.common.RouteDto.action.delete.tip")}; } +#move { + _observeAction:{MoveRouteUIAction.ACTION_NAME}; +} \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jaxx ===================================== @@ -41,6 +41,7 @@ fr.ird.observe.dto.referential.DataQualityReference fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveTripSeineUIAction fr.ird.observe.client.ui.util.JComment fr.ird.observe.client.ui.util.tripMap.TripMapUI @@ -262,5 +263,7 @@ protected boolean canEditOcean(java.util.LinkedHashSet<RouteStubDto> routes) { <JButton id='close'/> <JButton id='closeAndCreate'/> <JButton id='actionDown'/> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss ===================================== @@ -151,3 +151,6 @@ NumberEditor { #delete { _toolTipText:{t("observe.common.TripDto.action.delete.tip")}; } +#move { + _observeAction:{MoveTripSeineUIAction.ACTION_NAME}; +} \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/ContentReferenceUIHandler.java ===================================== @@ -418,7 +418,7 @@ public class ContentReferenceUIHandler<D extends ReferentialDto, R extends Refer } @Override - protected D getSelectedBean() { + public D getSelectedBean() { return getModel().getSelectedBean(); } ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml ===================================== @@ -179,7 +179,7 @@ <field-validator type="quadrantDto" short-circuit="true"> <param name="ocean">currentTripSeine.ocean</param> <message> - observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.libelle} + observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.label} </message> </field-validator> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml ===================================== @@ -37,7 +37,7 @@ <field-validator type="quadrantDto" short-circuit="true"> <param name="ocean">currentTripSeine.ocean</param> <message> - observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.libelle} + observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.label} </message> </field-validator> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/d1e7c51b29e155397778dce934… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/d1e7c51b29e155397778dce934… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop] 2 commits: start to improve navigation popup
by Tony CHEMIT 21 Sep '18

21 Sep '18
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 8ee80278 by Tony CHEMIT at 2018-09-21T12:08:11Z start to improve navigation popup - - - - - 49c9586a by Tony CHEMIT at 2018-09-21T12:20:37Z Fix some validation messages - - - - - 23 changed files: - client/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss - client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java - client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java - + client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java - client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/obs/ActivityLonglineObsUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/longline/obs/ActivityLonglineObsUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/ref/ContentReferenceUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/tree/ObserveNavigationTreeShowPopupAction.java - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml - validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveCommon.jcss ===================================== @@ -24,6 +24,10 @@ computeI18n:"skip" } +.forceNavigation { + _forceNavigation: true; +} + JToolBar { borderPainted:false; floatable:false; ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java ===================================== @@ -85,6 +85,7 @@ public abstract class ObserveKeyStrokes { public static final KeyStroke KEY_STROKE_CHANGE_FOCUS = KeyStroke.getKeyStroke("pressed F1"); public static final KeyStroke KEY_STROKE_SAVE = KeyStroke.getKeyStroke("ctrl pressed S"); public static final KeyStroke KEY_STROKE_SHIFT_ALT_ENTER = KeyStroke.getKeyStroke("alt shift pressed ENTER"); + public static final KeyStroke KEY_STROKE_SHOW_TECHNICAL_INFORMATIONS = KeyStroke.getKeyStroke("shift pressed F1"); public static final KeyStroke KEY_STROKE_GO_DOWN = KeyStroke.getKeyStroke("alt pressed D"); public static final KeyStroke KEY_STROKE_ADD_DCP = KeyStroke.getKeyStroke("ctrl pressed P"); public static final KeyStroke KEY_STROKE_ADD_SET_LONGLINE = KeyStroke.getKeyStroke("ctrl pressed L"); ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/UIActionSupport.java ===================================== @@ -82,6 +82,19 @@ public abstract class UIActionSupport extends AbstractAction { } } + + public String getText() { + return (String) getValue(SHORT_DESCRIPTION); + } + + public String getToolTipText() { + return (String) getValue(LONG_DESCRIPTION); + } + + public Icon getIcon() { + return (Icon) getValue(SMALL_ICON); + } + public static void register(Action action, InputMap inputMap, ActionMap actionMap, KeyStroke keyStroke, String actionCommandKey) { if (keyStroke != null) { inputMap.put(keyStroke, actionCommandKey); ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/ShowTechnicalInformationsAction.java ===================================== @@ -0,0 +1,162 @@ +package fr.ird.observe.client.ui.actions.content; + +/*- + * #%L + * ObServe :: Client + * %% + * Copyright (C) 2008 - 2018 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.ui.ObserveKeyStrokes; +import fr.ird.observe.client.ui.ObserveMainUI; +import fr.ird.observe.client.ui.content.ContentUI; +import fr.ird.observe.client.ui.content.ContentUIModel; +import fr.ird.observe.client.ui.util.SpringUtilities; +import fr.ird.observe.dto.IdDto; +import fr.ird.observe.dto.referential.ReferentialDto; +import org.apache.commons.lang3.time.FastDateFormat; +import org.nuiton.decorator.Decorator; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTextField; +import javax.swing.SpringLayout; +import javax.swing.border.TitledBorder; +import java.awt.Dimension; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.Locale; +import java.util.Objects; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +/** + * Created by tchemit on 21/09/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class ShowTechnicalInformationsAction extends AbstractContentUIAction { + + public static final String ACTION_NAME = ShowTechnicalInformationsAction.class.getName(); + private static final long serialVersionUID = 1L; + + private final FastDateFormat dateFormat; + + public ShowTechnicalInformationsAction(ObserveMainUI mainUI) { + super(mainUI, + ACTION_NAME, + null, + n("observe.action.show.technical.informations.tip"), + "show-informations", + ObserveKeyStrokes.KEY_STROKE_SHOW_TECHNICAL_INFORMATIONS); + putValue(NAME, null); + Locale locale = ObserveSwingApplicationContext.get().getConfig().getLocale(); + if (Locale.ENGLISH.equals(locale)) { + dateFormat = FastDateFormat.getInstance("yyyy-MM-ddZZ hh:mm:ss"); + } else { + dateFormat = FastDateFormat.getInstance("dd/MM/yyyy hh:mm:ss"); + } + } + + @Override + protected void actionPerformed(ContentUI<?, ?> contentUI) { + + JButton button = contentUI.getShowTechnicalInformations(); + + ContentUIModel<?> model = contentUI.getModel(); + IdDto bean = model.isEditing() ? model.getBean() : contentUI.getHandler().getSelectedBean(); + + if (bean.getLastUpdateDate() == null) { + return; + } + + JPanel content = new JPanel(new SpringLayout()); + + FocusListener l = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + JTextField source = (JTextField) e.getSource(); + source.setSelectionStart(0); + source.setSelectionEnd(source.getText().length()); + } + + @Override + public void focusLost(FocusEvent e) { + + } + }; + + { + content.add(new JLabel(t("observe.common.Dto.topiaId"))); + JTextField comp = new JTextField(bean.getId()); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + Class<?> beanType = model.getBeanType(); + boolean isReferential = ReferentialDto.class.isAssignableFrom(beanType); + if (isReferential) { + content.add(new JLabel(t("observe.common.Dto.topiaCreateDate"))); + JTextField comp = new JTextField(dateFormat.format(bean.getCreateDate())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + { + content.add(new JLabel(t("observe.common.Dto.lastUpdateDate"))); + JTextField comp = new JTextField(dateFormat.format(bean.getLastUpdateDate())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + if (isReferential) { + content.add(new JLabel(t("observe.common.Dto.topiaVersion"))); + JTextField comp = new JTextField(String.valueOf(bean.getVersion())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + + SpringUtilities.makeCompactGrid(content, isReferential ? 4 : 2, 2, 5, 5, 5, 5); + + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(beanType); + Objects.requireNonNull(decorator, "Cant find decorator of type " + beanType); + String title = t("observe.common.Dto.technicalInformations", "\n" + decorator.toString(bean)); + + content.setBorder(new TitledBorder(title)); + + JPopupMenu popup = new JPopupMenu(); + popup.setBorderPainted(true); + popup.add(content); + popup.pack(); + + Dimension dim = popup.getPreferredSize(); + int x = (int) (button.getPreferredSize().getWidth() - dim.getWidth()); + int y = button.getHeight(); + popup.show(button, x, y); + + } + +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jaxx ===================================== @@ -36,6 +36,7 @@ fr.ird.observe.client.configuration.ClientConfig fr.ird.observe.client.ui.actions.content.GoUpUIAction fr.ird.observe.client.ui.actions.content.GoDownUIAction + fr.ird.observe.client.ui.actions.content.ShowTechnicalInformationsAction fr.ird.observe.client.ui.content.ContentUIHandler fr.ird.observe.dto.IdDto @@ -47,6 +48,9 @@ javax.swing.JComboBox javax.swing.JList javax.swing.UIManager + javax.swing.AbstractButton + + static org.nuiton.i18n.I18n.t </import> <ClientConfig id='config' initializer='ObserveSwingApplicationContext.get().getConfig()'/> @@ -73,6 +77,8 @@ public abstract ContentUIHandler<E,U> getHandler(); + public List<AbstractButton> getNavigationPopupActions() { return getHandler().getNavigationPopupActions(); } + public Object getSelectedBean(JComboBox combo) { return combo.getSelectedItem(); } @@ -140,8 +146,7 @@ public void createData() { <JButton id='actionDown'/> </JXLayer> - <JButton id='showTechnicalInformations' - onActionPerformed='getHandler().showTechnicalInformations((JButton) event.getSource());'/> + <JButton id='showTechnicalInformations'/> <JLabel id='titleRight'/> </JToolBar> @@ -160,6 +165,9 @@ public void createData() { <JPanel id="invisible" visible='false'> + <JPanel id="navigationActions"> + <!--Place here all actions you want to see in navigation popup but not in the form--> + </JPanel> </JPanel> </org.jdesktop.swingx.JXTitledPanel> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUI.jcss ===================================== @@ -37,6 +37,7 @@ #actionDown { _observeAction:{GoDownUIAction.ACTION_NAME}; _protectFocus:true; + _skipNavigation:true; } #actionUpPane { @@ -46,6 +47,7 @@ #actionUp { _observeAction:{GoUpUIAction.ACTION_NAME}; _protectFocus:true; + _skipNavigation:true; } @@ -59,8 +61,7 @@ #showTechnicalInformations { _original:true; - toolTipText:"observe.action.show.technical.informations.tip"; - actionIcon:"show-informations"; + _observeAction:{ShowTechnicalInformationsAction.ACTION_NAME}; enabled:{!model.isCreatingMode() && (model.getBean() != null)}; focusPainted:false; borderPainted:false; ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java ===================================== @@ -106,6 +106,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.nuiton.decorator.Decorator; import org.nuiton.decorator.DecoratorUtil; +import org.nuiton.jaxx.runtime.JAXXObject; import org.nuiton.jaxx.runtime.context.DefaultJAXXContext; import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; @@ -1179,7 +1180,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U } - protected E getSelectedBean() { + public E getSelectedBean() { return getModel().getBean(); } @@ -1603,4 +1604,55 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U List<R> filter(List<R> incomingReferences); } + /** + * @return actions usable in the navigation popup. + */ + public List<AbstractButton> getNavigationPopupActions() { + List<AbstractButton> result = new LinkedList<>(); + collectNavigationPopupActions(result, ui, "actions", "extraActions", "navigationActions", "titleRightToolBar"); + for (Object object : ui.get$objectMap().values()) { + if (object != ui && object instanceof ContentUI) { + collectNavigationPopupActions(result, (JAXXObject) object, "actions", "extraActions", "navigationActions"); + } + } + return result; + } + + protected void collectNavigationPopupActions(List<AbstractButton> result, JAXXObject jaxxObject, String... containers) { + for (Object object : jaxxObject.get$objectMap().values()) { + if (object instanceof AbstractButton) { + AbstractButton button = (AbstractButton) object; + boolean force = Objects.equals(true, button.getClientProperty("forceNavigation")); + if (!force) { + if (!button.isEnabled()) { + log.info("Reject (disabled) action: " + button.getName() + " - " + button.getText()); + continue; + } + if (!button.isShowing()) { + log.info("Reject (hidden) action: " + button.getName() + " - " + button.getText()); + continue; + } + if (Objects.equals(true, button.getClientProperty("skipNavigation"))) { + log.info("Reject (skip) action: " + button.getName() + " - " + button.getText()); + continue; + } + + boolean found = false; + for (String container : containers) { + found = SwingUtilities.getAncestorNamed(container, button) != null; + if (found) { + break; + } + } + if (!found) { + log.info("Reject (out of zone) action: " + button.getName() + " - " + button.getText()); + continue; + } + } + log.info("Keep action: " + button.getName() + " - " + button.getText()); + result.add(button); + } + } + + } } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jaxx ===================================== @@ -40,6 +40,7 @@ fr.ird.observe.dto.referential.longline.ObservationTripTypeReference fr.ird.observe.dto.referential.longline.LogbookTripTypeReference fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveTripLonglineUIAction fr.ird.observe.client.ui.actions.main.global.DeleteDataGlobalUIAction fr.ird.observe.client.ui.actions.main.global.NewNextDataGlobalUIAction fr.ird.observe.client.ui.util.JComment @@ -355,4 +356,7 @@ protected boolean canEditOcean(java.util.LinkedHashSet<TripLonglineActivityObsDt <JButton id='closeAndCreate'/> <JButton id='actionDown'/> + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/TripLonglineUI.jcss ===================================== @@ -216,3 +216,7 @@ BigTextEditor { #logbookComment { property:{TripLonglineDto.PROPERTY_LOGBOOK_COMMENT}; } + +#move { + _observeAction:{MoveTripLonglineUIAction.ACTION_NAME}; +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUI.jaxx ===================================== @@ -38,6 +38,7 @@ fr.ird.observe.client.ui.actions.content.AddActivityLonglineLogbookSetUIAction fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveActivityLonglineLogbookUIAction 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 ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUI.jcss ===================================== @@ -100,3 +100,7 @@ enabled:{!model.isModified() && model.isValid() && model.isSetOperation() && ! bean.isHasSetLongline()}; _observeAction:{AddActivityLonglineLogbookSetUIAction.ACTION_NAME}; } + +#move { + _observeAction:{MoveActivityLonglineLogbookUIAction.ACTION_NAME}; +} \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/obs/ActivityLonglineObsUI.jaxx ===================================== @@ -35,6 +35,7 @@ fr.ird.observe.client.ui.actions.content.AddActivityLonglineObsSetUIAction fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveActivityLonglineObsUIAction 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 @@ -155,5 +156,7 @@ </cell> </row> </Table> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/longline/obs/ActivityLonglineObsUI.jcss ===================================== @@ -97,3 +97,7 @@ _observeAction:{AddActivityLonglineObsSetUIAction.ACTION_NAME}; } + +#move { + _observeAction:{MoveActivityLonglineObsUIAction.ACTION_NAME}; +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jaxx ===================================== @@ -44,9 +44,10 @@ org.nuiton.jaxx.widgets.temperature.TemperatureEditor org.nuiton.jaxx.widgets.temperature.TemperatureEditorConfig - fr.ird.observe.client.ui.actions.content.DeleteDataUIAction fr.ird.observe.client.ui.actions.content.AddActivitySeineSetUIAction fr.ird.observe.client.ui.actions.content.AddActivitySeineFloatingObjectUIAction + fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveActivitySeineUIAction fr.ird.observe.client.ui.util.JComment org.nuiton.jaxx.widgets.number.NumberEditor @@ -303,5 +304,7 @@ </cell> </row> </Table> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/ActivitySeineUI.jcss ===================================== @@ -181,3 +181,6 @@ visible:{bean.isDcpOperation()}; _observeAction:{AddActivitySeineFloatingObjectUIAction.ACTION_NAME}; } +#move { + _observeAction:{MoveActivitySeineUIAction.ACTION_NAME}; +} \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jaxx ===================================== @@ -30,6 +30,7 @@ <import> fr.ird.observe.dto.data.seine.RouteDto fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveRouteUIAction fr.ird.observe.client.ui.util.JComment org.jdesktop.swingx.JXDatePicker @@ -95,5 +96,7 @@ <JButton id='close'/> <JButton id='closeAndCreate'/> <JButton id='actionDown'/> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUI.jcss ===================================== @@ -66,3 +66,6 @@ NumberEditor { #delete { _toolTipText:{t("observe.common.RouteDto.action.delete.tip")}; } +#move { + _observeAction:{MoveRouteUIAction.ACTION_NAME}; +} \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jaxx ===================================== @@ -41,6 +41,7 @@ fr.ird.observe.dto.referential.DataQualityReference fr.ird.observe.client.ui.actions.content.DeleteDataUIAction + fr.ird.observe.client.ui.actions.content.MoveTripSeineUIAction fr.ird.observe.client.ui.util.JComment fr.ird.observe.client.ui.util.tripMap.TripMapUI @@ -262,5 +263,7 @@ protected boolean canEditOcean(java.util.LinkedHashSet<RouteStubDto> routes) { <JButton id='close'/> <JButton id='closeAndCreate'/> <JButton id='actionDown'/> - + <JPanel id="forceNavigation"> + <JButton id='move' styleClass="forceNavigation"/> + </JPanel> </fr.ird.observe.client.ui.content.open.ContentOpenableUI> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/TripSeineUI.jcss ===================================== @@ -153,3 +153,6 @@ NumberEditor { #delete { _toolTipText:{t("observe.common.TripDto.action.delete.tip")}; } +#move { + _observeAction:{MoveTripSeineUIAction.ACTION_NAME}; +} \ No newline at end of file ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/ContentReferenceUIHandler.java ===================================== @@ -414,7 +414,7 @@ public class ContentReferenceUIHandler<D extends ReferentialDto, R extends Refer } @Override - protected D getSelectedBean() { + public D getSelectedBean() { return getModel().getSelectedBean(); } ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/ObserveNavigationTreeShowPopupAction.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.tree; * 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>. @@ -24,40 +24,35 @@ package fr.ird.observe.client.ui.tree; import com.google.common.base.Preconditions; import fr.ird.observe.client.ObserveSwingApplicationContext; -import fr.ird.observe.client.ui.actions.content.MoveActivityLonglineLogbookUIAction; -import fr.ird.observe.client.ui.actions.content.MoveActivityLonglineObsUIAction; -import fr.ird.observe.client.ui.actions.content.MoveActivitySeineUIAction; -import fr.ird.observe.client.ui.actions.content.MoveRouteUIAction; -import fr.ird.observe.client.ui.actions.content.MoveTripLonglineUIAction; -import fr.ird.observe.client.ui.actions.content.MoveTripSeineUIAction; +import fr.ird.observe.client.ui.ObserveKeyStrokes; import fr.ird.observe.client.ui.content.ContentUI; -import fr.ird.observe.client.ui.content.open.ContentOpenableUI; 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.ReferenceNavigationTreeNodeSupport; -import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookReference; -import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference; -import fr.ird.observe.dto.data.longline.TripLonglineReference; -import fr.ird.observe.dto.data.seine.ActivitySeineReference; -import fr.ird.observe.dto.data.seine.RouteReference; -import fr.ird.observe.dto.data.seine.TripSeineReference; -import fr.ird.observe.dto.navigation.ObserveNavigationNode; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; -import javax.swing.JButton; +import javax.swing.AbstractAction; +import javax.swing.AbstractButton; +import javax.swing.Action; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; +import javax.swing.KeyStroke; import javax.swing.MenuElement; import javax.swing.SwingUtilities; import javax.swing.tree.TreePath; import java.awt.Point; import java.awt.Rectangle; +import java.awt.event.ActionEvent; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.TreeMap; /** * Created on 1/8/15. @@ -70,21 +65,21 @@ public class ObserveNavigationTreeShowPopupAction { /** Logger. */ private static final Logger log = LogManager.getLogger(ObserveNavigationTreeShowPopupAction.class); - private static final String TRIP_SEINE_MENU_ITEMS = "tripSeine"; - private static final String TRIP_LONGLINE_MENU_ITEMS = "tripLongline"; - private static final String ROUTE_MENU_ITEMS = "route"; - private static final String ACTIVITY_SEINE_MENU_ITEMS = "activitySeine"; - private static final String ACTIVITY_LONGLINE_MENU_ITEMS = "activityLongline"; +// private static final String TRIP_SEINE_MENU_ITEMS = "tripSeine"; +// private static final String TRIP_LONGLINE_MENU_ITEMS = "tripLongline"; +// private static final String ROUTE_MENU_ITEMS = "route"; +// private static final String ACTIVITY_SEINE_MENU_ITEMS = "activitySeine"; +// private static final String ACTIVITY_LONGLINE_MENU_ITEMS = "activityLongline"; private final JPopupMenu popup; private final NavigationTree tree; private final JMenuItem noAction; - private final JMenuItem openAction; - private final JMenuItem closeAction; - private final JMenuItem moveAction; - private final JMenuItem deleteAction; +// private final JMenuItem openAction; +// private final JMenuItem closeAction; +// private final JMenuItem moveAction; +// private final JMenuItem deleteAction; public ObserveNavigationTreeShowPopupAction(NavigationTree tree, JScrollPane pane, JPopupMenu popup) { @@ -92,36 +87,35 @@ public class ObserveNavigationTreeShowPopupAction { this.tree = tree; JMenuItem noActionComponent = null; - // trip menus - JMenuItem moveComponent = null; - JMenuItem openActionComponent = null; - JMenuItem closeActionComponent = null; - JMenuItem deleteActionComponent = null; +// JMenuItem moveComponent = null; +// JMenuItem openActionComponent = null; +// JMenuItem closeActionComponent = null; +// JMenuItem deleteActionComponent = null; for (MenuElement menuElement : popup.getSubElements()) { if (menuElement.getComponent().getName().equals("navigationNoAction")) { noActionComponent = (JMenuItem) menuElement.getComponent(); } - if (menuElement.getComponent().getName().equals("navigationMoveAction")) { - moveComponent = (JMenuItem) menuElement.getComponent(); - } - if (menuElement.getComponent().getName().equals("navigationOpenAction")) { - openActionComponent = (JMenuItem) menuElement.getComponent(); - } - if (menuElement.getComponent().getName().equals("navigationCloseAction")) { - closeActionComponent = (JMenuItem) menuElement.getComponent(); - } - if (menuElement.getComponent().getName().equals("navigationDeleteAction")) { - deleteActionComponent = (JMenuItem) menuElement.getComponent(); - } +// if (menuElement.getComponent().getName().equals("navigationMoveAction")) { +// moveComponent = (JMenuItem) menuElement.getComponent(); +// } +// if (menuElement.getComponent().getName().equals("navigationOpenAction")) { +// openActionComponent = (JMenuItem) menuElement.getComponent(); +// } +// if (menuElement.getComponent().getName().equals("navigationCloseAction")) { +// closeActionComponent = (JMenuItem) menuElement.getComponent(); +// } +// if (menuElement.getComponent().getName().equals("navigationDeleteAction")) { +// deleteActionComponent = (JMenuItem) menuElement.getComponent(); +// } } this.noAction = noActionComponent; - this.openAction = openActionComponent; - this.closeAction = closeActionComponent; - this.moveAction = moveComponent; - this.deleteAction = deleteActionComponent; +// this.openAction = openActionComponent; +// this.closeAction = closeActionComponent; +// this.moveAction = moveComponent; +// this.deleteAction = deleteActionComponent; KeyAdapter keyAdapter = new KeyAdapter() { @Override @@ -146,124 +140,115 @@ public class ObserveNavigationTreeShowPopupAction { pane.addMouseListener(mouseAdapter); } + @NotNull + private static String removeKeyStroke(String text) { + int lastIndex = text.lastIndexOf('('); + if (lastIndex > -1) { + text = text.substring(0, lastIndex - 1).trim(); + } + return text; + } + private void autoSelectNodeInTree(MouseEvent e) { + boolean rightClick = SwingUtilities.isRightMouseButton(e); + if (rightClick) { + // get the coordinates of the mouse click Point p = e.getPoint(); + int closestRowForLocation = tree.getClosestRowForLocation(e.getX(), e.getY()); + int rowToSelect = -1; + if (isRowSelected(closestRowForLocation)) { + rowToSelect = closestRowForLocation; } + if (rowToSelect == -1) { + // try to change selection + TreePath pathForRow = tree.getPathForRow(closestRowForLocation); tree.setSelectionPath(pathForRow); + if (isRowSelected(closestRowForLocation)) { + rowToSelect = closestRowForLocation; } + } + if (rowToSelect != -1) { + showPopup(rowToSelect, p); + } + } } private void openNodeMenu(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU && !tree.isSelectionEmpty()) { + // get the lowest selected row int lowestRow = getLowestSelectedRowCount(); + // get the selected column Rectangle r = tree.getRowBounds(lowestRow); + // get the point in the middle lower of the cell Point p = new Point(r.x + r.width / 2, r.y + r.height); - log.debug("Row " + lowestRow + " found t point [" + p + "]"); + + if (log.isDebugEnabled()) { + log.debug("Row " + lowestRow + " found t point [" + p + "]"); + } + showPopup(lowestRow, p); + } } private void showPopup(int row, Point p) { + log.info("Will show popup from row: " + row); + NavigationTreeNodeSupport selectedNode = (NavigationTreeNodeSupport) tree.getPathForRow(row).getLastPathComponent(); + log.info("Found selected node: " + selectedNode); - beforeOpenPopup(selectedNode); - popup.show(tree, p.x, p.y); + + SwingUtilities.invokeLater(() -> { + beforeOpenPopup(selectedNode); + popup.show(tree, p.x, p.y); + }); + } - //FIXME private void beforeOpenPopup(NavigationTreeNodeSupport selectedNode) { + + // clean popup popup.removeAll(); + popup.setLabel(selectedNode.getText()); ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); -// ClientDataContext dataContext = applicationContext.getDataContext(); ContentUI<?, ?> selectedContentUI = applicationContext.getContentUIManager().getSelectedContentUI(); - ObserveNavigationNode<?> selectedNodeId = selectedContentUI.getHandler().getSelectedNode(); - String selectedId = selectedNodeId.getId(); - ObserveNavigationNode<?> editNode = selectedContentUI.getHandler().getEditNode(); -// ObserveOpenDataManager openDataManager = applicationContext.getOpenDataManager(); - boolean closeActionEnabled = false; - if (selectedContentUI instanceof ContentOpenableUI) { - JButton closeButton = ((ContentOpenableUI) selectedContentUI).getClose(); - closeActionEnabled = closeButton.isEnabled(); + List<AbstractButton> actions = selectedContentUI.getNavigationPopupActions(); + if (actions.isEmpty()) { + popup.add(noAction); + } else { + Map<String, AbstractButton> actionMap = new TreeMap<>(); + actions.forEach(a -> actionMap.put(getActionText(a), a)); + actionMap.forEach(this::addAction); } -// Class dataType = selectedNode.getDataType(); -// if (TripSeineReference.class.equals(dataType)) { -// beforeOpenMenu((ReferenceNavigationTreeNodeSupport) selectedNode, TRIP_SEINE_MENU_ITEMS); -// openAction.setEnabled(editNode.isDisabled()); -// closeAction.setEnabled(closeActionEnabled); -// } else if (TripLonglineReference.class.equals(dataType)) { -// beforeOpenMenu((ReferenceNavigationTreeNodeSupport) selectedNode, TRIP_LONGLINE_MENU_ITEMS); -// openAction.setEnabled(editNode.isDisabled()); -// closeAction.setEnabled(closeActionEnabled); -// } else if (RouteReference.class.equals(dataType)) { -// beforeOpenMenu((ReferenceNavigationTreeNodeSupport) selectedNode, ROUTE_MENU_ITEMS); -// openAction.setEnabled(openDataManager.canOpenRoute(dataContext.getSelectedTripSeineId())); -// closeAction.setEnabled(closeActionEnabled); -// } else if (ActivitySeineReference.class.equals(dataType)) { -// beforeOpenMenu((ReferenceNavigationTreeNodeSupport) selectedNode, ACTIVITY_SEINE_MENU_ITEMS); -// openAction.setEnabled(openDataManager.canOpenActivitySeine(dataContext.getSelectedRouteId())); -// closeAction.setEnabled(closeActionEnabled); -// } else if (ActivityLonglineObsReference.class.equals(dataType)) { -// beforeOpenMenu((ReferenceNavigationTreeNodeSupport) selectedNode, ACTIVITY_LONGLINE_MENU_ITEMS); -// openAction.setEnabled(openDataManager.canOpenActivityLonglineObs(dataContext.getSelectedTripLonglineId())); -// closeAction.setEnabled(closeActionEnabled); -// } else if (ActivityLonglineLogbookReference.class.equals(dataType)) { -// beforeOpenMenu((ReferenceNavigationTreeNodeSupport) selectedNode, ACTIVITY_LONGLINE_MENU_ITEMS); -// openAction.setEnabled(openDataManager.canOpenActivityLonglineLogbook(dataContext.getSelectedTripLonglineId())); -// closeAction.setEnabled(closeActionEnabled); -// } else { -// popup.add(noAction); -// } } - private void beforeOpenMenu(ReferenceNavigationTreeNodeSupport selectedNode, String nodeType) { - log.info("Will load popup for " + nodeType + " node."); - ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); - if (selectedNode.isOpen()) { - closeAction.putClientProperty("ui", applicationContext.getContentUIManager().getSelectedContentUI()); - popup.add(closeAction); - } else { - openAction.putClientProperty("ui", applicationContext.getContentUIManager().getSelectedContentUI()); - popup.add(openAction); - } - Class dataType = selectedNode.getDataType(); - if (TripSeineReference.class.equals(dataType)) { - moveAction.setAction(new MoveTripSeineUIAction(applicationContext.getMainUI())); - } else if (TripLonglineReference.class.equals(dataType)) { - moveAction.setAction(new MoveTripLonglineUIAction(applicationContext.getMainUI())); - } else if (RouteReference.class.equals(dataType)) { - moveAction.setAction(new MoveRouteUIAction(applicationContext.getMainUI())); - } else if (ActivitySeineReference.class.equals(dataType)) { - moveAction.setAction(new MoveActivitySeineUIAction(applicationContext.getMainUI())); - } else if (ActivityLonglineObsReference.class.equals(dataType)) { - moveAction.setAction(new MoveActivityLonglineObsUIAction(applicationContext.getMainUI())); - } else if (ActivityLonglineLogbookReference.class.equals(dataType)) { - moveAction.setAction(new MoveActivityLonglineLogbookUIAction(applicationContext.getMainUI())); - } - popup.add(moveAction); - deleteAction.putClientProperty("ui", applicationContext.getContentUIManager().getSelectedContentUI()); - deleteAction.setEnabled(selectedNode.isOpen()); - popup.add(deleteAction); + private void addAction(String text, AbstractButton abstractButton) { + JMenuItem menuItem = new JMenuItem(); + MenuAction menuAction = new MenuAction(abstractButton, text, popup.getComponentCount()); + menuItem.setAction(menuAction); + popup.add(menuItem); } private boolean isRowSelected(int requiredRow) { @@ -272,6 +257,7 @@ public class ObserveNavigationTreeShowPopupAction { if (selectedRows != null) { for (int selectedRow : selectedRows) { if (requiredRow == selectedRow) { + // match result = true; break; @@ -293,4 +279,41 @@ public class ObserveNavigationTreeShowPopupAction { return lowestRow; } + private String getActionText(AbstractButton abstractButton) { + String text = abstractButton.getText(); + if (text == null || text.equals(abstractButton.getName())) { + text = abstractButton.getToolTipText(); + } + Objects.requireNonNull(text, "Button with no text, nor tip, kind of strange, don't you think?"); + return text; + } + + private static class MenuAction extends AbstractAction { + + private final Action action; + + MenuAction(AbstractButton abstractButton, String text, int pos) { + super(removeKeyStroke(text), abstractButton.getIcon()); + int a = 'A' + pos; + KeyStroke keyStroke = KeyStroke.getKeyStroke("ctrl pressed " + (char) a); + putValue(ACCELERATOR_KEY, keyStroke); + String toolTipText = abstractButton.getToolTipText(); + if (toolTipText != null) { + toolTipText = removeKeyStroke(toolTipText); + toolTipText = ObserveKeyStrokes.suffixTextWithKeyStroke(toolTipText, keyStroke); + putValue(SHORT_DESCRIPTION, toolTipText); + } + this.action = new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + abstractButton.doClick(); + } + }; + } + + @Override + public void actionPerformed(ActionEvent e) { + action.actionPerformed(e); + } + } } ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-create-error-validation.xml ===================================== @@ -179,7 +179,7 @@ <field-validator type="quadrantDto" short-circuit="true"> <param name="ocean">currentTripSeine.ocean</param> <message> - observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.libelle} + observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.label} </message> </field-validator> ===================================== validation/src/main/resources/fr/ird/observe/dto/data/seine/ActivitySeineDto-update-error-validation.xml ===================================== @@ -37,7 +37,7 @@ <field-validator type="quadrantDto" short-circuit="true"> <param name="ocean">currentTripSeine.ocean</param> <message> - observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.libelle} + observe.validation.activity.invalid.quadrant##${currentTripSeine.ocean.label} </message> </field-validator> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/3071f6df9ed75c7aa631dc9efd… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/3071f6df9ed75c7aa631dc9efd… You're receiving this email because of your account on gitlab.com.
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • ...
  • 15
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.