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

July 2018

  • 1 participants
  • 80 discussions
[Git][ultreiaio/ird-observe][develop-7.x] Gestion de référentiel avancé - tests - Closes #1033
by Tony CHEMIT 15 Jul '18

15 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 684fbeab by Tony CHEMIT at 2018-07-15T15:42:05Z Gestion de référentiel avancé - tests - Closes #1033 - - - - - 1 changed file: - pom.xml Changes: ===================================== pom.xml ===================================== @@ -152,7 +152,7 @@ <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format> <buildDate>${maven.build.timestamp}</buildDate> - <observeToolkitVersion>3.7.2</observeToolkitVersion> + <observeToolkitVersion>3.7.3</observeToolkitVersion> <!--<lib.version.java4all.jaxx>3.0-alpha-31</lib.version.java4all.jaxx>--> <!--<lib.version.nuiton.topia>3.4.2-SNAPSHOT</lib.version.nuiton.topia>--> <lib.version.nuiton.validation>3.1</lib.version.nuiton.validation> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/684fbeab7ad436d782154157ef5… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/684fbeab7ad436d782154157ef5… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] update toolkit
by Tony CHEMIT 13 Jul '18

13 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 900c2b19 by Tony CHEMIT at 2018-07-13T19:45:24Z update toolkit - - - - - 1 changed file: - pom.xml Changes: ===================================== pom.xml ===================================== @@ -152,7 +152,7 @@ <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format> <buildDate>${maven.build.timestamp}</buildDate> - <observeToolkitVersion>3.7.2</observeToolkitVersion> + <observeToolkitVersion>3.7.3</observeToolkitVersion> <!--<lib.version.java4all.jaxx>3.0-alpha-31</lib.version.java4all.jaxx>--> <!--<lib.version.nuiton.topia>3.4.2-SNAPSHOT</lib.version.nuiton.topia>--> <lib.version.nuiton.validation>3.1</lib.version.nuiton.validation> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/900c2b19ebb881656192a34f4b4… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/900c2b19ebb881656192a34f4b4… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Fix source layout
by Tony CHEMIT 13 Jul '18

