Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

18 changed files:

Changes:

  • client/core/src/main/java/fr/ird/observe/client/main/ObserveMainUIHandler.java
    ... ... @@ -38,6 +38,8 @@ import org.nuiton.jaxx.runtime.swing.action.JAXXObjectActionSupport;
    38 38
     import org.nuiton.jaxx.widgets.error.ErrorDialogUI;
    
    39 39
     
    
    40 40
     import javax.swing.JComponent;
    
    41
    +import javax.swing.event.MenuEvent;
    
    42
    +import javax.swing.event.MenuListener;
    
    41 43
     import java.util.Locale;
    
    42 44
     
    
    43 45
     import static io.ultreia.java4all.i18n.I18n.t;
    
    ... ... @@ -103,6 +105,23 @@ public class ObserveMainUIHandler implements UIHandler<ObserveMainUI>, WithClien
    103 105
     
    
    104 106
             busyModel.addPropertyChangeListener(BusyModel.BUSY_PROPERTY_NAME, evt -> reload(model, config, busyModel));
    
    105 107
     
    
    108
    +        ui.getMenuLanguage().disabled();
    
    109
    +        ui.getMenuHelp().addMenuListener(new MenuListener() {
    
    110
    +            @Override
    
    111
    +            public void menuSelected(MenuEvent e) {
    
    112
    +                ui.getMenuLanguage().enabled();
    
    113
    +            }
    
    114
    +
    
    115
    +            @Override
    
    116
    +            public void menuDeselected(MenuEvent e) {
    
    117
    +                ui.getMenuLanguage().disabled();
    
    118
    +            }
    
    119
    +
    
    120
    +            @Override
    
    121
    +            public void menuCanceled(MenuEvent e) {
    
    122
    +                ui.getMenuLanguage().disabled();
    
    123
    +            }
    
    124
    +        });
    
    106 125
         }
    
    107 126
     
    
    108 127
         public void destroy() {
    

  • client/core/src/main/java/fr/ird/observe/client/util/JMenuWithAccelerator.java
    ... ... @@ -39,10 +39,25 @@ public class JMenuWithAccelerator extends JMenu {
    39 39
         private static final Logger log = LogManager.getLogger(JMenuWithAccelerator.class);
    
    40 40
     
    
    41 41
         private KeyStroke accelerator;
    
    42
    +    private boolean accessible;
    
    42 43
     
    
    43 44
         @Override
    
    44 45
         public KeyStroke getAccelerator() {
    
    45
    -        return accelerator;
    
    46
    +        return accessible ? accelerator : null;
    
    47
    +    }
    
    48
    +
    
    49
    +    public void enabled() {
    
    50
    +        KeyStroke oldValue = getAccelerator();
    
    51
    +        accessible = true;
    
    52
    +        repaint();
    
    53
    +        revalidate();
    
    54
    +        firePropertyChange("accelerator", oldValue, getAccelerator());
    
    55
    +    }
    
    56
    +
    
    57
    +    public void disabled() {
    
    58
    +        KeyStroke oldValue = getAccelerator();
    
    59
    +        accessible = false;
    
    60
    +        firePropertyChange("accelerator", oldValue, getAccelerator());
    
    46 61
         }
    
    47 62
     
    
    48 63
         @Override
    

  • client/core/src/main/java/fr/ird/observe/client/util/table/JXTableUtil.java
    ... ... @@ -116,7 +116,7 @@ public class JXTableUtil {
    116 116
                     return null;
    
    117 117
                 }
    
    118 118
                 Number reference = (Number) value;
    
    119
    -            if (reference.intValue() == 0) {
    
    119
    +            if (reference.doubleValue() == 0) {
    
    120 120
                     return null;
    
    121 121
                 }
    
    122 122
                 return reference.toString();
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUIModelStates.java
    ... ... @@ -61,7 +61,7 @@ public class ContentTableUIModelStates<D extends DataDto, C extends ContainerChi
    61 61
          */
    
    62 62
         private boolean canResetRow;
    
    63 63
         /**
    
    64
    -     * Pour savoir si on peut voir les données du l'écran.
    
    64
    +     * Pour savoir si on peut voir les données de l'écran.
    
    65 65
          * <p>
    
    66 66
          * Cela diffère du mode de l'écran, à utiliser par exemple pour les écrans
    
    67 67
          * d'échantillons lorsque aucune discarded n'est effectuée. on se retrouve en
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/menu/DataSourceEditorNavigationMenuHandler.java
    ... ... @@ -31,6 +31,8 @@ import io.ultreia.java4all.i18n.I18n;
    31 31
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    32 32
     
    
    33 33
     import javax.swing.JMenuItem;
    
    34
    +import javax.swing.event.MenuEvent;
    
    35
    +import javax.swing.event.MenuListener;
    
    34 36
     import java.beans.PropertyChangeEvent;
    
    35 37
     import java.beans.PropertyChangeListener;
    
    36 38
     
    
    ... ... @@ -65,6 +67,26 @@ public class DataSourceEditorNavigationMenuHandler implements UIHandler<DataSour
    65 67
             psContext = new DataSourceEditorNavigationModuleContext(ui, editModel.getPs());
    
    66 68
             llContext = new DataSourceEditorNavigationModuleContext(ui, editModel.getLl());
    
    67 69
     
    
    70
    +        ui.addMenuListener(new MenuListener() {
    
    71
    +            @Override
    
    72
    +            public void menuSelected(MenuEvent e) {
    
    73
    +                psContext.rootMenu.enabled();
    
    74
    +                llContext.rootMenu.enabled();
    
    75
    +            }
    
    76
    +
    
    77
    +            @Override
    
    78
    +            public void menuDeselected(MenuEvent e) {
    
    79
    +                psContext.rootMenu.disabled();
    
    80
    +                llContext.rootMenu.disabled();
    
    81
    +            }
    
    82
    +
    
    83
    +            @Override
    
    84
    +            public void menuCanceled(MenuEvent e) {
    
    85
    +                psContext.rootMenu.disabled();
    
    86
    +                llContext.rootMenu.disabled();
    
    87
    +            }
    
    88
    +        });
    
    89
    +
    
    68 90
             selectCommonReferential = new JMenuItem();
    
    69 91
             ObserveBusinessProject project = ObserveBusinessProject.get();
    
    70 92
             SelectReferentialAction.install(ui, ui.getPopupMenu(), selectCommonReferential, project.getCommonBusinessModule(), project.getCommonBusinessModule().getCommonBusinessSubModule());
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/menu/DataSourceEditorNavigationModuleContext.java
    ... ... @@ -64,8 +64,9 @@ public class DataSourceEditorNavigationModuleContext implements PropertyChangeLi
    64 64
             JMenuWithAccelerator rootMenu = new JMenuWithAccelerator();
    
    65 65
             KeyStroke keyStroke = MenuAction.getMenuKeyStroke(ui.getPopupMenu());
    
    66 66
             rootMenu.setAccelerator(keyStroke);
    
    67
    -        rootMenu.setMnemonic(keyStroke.getKeyChar());
    
    67
    +        rootMenu.setMnemonic((char) keyStroke.getKeyCode());
    
    68 68
             this.rootMenu = rootMenu;
    
    69
    +        this.rootMenu.disabled();
    
    69 70
             rootMenu.setText(I18n.t("observe.ui.menu.navigation." + editModel.getModel().toLowerCase()));
    
    70 71
             ui.add(rootMenu);
    
    71 72
             NavigationModelNode<?> node = editModel.getNode(1);
    
    ... ... @@ -75,7 +76,7 @@ public class DataSourceEditorNavigationModuleContext implements PropertyChangeLi
    75 76
             for (BusinessSubModule subModule : module.getSubModules()) {
    
    76 77
                 for (EditNode<?> editNode : nodes) {
    
    77 78
                     //FIXME We need to get a better order from persistence model
    
    78
    -                if (editNode.getSubModule().equals(subModule)) {
    
    79
    +                if (editNode.getSubModule().equals(subModule) && editNode.getLevel() > 0) {
    
    79 80
                         JMenuItem item = new JMenuItem();
    
    80 81
                         dataItems.add(item);
    
    81 82
                         SelectEditDataAction.install(ui, rootMenu.getPopupMenu(), item, editNode);
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/localmarket/TripBatchUI.jaxx
    ... ... @@ -111,8 +111,11 @@
    111 111
         </row>
    
    112 112
         <!-- origin -->
    
    113 113
         <row>
    
    114
    -      <cell columns='2'>
    
    115
    -        <BigTextEditor id="origin"/>
    
    114
    +      <cell>
    
    115
    +        <JLabel id='originLabel'/>
    
    116
    +      </cell>
    
    117
    +      <cell weightx='1' anchor='east'>
    
    118
    +        <NormalTextEditor id="origin"/>
    
    116 119
           </cell>
    
    117 120
         </row>
    
    118 121
       </Table>
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/localmarket/TripBatchUIModelStates.java
    ... ... @@ -53,10 +53,11 @@ import java.util.Set;
    53 53
     
    
    54 54
     @GenerateJavaBeanDefinition
    
    55 55
     public class TripBatchUIModelStates extends GeneratedTripBatchUIModelStates {
    
    56
    -    public static final Set<String> COMPUTE_PROPERTIES = Set.of(BatchDto.PROPERTY_WEIGHT, BatchDto.PROPERTY_PACKAGING);
    
    56
    +    public static final Set<String> COMPUTE_PROPERTIES = Set.of(BatchDto.PROPERTY_COUNT, BatchDto.PROPERTY_WEIGHT, BatchDto.PROPERTY_PACKAGING);
    
    57 57
         private static final Logger log = LogManager.getLogger(TripBatchUIModelStates.class);
    
    58 58
         private final ConsolidateDataService psConsolidateDataService;
    
    59 59
         private TripDto trip;
    
    60
    +    private boolean computing;
    
    60 61
     
    
    61 62
         public TripBatchUIModelStates(GeneratedTripBatchUIModel model) {
    
    62 63
             super(model);
    
    ... ... @@ -70,11 +71,19 @@ public class TripBatchUIModelStates extends GeneratedTripBatchUIModelStates {
    70 71
             if (context.getSelectModel().getPs().getCommonTrip().isEnabled()) {
    
    71 72
                 trip = context.getCurrentPsCommonTrip();
    
    72 73
             }
    
    73
    -        getTableEditBean().addPropertyChangeListener(this::recomputeComputedValues);
    
    74
    +        getTableEditBean().addPropertyChangeListener(BatchDto.PROPERTY_WEIGHT, this::resetComputedValues);
    
    75
    +        //TODO Do not compute it for the moment
    
    76
    +//        getTableEditBean().addPropertyChangeListener(this::recomputeComputedValues);
    
    74 77
             //FIXME Should come from node context not from here...
    
    75 78
     //        setShowData(getBean().isNotAvailablePackagingsEmpty());
    
    76 79
         }
    
    77 80
     
    
    81
    +    public void resetComputedValues(PropertyChangeEvent event) {
    
    82
    +        if (event.getNewValue() == null && getTableModel().isCanConsolidate()) {
    
    83
    +            getTableEditBean().setWeightComputedSource(null);
    
    84
    +        }
    
    85
    +    }
    
    86
    +    
    
    78 87
         public void recomputeComputedValues(PropertyChangeEvent event) {
    
    79 88
             String propertyName = event.getPropertyName();
    
    80 89
             if (!COMPUTE_PROPERTIES.contains(propertyName) || !getTableModel().isCanConsolidate()) {
    
    ... ... @@ -84,15 +93,29 @@ public class TripBatchUIModelStates extends GeneratedTripBatchUIModelStates {
    84 93
         }
    
    85 94
     
    
    86 95
         public void recomputeComputedValues() {
    
    87
    -        BatchConsolidateRequest request = new BatchConsolidateRequest();
    
    88
    -        request.setBatch(getTableEditBean());
    
    89
    -        request.setOceanId(trip.getOcean().getId());
    
    90
    -        request.setDate(trip.getEndDate());
    
    91
    -        request.setFailIfLengthWeightParameterNotFound(getClientConfig().isValidationLengthWeightEnable());
    
    92
    -        BatchConsolidateResult result = psConsolidateDataService.consolidateLocalmarketBatch(request);
    
    93
    -        if (result != null) {
    
    94
    -            log.info("Flush consolidate batch changes...");
    
    95
    -            result.flushToDto(getTableEditBean());
    
    96
    +        if (computing) {
    
    97
    +            return;
    
    98
    +        }
    
    99
    +        computing = true;
    
    100
    +
    
    101
    +        try {
    
    102
    +            log.info("Will recompute some values...");
    
    103
    +            BatchConsolidateRequest request = new BatchConsolidateRequest();
    
    104
    +            request.setBatch(getTableEditBean());
    
    105
    +            request.setOceanId(trip.getOcean().getId());
    
    106
    +            request.setDate(trip.getEndDate());
    
    107
    +            request.setFailIfLengthWeightParameterNotFound(false);
    
    108
    +            BatchConsolidateResult result = psConsolidateDataService.consolidateLocalmarketBatch(request);
    
    109
    +            if (result != null) {
    
    110
    +                log.info("Flush consolidate batch changes...");
    
    111
    +                result.flushToDto(getTableEditBean());
    
    112
    +                String lengthWeightParameterNotFound = result.getLengthWeightParameterNotFound();
    
    113
    +                if (lengthWeightParameterNotFound != null) {
    
    114
    +                    log.warn(lengthWeightParameterNotFound);
    
    115
    +                }
    
    116
    +            }
    
    117
    +        } finally {
    
    118
    +            computing = false;
    
    96 119
             }
    
    97 120
         }
    
    98 121
     
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/ActivityUIHandler.java
    ... ... @@ -43,8 +43,6 @@ class ActivityUIHandler extends GeneratedActivityUIHandler {
    43 43
             String text = t("observe.Common.vesselActivity.comment", label);
    
    44 44
             ui.vesselActivityInformation.setText(text);
    
    45 45
             ui.vesselActivityInformation.setToolTipText(text);
    
    46
    -        //FIXME if dto.time is null, then we have the current time :(
    
    47
    -        ui.getTime().reset();
    
    48 46
         }
    
    49 47
     
    
    50 48
         @Override
    

  • models/definition/src/main/models/Observe/dto/attribute/mayNotNull.properties
    ... ... @@ -56,6 +56,7 @@ data.ps.localmarket.SampleSampleSpecies.attribute.sampleSpecies=true
    56 56
     data.ps.logbook.Activity.attribute.currentDirection=true
    
    57 57
     data.ps.logbook.Activity.attribute.relatedObservedActivity=true
    
    58 58
     data.ps.logbook.Activity.attribute.seaSurfaceTemperature=true
    
    59
    +data.ps.logbook.Activity.attribute.time=true
    
    59 60
     data.ps.logbook.Activity.attribute.wind=true
    
    60 61
     data.ps.logbook.Catch.attribute.weightCategory=true
    
    61 62
     data.ps.logbook.Route.attribute.comment=true
    

  • models/dto/java/src/main/java/fr/ird/observe/dto/data/ps/localmarket/BatchWeightComputedValueSource.java
    ... ... @@ -49,6 +49,6 @@ public enum BatchWeightComputedValueSource {
    49 49
         }
    
    50 50
         @Override
    
    51 51
         public String toString() {
    
    52
    -        return super.toString();
    
    52
    +        return getLabel();
    
    53 53
         }
    
    54 54
     }

  • models/dto/java/src/main/resources/observe-reports.properties
    ... ... @@ -1298,7 +1298,7 @@ Date départ,\
    1298 1298
     Date arrivée,\
    
    1299 1299
     Date de l'échantillon,\
    
    1300 1300
     Cuves,\
    
    1301
    -Composition du l'échantillon (tuple espèce - type de mesure - classe de taille - effectif),\
    
    1301
    +Composition de l'échantillon (tuple espèce - type de mesure - classe de taille - effectif),\
    
    1302 1302
     Commentaire
    
    1303 1303
     report.psLocalmarketSample.operations.1=ComputeLocalmarketSampleWellAndSpeciesMeasure
    
    1304 1304
     report.psLocalmarketSample.repeatVariable.sampleId=java.lang.String|\
    

  • pom.xml
    ... ... @@ -24,7 +24,7 @@
    24 24
       <parent>
    
    25 25
         <groupId>io.ultreia.maven</groupId>
    
    26 26
         <artifactId>pom</artifactId>
    
    27
    -    <version>2021.95</version>
    
    27
    +    <version>2021.96</version>
    
    28 28
       </parent>
    
    29 29
     
    
    30 30
       <groupId>fr.ird.observe</groupId>
    

  • services/api-test/src/main/resources/fixtures/fr/ird/observe/services/service/actions/report/ReportService.properties
    ... ... @@ -355,7 +355,7 @@ psLocalmarketSample.result.1=483^CAP BOJADOR^30/3/2019^8/4/2019^27/3/2021^3B, 3T
    355 355
     psLocalmarketSample.result.columns=8
    
    356 356
     psLocalmarketSample.result.rows=2
    
    357 357
     psLocalmarketSample.syntax.columns=8
    
    358
    -psLocalmarketSample.syntax.columnsHeader=Code bateau^Nom bateau^Date départ^Date arrivée^Date de l'échantillon^Cuves^Composition du l'échantillon (tuple espèce - type de mesure - classe de taille - effectif)^Commentaire
    
    358
    +psLocalmarketSample.syntax.columnsHeader=Code bateau^Nom bateau^Date départ^Date arrivée^Date de l'échantillon^Cuves^Composition de l'échantillon (tuple espèce - type de mesure - classe de taille - effectif)^Commentaire
    
    359 359
     psLocalmarketSample.syntax.description=Marché local - Échantillons
    
    360 360
     psLocalmarketSample.syntax.name=Marché local - Échantillons
    
    361 361
     psLocalmarketSample.syntax.nbRequests=1
    

  • services/i18n/src/main/i18n/translations/services_en_GB.properties
    ... ... @@ -408,7 +408,7 @@ observe.common.exist.on.remote=%1$s (already exist)
    408 408
     observe.constant.AcquisitionMode.individual=By individu
    
    409 409
     observe.constant.AcquisitionMode.number=By effectif
    
    410 410
     observe.constant.BatchWeightComputedValueSource.fromPackagingMeanWeight=Computed from packaging mean weight
    
    411
    -observe.constant.BatchWeightComputedValueSource.fromSpeciesMeanWeight=Computed from species mean weight
    
    411
    +<F extends DataDto&FloatingObjectAware, P extends DataDto&FloatingObjectPartAware>Computed from species mean weight
    
    412 412
     observe.constant.CatchAcquisitionMode.GROUPED=Batch
    
    413 413
     observe.constant.CatchAcquisitionMode.INDIVIDUAL=Individual
    
    414 414
     observe.constant.CatchComputedValueSource.fromData=Computed from data
    

  • services/i18n/src/main/i18n/translations/services_fr_FR.properties
    ... ... @@ -408,7 +408,7 @@ observe.common.exist.on.remote=%1$s (déjà existante)
    408 408
     observe.constant.AcquisitionMode.individual=Saisie par individu
    
    409 409
     observe.constant.AcquisitionMode.number=Saisie par nombre
    
    410 410
     observe.constant.BatchWeightComputedValueSource.fromPackagingMeanWeight=Calculé depuis le poids moyen du conditionnement
    
    411
    -observe.constant.BatchWeightComputedValueSource.fromSpeciesMeanWeight=Calculé depuis le poids moyen de l'espèceobserve.constant.BatchWeightComputedValueSource.fromPackagingMeanWeight\=
    
    411
    +observe.constant.BatchWeightComputedValueSource.fromSpeciesMeanWeight=Calculé depuis le poids moyen de l'espèce
    
    412 412
     observe.constant.CatchAcquisitionMode.GROUPED=Groupé
    
    413 413
     observe.constant.CatchAcquisitionMode.INDIVIDUAL=Par individu
    
    414 414
     observe.constant.CatchComputedValueSource.fromData=calculé à partir des autres données
    

  • services/validation/src/main/validation/fr/ird/observe/dto/data/ps/localmarket/BatchDto-create-warning-validation.xml
    ... ... @@ -23,15 +23,6 @@
    23 23
         "-//Apache Struts//XWork Validator 1.0.3//EN"
    
    24 24
         "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
    
    25 25
     <validators>
    
    26
    -  <field name="count">
    
    27
    -    <!-- count is mandatory except if countOrWeightValid -->
    
    28
    -    <field-validator type="fieldexpression" short-circuit="true">
    
    29
    -      <param name="expression">
    
    30
    -        <![CDATA[ countOrWeightValid ]]>
    
    31
    -      </param>
    
    32
    -      <message>observe.data.ps.localmarket.Batch.count.validation.required</message>
    
    33
    -    </field-validator>
    
    34
    -  </field>
    
    35 26
       <field name="date">
    
    36 27
         <!-- date >= trip.endDate and max delay is 5 days  -->
    
    37 28
         <field-validator type="dayAfter" short-circuit="true">
    
    ... ... @@ -41,14 +32,5 @@
    41 32
           <message>observe.data.ps.localmarket.Batch.validation.date.after.currentTrip.endDate##${startDate}##${endDate}</message>
    
    42 33
         </field-validator>
    
    43 34
       </field>
    
    44
    -  <field name="weight">
    
    45
    -    <!-- weight is mandatory except if countOrWeightValid -->
    
    46
    -    <field-validator type="fieldexpression" short-circuit="true">
    
    47
    -      <param name="expression">
    
    48
    -        <![CDATA[ countOrWeightValid ]]>
    
    49
    -      </param>
    
    50
    -      <message>observe.data.ps.localmarket.Batch.count.validation.required</message>
    
    51
    -    </field-validator>
    
    52
    -  </field>
    
    53 35
     
    
    54 36
     </validators>

  • services/validation/src/main/validation/fr/ird/observe/dto/data/ps/localmarket/BatchDto-update-warning-validation.xml
    ... ... @@ -23,15 +23,6 @@
    23 23
         "-//Apache Struts//XWork Validator 1.0.3//EN"
    
    24 24
         "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
    
    25 25
     <validators>
    
    26
    -  <field name="count">
    
    27
    -    <!-- count is mandatory except if countOrWeightValid -->
    
    28
    -    <field-validator type="fieldexpression" short-circuit="true">
    
    29
    -      <param name="expression">
    
    30
    -        <![CDATA[ countOrWeightValid ]]>
    
    31
    -      </param>
    
    32
    -      <message>observe.data.ps.localmarket.Batch.count.validation.required</message>
    
    33
    -    </field-validator>
    
    34
    -  </field>
    
    35 26
       <field name="date">
    
    36 27
         <!-- date >= trip.endDate and max delay is 5 days  -->
    
    37 28
         <field-validator type="dayAfter" short-circuit="true">
    
    ... ... @@ -41,14 +32,5 @@
    41 32
           <message>observe.data.ps.localmarket.Batch.validation.date.after.currentTrip.endDate##${startDate}##${endDate}</message>
    
    42 33
         </field-validator>
    
    43 34
       </field>
    
    44
    -  <field name="weight">
    
    45
    -    <!-- weight is mandatory except if countOrWeightValid -->
    
    46
    -    <field-validator type="fieldexpression" short-circuit="true">
    
    47
    -      <param name="expression">
    
    48
    -        <![CDATA[ countOrWeightValid ]]>
    
    49
    -      </param>
    
    50
    -      <message>observe.data.ps.localmarket.Batch.count.validation.required</message>
    
    51
    -    </field-validator>
    
    52
    -  </field>
    
    53 35
     
    
    54 36
     </validators>