13 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: d507ff45 by Tony CHEMIT at 2018-07-13T13:01:00Z Fix source layout - - - - - 2 changed files: - client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthLengthParameterUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthWeightParameterUI.jaxx Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthLengthParameterUI.jaxx ===================================== @@ -161,16 +161,16 @@ <!-- source --> <row> - <cell columns="2"> + <cell columns="2" weighty="1"> <BigTextEditor id="sourceField"/> </cell> </row> - <row> - <cell columns="2" weighty="1"> - <JLabel styleClass="skipI18n"/> - </cell> - </row> + <!--<row>--> + <!--<cell columns="2" weighty="1">--> + <!--<JLabel styleClass="skipI18n"/>--> + <!--</cell>--> + <!--</row>--> </Table> </tab> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthWeightParameterUI.jaxx ===================================== @@ -157,14 +157,6 @@ public void decorateUniqueKeyTable(JTable table, TableCellRenderer renderer, JSc onItemStateChanged='getBean().setStatus((ReferenceStatus)status.getSelectedItem())'/> </cell> </row> - - <!-- source --> - <row> - <cell columns="2"> - <BigTextEditor id="sourceField"/> - </cell> - </row> - <!-- needComment --> <row> <cell anchor='east' weightx="1" fill="both" columns="2"> @@ -172,11 +164,19 @@ public void decorateUniqueKeyTable(JTable table, TableCellRenderer renderer, JSc </cell> </row> + <!-- source --> <row> <cell columns="2" weighty="1"> - <JLabel styleClass="skipI18n"/> + <BigTextEditor id="sourceField"/> </cell> </row> + + + <!--<row>--> + <!--<cell columns="2" weighty="1">--> + <!--<JLabel styleClass="skipI18n"/>--> + <!--</cell>--> + <!--</row>--> </Table> </tab> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/d507ff45e5a30a3f3c76ccc084d… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/d507ff45e5a30a3f3c76ccc084d… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Fix source layout
by Tony CHEMIT 13 Jul '18

13 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 7640642c by Tony CHEMIT at 2018-07-13T13:00:43Z Fix source layout - - - - - 3 changed files: - client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthLengthParameterUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthWeightParameterUI.jaxx - pom.xml Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthLengthParameterUI.jaxx ===================================== @@ -161,16 +161,16 @@ <!-- source --> <row> - <cell columns="2"> + <cell columns="2" weighty="1"> <BigTextEditor id="sourceField"/> </cell> </row> - <row> - <cell columns="2" weighty="1"> - <JLabel styleClass="skipI18n"/> - </cell> - </row> + <!--<row>--> + <!--<cell columns="2" weighty="1">--> + <!--<JLabel styleClass="skipI18n"/>--> + <!--</cell>--> + <!--</row>--> </Table> </tab> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/common/LengthWeightParameterUI.jaxx ===================================== @@ -157,14 +157,6 @@ public void decorateUniqueKeyTable(JTable table, TableCellRenderer renderer, JSc onItemStateChanged='getBean().setStatus((ReferenceStatus)status.getSelectedItem())'/> </cell> </row> - - <!-- source --> - <row> - <cell columns="2"> - <BigTextEditor id="sourceField"/> - </cell> - </row> - <!-- needComment --> <row> <cell anchor='east' weightx="1" fill="both" columns="2"> @@ -172,11 +164,19 @@ public void decorateUniqueKeyTable(JTable table, TableCellRenderer renderer, JSc </cell> </row> + <!-- source --> <row> <cell columns="2" weighty="1"> - <JLabel styleClass="skipI18n"/> + <BigTextEditor id="sourceField"/> </cell> </row> + + + <!--<row>--> + <!--<cell columns="2" weighty="1">--> + <!--<JLabel styleClass="skipI18n"/>--> + <!--</cell>--> + <!--</row>--> </Table> </tab> ===================================== pom.xml ===================================== @@ -152,7 +152,7 @@ <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format> <buildDate>${maven.build.timestamp}</buildDate> - <observeToolkitVersion>3.7.2</observeToolkitVersion> + <observeToolkitVersion>3.7.3-SNAPSHOT</observeToolkitVersion> <!--<lib.version.java4all.jaxx>3.0-alpha-31</lib.version.java4all.jaxx>--> <!--<lib.version.nuiton.topia>3.4.2-SNAPSHOT</lib.version.nuiton.topia>--> <lib.version.nuiton.validation>3.1</lib.version.nuiton.validation> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/7640642c1c41b0f2b02e826aa54… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/7640642c1c41b0f2b02e826aa54… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] use last pom
by Tony CHEMIT 13 Jul '18

13 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 836a867f by Tony CHEMIT at 2018-07-13T10:19:44Z use last pom - - - - - 1 changed file: - pom.xml Changes: ===================================== pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2018.40</version> + <version>2018.41</version> </parent> <groupId>fr.ird.observe</groupId> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/836a867f8155883882d6cf34eef… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/836a867f8155883882d6cf34eef… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Création automatique de l'activité de fin de veille non fonctionnelle - Closes #996
by Tony CHEMIT 13 Jul '18

13 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 54c95a00 by Tony CHEMIT at 2018-07-13T09:29:41Z Création automatique de l&#39;activité de fin de veille non fonctionnelle - Closes #996 - - - - - 5 changed files: - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTree.java - client/src/main/resources/i18n/client_en_GB.properties - client/src/main/resources/i18n/client_es_ES.properties - client/src/main/resources/i18n/client_fr_FR.properties Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/RouteUIHandler.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% @@ -33,7 +33,6 @@ import fr.ird.observe.dto.data.seine.ActivitySeineDto; import fr.ird.observe.dto.data.seine.RouteDto; import fr.ird.observe.dto.data.seine.RouteHelper; import fr.ird.observe.dto.data.seine.TripSeineDto; -import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper; import fr.ird.observe.dto.form.Form; import fr.ird.observe.dto.referential.seine.VesselActivitySeineHelper; import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference; @@ -46,7 +45,6 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JOptionPane; import java.util.Date; -import java.util.Objects; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -88,8 +86,8 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme if (!dataContext.isSelectedOpen(TripSeineDto.class)) { addMessage(ui, NuitonValidatorScope.INFO, - getTypeI18nKey(TripSeineDto.class), - t("observe.common.TripSeineDto.message.not.open")); + getTypeI18nKey(TripSeineDto.class), + t("observe.common.TripSeineDto.message.not.open")); } else { @@ -157,14 +155,14 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme if (create) { addMessage(ui, - NuitonValidatorScope.INFO, - getTypeI18nKey(RouteDto.class), - t("observe.common.RouteDto.message.creating")); + NuitonValidatorScope.INFO, + getTypeI18nKey(RouteDto.class), + t("observe.common.RouteDto.message.creating")); } else { addMessage(ui, - NuitonValidatorScope.INFO, - getTypeI18nKey(RouteDto.class), - t("observe.common.RouteDto.message.updating")); + NuitonValidatorScope.INFO, + getTypeI18nKey(RouteDto.class), + t("observe.common.RouteDto.message.updating")); if (getModel().isHistoricalData()) { @@ -173,11 +171,11 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme } super.startEditUI(RouteUI.BINDING_DATE_DATE, - RouteUI.BINDING_START_LOG_VALUE_NUMBER_VALUE, - RouteUI.BINDING_END_LOG_VALUE_ENABLED, - RouteUI.BINDING_COMMENT_MODEL, - RouteUI.BINDING_CLOSE_ENABLED, - RouteUI.BINDING_CLOSE_AND_CREATE_ENABLED); + RouteUI.BINDING_START_LOG_VALUE_NUMBER_VALUE, + RouteUI.BINDING_END_LOG_VALUE_ENABLED, + RouteUI.BINDING_COMMENT_MODEL, + RouteUI.BINDING_CLOSE_ENABLED, + RouteUI.BINDING_CLOSE_AND_CREATE_ENABLED); // le formulaire est en état modifié uniquement si on est en création getModel().setModified(create); @@ -270,17 +268,11 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme RouteDto route = getBean(); - // on doit vérifier qu'il existe une activité de fin - // de veille (type activity vessel == 16) + // on doit vérifier qu'il existe une activité de fin de veille (type activity vessel == 16) - boolean mustAddFinVeille = !route.isActivityFindDeVeilleFound(); + boolean mustAddFinVeille = !route.isActivitySeineEmpty() && !route.isActivityFindDeVeilleFound(); boolean createActivityFinDeVeille = false; - boolean closeActivityFinDeVeille = false; - boolean gotoActivityFinDeVeille = false; - - NavigationTree treeHelper = getNavigationTree(); - NavigationTreeNodeSupport routeNode = treeHelper.getSelectedNode(); if (mustAddFinVeille) { @@ -292,11 +284,12 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme t("observe.common.RouteDto.message.need.fin.veille.activity"), JOptionPane.WARNING_MESSAGE, new Object[]{ - t("observe.common.RouteDto.choice.not.create.fin.veille.activity.and.continue"), - t("observe.common.RouteDto.choice.create.fin.veille.activity.and.continue"), + t("observe.choice.cancel"), t("observe.common.RouteDto.choice.create.fin.veille.activity"), - t("observe.choice.cancel")}, - 0); + t("observe.common.RouteDto.choice.not.create.fin.veille.activity.and.continue"), + + }, + 2); if (log.isDebugEnabled()) { log.debug("response : " + reponse); } @@ -304,11 +297,11 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme switch (reponse) { case JOptionPane.CLOSED_OPTION: - case 3: + case 0: - // abandon objectOperation + // abandon operation return false; - case 0: + case 2: // rien a faire // on veut juste cloturer la route @@ -319,15 +312,7 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme // fermeture de l'activity de fin de veille // fermeture de la route createActivityFinDeVeille = true; - closeActivityFinDeVeille = true; - - break; - case 2: - // creation de l'activity de fin de veille - // selection de cette activity de fin de veille - createActivityFinDeVeille = true; - gotoActivityFinDeVeille = true; break; } } @@ -338,18 +323,11 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme stopEditUI(); // creation de l'action de fin de veille - addActivityFinDeVeille(closeActivityFinDeVeille); - - if (gotoActivityFinDeVeille) { + addActivityFinDeVeille(); - // on selection l'activity de fin de veille et on y reste - // donc on ne continue pas la fermeture de la route - return false; - } - - // on retourne sur la route - // que l'on va refermer - treeHelper.selectNode(routeNode); + // on selection l'activity de fin de veille et on y reste + // donc on ne continue pas la fermeture de la route + return false; } // fermeture de la route @@ -357,16 +335,18 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme return true; } - private ActivitySeineUI addActivityFinDeVeille(boolean close) { + private ActivitySeineUI addActivityFinDeVeille() { NavigationTree treeHelper = getNavigationTree(); // on créee l'activity de fin de veille NavigationTreeNodeSupport<?> parentNode = treeHelper.getSelectedNode().findChildByClass(ActivitySeineDto.class); log.debug("PARENT NODE = " + parentNode); - treeHelper.addUnsavedNode(Objects.requireNonNull(parentNode), ActivitySeineDto.class); - NavigationTreeNodeSupport activityNode = treeHelper.getSelectedNode(); - Objects.requireNonNull(activityNode); + // 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.addUnsavedNode(parentNode, ActivitySeineDto.class); + // on recupère l'écran d'édition ActivitySeineUI selectedUI = (ActivitySeineUI) ObserveSwingApplicationContext.get().getContentUIManager().getSelectedContentUI(); @@ -387,17 +367,6 @@ class RouteUIHandler extends ContentOpenableUIHandler<RouteDto, RouteUI> impleme // on initialise la fin de veille a la dernière minute du jour selectedUI.getBean().setTime(DateUtil.getEndOfDay(DateUtil.createDate(0, 0, 0))); - if (close) { - - // on sauvegarde l'activité - selectedUI.save(false); - - // on ferme l'activité - selectedUI.closeData(); - - // on ferme l'écran - selectedUI.stopEdit(); - } return selectedUI; } ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTree.java ===================================== @@ -98,7 +98,7 @@ public class NavigationTree extends JXTree { setSelectionModel(new DefaultTreeSelectionModel() { @Override public void setSelectionPath(TreePath path) { - boolean canChange = adjusting || (!Objects.equals(path, getSelectionPath()) && ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI()); + boolean canChange = !Objects.equals(path, getSelectionPath()) && ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI(); if (!canChange) { // cancel the change of node return; @@ -401,8 +401,6 @@ public class NavigationTree extends JXTree { reloadNode(node, refreshChilds); } - private boolean adjusting; - public NavigationTreeNodeSupport addUnsavedNode(NavigationTreeNodeSupport parentNode, Class<?> type) { // noeud en mode creation @@ -435,13 +433,8 @@ public class NavigationTree extends JXTree { // Fix bug (if no child in parent node, it will not expand...) fireTreeExpanded(new TreePath(result.getPath())); - adjusting=true; - try { - // Select new node - selectNode(result); - } finally { - adjusting=false; - } + // Select new node + selectNode(result); return result; } ===================================== client/src/main/resources/i18n/client_en_GB.properties ===================================== @@ -844,13 +844,12 @@ observe.common.RouteDto.action.reopen.tip=Reopen route observe.common.RouteDto.action.reopenSelected=Reopen route observe.common.RouteDto.action.reopenSelected.tip=Reopen route observe.common.RouteDto.choice.create.fin.veille.activity=Create end activity -observe.common.RouteDto.choice.create.fin.veille.activity.and.continue=Create end watch activity and continue observe.common.RouteDto.choice.not.create.fin.veille.activity.and.continue=do not create end watch activity and continue observe.common.RouteDto.list=List of routes observe.common.RouteDto.message.active.found=A route was found. observe.common.RouteDto.message.active.found.for.other.trip=An open route exists in another trip. observe.common.RouteDto.message.creating=Route is in creation -observe.common.RouteDto.message.need.fin.veille.activity=No end watch activity was found in route to close.\nyou can\:\n\n\t- Cancel and go back to route\n\t- Create and go the end watch activity\n\t- Create end watch activity and close route\n\t- Close route without creating the end watch activity. +observe.common.RouteDto.message.need.fin.veille.activity=No end watch activity was found in route to close.\nyou can\:\n\n\t- Close route without creating the end watch activity\n\t- Create and go the end watch activity\n\t- Cancel and go back to route observe.common.RouteDto.message.no.active.found=No open route found, you can create a new one or reopen one. observe.common.RouteDto.message.no.active.found.for.other.trip=No open route found on open trip observe.common.RouteDto.message.not.open=Current route is not open, no modification is possible. ===================================== client/src/main/resources/i18n/client_es_ES.properties ===================================== @@ -844,13 +844,12 @@ observe.common.RouteDto.action.reopen.tip=Reabrir la ruta observe.common.RouteDto.action.reopenSelected=Reabrir la ruta observe.common.RouteDto.action.reopenSelected.tip=Reabrir la ruta seleccionada observe.common.RouteDto.choice.create.fin.veille.activity=Crear la actividad de fin de guardia -observe.common.RouteDto.choice.create.fin.veille.activity.and.continue=Crear la actividad de fin de guardia y continuar observe.common.RouteDto.choice.not.create.fin.veille.activity.and.continue=No crear la actividad de fin de guardia y continuar observe.common.RouteDto.list=Lista de rutas observe.common.RouteDto.message.active.found=Ruta abierta. observe.common.RouteDto.message.active.found.for.other.trip=Existe una ruta abierta en otra marea. observe.common.RouteDto.message.creating=Ruta en proceso de creación. -observe.common.RouteDto.message.need.fin.veille.activity=Ninguna actividad de fin de guardia registrada en la ruta a cerrar.\n Puede \:\n\n\t- Cancelar el cierre y continuar con la ruta\n\t- Crear la actividad de fin de guardia e ir a ella.\n\t- Crear la actividad de fin de guardia y a continuación cerra la ruta\n\t- Continuar con el cierra de la ruta sin crear la actividad de fin de guardia. +observe.common.RouteDto.message.need.fin.veille.activity=Ninguna actividad de fin de guardia registrada en la ruta a cerrar.\n Puede \:\n\n\t- Continuar con el cierra de la ruta sin crear la actividad de fin de guardia\n\t- Crear la actividad de fin de guardia e ir a ella\n\t- Cancelar el cierre y continuar con la ruta observe.common.RouteDto.message.no.active.found=Ninguna ruta abierta, puede crear una nueva o reabrir una. observe.common.RouteDto.message.no.active.found.for.other.trip=Ninguna ruta abierta sobre la marea abierta observe.common.RouteDto.message.not.open=la ruta actual no está abierta, no se pueden hacer modificaciones. ===================================== client/src/main/resources/i18n/client_fr_FR.properties ===================================== @@ -844,13 +844,12 @@ observe.common.RouteDto.action.reopen.tip=Rouvrir la route observe.common.RouteDto.action.reopenSelected=Rouvrir la route observe.common.RouteDto.action.reopenSelected.tip=Rouvrir la route sélectionnée observe.common.RouteDto.choice.create.fin.veille.activity=Créer l'activité de fin de veille -observe.common.RouteDto.choice.create.fin.veille.activity.and.continue=Créer l'activité de fin de veille et continuer observe.common.RouteDto.choice.not.create.fin.veille.activity.and.continue=Ne pas créer l'activité de fin de veille et continuer observe.common.RouteDto.list=Liste des routes observe.common.RouteDto.message.active.found=Une route est ouverte. observe.common.RouteDto.message.active.found.for.other.trip=Une route ouverte existe dans une autre marée. observe.common.RouteDto.message.creating=La route est en cours de création. -observe.common.RouteDto.message.need.fin.veille.activity=Aucune activité de fin de veille enregistrée sur la route à clôturer.\nVous pouvez \:\n\n\t- Annuler la fermeture et rester sur la route\n\t- Créer l'activité de fin de veille et vous y rendre\n\t- Créer l'activité de fin de veille, la clôturer puis clôturer la route\n\t- Continuer la clôture de la route sans créer cette activité de fin de veille. +observe.common.RouteDto.message.need.fin.veille.activity=Aucune activité de fin de veille enregistrée sur la route à clôturer.\nVous pouvez \:\n\n\t- Continuer la clôture de la route sans créer cette activité de fin de veille\n\t- Créer l'activité de fin de veille et vous y rendre\n\t- Annuler la fermeture et rester sur la route observe.common.RouteDto.message.no.active.found=Aucune route ouverte, vous pouvez soit en créer une nouvelle, soit en réouvrir une. observe.common.RouteDto.message.no.active.found.for.other.trip=Aucune route ouverte sur la marée ouverte observe.common.RouteDto.message.not.open=La route courante n'est pas ouverte, aucune modification possible. View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/54c95a00f9b14f06a0ef98f0099… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/54c95a00f9b14f06a0ef98f0099… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Improve FOB Form - Closes #948
by Tony CHEMIT 12 Jul '18

12 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: ef780559 by Tony CHEMIT at 2018-07-12T16:20:27Z Improve FOB Form - Closes #948 - - - - - 9 changed files: - client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jcss - 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/FloatingObjectUIModel.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java - + client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTable.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java - dto/src/main/java/fr/ird/observe/dto/data/seine/ObjectMaterialHierarchyDto.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java ===================================== @@ -111,6 +111,8 @@ public abstract class ObserveKeyStrokes { public static final KeyStroke KEY_STROKE_QUIT = KeyStroke.getKeyStroke("ctrl pressed Q"); public static final KeyStroke KEY_STROKE_DELETE = KeyStroke.getKeyStroke("ctrl pressed U"); + public static final KeyStroke KEY_STROKE_EXPAND_TREE_TABLE_NODE = KeyStroke.getKeyStroke("ctrl released RIGHT"); + public static final KeyStroke KEY_STROKE_COLLAPSE_TREE_TABLE_NODE = KeyStroke.getKeyStroke("ctrl released LEFT"); private static final ImmutableList<KeyStroke> KEY_STROKE_GO_TABS = ImmutableList.of( KEY_STROKE_GO_TAB_1, ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jaxx ===================================== @@ -39,6 +39,7 @@ fr.ird.observe.client.ui.actions.main.global.DeleteDataGlobalUIAction fr.ird.observe.client.ui.actions.main.global.ResetDataGlobalUIAction fr.ird.observe.client.ui.actions.main.global.SaveDataGlobalUIAction + fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTable fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTableModel fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartLegendTreeCellRenderer fr.ird.observe.client.ui.util.JComment @@ -175,7 +176,7 @@ <row> <cell anchor="north" weightx="1" weighty="1"> <JScrollPane id='tableScroll'> - <JXTreeTable id='table'/> + <FloatingObjectPartsTreeTable id='table' constructorParams="new FloatingObjectPartsTreeTableModel(getModel())"/> </JScrollPane> </cell> </row> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jcss ===================================== @@ -140,9 +140,3 @@ BeanComboBox { focusable:false; } -#table { - treeTableModel:{new FloatingObjectPartsTreeTableModel(getModel())}; - treeCellRenderer:{new FloatingObjectPartLegendTreeCellRenderer()}; - selectionMode:{ListSelectionModel.SINGLE_SELECTION}; - rootVisible:false; -} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java ===================================== @@ -29,9 +29,6 @@ import fr.ird.observe.client.db.constants.DataContextType; import fr.ird.observe.client.ui.content.ContentMode; import fr.ird.observe.client.ui.content.ContentUIHandler; import fr.ird.observe.client.ui.content.ContentUIModel; -import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTableCellEditor; -import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTableCellRenderer; -import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeNode; import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTableModel; import fr.ird.observe.client.ui.tree.navigation.NavigationTree; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; @@ -53,12 +50,6 @@ import fr.ird.observe.services.service.actions.consolidate.dcp.ConsolidateFloati import fr.ird.observe.spi.DtoModelHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.lf5.viewer.categoryexplorer.TreeModelAdapter; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.JXTreeTable; -import org.jdesktop.swingx.decorator.ColorHighlighter; -import org.jdesktop.swingx.table.ColumnFactory; -import org.jdesktop.swingx.table.TableColumnExt; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.runtime.swing.SwingUtil; import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; @@ -68,8 +59,6 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.Icon; import javax.swing.SwingUtilities; import javax.swing.event.TableModelListener; -import javax.swing.event.TreeModelEvent; -import java.awt.Color; import java.util.HashSet; import java.util.Map; import java.util.Objects; @@ -182,17 +171,18 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, } loadReferentialReferenceSetsInModel(form); - getModel().setForm(form); + FloatingObjectUIModel model = getModel(); + model.setForm(form); FloatingObjectHelper.copyFloatingObjectDto(form.getObject(), bean); - getModel().reset(); + model.reset(); - openTable(partsSet, getUi().getTable(), bean.isPersisted()); + getUi().getTable().openTable(model, partsSet, bean.isPersisted()); setContentMode(mode); // do this after setting mode (since only update mode use this...) - getModel().setReference(floatingObjectReference.orElse(null)); + model.setReference(floatingObjectReference.orElse(null)); if (mode != ContentMode.READ) { getUi().startEdit(null); @@ -203,31 +193,15 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, @Override protected void openedUI() { - SwingUtilities.invokeLater(this::forceGrabFocusOnForm); } - private void openTable(Set<FloatingObjectPartReference> partsSet, JXTreeTable table, boolean persisted) { - - FloatingObjectUIModel model = getModel(); - for (FloatingObjectPartReference p : partsSet) { - String objectMaterialId = p.getObjectMaterialId(); - String whenArriving = p.getWhenArriving(); - String whenLeaving = p.getWhenLeaving(); - if (whenArriving != null && !Objects.equals("false", whenArriving)) { - model.setWhenArriving(objectMaterialId, whenArriving); - } - if (whenLeaving != null && !Objects.equals("false", whenLeaving)) { - model.setWhenLeaving(objectMaterialId, whenLeaving); - } - } - - FloatingObjectPartsTreeTableModel treeTableModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel(); - treeTableModel.reset(); - - if (persisted) { - table.expandAll(); + @Override + public void stopEditUI() { + if (ui.getMainTabbedPane().getSelectedIndex() == 1) { + ui.getTable().editingCanceled(null); } + super.stopEditUI(); } @Override @@ -334,7 +308,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, FloatingObjectUIModel model = getModel(); model.setReferentialMap(allMap); - initTable(detailedForm, ui.getTable()); + ui.getTable().initTable(model, () -> getUi().getPreferredSize().width - 200, detailedForm); model.addPropertyChangeListener(FloatingObjectUIModel.PROPERTY_REFERENCE, e -> { if (!model.isUpdatingMode()) { @@ -386,60 +360,10 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, getModel().setArriving(operation.isWhenArriving()); getModel().setLeaving(operation.isWhenLeaving()); } - FloatingObjectPartsTreeTableModel treeModel = (FloatingObjectPartsTreeTableModel) getUi().getTable().getTreeTableModel(); + FloatingObjectPartsTreeTableModel treeModel = getUi().getTable().getTreeTableModel(); treeModel.reset(); } - private void initTable(ObjectMaterialHierarchyDto materials, JXTreeTable table) { - - FloatingObjectPartsTreeTableModel treeModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel(); - treeModel.rebuildRootNode(materials); - - table.setColumnFactory(new ColumnFactory() { - - @Override - public void configureColumnWidths(JXTable table, TableColumnExt columnExt) { - if (table.getColumn(0).equals(columnExt)) { - columnExt.setPreferredWidth(getUi().getPreferredSize().width - 200); - columnExt.setMinWidth(columnExt.getPreferredWidth()); - return; - } - super.configureColumnWidths(table, columnExt); - columnExt.setMinWidth(columnExt.getPreferredWidth()); - } - }); - treeModel.addTreeModelListener(new TreeModelAdapter() { - @Override - public void treeNodesChanged(TreeModelEvent e) { - if (treeModel.isAdjusting()) { - return; - } - getModel().setModified(true); - getModel().setPartsModified(); - } - - }); - - table.setDefaultRenderer(Object.class, new FloatingObjectPartsTableCellRenderer(table)); - table.setDefaultEditor(Object.class, new FloatingObjectPartsTableCellEditor(table)); - table.addHighlighter(new ColorHighlighter((renderer, adapter) -> { - JXTreeTable component = (JXTreeTable) adapter.getComponent(); - int row = adapter.convertRowIndexToModel(adapter.row); - FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) component.getPathForRow(row).getLastPathComponent(); - boolean valid1 = node.isValid(1); - boolean valid2 = node.isValid(2); - switch (adapter.convertRowIndexToModel(adapter.column)) { - case 0: - return false; - case 1: - return !valid1; - case 2: - return !valid2; - } - return true; - }, ObserveSwingApplicationContext.get().getConfig().getFloatingObjectMaterialErrorColor(), Color.WHITE)); - } - protected void computeTabValidState(SwingValidatorMessageTableModel errorTableModel) { Set<String> errorProperties = new HashSet<>(); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIModel.java ===================================== @@ -127,7 +127,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { return result.build(); } - void setPartsModified() { + public void setPartsModified() { firePropertyChange(PROPERTY_PARTS_MODIFIED, true); } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java ===================================== @@ -23,9 +23,10 @@ package fr.ird.observe.client.ui.content.data.seine.dcp; */ import com.google.common.collect.ImmutableSet; +import fr.ird.observe.client.ObserveSwingApplicationContext; import fr.ird.observe.client.ui.content.data.seine.FloatingObjectUIModel; import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto; -import fr.ird.observe.dto.referential.FormulaHelper; +import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeReference; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -60,13 +61,13 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im static FloatingObjectPartsTreeNode createRoot(FloatingObjectUIModel model, ObjectMaterialHierarchyDto dto) { FloatingObjectPartsTreeNode root; FloatingObjectPartsTreeNodeContext rootModel = new FloatingObjectPartsTreeNodeContext(model); - if (dto != null) { + if (dto == null) { + root = new FloatingObjectPartsTreeNode(rootModel); + } else { FloatingObjectPartsTreeNodeContext childModel = new FloatingObjectPartsTreeNodeContext(dto, rootModel); root = new FloatingObjectPartsTreeNode(childModel); root.computeCompanions(null); root.setCompanions(null); - } else { - root = new FloatingObjectPartsTreeNode(rootModel); } return root; } @@ -164,6 +165,8 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im getUserObject().text = null; getUserObject().validWhenArriving = true; getUserObject().validWhenLeaving = true; + getUserObject().needOneSelectionOnArriving = false; + getUserObject().needOneSelectionOnLeaving = false; } @Override @@ -171,83 +174,88 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im return (FloatingObjectPartsTreeNode) super.getParent(); } - void fillNodeSets(ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder, - ImmutableSet.Builder<FloatingObjectPartsTreeNode> needOneSelectionNodesBuilder, - ImmutableSet.Builder<FloatingObjectPartsTreeNode> mandatoryNodesBuilder) { + ImmutableSet<FloatingObjectPartsTreeNode> getShell() { - allNodesBuilder.add(this); - if (getUserObject().needOneSelection) { - needOneSelectionNodesBuilder.add(this); - } - if (getUserObject().mandatory) { - mandatoryNodesBuilder.add(this); - } + ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder = ImmutableSet.builder(); + getShell(allNodesBuilder); + return allNodesBuilder.build(); + } + private void getShell(ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder) { + allNodesBuilder.add(this); for (FloatingObjectPartsTreeNode child : this) { - child.fillNodeSets(allNodesBuilder, needOneSelectionNodesBuilder, mandatoryNodesBuilder); + child.getShell(allNodesBuilder); } + } + boolean withMandatoryConstraintsOnChildren() { + ObjectMaterialHierarchyDto userObject = getUserObject().dto; + return userObject == null || userObject.isChildSelectionMandatory(); } void computeNeedAtLeastOnSelectValidState(boolean whenArriving, boolean whenLeaving) { - + boolean needSelect = isEditable(); + FloatingObjectPartsTreeNodeContext userObject = getUserObject(); if (whenArriving) { - getUserObject().validWhenArriving = isAtLeastOneSelected(1); + userObject.needOneSelectionOnArriving = (!needSelect || withValue(1)) && isAtLeastOneSelected(1); } if (whenLeaving) { - getUserObject().validWhenLeaving = isAtLeastOneSelected(2); + userObject.needOneSelectionOnLeaving = (!needSelect || withValue(2)) && isAtLeastOneSelected(2); + } + if (userObject.needOneSelectionOnArriving || userObject.needOneSelectionOnLeaving) { + log.info("Validate node " + this); } - - log.info("Validate node " + this); } - void computeMandatoryValidState(boolean whenArriving, boolean whenLeaving) { - if (whenArriving) { - getUserObject().validWhenArriving = getParent().getUserObject().validWhenArriving; - } - if (whenLeaving) { - getUserObject().validWhenLeaving = getParent().getUserObject().validWhenLeaving; + private FloatingObjectPartsTreeNode getFirstAncestorNeedOneSelection(int column) { + if (withMandatoryConstraintsOnChildren()) { + if (parent == null) { + return this; + } + if (withValue(column)) { + return this; + } } - - log.info("Validate node " + this); + return getParent().getFirstAncestorNeedOneSelection(column); } - void computeFormulaValidState(boolean whenArriving, boolean whenLeaving) { - if (getUserObject().dto == null || getUserObject().dto.isBoolean()) { - return; - } - String validation = getUserObject().dto.getValidation(); - if (whenArriving && getUserObject().validWhenArriving) { - Object value = getUserObject().getValueAt(1); - if (value != null) { - if (getUserObject().dto.isText()) { - getUserObject().validWhenArriving = FormulaHelper.validateObjectMaterialValidation(validation, value); - } else if (getUserObject().dto.isInteger()) { - getUserObject().validWhenArriving = FormulaHelper.validateObjectMaterialValidation(validation, Integer.valueOf(value.toString())); - } else if (getUserObject().dto.isFloat()) { - getUserObject().validWhenArriving = FormulaHelper.validateObjectMaterialValidation(validation, Float.valueOf(value.toString())); - } + void computeMandatoryValidState(boolean whenArriving, boolean whenLeaving) { + FloatingObjectPartsTreeNodeContext userObject = getUserObject(); + FloatingObjectPartsTreeNode parent = getParent(); + if (whenArriving) { + if (parent != null && !parent.getUserObject().validWhenArriving) { + userObject.validWhenArriving = false; + } else { + userObject.validWhenArriving = getFirstAncestorNeedOneSelection(1).getUserObject().needOneSelectionOnArriving; } } - if (whenLeaving && getUserObject().validWhenLeaving) { - Object value = getUserObject().getValueAt(2); - if (value != null) { - if (getUserObject().dto.isText()) { - getUserObject().validWhenLeaving = FormulaHelper.validateObjectMaterialValidation(validation, value); - } else if (getUserObject().dto.isInteger()) { - getUserObject().validWhenLeaving = FormulaHelper.validateObjectMaterialValidation(validation, Integer.valueOf(value.toString())); - } else if (getUserObject().dto.isFloat()) { - getUserObject().validWhenLeaving = FormulaHelper.validateObjectMaterialValidation(validation, Float.valueOf(value.toString())); - } + if (whenLeaving) { + if (parent != null && !parent.getUserObject().validWhenLeaving) { + userObject.validWhenLeaving = false; + } else { + userObject.validWhenLeaving = getFirstAncestorNeedOneSelection(2).getUserObject().needOneSelectionOnLeaving; } } + if (userObject.getValueAt(1) != null || userObject.getValueAt(2) != null) { + log.info("Validate node " + this); + } } - boolean withValidation() { - return getUserObject().dto != null && getUserObject().dto.withValidation(); - } +// void computeFormulaValidState(boolean whenArriving, boolean whenLeaving) { +// FloatingObjectPartsTreeNodeContext userObject = getUserObject(); +// ObjectMaterialHierarchyDto dto = Objects.requireNonNull(userObject.dto); +// if (whenArriving && userObject.validWhenArriving) { +// Object value = userObject.getValueAt(1); +// userObject.validWhenArriving = dto.isValid(value); +// } +// if (whenLeaving && userObject.validWhenLeaving) { +// Object value = userObject.getValueAt(2); +// userObject.validWhenLeaving = dto.isValid(value); +// } +// +// } private void setCompanions(ImmutableSet.Builder<FloatingObjectPartsTreeNode> companionsBuilder) { if (companionsBuilder != null) { @@ -258,12 +266,21 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im } } + private boolean withValue(int column) { + return getValueAt(column) != null; + } + + private boolean withValidValue(int column) { + return withValue(column) && (column == 1 ? getUserObject().valueValidOnArriving : getUserObject().valueValidOnLeaving); + } + private boolean isAtLeastOneSelected(int column) { - if (getValueAt(column) != null) { - return true; - } for (FloatingObjectPartsTreeNode child : this) { - if (child.isAtLeastOneSelected(column)) { + if (child.withValidValue(column)) { + return true; + } + boolean result = child.isAtLeastOneSelected(column); + if (result) { return true; } } @@ -288,6 +305,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf(); } + //TODO Improve the design, we should not store anything in uiModel and separate leaving and arriving data private static class FloatingObjectPartsTreeNodeContext { // main model to get and store values @@ -298,15 +316,22 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im private final boolean enabled; // Is this node editable ? private final boolean editable; - // Is this node need at least one child selected ? - private final boolean needOneSelection; - // Is this node in the path of at least one mandatory child ancestor ? - private final boolean mandatory; // Is the node is exclusive (means only one value possible for him and his brothers) ? private final boolean exclusive; - // Is the node valid for whenArriving column ? + // Is the node use validation on his value ? + private final boolean useValidation; + private final ReferentialLocale referentialLocale; + // Is this node (on arriving) need at least one child selected ? (if editable then node must be selected) + private boolean needOneSelectionOnLeaving; + // Is this node (on leaving) need at least one child selected ? (if editable then node must be selected) + private boolean needOneSelectionOnArriving; + // for a validation node (on arriving), is value valid (if no value then it is valid) + private boolean valueValidOnLeaving = true; + // for a validation node (on leaving), is value valid (if no value then it is valid) + private boolean valueValidOnArriving = true; + // Is the node valid (on arriving) column ? private boolean validWhenArriving = true; - // Is the node valid for whenLeaving column ? + // Is the node valid (on leeaving) column ? private boolean validWhenLeaving = true; // Set of brothers of this node that is in a exclusive group of node (only one value among all of them) private ImmutableSet<FloatingObjectPartsTreeNode> companions; @@ -314,33 +339,33 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im private String text; FloatingObjectPartsTreeNodeContext(FloatingObjectUIModel uiModel) { - Objects.requireNonNull(uiModel); - this.uiModel = uiModel; + this.uiModel = Objects.requireNonNull(uiModel); this.dto = null; this.enabled = true; this.editable = false; - this.mandatory = false; this.exclusive = false; - this.needOneSelection = false; + this.useValidation = false; + this.valueValidOnArriving = true; + this.valueValidOnLeaving = true; + this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); } FloatingObjectPartsTreeNodeContext(ObjectMaterialHierarchyDto dto, FloatingObjectPartsTreeNodeContext parent) { - Objects.requireNonNull(dto); - Objects.requireNonNull(parent); - this.uiModel = parent.uiModel; - this.dto = dto; + this.uiModel = Objects.requireNonNull(parent).uiModel; + this.dto = Objects.requireNonNull(dto); // enabled if parent is enabled and dto is enabled this.enabled = parent.enabled && dto.isEnabled(); - // need one selection if is enabled and dto requires it - this.needOneSelection = enabled && dto.isChildSelectionMandatory(); // editable if dto is selectable (we also make sure that the object material type is here too) this.editable = dto.isSelectable() && dto.getObjectMaterialType() != null; - - // mandatory if enabled parent is so or parent makes this child to be - this.mandatory = parent.mandatory || parent.needOneSelection; + this.useValidation = enabled && editable && dto.withValidation(); + if (!useValidation) { + valueValidOnArriving = true; + valueValidOnLeaving = true; + } // exclusive if his parent requires it this.exclusive = parent.dto != null && !parent.dto.isChildrenMultiSelectable(); - log.info(String.format("New node: %s - mandatory %s - needOneSelection %s - exclusive %s", dto.getLabel2(), mandatory, needOneSelection, exclusive)); + this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); + log.info(String.format("New node: %s %s - needOneSelection %b-%b - exclusive %s", dto.getCode(), dto.getLabel(referentialLocale), needOneSelectionOnArriving, needOneSelectionOnLeaving, exclusive)); } Object getValueAt(int column) { @@ -356,12 +381,19 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im } void setValueAt(Object aValue, int column) { + text = null; switch (column) { case 1: // when arriving uiModel.setWhenArriving(dto.getId(), aValue == null ? null : String.valueOf(aValue)); + if (useValidation) { + valueValidOnArriving = dto.isValid(aValue); + } return; case 2: // when leaving uiModel.setWhenLeaving(dto.getId(), aValue == null ? null : String.valueOf(aValue)); + if (useValidation) { + valueValidOnLeaving = dto.isValid(aValue); + } return; } throw new IllegalStateException(); @@ -393,7 +425,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im public String getText() { if (text == null && dto != null) { - text = String.format("%s [value: %s-%s] [valid: %s-%s]", dto.getLabel2(), getValueAt(1), getValueAt(2), isValid(1), isValid(2)); + text = String.format("%s [value: %s-%s] [valid: %s-%s]", dto.getLabel(referentialLocale), getValueAt(1), getValueAt(2), isValid(1), isValid(2)); } return text; } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTable.java ===================================== @@ -0,0 +1,188 @@ +package fr.ird.observe.client.ui.content.data.seine.dcp; + +/*- + * #%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.content.data.seine.FloatingObjectUIModel; +import fr.ird.observe.dto.data.seine.FloatingObjectPartReference; +import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto; +import org.apache.log4j.lf5.viewer.categoryexplorer.TreeModelAdapter; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.JXTreeTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.table.ColumnFactory; +import org.jdesktop.swingx.table.TableColumnExt; +import org.jdesktop.swingx.treetable.MutableTreeTableNode; + +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.InputMap; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.event.TreeModelEvent; +import javax.swing.tree.TreePath; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.util.Enumeration; +import java.util.Objects; +import java.util.Set; +import java.util.function.Supplier; + +/** + * Created by tchemit on 11/07/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class FloatingObjectPartsTreeTable extends JXTreeTable { + + public FloatingObjectPartsTreeTable(FloatingObjectPartsTreeTableModel treeModel) { + super(treeModel); + setTreeCellRenderer(new FloatingObjectPartLegendTreeCellRenderer()); + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + setRootVisible(false); + } + + @Override + public FloatingObjectPartsTreeTableModel getTreeTableModel() { + return (FloatingObjectPartsTreeTableModel) super.getTreeTableModel(); + } + + public void openTable(FloatingObjectUIModel model, Set<FloatingObjectPartReference> partsSet, boolean persisted) { + + for (FloatingObjectPartReference p : partsSet) { + String objectMaterialId = p.getObjectMaterialId(); + String whenArriving = p.getWhenArriving(); + String whenLeaving = p.getWhenLeaving(); + if (whenArriving != null && !Objects.equals("false", whenArriving)) { + model.setWhenArriving(objectMaterialId, whenArriving); + } + if (whenLeaving != null && !Objects.equals("false", whenLeaving)) { + model.setWhenLeaving(objectMaterialId, whenLeaving); + } + } + + FloatingObjectPartsTreeTableModel treeTableModel = getTreeTableModel(); + treeTableModel.reset(); + + if (persisted) { + expandAll(); + } else { + // expand first level nodes (except if they are disabled) + FloatingObjectPartsTreeNode root = treeTableModel.getRoot(); + Enumeration<? extends MutableTreeTableNode> children = root.children(); + while (children.hasMoreElements()) { + FloatingObjectPartsTreeNode mutableTreeTableNode = (FloatingObjectPartsTreeNode) children.nextElement(); + if (mutableTreeTableNode.isEnabled()) { + SwingUtilities.invokeLater(() -> expandPath(new TreePath(new Object[]{root, mutableTreeTableNode}))); + } + } + } + // auto expand nodes when selected + addTreeSelectionListener(e -> { + int selectedRow = getSelectedRow(); + if (selectedRow != -1) { + if (!isExpanded(selectedRow)) { + SwingUtilities.invokeLater(() -> expandRow(selectedRow)); + } + } + }); + } + + public void initTable(FloatingObjectUIModel model, Supplier<Integer> width, ObjectMaterialHierarchyDto materials) { + + FloatingObjectPartsTreeTableModel treeModel = getTreeTableModel(); + treeModel.rebuildRootNode(materials); + + setColumnFactory(new ColumnFactory() { + + @Override + public void configureColumnWidths(JXTable table, TableColumnExt columnExt) { + if (table.getColumn(0).equals(columnExt)) { + columnExt.setPreferredWidth(width.get()); + columnExt.setMinWidth(columnExt.getPreferredWidth()); + return; + } + super.configureColumnWidths(table, columnExt); + columnExt.setMinWidth(columnExt.getPreferredWidth()); + } + }); + treeModel.addTreeModelListener(new TreeModelAdapter() { + @Override + public void treeNodesChanged(TreeModelEvent e) { + if (treeModel.isAdjusting()) { + return; + } + model.setModified(true); + model.setPartsModified(); + } + + }); + + setDefaultRenderer(Object.class, new FloatingObjectPartsTableCellRenderer(this)); + setDefaultEditor(Object.class, new FloatingObjectPartsTableCellEditor(this)); + addHighlighter(new ColorHighlighter((renderer, adapter) -> { + JXTreeTable component = (JXTreeTable) adapter.getComponent(); + int row = adapter.convertRowIndexToModel(adapter.row); + FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) component.getPathForRow(row).getLastPathComponent(); + boolean valid1 = node.isValid(1); + boolean valid2 = node.isValid(2); + switch (adapter.convertRowIndexToModel(adapter.column)) { + case 0: + return false; + case 1: + return !valid1; + case 2: + return !valid2; + } + return true; + }, ObserveSwingApplicationContext.get().getConfig().getFloatingObjectMaterialErrorColor(), Color.WHITE)); + + InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW); + ActionMap actionMap = getActionMap(); + inputMap.put(ObserveKeyStrokes.KEY_STROKE_EXPAND_TREE_TABLE_NODE,"expandNode"); + actionMap.put("expandNode", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + int selectedRow = getSelectedRow(); + if (selectedRow != -1) { + if (!isExpanded(selectedRow)) { + SwingUtilities.invokeLater(() -> expandRow(selectedRow)); + } + } + } + }); + inputMap.put(ObserveKeyStrokes.KEY_STROKE_COLLAPSE_TREE_TABLE_NODE,"collapseNode"); + actionMap.put("collapseNode", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + int selectedRow = getSelectedRow(); + if (selectedRow != -1) { + if (!isCollapsed(selectedRow)) { + SwingUtilities.invokeLater(() -> collapseRow(selectedRow)); + } + } + } + }); + } +} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java ===================================== @@ -33,7 +33,6 @@ import org.nuiton.i18n.I18n; import java.util.Arrays; import java.util.Optional; -import java.util.stream.Collectors; /** * Created by tchemit on 05/08/17. @@ -51,7 +50,6 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { private ImmutableSet<FloatingObjectPartsTreeNode> allNodes; private ImmutableSet<FloatingObjectPartsTreeNode> needOneSelectionNodes; private ImmutableSet<FloatingObjectPartsTreeNode> mandatoryNodes; - private ImmutableSet<FloatingObjectPartsTreeNode> withValidationNodes; private boolean adjusting; public FloatingObjectPartsTreeTableModel(FloatingObjectUIModel uiModel) { @@ -71,18 +69,22 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { public void setRoot(TreeTableNode root) { super.setRoot(root); - FloatingObjectPartsTreeNode myRoot = (FloatingObjectPartsTreeNode) root; + allNodes = ((FloatingObjectPartsTreeNode) root).getShell(); - ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<FloatingObjectPartsTreeNode> needOneSelectionNodesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<FloatingObjectPartsTreeNode> mandatoryNodesBuilder = ImmutableSet.builder(); - myRoot.fillNodeSets(allNodesBuilder, needOneSelectionNodesBuilder, mandatoryNodesBuilder); - - allNodes = allNodesBuilder.build(); + for (FloatingObjectPartsTreeNode node : allNodes) { + if (!node.isEnabled()) { + continue; + } + mandatoryNodesBuilder.add(node); + if (node.withMandatoryConstraintsOnChildren()) { + needOneSelectionNodesBuilder.add(node); + } + } needOneSelectionNodes = needOneSelectionNodesBuilder.build(); mandatoryNodes = mandatoryNodesBuilder.build(); - withValidationNodes = ImmutableSet.copyOf(allNodes.stream().filter(FloatingObjectPartsTreeNode::withValidation).collect(Collectors.toSet())); } public void rebuildRootNode(ObjectMaterialHierarchyDto materials) { @@ -129,7 +131,6 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { needOneSelectionNodes.forEach(n -> n.computeNeedAtLeastOnSelectValidState(whenArriving, whenLeaving)); mandatoryNodes.forEach(n -> n.computeMandatoryValidState(whenArriving, whenLeaving)); - withValidationNodes.forEach(n -> n.computeFormulaValidState(whenArriving, whenLeaving)); boolean notValid = allNodes.stream().anyMatch(FloatingObjectPartsTreeNode::isNotValid); uiModel.getBean().setMaterialsValid(!notValid); ===================================== dto/src/main/java/fr/ird/observe/dto/data/seine/ObjectMaterialHierarchyDto.java ===================================== @@ -22,6 +22,7 @@ package fr.ird.observe.dto.data.seine; * #L% */ +import fr.ird.observe.dto.referential.FormulaHelper; import fr.ird.observe.dto.referential.seine.ObjectMaterialDto; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; @@ -60,6 +61,20 @@ public class ObjectMaterialHierarchyDto extends ObjectMaterialDto { return result; } + public boolean isValid(Object value) { + if (value==null) { + return true; + } + if (isText()) { + return FormulaHelper.validateObjectMaterialValidation(validation, value); + } else if (isInteger()) { + return FormulaHelper.validateObjectMaterialValidation(validation, Integer.valueOf(value.toString())); + } else if (isFloat()) { + return FormulaHelper.validateObjectMaterialValidation(validation, Float.valueOf(value.toString())); + } + throw new IllegalStateException("Can't validate this dto... "+this); + } + private void getAllDtos(ObjectMaterialHierarchyDto hierarchyDto, Set<ObjectMaterialHierarchyDto> result) { result.add(hierarchyDto); hierarchyDto.getChildren().forEach(c -> getAllDtos(c, result)); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/ef7805596cb94ee1e1347451ae2… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/ef7805596cb94ee1e1347451ae2… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Improve FOB Form - See #948
by Tony CHEMIT 12 Jul '18

12 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: cb682d54 by Tony CHEMIT at 2018-07-12T15:56:13Z Improve FOB Form - See #948 - - - - - 4 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/FloatingObjectPartsTreeNode.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java - dto/src/main/java/fr/ird/observe/dto/data/seine/ObjectMaterialHierarchyDto.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java ===================================== @@ -196,6 +196,14 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, SwingUtilities.invokeLater(this::forceGrabFocusOnForm); } + @Override + public void stopEditUI() { + if (ui.getMainTabbedPane().getSelectedIndex() == 1) { + ui.getTable().editingCanceled(null); + } + super.stopEditUI(); + } + @Override public void startEditUI(String... binding) { ContentUIModel<FloatingObjectDto> contentUIModel = getModel(); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java ===================================== @@ -26,7 +26,6 @@ import com.google.common.collect.ImmutableSet; import fr.ird.observe.client.ObserveSwingApplicationContext; import fr.ird.observe.client.ui.content.data.seine.FloatingObjectUIModel; import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto; -import fr.ird.observe.dto.referential.FormulaHelper; import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeReference; import org.apache.commons.logging.Log; @@ -62,13 +61,13 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im static FloatingObjectPartsTreeNode createRoot(FloatingObjectUIModel model, ObjectMaterialHierarchyDto dto) { FloatingObjectPartsTreeNode root; FloatingObjectPartsTreeNodeContext rootModel = new FloatingObjectPartsTreeNodeContext(model); - if (dto != null) { + if (dto == null) { + root = new FloatingObjectPartsTreeNode(rootModel); + } else { FloatingObjectPartsTreeNodeContext childModel = new FloatingObjectPartsTreeNodeContext(dto, rootModel); root = new FloatingObjectPartsTreeNode(childModel); root.computeCompanions(null); root.setCompanions(null); - } else { - root = new FloatingObjectPartsTreeNode(rootModel); } return root; } @@ -166,6 +165,8 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im getUserObject().text = null; getUserObject().validWhenArriving = true; getUserObject().validWhenLeaving = true; + getUserObject().needOneSelectionOnArriving = false; + getUserObject().needOneSelectionOnLeaving = false; } @Override @@ -173,44 +174,68 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im return (FloatingObjectPartsTreeNode) super.getParent(); } - void fillNodeSets(ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder, - ImmutableSet.Builder<FloatingObjectPartsTreeNode> needOneSelectionNodesBuilder, - ImmutableSet.Builder<FloatingObjectPartsTreeNode> mandatoryNodesBuilder) { + ImmutableSet<FloatingObjectPartsTreeNode> getShell() { - allNodesBuilder.add(this); - if (getUserObject().needOneSelection) { - needOneSelectionNodesBuilder.add(this); - } - if (getUserObject().mandatory) { - mandatoryNodesBuilder.add(this); - } + ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder = ImmutableSet.builder(); + getShell(allNodesBuilder); + return allNodesBuilder.build(); + } + private void getShell(ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder) { + allNodesBuilder.add(this); for (FloatingObjectPartsTreeNode child : this) { - child.fillNodeSets(allNodesBuilder, needOneSelectionNodesBuilder, mandatoryNodesBuilder); + child.getShell(allNodesBuilder); } + } + boolean withMandatoryConstraintsOnChildren() { + ObjectMaterialHierarchyDto userObject = getUserObject().dto; + return userObject == null || userObject.isChildSelectionMandatory(); } void computeNeedAtLeastOnSelectValidState(boolean whenArriving, boolean whenLeaving) { - + boolean needSelect = isEditable(); + FloatingObjectPartsTreeNodeContext userObject = getUserObject(); if (whenArriving) { - getUserObject().validWhenArriving = isAtLeastOneSelected(1); + userObject.needOneSelectionOnArriving = (!needSelect || withValue(1)) && isAtLeastOneSelected(1); } if (whenLeaving) { - getUserObject().validWhenLeaving = isAtLeastOneSelected(2); + userObject.needOneSelectionOnLeaving = (!needSelect || withValue(2)) && isAtLeastOneSelected(2); + } + if (userObject.needOneSelectionOnArriving || userObject.needOneSelectionOnLeaving) { + log.info("Validate node " + this); } - log.info("Validate node " + this); + } + private FloatingObjectPartsTreeNode getFirstAncestorNeedOneSelection(int column) { + if (withMandatoryConstraintsOnChildren()) { + if (parent == null) { + return this; + } + if (withValue(column)) { + return this; + } + } + return getParent().getFirstAncestorNeedOneSelection(column); } void computeMandatoryValidState(boolean whenArriving, boolean whenLeaving) { FloatingObjectPartsTreeNodeContext userObject = getUserObject(); + FloatingObjectPartsTreeNode parent = getParent(); if (whenArriving) { - userObject.validWhenArriving = getParent().getUserObject().validWhenArriving; + if (parent != null && !parent.getUserObject().validWhenArriving) { + userObject.validWhenArriving = false; + } else { + userObject.validWhenArriving = getFirstAncestorNeedOneSelection(1).getUserObject().needOneSelectionOnArriving; + } } if (whenLeaving) { - userObject.validWhenLeaving = getParent().getUserObject().validWhenLeaving; + if (parent != null && !parent.getUserObject().validWhenLeaving) { + userObject.validWhenLeaving = false; + } else { + userObject.validWhenLeaving = getFirstAncestorNeedOneSelection(2).getUserObject().needOneSelectionOnLeaving; + } } if (userObject.getValueAt(1) != null || userObject.getValueAt(2) != null) { @@ -218,41 +243,19 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im } } - void computeFormulaValidState(boolean whenArriving, boolean whenLeaving) { - if (getUserObject().dto == null || getUserObject().dto.isBoolean()) { - return; - } - String validation = getUserObject().dto.getValidation(); - if (whenArriving && getUserObject().validWhenArriving) { - Object value = getUserObject().getValueAt(1); - if (value != null) { - if (getUserObject().dto.isText()) { - getUserObject().validWhenArriving = FormulaHelper.validateObjectMaterialValidation(validation, value); - } else if (getUserObject().dto.isInteger()) { - getUserObject().validWhenArriving = FormulaHelper.validateObjectMaterialValidation(validation, Integer.valueOf(value.toString())); - } else if (getUserObject().dto.isFloat()) { - getUserObject().validWhenArriving = FormulaHelper.validateObjectMaterialValidation(validation, Float.valueOf(value.toString())); - } - } - } - if (whenLeaving && getUserObject().validWhenLeaving) { - Object value = getUserObject().getValueAt(2); - if (value != null) { - if (getUserObject().dto.isText()) { - getUserObject().validWhenLeaving = FormulaHelper.validateObjectMaterialValidation(validation, value); - } else if (getUserObject().dto.isInteger()) { - getUserObject().validWhenLeaving = FormulaHelper.validateObjectMaterialValidation(validation, Integer.valueOf(value.toString())); - } else if (getUserObject().dto.isFloat()) { - getUserObject().validWhenLeaving = FormulaHelper.validateObjectMaterialValidation(validation, Float.valueOf(value.toString())); - } - } - } - - } - - boolean withValidation() { - return getUserObject().dto != null && getUserObject().dto.withValidation(); - } +// void computeFormulaValidState(boolean whenArriving, boolean whenLeaving) { +// FloatingObjectPartsTreeNodeContext userObject = getUserObject(); +// ObjectMaterialHierarchyDto dto = Objects.requireNonNull(userObject.dto); +// if (whenArriving && userObject.validWhenArriving) { +// Object value = userObject.getValueAt(1); +// userObject.validWhenArriving = dto.isValid(value); +// } +// if (whenLeaving && userObject.validWhenLeaving) { +// Object value = userObject.getValueAt(2); +// userObject.validWhenLeaving = dto.isValid(value); +// } +// +// } private void setCompanions(ImmutableSet.Builder<FloatingObjectPartsTreeNode> companionsBuilder) { if (companionsBuilder != null) { @@ -263,12 +266,21 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im } } + private boolean withValue(int column) { + return getValueAt(column) != null; + } + + private boolean withValidValue(int column) { + return withValue(column) && (column == 1 ? getUserObject().valueValidOnArriving : getUserObject().valueValidOnLeaving); + } + private boolean isAtLeastOneSelected(int column) { - if (getValueAt(column) != null) { - return true; - } for (FloatingObjectPartsTreeNode child : this) { - if (child.isAtLeastOneSelected(column)) { + if (child.withValidValue(column)) { + return true; + } + boolean result = child.isAtLeastOneSelected(column); + if (result) { return true; } } @@ -293,6 +305,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im return dto != null && !dto.isChildrenMultiSelectable() && !isLeaf(); } + //TODO Improve the design, we should not store anything in uiModel and separate leaving and arriving data private static class FloatingObjectPartsTreeNodeContext { // main model to get and store values @@ -303,16 +316,22 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im private final boolean enabled; // Is this node editable ? private final boolean editable; - // Is this node need at least one child selected ? - private final boolean needOneSelection; - // Is this node in the path of at least one mandatory child ancestor ? - private final boolean mandatory; // Is the node is exclusive (means only one value possible for him and his brothers) ? private final boolean exclusive; + // Is the node use validation on his value ? + private final boolean useValidation; private final ReferentialLocale referentialLocale; - // Is the node valid for whenArriving column ? + // Is this node (on arriving) need at least one child selected ? (if editable then node must be selected) + private boolean needOneSelectionOnLeaving; + // Is this node (on leaving) need at least one child selected ? (if editable then node must be selected) + private boolean needOneSelectionOnArriving; + // for a validation node (on arriving), is value valid (if no value then it is valid) + private boolean valueValidOnLeaving = true; + // for a validation node (on leaving), is value valid (if no value then it is valid) + private boolean valueValidOnArriving = true; + // Is the node valid (on arriving) column ? private boolean validWhenArriving = true; - // Is the node valid for whenLeaving column ? + // Is the node valid (on leeaving) column ? private boolean validWhenLeaving = true; // Set of brothers of this node that is in a exclusive group of node (only one value among all of them) private ImmutableSet<FloatingObjectPartsTreeNode> companions; @@ -320,35 +339,33 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im private String text; FloatingObjectPartsTreeNodeContext(FloatingObjectUIModel uiModel) { - Objects.requireNonNull(uiModel); - this.uiModel = uiModel; + this.uiModel = Objects.requireNonNull(uiModel); this.dto = null; this.enabled = true; this.editable = false; - this.mandatory = false; this.exclusive = false; - this.needOneSelection = false; - this.referentialLocale=ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); + this.useValidation = false; + this.valueValidOnArriving = true; + this.valueValidOnLeaving = true; + this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); } FloatingObjectPartsTreeNodeContext(ObjectMaterialHierarchyDto dto, FloatingObjectPartsTreeNodeContext parent) { - Objects.requireNonNull(dto); - Objects.requireNonNull(parent); - this.uiModel = parent.uiModel; - this.dto = dto; + this.uiModel = Objects.requireNonNull(parent).uiModel; + this.dto = Objects.requireNonNull(dto); // enabled if parent is enabled and dto is enabled this.enabled = parent.enabled && dto.isEnabled(); - // need one selection if is enabled and dto requires it - this.needOneSelection = enabled && dto.isChildSelectionMandatory(); // editable if dto is selectable (we also make sure that the object material type is here too) this.editable = dto.isSelectable() && dto.getObjectMaterialType() != null; - - // mandatory if enabled parent is so or parent makes this child to be - this.mandatory = parent.mandatory || parent.needOneSelection; + this.useValidation = enabled && editable && dto.withValidation(); + if (!useValidation) { + valueValidOnArriving = true; + valueValidOnLeaving = true; + } // exclusive if his parent requires it this.exclusive = parent.dto != null && !parent.dto.isChildrenMultiSelectable(); - this.referentialLocale=ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); - log.info(String.format("New node: %s - mandatory %s - needOneSelection %s - exclusive %s", dto.getLabel(referentialLocale), mandatory, needOneSelection, exclusive)); + this.referentialLocale = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); + log.info(String.format("New node: %s %s - needOneSelection %b-%b - exclusive %s", dto.getCode(), dto.getLabel(referentialLocale), needOneSelectionOnArriving, needOneSelectionOnLeaving, exclusive)); } Object getValueAt(int column) { @@ -368,9 +385,15 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im switch (column) { case 1: // when arriving uiModel.setWhenArriving(dto.getId(), aValue == null ? null : String.valueOf(aValue)); + if (useValidation) { + valueValidOnArriving = dto.isValid(aValue); + } return; case 2: // when leaving uiModel.setWhenLeaving(dto.getId(), aValue == null ? null : String.valueOf(aValue)); + if (useValidation) { + valueValidOnLeaving = dto.isValid(aValue); + } return; } throw new IllegalStateException(); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTableModel.java ===================================== @@ -33,7 +33,6 @@ import org.nuiton.i18n.I18n; import java.util.Arrays; import java.util.Optional; -import java.util.stream.Collectors; /** * Created by tchemit on 05/08/17. @@ -51,7 +50,6 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { private ImmutableSet<FloatingObjectPartsTreeNode> allNodes; private ImmutableSet<FloatingObjectPartsTreeNode> needOneSelectionNodes; private ImmutableSet<FloatingObjectPartsTreeNode> mandatoryNodes; - private ImmutableSet<FloatingObjectPartsTreeNode> withValidationNodes; private boolean adjusting; public FloatingObjectPartsTreeTableModel(FloatingObjectUIModel uiModel) { @@ -71,18 +69,22 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { public void setRoot(TreeTableNode root) { super.setRoot(root); - FloatingObjectPartsTreeNode myRoot = (FloatingObjectPartsTreeNode) root; + allNodes = ((FloatingObjectPartsTreeNode) root).getShell(); - ImmutableSet.Builder<FloatingObjectPartsTreeNode> allNodesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<FloatingObjectPartsTreeNode> needOneSelectionNodesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<FloatingObjectPartsTreeNode> mandatoryNodesBuilder = ImmutableSet.builder(); - myRoot.fillNodeSets(allNodesBuilder, needOneSelectionNodesBuilder, mandatoryNodesBuilder); - - allNodes = allNodesBuilder.build(); + for (FloatingObjectPartsTreeNode node : allNodes) { + if (!node.isEnabled()) { + continue; + } + mandatoryNodesBuilder.add(node); + if (node.withMandatoryConstraintsOnChildren()) { + needOneSelectionNodesBuilder.add(node); + } + } needOneSelectionNodes = needOneSelectionNodesBuilder.build(); mandatoryNodes = mandatoryNodesBuilder.build(); - withValidationNodes = ImmutableSet.copyOf(allNodes.stream().filter(FloatingObjectPartsTreeNode::withValidation).collect(Collectors.toSet())); } public void rebuildRootNode(ObjectMaterialHierarchyDto materials) { @@ -129,7 +131,6 @@ public class FloatingObjectPartsTreeTableModel extends DefaultTreeTableModel { needOneSelectionNodes.forEach(n -> n.computeNeedAtLeastOnSelectValidState(whenArriving, whenLeaving)); mandatoryNodes.forEach(n -> n.computeMandatoryValidState(whenArriving, whenLeaving)); - withValidationNodes.forEach(n -> n.computeFormulaValidState(whenArriving, whenLeaving)); boolean notValid = allNodes.stream().anyMatch(FloatingObjectPartsTreeNode::isNotValid); uiModel.getBean().setMaterialsValid(!notValid); ===================================== dto/src/main/java/fr/ird/observe/dto/data/seine/ObjectMaterialHierarchyDto.java ===================================== @@ -22,6 +22,7 @@ package fr.ird.observe.dto.data.seine; * #L% */ +import fr.ird.observe.dto.referential.FormulaHelper; import fr.ird.observe.dto.referential.seine.ObjectMaterialDto; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; @@ -60,6 +61,20 @@ public class ObjectMaterialHierarchyDto extends ObjectMaterialDto { return result; } + public boolean isValid(Object value) { + if (value==null) { + return true; + } + if (isText()) { + return FormulaHelper.validateObjectMaterialValidation(validation, value); + } else if (isInteger()) { + return FormulaHelper.validateObjectMaterialValidation(validation, Integer.valueOf(value.toString())); + } else if (isFloat()) { + return FormulaHelper.validateObjectMaterialValidation(validation, Float.valueOf(value.toString())); + } + throw new IllegalStateException("Can't validate this dto... "+this); + } + private void getAllDtos(ObjectMaterialHierarchyDto hierarchyDto, Set<ObjectMaterialHierarchyDto> result) { result.add(hierarchyDto); hierarchyDto.getChildren().forEach(c -> getAllDtos(c, result)); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/cb682d5495dac9538a460a4c4ef… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/cb682d5495dac9538a460a4c4ef… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] Improve FOB Form (expand node when selected + expand enabled first level nodes…
by Tony CHEMIT 11 Jul '18

11 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 7f1ce7d1 by Tony CHEMIT at 2018-07-11T15:17:05Z Improve FOB Form (expand node when selected + expand enabled first level nodes on create mode) - See #948 - - - - - 6 changed files: - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jcss - 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/FloatingObjectUIModel.java - client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.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/FloatingObjectUI.jaxx ===================================== @@ -39,6 +39,7 @@ fr.ird.observe.client.ui.actions.main.global.DeleteDataGlobalUIAction fr.ird.observe.client.ui.actions.main.global.ResetDataGlobalUIAction fr.ird.observe.client.ui.actions.main.global.SaveDataGlobalUIAction + fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTable fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTableModel fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartLegendTreeCellRenderer fr.ird.observe.client.ui.util.JComment @@ -175,7 +176,7 @@ <row> <cell anchor="north" weightx="1" weighty="1"> <JScrollPane id='tableScroll'> - <JXTreeTable id='table'/> + <FloatingObjectPartsTreeTable id='table' constructorParams="new FloatingObjectPartsTreeTableModel(getModel())"/> </JScrollPane> </cell> </row> ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUI.jcss ===================================== @@ -140,9 +140,3 @@ BeanComboBox { focusable:false; } -#table { - treeTableModel:{new FloatingObjectPartsTreeTableModel(getModel())}; - treeCellRenderer:{new FloatingObjectPartLegendTreeCellRenderer()}; - selectionMode:{ListSelectionModel.SINGLE_SELECTION}; - rootVisible:false; -} ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java ===================================== @@ -29,9 +29,6 @@ import fr.ird.observe.client.db.constants.DataContextType; import fr.ird.observe.client.ui.content.ContentMode; import fr.ird.observe.client.ui.content.ContentUIHandler; import fr.ird.observe.client.ui.content.ContentUIModel; -import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTableCellEditor; -import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTableCellRenderer; -import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeNode; import fr.ird.observe.client.ui.content.data.seine.dcp.FloatingObjectPartsTreeTableModel; import fr.ird.observe.client.ui.tree.navigation.NavigationTree; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; @@ -53,12 +50,6 @@ import fr.ird.observe.services.service.actions.consolidate.dcp.ConsolidateFloati import fr.ird.observe.spi.DtoModelHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.lf5.viewer.categoryexplorer.TreeModelAdapter; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.JXTreeTable; -import org.jdesktop.swingx.decorator.ColorHighlighter; -import org.jdesktop.swingx.table.ColumnFactory; -import org.jdesktop.swingx.table.TableColumnExt; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.runtime.swing.SwingUtil; import org.nuiton.jaxx.validator.swing.SwingValidatorMessage; @@ -68,8 +59,6 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.Icon; import javax.swing.SwingUtilities; import javax.swing.event.TableModelListener; -import javax.swing.event.TreeModelEvent; -import java.awt.Color; import java.util.HashSet; import java.util.Map; import java.util.Objects; @@ -182,17 +171,18 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, } loadReferentialReferenceSetsInModel(form); - getModel().setForm(form); + FloatingObjectUIModel model = getModel(); + model.setForm(form); FloatingObjectHelper.copyFloatingObjectDto(form.getObject(), bean); - getModel().reset(); + model.reset(); - openTable(partsSet, getUi().getTable(), bean.isPersisted()); + getUi().getTable().openTable(model, partsSet, bean.isPersisted()); setContentMode(mode); // do this after setting mode (since only update mode use this...) - getModel().setReference(floatingObjectReference.orElse(null)); + model.setReference(floatingObjectReference.orElse(null)); if (mode != ContentMode.READ) { getUi().startEdit(null); @@ -203,33 +193,9 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, @Override protected void openedUI() { - SwingUtilities.invokeLater(this::forceGrabFocusOnForm); } - private void openTable(Set<FloatingObjectPartReference> partsSet, JXTreeTable table, boolean persisted) { - - FloatingObjectUIModel model = getModel(); - for (FloatingObjectPartReference p : partsSet) { - String objectMaterialId = p.getObjectMaterialId(); - String whenArriving = p.getWhenArriving(); - String whenLeaving = p.getWhenLeaving(); - if (whenArriving != null && !Objects.equals("false", whenArriving)) { - model.setWhenArriving(objectMaterialId, whenArriving); - } - if (whenLeaving != null && !Objects.equals("false", whenLeaving)) { - model.setWhenLeaving(objectMaterialId, whenLeaving); - } - } - - FloatingObjectPartsTreeTableModel treeTableModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel(); - treeTableModel.reset(); - - if (persisted) { - table.expandAll(); - } - } - @Override public void startEditUI(String... binding) { ContentUIModel<FloatingObjectDto> contentUIModel = getModel(); @@ -334,7 +300,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, FloatingObjectUIModel model = getModel(); model.setReferentialMap(allMap); - initTable(detailedForm, ui.getTable()); + ui.getTable().initTable(model, () -> getUi().getPreferredSize().width - 200, detailedForm); model.addPropertyChangeListener(FloatingObjectUIModel.PROPERTY_REFERENCE, e -> { if (!model.isUpdatingMode()) { @@ -386,60 +352,10 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto, getModel().setArriving(operation.isWhenArriving()); getModel().setLeaving(operation.isWhenLeaving()); } - FloatingObjectPartsTreeTableModel treeModel = (FloatingObjectPartsTreeTableModel) getUi().getTable().getTreeTableModel(); + FloatingObjectPartsTreeTableModel treeModel = getUi().getTable().getTreeTableModel(); treeModel.reset(); } - private void initTable(ObjectMaterialHierarchyDto materials, JXTreeTable table) { - - FloatingObjectPartsTreeTableModel treeModel = (FloatingObjectPartsTreeTableModel) table.getTreeTableModel(); - treeModel.rebuildRootNode(materials); - - table.setColumnFactory(new ColumnFactory() { - - @Override - public void configureColumnWidths(JXTable table, TableColumnExt columnExt) { - if (table.getColumn(0).equals(columnExt)) { - columnExt.setPreferredWidth(getUi().getPreferredSize().width - 200); - columnExt.setMinWidth(columnExt.getPreferredWidth()); - return; - } - super.configureColumnWidths(table, columnExt); - columnExt.setMinWidth(columnExt.getPreferredWidth()); - } - }); - treeModel.addTreeModelListener(new TreeModelAdapter() { - @Override - public void treeNodesChanged(TreeModelEvent e) { - if (treeModel.isAdjusting()) { - return; - } - getModel().setModified(true); - getModel().setPartsModified(); - } - - }); - - table.setDefaultRenderer(Object.class, new FloatingObjectPartsTableCellRenderer(table)); - table.setDefaultEditor(Object.class, new FloatingObjectPartsTableCellEditor(table)); - table.addHighlighter(new ColorHighlighter((renderer, adapter) -> { - JXTreeTable component = (JXTreeTable) adapter.getComponent(); - int row = adapter.convertRowIndexToModel(adapter.row); - FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) component.getPathForRow(row).getLastPathComponent(); - boolean valid1 = node.isValid(1); - boolean valid2 = node.isValid(2); - switch (adapter.convertRowIndexToModel(adapter.column)) { - case 0: - return false; - case 1: - return !valid1; - case 2: - return !valid2; - } - return true; - }, ObserveSwingApplicationContext.get().getConfig().getFloatingObjectMaterialErrorColor(), Color.WHITE)); - } - protected void computeTabValidState(SwingValidatorMessageTableModel errorTableModel) { Set<String> errorProperties = new HashSet<>(); ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIModel.java ===================================== @@ -127,7 +127,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> { return result.build(); } - void setPartsModified() { + public void setPartsModified() { firePropertyChange(PROPERTY_PARTS_MODIFIED, true); } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeNode.java ===================================== @@ -23,9 +23,11 @@ package fr.ird.observe.client.ui.content.data.seine.dcp; */ import com.google.common.collect.ImmutableSet; +import fr.ird.observe.client.ObserveSwingApplicationContext; import fr.ird.observe.client.ui.content.data.seine.FloatingObjectUIModel; import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto; import fr.ird.observe.dto.referential.FormulaHelper; +import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeReference; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -203,14 +205,17 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im } void computeMandatoryValidState(boolean whenArriving, boolean whenLeaving) { + FloatingObjectPartsTreeNodeContext userObject = getUserObject(); if (whenArriving) { - getUserObject().validWhenArriving = getParent().getUserObject().validWhenArriving; + userObject.validWhenArriving = getParent().getUserObject().validWhenArriving; } if (whenLeaving) { - getUserObject().validWhenLeaving = getParent().getUserObject().validWhenLeaving; + userObject.validWhenLeaving = getParent().getUserObject().validWhenLeaving; } - log.info("Validate node " + this); + if (userObject.getValueAt(1) != null || userObject.getValueAt(2) != null) { + log.info("Validate node " + this); + } } void computeFormulaValidState(boolean whenArriving, boolean whenLeaving) { @@ -304,6 +309,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im private final boolean mandatory; // Is the node is exclusive (means only one value possible for him and his brothers) ? private final boolean exclusive; + private final ReferentialLocale referentialLocale; // Is the node valid for whenArriving column ? private boolean validWhenArriving = true; // Is the node valid for whenLeaving column ? @@ -322,6 +328,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im this.mandatory = false; this.exclusive = false; this.needOneSelection = false; + this.referentialLocale=ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); } FloatingObjectPartsTreeNodeContext(ObjectMaterialHierarchyDto dto, FloatingObjectPartsTreeNodeContext parent) { @@ -340,7 +347,8 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im this.mandatory = parent.mandatory || parent.needOneSelection; // exclusive if his parent requires it this.exclusive = parent.dto != null && !parent.dto.isChildrenMultiSelectable(); - log.info(String.format("New node: %s - mandatory %s - needOneSelection %s - exclusive %s", dto.getLabel2(), mandatory, needOneSelection, exclusive)); + this.referentialLocale=ObserveSwingApplicationContext.get().getDecoratorService().getReferentialLocale(); + log.info(String.format("New node: %s - mandatory %s - needOneSelection %s - exclusive %s", dto.getLabel(referentialLocale), mandatory, needOneSelection, exclusive)); } Object getValueAt(int column) { @@ -356,6 +364,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im } void setValueAt(Object aValue, int column) { + text = null; switch (column) { case 1: // when arriving uiModel.setWhenArriving(dto.getId(), aValue == null ? null : String.valueOf(aValue)); @@ -393,7 +402,7 @@ public class FloatingObjectPartsTreeNode extends AbstractMutableTreeTableNode im public String getText() { if (text == null && dto != null) { - text = String.format("%s [value: %s-%s] [valid: %s-%s]", dto.getLabel2(), getValueAt(1), getValueAt(2), isValid(1), isValid(2)); + text = String.format("%s [value: %s-%s] [valid: %s-%s]", dto.getLabel(referentialLocale), getValueAt(1), getValueAt(2), isValid(1), isValid(2)); } return text; } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/data/seine/dcp/FloatingObjectPartsTreeTable.java ===================================== @@ -0,0 +1,156 @@ +package fr.ird.observe.client.ui.content.data.seine.dcp; + +/*- + * #%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.content.data.seine.FloatingObjectUIModel; +import fr.ird.observe.dto.data.seine.FloatingObjectPartReference; +import fr.ird.observe.dto.data.seine.ObjectMaterialHierarchyDto; +import org.apache.log4j.lf5.viewer.categoryexplorer.TreeModelAdapter; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.JXTreeTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.table.ColumnFactory; +import org.jdesktop.swingx.table.TableColumnExt; +import org.jdesktop.swingx.treetable.MutableTreeTableNode; + +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.event.TreeModelEvent; +import javax.swing.tree.TreePath; +import java.awt.Color; +import java.util.Enumeration; +import java.util.Objects; +import java.util.Set; +import java.util.function.Supplier; + +/** + * Created by tchemit on 11/07/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class FloatingObjectPartsTreeTable extends JXTreeTable { + + public FloatingObjectPartsTreeTable(FloatingObjectPartsTreeTableModel treeModel) { + super(treeModel); + setTreeCellRenderer(new FloatingObjectPartLegendTreeCellRenderer()); + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + setRootVisible(false); + } + + @Override + public FloatingObjectPartsTreeTableModel getTreeTableModel() { + return (FloatingObjectPartsTreeTableModel) super.getTreeTableModel(); + } + + public void openTable(FloatingObjectUIModel model, Set<FloatingObjectPartReference> partsSet, boolean persisted) { + + for (FloatingObjectPartReference p : partsSet) { + String objectMaterialId = p.getObjectMaterialId(); + String whenArriving = p.getWhenArriving(); + String whenLeaving = p.getWhenLeaving(); + if (whenArriving != null && !Objects.equals("false", whenArriving)) { + model.setWhenArriving(objectMaterialId, whenArriving); + } + if (whenLeaving != null && !Objects.equals("false", whenLeaving)) { + model.setWhenLeaving(objectMaterialId, whenLeaving); + } + } + + FloatingObjectPartsTreeTableModel treeTableModel = getTreeTableModel(); + treeTableModel.reset(); + + if (persisted) { + expandAll(); + } else { + // expand first level nodes (except if they are disabled) + FloatingObjectPartsTreeNode root = treeTableModel.getRoot(); + Enumeration<? extends MutableTreeTableNode> children = root.children(); + while (children.hasMoreElements()) { + FloatingObjectPartsTreeNode mutableTreeTableNode = (FloatingObjectPartsTreeNode) children.nextElement(); + if (mutableTreeTableNode.isEnabled()) { + SwingUtilities.invokeLater(() -> expandPath(new TreePath(new Object[]{root, mutableTreeTableNode}))); + } + } + } + // auto expand nodes when selected + addTreeSelectionListener(e -> { + int selectedRow = getSelectedRow(); + if (selectedRow != -1) { + if (!isExpanded(selectedRow)) { + SwingUtilities.invokeLater(() -> expandRow(selectedRow)); + } + } + }); + } + + public void initTable(FloatingObjectUIModel model, Supplier<Integer> width, ObjectMaterialHierarchyDto materials) { + + FloatingObjectPartsTreeTableModel treeModel = getTreeTableModel(); + treeModel.rebuildRootNode(materials); + + setColumnFactory(new ColumnFactory() { + + @Override + public void configureColumnWidths(JXTable table, TableColumnExt columnExt) { + if (table.getColumn(0).equals(columnExt)) { + columnExt.setPreferredWidth(width.get()); + columnExt.setMinWidth(columnExt.getPreferredWidth()); + return; + } + super.configureColumnWidths(table, columnExt); + columnExt.setMinWidth(columnExt.getPreferredWidth()); + } + }); + treeModel.addTreeModelListener(new TreeModelAdapter() { + @Override + public void treeNodesChanged(TreeModelEvent e) { + if (treeModel.isAdjusting()) { + return; + } + model.setModified(true); + model.setPartsModified(); + } + + }); + + setDefaultRenderer(Object.class, new FloatingObjectPartsTableCellRenderer(this)); + setDefaultEditor(Object.class, new FloatingObjectPartsTableCellEditor(this)); + addHighlighter(new ColorHighlighter((renderer, adapter) -> { + JXTreeTable component = (JXTreeTable) adapter.getComponent(); + int row = adapter.convertRowIndexToModel(adapter.row); + FloatingObjectPartsTreeNode node = (FloatingObjectPartsTreeNode) component.getPathForRow(row).getLastPathComponent(); + boolean valid1 = node.isValid(1); + boolean valid2 = node.isValid(2); + switch (adapter.convertRowIndexToModel(adapter.column)) { + case 0: + return false; + case 1: + return !valid1; + case 2: + return !valid2; + } + return true; + }, ObserveSwingApplicationContext.get().getConfig().getFloatingObjectMaterialErrorColor(), Color.WHITE)); + } +} View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/7f1ce7d15063b77511c57902d2b… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/7f1ce7d15063b77511c57902d2b… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-7.x] [PS][SERVER] La création du form FOB (Ctrl+P) depuis le form activité échoue en…
by Tony CHEMIT 11 Jul '18

11 Jul '18
Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 716b1330 by Tony CHEMIT at 2018-07-11T13:04:24Z [PS][SERVER] La création du form FOB (Ctrl+P) depuis le form activité échoue en mode serveur - closes #1024 - - - - - 15 changed files: - client/src/main/java/fr/ird/observe/client/ui/actions/content/LonglineDetailCompositionDeleteAllSectionsAction.java - client/src/main/java/fr/ird/observe/client/ui/actions/content/LonglineDetailCompositionGenerateAllSectionsAction.java - dto/src/main/java/fr/ird/observe/dto/referential/LengthLengthParameterDto.java - dto/src/main/java/fr/ird/observe/dto/referential/LengthWeightParameterDto.java - − dto/src/main/java/fr/ird/observe/dto/referential/WithLengthFormula.java - − dto/src/main/java/fr/ird/observe/dto/referential/WithStartEndDate.java - dto/src/main/models/Observe.model - persistence/src/main/java/fr/ird/observe/entities/referentiel/FormulaSupportImpl.java - persistence/src/main/models/Observe.model - pom.xml - server/src/main/java/fr/ird/observe/server/ObserveWebApplicationContext.java - + services/src/main/java/fr/ird/observe/services/gson/FloatingObjectModificationAdapter.java - services/src/main/java/fr/ird/observe/services/gson/ObserveDtoGsonSupplier.java - services/src/main/java/fr/ird/observe/services/service/actions/consolidate/dcp/FloatingObjectModification.java - services/src/main/java/fr/ird/observe/services/service/data/seine/FloatingObjectService.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/actions/content/LonglineDetailCompositionDeleteAllSectionsAction.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/actions/content/LonglineDetailCompositionGenerateAllSectionsAction.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 com.google.common.collect.Lists; import fr.ird.observe.client.ui.ObserveKeyStrokes; import fr.ird.observe.client.ui.ObserveMainUI; ===================================== dto/src/main/java/fr/ird/observe/dto/referential/LengthLengthParameterDto.java ===================================== @@ -22,11 +22,6 @@ package fr.ird.observe.dto.referential; * #L% */ -import io.ultreia.java4all.bean.definition.JavaBeanDefinition; -import io.ultreia.java4all.bean.definition.JavaBeanDefinitionStore; -import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition; - -@GenerateJavaBeanDefinition public class LengthLengthParameterDto extends GeneratedLengthLengthParameterDto { private static final long serialVersionUID = 1L; @@ -83,8 +78,4 @@ public class LengthLengthParameterDto extends GeneratedLengthLengthParameterDto setOutputInputFormulaValid(formulaTwoValid); } - @Override - public JavaBeanDefinition javaBeanDefinition() { - return JavaBeanDefinitionStore.definition(LengthLengthParameterDtoJavaBeanDefinition.class); - } } ===================================== dto/src/main/java/fr/ird/observe/dto/referential/LengthWeightParameterDto.java ===================================== @@ -23,11 +23,7 @@ package fr.ird.observe.dto.referential; */ import io.ultreia.java4all.bean.JavaBean; -import io.ultreia.java4all.bean.definition.JavaBeanDefinition; -import io.ultreia.java4all.bean.definition.JavaBeanDefinitionStore; -import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition; -@GenerateJavaBeanDefinition public class LengthWeightParameterDto extends GeneratedLengthWeightParameterDto implements JavaBean { private static final long serialVersionUID = 1L; @@ -84,8 +80,4 @@ public class LengthWeightParameterDto extends GeneratedLengthWeightParameterDto setWeightLengthFormulaValid(formulaTwoValid); } - @Override - public JavaBeanDefinition javaBeanDefinition() { - return JavaBeanDefinitionStore.definition(LengthWeightParameterDtoJavaBeanDefinition.class); - } } ===================================== dto/src/main/java/fr/ird/observe/dto/referential/WithLengthFormula.java deleted ===================================== @@ -1,103 +0,0 @@ -package fr.ird.observe.dto.referential; - -/*- - * #%L - * ObServe Toolkit :: Common Dto - * %% - * Copyright (C) 2017 - 2018 IRD, 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 java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.Set; - -/** - * Created on 22/12/16. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 6.0 - */ -public interface WithLengthFormula extends WithFormula, WithStartEndDate { - - String PROPERTY_OCEAN = "ocean"; - String PROPERTY_SPECIES = "species"; - String PROPERTY_SEX = "sex"; - String PROPERTY_START_DATE = "startDate"; - String PROPERTY_END_DATE = "endDate"; - String PROPERTY_COEFFICIENTS = "coefficients"; - String PROPERTY_SOURCE = "source"; - - Comparator<WithLengthFormula> FORMULA_SUPPORT_START_DATE_COMPARATOR = Comparator.comparing(WithStartEndDate::getStartDate, WithStartEndDate.START_DATE_COMPARATOR); - Comparator<WithLengthFormula> FORMULA_SUPPORT_END_DATE_COMPARATOR = Comparator.comparing(WithStartEndDate::getEndDate, WithStartEndDate.END_DATE_COMPARATOR); - Comparator<WithLengthFormula> FORMULA_SUPPORT_COMPARATOR = FORMULA_SUPPORT_START_DATE_COMPARATOR.thenComparing(FORMULA_SUPPORT_END_DATE_COMPARATOR); - - static <D extends WithLengthFormula> void sort(List<D> list) { - list.sort(FORMULA_SUPPORT_COMPARATOR); - } - -// static <D extends WithStartEndDate> List<D> filter(List<D> list, Date date) { -// return list.stream() -// .filter(f -> WithStartEndDate.START_DATE_COMPARATOR.compare(f.getStartDate(), date) <= 0 && WithStartEndDate.END_DATE_COMPARATOR.compare(date, f.getEndDate()) <= 0) -// .collect(Collectors.toList()); -// } - - String getFormulaOneVariableName(); - - String getFormulaTwoVariableName(); - - void setStartDate(Date startDate); - - void setEndDate(Date endDate); - - void setCoefficients(String coefficients); - - String getSource(); - - void setSource(String source); - - default Set<String> getCoefficientNames() { - return getCoefficientValues().keySet(); - } - - String getFormulaOne(); - - String getFormulaTwo(); - - default void revalidateFormulaOne() { - boolean result = FormulaHelper.validateRelation(this, getFormulaOne(), getFormulaOneVariableName()); - setFormulaOneValid(result); - } - - boolean isFormulaOneValid(); - - void setFormulaOneValid(boolean formulaOneValid); - - boolean isFormulaTwoValid(); - - void setFormulaTwoValid(boolean formulaTwoValid); - - default void revalidateFormulaTwo() { - boolean result = FormulaHelper.validateRelation(this, getFormulaTwo(), getFormulaTwoVariableName()); - setFormulaTwoValid(result); - } - - default Double getCoefficientValue(String coefficientName) { - return getCoefficientValues().get(coefficientName); - } -} ===================================== dto/src/main/java/fr/ird/observe/dto/referential/WithStartEndDate.java deleted ===================================== @@ -1,26 +0,0 @@ -package fr.ird.observe.dto.referential; - -import com.google.common.collect.Ordering; -import fr.ird.observe.dto.reference.DtoReferenceAware; - -import java.util.Comparator; -import java.util.Date; - -/** - * Created by tchemit on 10/07/2018. - * - * @author Tony Chemit - dev(a)tchemit.fr - */ -public interface WithStartEndDate extends DtoReferenceAware { - - Comparator<Date> START_DATE_COMPARATOR = Ordering.natural().nullsFirst(); - Comparator<Date> END_DATE_COMPARATOR = Ordering.natural().nullsLast(); - - Comparator<WithStartEndDate> WITH_START_DATE_COMPARATOR = Comparator.comparing(WithStartEndDate::getStartDate, START_DATE_COMPARATOR); - Comparator<WithStartEndDate> WITH_END_DATE_COMPARATOR = Comparator.comparing(WithStartEndDate::getEndDate, END_DATE_COMPARATOR); - - Date getStartDate(); - - Date getEndDate(); - -} ===================================== dto/src/main/models/Observe.model ===================================== @@ -12,19 +12,9 @@ package fr.ird.observe.dto.form enum constants.ObserveDbRole -enum data.seine.SetSeineConstants -targetSampleCapture -endSetDate -endPursingDate -endSetTime -endPursingTime - -enum data.seine.TargetLengthConstants -totalWeight - interface ObserveDto -interface referential.WithLengthFormula +interface referential.WithFormula interface WithComment getComment() String @@ -70,7 +60,7 @@ label6 + {*:1} String label7 + {*:1} String label8 + {*:1} String -abstract referential.LengthFormulaSupport > referential.Referential >> referential.WithLengthFormula +abstract referential.LengthFormulaSupport > referential.Referential >> referential.WithFormula startDate + {*:1} Date endDate + {*:1} Date coefficients + {*:1} String @@ -750,7 +740,7 @@ totalWeight + {*:1} Integer meanWeight + {*:1} Integer species {*:1} fr.ird.observe.dto.referential.SpeciesReference -data.seine.SetSeine > data.Commentable | references=comment +data.seine.SetSeine > data.Commentable | references=comment constants=targetSampleCapture,endSetDate,endPursingDate,endSetTime,endPursingTime startTime + {*:1} Date endPursingTimeStamp + {*:1} Date endSetTimeStamp + {*:1} Date @@ -795,7 +785,7 @@ weightCategory {*:1} fr.ird.observe.dto.referential.seine.WeightCategoryReferenc reasonForDiscard {*:0..1} fr.ird.observe.dto.referential.seine.ReasonForDiscardReference species {*:1} fr.ird.observe.dto.referential.SpeciesReference -data.seine.TargetLength > data.Data | references=speciesLabel,length,count +data.seine.TargetLength > data.Data | references=speciesLabel,length,count constants=totalWeight length + {*:1} Float isLengthComputed + {*:1} boolean count + {*:1} Integer ===================================== persistence/src/main/java/fr/ird/observe/entities/referentiel/FormulaSupportImpl.java ===================================== @@ -23,7 +23,6 @@ package fr.ird.observe.entities.referentiel; */ import fr.ird.observe.dto.referential.FormulaHelper; -import fr.ird.observe.dto.referential.WithLengthFormula; import org.apache.commons.lang3.BooleanUtils; import java.util.Map; @@ -34,7 +33,7 @@ import java.util.Map; * @author Tony Chemit - dev(a)tchemit.fr * @since 6.0 */ -public abstract class FormulaSupportImpl extends FormulaSupportAbstract implements WithLengthFormula { +public abstract class FormulaSupportImpl extends FormulaSupportAbstract { private static final long serialVersionUID = 1L; ===================================== persistence/src/main/models/Observe.model ===================================== @@ -25,62 +25,6 @@ enum !fr.ird.observe.dto.data.seine.TypeTransmittingBuoyOperation enum !fr.ird.observe.dto.data.seine.DcpComputedValue -enum longline.ActivityLonglineConstants -date -time - -enum longline.BranchlineConstants -timerTimeOnBoardDate -timerTimeOnBoardTime - -enum longline.SetLonglineConstants -settingStartDate -settingStartTime -settingStartQuadrant -settingEndDate -settingEndTime -settingEndQuadrant -haulingStartDate -haulingStartTime -haulingStartQuadrant -haulingEndDate -haulingEndTime -haulingEndQuadrant -floatlinesCompositionProportionSum -branchlinesCompositionProportionSum -hooksCompositionProportionSum -baitsCompositionProportionSum - -enum longline.TdrConstants -deployementStartDate -deployementStartTime -deployementEndDate -deployementEndTime -fishingStartDate -fishingStartTime -fishingEndDate -fishingEndTime - -enum referentiel.FormulaSupportConstants -formulaOneValid -formulaTwoValid - -enum referentiel.HarbourConstants -quadrant - -enum referentiel.ProgramConstants -gearTypePrefix - -enum seine.SetConstants -targetSampleCapture -endSetDate -endPursingDate -endSetTime -endPursingTime - -enum seine.TargetLengthConstants -totalWeight - interface Activity interface LengthWeightComputable @@ -122,7 +66,7 @@ abstract ObserveDataEntity > ObserveEntity | entity abstract ObserveEntity >> fr.ird.observe.dto.reference.DtoReferenceAware | entity lastUpdateDate + {*:1} Date | notNull -longline.ActivityLongline > CommentableEntity >> Activity | entity dbName=Activity +longline.ActivityLongline > CommentableEntity >> Activity | entity dbName=Activity constants=date,time timeStamp + {*:1} Date latitude + {*:1} Float longitude + {*:1} Float @@ -156,7 +100,7 @@ catchLongline {*} longline.CatchLongline tdr {*} longline.Tdr setLongline {*:1} longline.SetLongline | dbName=set -longline.Branchline > CommentableEntity >> longline.LonglineCompositionEntity | entity +longline.Branchline > CommentableEntity >> longline.LonglineCompositionEntity | entity constants=timerTimeOnBoardDate,timerTimeOnBoardTime settingIdentifier + {*:1} Integer | notNull haulingIdentifier + {*:1} Integer depthRecorder + {*:1} Boolean @@ -265,7 +209,7 @@ sensorType {*:1} referentiel.longline.SensorType sensorDataFormat {*:0..1} referentiel.longline.SensorDataFormat sensorBrand {*:1} referentiel.longline.SensorBrand -longline.SetLongline > CommentableEntity >> ObserveSet | entity dbName=Set +longline.SetLongline > CommentableEntity >> ObserveSet | entity dbName=Set constants=settingStartTime,settingStartQuadrant,settingEndDate,settingEndTime,settingEndQuadrant,haulingStartDate,haulingStartTime,haulingStartQuadrant,haulingEndDate,haulingEndTime,haulingEndQuadrant,floatlinesCompositionProportionSum,branchlinesCompositionProportionSum,hooksCompositionProportionSum,baitsCompositionProportionSum homeId + {*:1} String number + {*:1} Integer basketsPerSectionCount + {*:1} Integer @@ -347,7 +291,7 @@ longline.SizeMeasure > ObserveDataEntity | entity size + {*:1} Float | sqlType=numeric sizeMeasureType {*:1} referentiel.SizeMeasureType -longline.Tdr > ObserveDataEntity >> longline.LonglinePositionAware | entity +longline.Tdr > ObserveDataEntity >> longline.LonglinePositionAware | entity constants=deployementStartDate,deployementStartTime,deployementEndDate,deployementEndTime,fishingStartDate,fishingStartTime,fishingEndDate,fishingEndTime homeId + {*:1} String floatline1Length + {*:1} Float | sqlType=numeric floatline2Length + {*:1} Float | sqlType=numeric @@ -427,7 +371,7 @@ iso3Code + {*:1} String referentiel.DataQuality > referentiel.I18nReferentialEntity | entity -abstract referentiel.FormulaSupport > referentiel.ObserveReferentialEntity >> fr.ird.observe.dto.referential.WithLengthFormula | entity +abstract referentiel.FormulaSupport > referentiel.ObserveReferentialEntity >> fr.ird.observe.dto.referential.WithFormula | entity constants=formulaOneValid,formulaTwoValid ocean {*:0..1} referentiel.Ocean | notNull lazy=false species {*:1} referentiel.Species | notNull lazy=false sex {*:1} referentiel.Sex | notNull lazy=false @@ -451,7 +395,7 @@ gearCaracteristicType {*:1} referentiel.GearCaracteristicType | lazy=false referentiel.GearCaracteristicType > referentiel.I18nReferentialEntity | entity -referentiel.Harbour > referentiel.ObserveReferentialEntity | entity +referentiel.Harbour > referentiel.ObserveReferentialEntity | entity constants=quadrant country {*:1} referentiel.Country locode + {*:1} String name + {*:1} String @@ -508,7 +452,7 @@ captain + {*:1} boolean dataEntryOperator + {*:1} boolean country {*:0..1} referentiel.Country -referentiel.Program > referentiel.I18nReferentialEntity | entity +referentiel.Program > referentiel.I18nReferentialEntity | entity constants=gearTypePrefix organism {*:1} referentiel.Organism | lazy=false nonTargetObservation + {*:1} int targetDiscardsObservation + {*:1} int @@ -827,7 +771,7 @@ meanWeight + {*:1} Integer setSeine {*:1} seine.SetSeine | naturalId dbName=set species {*:1} referentiel.Species | naturalId -seine.SetSeine > CommentableEntity >> ObserveSet | entity dbName=Set +seine.SetSeine > CommentableEntity >> ObserveSet | entity dbName=Set constants=targetSampleCapture,endSetDate,endPursingDate,endSetTime,endPursingTime startTime + {*:1} Date | hibernateAttributeType.java.util.Date=time endPursingTimeStamp + {*:1} Date endSetTimeStamp + {*:1} Date @@ -879,7 +823,7 @@ reasonForDiscard {*:0..1} referentiel.seine.ReasonForDiscard | naturalId notNull getSpecies() referentiel.Species setSpecies(species referentiel.Species) -seine.TargetLength > ObserveDataEntity >> LengthWeightComputable | entity +seine.TargetLength > ObserveDataEntity >> LengthWeightComputable | entity constants=totalWeight length + {*:1} Float | sqlType=numeric isLengthComputed + {*:1} boolean count + {*:1} Integer ===================================== pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2018.36</version> + <version>2018.40</version> </parent> <groupId>fr.ird.observe</groupId> @@ -152,8 +152,7 @@ <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format> <buildDate>${maven.build.timestamp}</buildDate> - <observeToolkitVersion>3.7.1</observeToolkitVersion> - + <observeToolkitVersion>3.7.2</observeToolkitVersion> <!--<lib.version.java4all.jaxx>3.0-alpha-31</lib.version.java4all.jaxx>--> <!--<lib.version.nuiton.topia>3.4.2-SNAPSHOT</lib.version.nuiton.topia>--> <lib.version.nuiton.validation>3.1</lib.version.nuiton.validation> @@ -162,7 +161,8 @@ <!--<lib.version.hibernate>5.2.10.Final</lib.version.hibernate>--> <!--can't use 1.4.197 (date has changed + blob also--> <lib.version.h2>1.4.196</lib.version.h2> - <lib.version.java4all.eugene>3.0-alpha-21</lib.version.java4all.eugene> + <!--<lib.version.java4all.eugene>3.0-alpha-21</lib.version.java4all.eugene>--> + <lib.version.java4all.eugene>3.0-alpha-23</lib.version.java4all.eugene> <!--<lib.version.java4all.topia>1.1.2-SNAPSHOT</lib.version.java4all.topia>--> <!-- license header configuration --> <license.licenseName>gpl_v3</license.licenseName> ===================================== server/src/main/java/fr/ird/observe/server/ObserveWebApplicationContext.java ===================================== @@ -39,9 +39,11 @@ import fr.ird.observe.services.ObserveServiceFactory; import fr.ird.observe.services.ObserveServiceInitializer; import fr.ird.observe.services.ObserveServiceMainFactory; import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; +import fr.ird.observe.services.gson.FloatingObjectModificationAdapter; import fr.ird.observe.services.gson.ObserveDataSourceConfigurationAdapter; import fr.ird.observe.services.gson.ObserveDtoGsonSupplier; import fr.ird.observe.services.service.ObserveService; +import fr.ird.observe.services.service.actions.consolidate.dcp.FloatingObjectModification; import org.debux.webmotion.server.call.HttpContext; import org.nuiton.version.Version; @@ -118,7 +120,8 @@ public class ObserveWebApplicationContext implements Closeable { @Override protected GsonBuilder getGsonBuilder(boolean prettyPrint) { return super.getGsonBuilder(prettyPrint) - .registerTypeAdapter(ObserveDataSourceConfiguration.class, new ObserveDataSourceConfigurationAdapter()); + .registerTypeAdapter(ObserveDataSourceConfiguration.class, new ObserveDataSourceConfigurationAdapter()) + .registerTypeAdapter(FloatingObjectModification.class, new FloatingObjectModificationAdapter()); } }; ===================================== services/src/main/java/fr/ird/observe/services/gson/FloatingObjectModificationAdapter.java ===================================== @@ -0,0 +1,65 @@ +package fr.ird.observe.services.gson; + +/*- + * #%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.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import fr.ird.observe.services.service.actions.consolidate.dcp.FloatingObjectModification; + +import java.io.Serializable; +import java.lang.reflect.Type; + +/** + * Created by tchemit on 11/07/2018. + * + * @author Tony Chemit - dev(a)tchemit.fr + */ +public class FloatingObjectModificationAdapter implements JsonDeserializer<FloatingObjectModification>, JsonSerializer<FloatingObjectModification> { + + @Override + public FloatingObjectModification deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + JsonObject reportVariableJson = json.getAsJsonObject(); + + String dcpId = context.deserialize(reportVariableJson.get("dcpId"), String.class); + String propertyName = context.deserialize(reportVariableJson.get("propertyName"), String.class); + Class<?> type = context.deserialize(reportVariableJson.get("type"), Class.class); + Serializable newValue1 = context.deserialize(reportVariableJson.get("newValue"), type); + return new FloatingObjectModification(dcpId, propertyName, newValue1); + } + + @Override + public JsonElement serialize(FloatingObjectModification src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject result = new JsonObject(); + result.add("dcpId", context.serialize(src.getDcpId())); + result.add("propertyName", context.serialize(src.getPropertyName())); + Serializable newValue = src.getNewValue(); + result.add("type", context.serialize(newValue == null ? String.class : newValue.getClass())); + result.add("newValue", context.serialize(newValue)); + return result; + } +} ===================================== services/src/main/java/fr/ird/observe/services/gson/ObserveDtoGsonSupplier.java ===================================== @@ -23,6 +23,7 @@ package fr.ird.observe.services.gson; */ import com.google.gson.GsonBuilder; +import fr.ird.observe.services.service.actions.consolidate.dcp.FloatingObjectModification; import fr.ird.observe.services.service.actions.report.ReportVariable; import io.ultreia.java4all.http.HResponseError; import io.ultreia.java4all.http.HResponseErrorAdapter; @@ -49,6 +50,7 @@ public class ObserveDtoGsonSupplier extends ObserveDtoGsonSupplierSupport { if (create) { gsonBuilder.registerTypeAdapter(ReportVariable.class, new ReportVariableAdapter()); gsonBuilder.registerTypeAdapter(HResponseError.class, new HResponseErrorAdapter()); + gsonBuilder.registerTypeAdapter(FloatingObjectModification.class, new FloatingObjectModificationAdapter()); } return gsonBuilder; ===================================== services/src/main/java/fr/ird/observe/services/service/actions/consolidate/dcp/FloatingObjectModification.java ===================================== @@ -22,6 +22,8 @@ package fr.ird.observe.services.service.actions.consolidate.dcp; * #L% */ +import fr.ird.observe.dto.ObserveDto; + import java.io.Serializable; /** @@ -29,7 +31,7 @@ import java.io.Serializable; * * @author Tony Chemit - dev(a)tchemit.fr */ -public class FloatingObjectModification implements Serializable { +public class FloatingObjectModification implements ObserveDto, Serializable { private static final long serialVersionUID = 1L; ===================================== services/src/main/java/fr/ird/observe/services/service/data/seine/FloatingObjectService.java ===================================== @@ -38,6 +38,7 @@ import fr.ird.observe.services.spi.Write; import fr.ird.observe.services.spi.WriteDataPermission; import io.ultreia.java4all.http.spi.Delete; import io.ultreia.java4all.http.spi.Get; +import io.ultreia.java4all.http.spi.Nullable; import io.ultreia.java4all.http.spi.Post; /** @@ -75,7 +76,7 @@ public interface FloatingObjectService extends ObserveService { @Get @WriteDataPermission - Form<FloatingObjectDto> preCreate(String activitySeineId, String floatingObjectPresetId); + Form<FloatingObjectDto> preCreate(String activitySeineId, @Nullable String floatingObjectPresetId); @Write @WriteDataPermission View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/716b1330ee45a26644115f691c0… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/716b1330ee45a26644115f691c0… 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
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.