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

Commits:

5 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java
    ... ... @@ -46,8 +46,8 @@ import fr.ird.observe.dto.navigation.edit.ObserveLonglineEditModel;
    46 46
     import fr.ird.observe.dto.navigation.edit.ObserveSeineEditModel;
    
    47 47
     import fr.ird.observe.dto.navigation.select.ObserveSelectModel;
    
    48 48
     import fr.ird.observe.dto.referential.ReferentialLocale;
    
    49
    -import org.apache.logging.log4j.Logger;
    
    50 49
     import org.apache.logging.log4j.LogManager;
    
    50
    +import org.apache.logging.log4j.Logger;
    
    51 51
     import org.nuiton.i18n.I18n;
    
    52 52
     import org.nuiton.jaxx.runtime.context.JAXXInitialContext;
    
    53 53
     import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel;
    
    ... ... @@ -231,14 +231,15 @@ public class ObserveMainUIInitializer {
    231 231
             List<ReferenceNavigationTreeNodeSupport<?, ?>> ids = new ArrayList<>();
    
    232 232
             for (Object o : nodes) {
    
    233 233
                 NavigationTreeNodeSupport n = (NavigationTreeNodeSupport) o;
    
    234
    -            if (n instanceof ReferenceNavigationTreeNodeSupport && n.getSelectNode().isDisabled()) {
    
    235
    -                n.getSelectNode().setId(n.getId());
    
    234
    +            if (n instanceof ReferenceNavigationTreeNodeSupport) {
    
    235
    +                log.info("Keep node with id: " + n.getId());
    
    236 236
                     ids.add((ReferenceNavigationTreeNodeSupport<?, ?>) n);
    
    237 237
                 }
    
    238 238
             }
    
    239 239
             ObserveSelectModel navigationSelect = ObserveSwingApplicationContext.get().getNavigationSelect();
    
    240 240
             navigationSelect.clear();
    
    241 241
             for (ReferenceNavigationTreeNodeSupport<?, ?> node : ids) {
    
    242
    +            log.info("Apply to select model: " + node);
    
    242 243
                 node.getSelectNode().setId(node.getId());
    
    243 244
             }
    
    244 245
     
    

  • client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java
    ... ... @@ -429,6 +429,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U
    429 429
     
    
    430 430
             NavigationTreeNodeSupport parentNode = treeHelper.getSelectedNode().getParent();
    
    431 431
             log.debug("PARENT NODE = " + parentNode);
    
    432
    +        getSelectedNode().setId(null);
    
    432 433
             treeHelper.addUnsavedNode(parentNode, getBeanType());
    
    433 434
         }
    
    434 435
     
    

  • client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUIHandler.java
    ... ... @@ -35,8 +35,8 @@ import fr.ird.observe.dto.navigation.edit.node.ObserveLonglineLogbookActivityEdi
    35 35
     import fr.ird.observe.dto.navigation.select.node.ObserveLonglineLogbookActivitySelectNode;
    
    36 36
     import fr.ird.observe.dto.reference.DataDtoReference;
    
    37 37
     import fr.ird.observe.dto.result.TripChildSaveResultDto;
    
    38
    -import org.apache.logging.log4j.Logger;
    
    39 38
     import org.apache.logging.log4j.LogManager;
    
    39
    +import org.apache.logging.log4j.Logger;
    
    40 40
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    41 41
     import org.nuiton.validator.NuitonValidatorScope;
    
    42 42
     
    
    ... ... @@ -55,6 +55,7 @@ import static org.nuiton.i18n.I18n.t;
    55 55
     class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<ActivityLonglineLogbookDto, ActivityLonglineLogbookUI> implements UIHandler<ActivityLonglineLogbookUI> {
    
    56 56
     
    
    57 57
         private static final Logger log = LogManager.getLogger(ActivityLonglineLogbookUIHandler.class);
    
    58
    +    private boolean addSet;
    
    58 59
     
    
    59 60
         ActivityLonglineLogbookUIHandler() {
    
    60 61
             super(ObserveLonglineLogbookActivitySelectNode.class, ObserveLonglineLogbookActivityEditNode.class, n("observe.common.ActivityLonglineLogbookDto.message.not.open"));
    
    ... ... @@ -214,12 +215,10 @@ class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<Activity
    214 215
             if (notPersisted) {
    
    215 216
                 // ouverture de l'activité après création
    
    216 217
                 getEditNode().setId(bean.getId());
    
    217
    -            if (ActivityLonglineLogbookHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId())) {
    
    218
    -                // création de l'opération de pêche
    
    219
    -                SwingUtilities.invokeLater(() -> getUi().getAddSet().doClick());
    
    220
    -            }
    
    221 218
             }
    
    222 219
     
    
    220
    +        addSet = notPersisted && ActivityLonglineLogbookHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId());
    
    221
    +
    
    223 222
             return true;
    
    224 223
         }
    
    225 224
     
    
    ... ... @@ -253,6 +252,17 @@ class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<Activity
    253 252
         protected void afterSave(boolean refresh) {
    
    254 253
             super.afterSave(refresh);
    
    255 254
             repaintTripNode();
    
    255
    +        if (addSet) {
    
    256
    +            try {
    
    257
    +                // création de l'opération de pêche
    
    258
    +                // FIXME On doit effectuer l'action sur l'ui rechargée car pour executer une action on regarde si son éditeur
    
    259
    +                // FIXME est showing et dans ce cas précis ce n'est pas vrai (getUI() retourne l'ui avant resélection du noeud...
    
    260
    +                ActivityLonglineLogbookUI content = ObserveSwingApplicationContext.get().getContentUIManager().getContent();
    
    261
    +                SwingUtilities.invokeLater(() -> content.getAddSet().doClick());
    
    262
    +            } finally {
    
    263
    +                addSet = false;
    
    264
    +            }
    
    265
    +        }
    
    256 266
         }
    
    257 267
     
    
    258 268
         @Override
    

  • client/src/main/java/fr/ird/observe/client/ui/content/data/longline/obs/ActivityLonglineObsUIHandler.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.content.data.longline.obs;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -35,8 +35,8 @@ import fr.ird.observe.dto.navigation.edit.node.ObserveLonglineObsActivityEditNod
    35 35
     import fr.ird.observe.dto.navigation.select.node.ObserveLonglineObsActivitySelectNode;
    
    36 36
     import fr.ird.observe.dto.reference.DataDtoReference;
    
    37 37
     import fr.ird.observe.dto.result.TripChildSaveResultDto;
    
    38
    -import org.apache.logging.log4j.Logger;
    
    39 38
     import org.apache.logging.log4j.LogManager;
    
    39
    +import org.apache.logging.log4j.Logger;
    
    40 40
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    41 41
     import org.nuiton.validator.NuitonValidatorScope;
    
    42 42
     
    
    ... ... @@ -55,6 +55,7 @@ import static org.nuiton.i18n.I18n.t;
    55 55
     class ActivityLonglineObsUIHandler extends ContentOpenableUIHandler<ActivityLonglineObsDto, ActivityLonglineObsUI> implements UIHandler<ActivityLonglineObsUI> {
    
    56 56
     
    
    57 57
         private static final Logger log = LogManager.getLogger(ActivityLonglineObsUIHandler.class);
    
    58
    +    private boolean addSet;
    
    58 59
     
    
    59 60
         ActivityLonglineObsUIHandler() {
    
    60 61
             super(ObserveLonglineObsActivitySelectNode.class, ObserveLonglineObsActivityEditNode.class, n("observe.common.ActivityLonglineObsDto.message.not.open"));
    
    ... ... @@ -213,12 +214,10 @@ class ActivityLonglineObsUIHandler extends ContentOpenableUIHandler<ActivityLong
    213 214
     
    
    214 215
             if (notPersisted) {
    
    215 216
                 // ouverture de l'activité après création
    
    216
    -            getEditNode().setId(null);
    
    217
    -            if (ActivityLonglineObsHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId())) {
    
    218
    -                // création de l'opération de pêche
    
    219
    -                SwingUtilities.invokeLater(() -> getUi().getAddSet().doClick());
    
    220
    -            }
    
    217
    +            getEditNode().setId(bean.getId());
    
    221 218
             }
    
    219
    +        addSet = notPersisted && ActivityLonglineObsHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId());
    
    220
    +
    
    222 221
             return true;
    
    223 222
         }
    
    224 223
     
    
    ... ... @@ -251,6 +250,17 @@ class ActivityLonglineObsUIHandler extends ContentOpenableUIHandler<ActivityLong
    251 250
         protected void afterSave(boolean refresh) {
    
    252 251
             super.afterSave(refresh);
    
    253 252
             repaintTripNode();
    
    253
    +        if (addSet) {
    
    254
    +            try {
    
    255
    +                // création de l'opération de pêche
    
    256
    +                // FIXME On doit effectuer l'action sur l'ui rechargée car pour executer une action on regarde si son éditeur
    
    257
    +                // FIXME est showing et dans ce cas précis ce n'est pas vrai (getUI() retourne l'ui avant resélection du noeud...
    
    258
    +                ActivityLonglineObsUI content = ObserveSwingApplicationContext.get().getContentUIManager().getContent();
    
    259
    +                SwingUtilities.invokeLater(() -> content.getAddSet().doClick());
    
    260
    +            } finally {
    
    261
    +                addSet = false;
    
    262
    +            }
    
    263
    +        }
    
    254 264
         }
    
    255 265
     
    
    256 266
         @Override
    

  • client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTree.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.tree.navigation;
    10 10
      * it under the terms of the GNU General Public License as
    
    11 11
      * published by the Free Software Foundation, either version 3 of the
    
    12 12
      * License, or (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU General Public
    
    20 20
      * License along with this program.  If not, see
    
    21 21
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -74,8 +74,8 @@ import fr.ird.observe.dto.referential.ProgramReference;
    74 74
     import fr.ird.observe.dto.referential.ReferentialLocale;
    
    75 75
     import fr.ird.observe.spi.DtoModelHelper;
    
    76 76
     import org.apache.commons.collections4.CollectionUtils;
    
    77
    -import org.apache.logging.log4j.Logger;
    
    78 77
     import org.apache.logging.log4j.LogManager;
    
    78
    +import org.apache.logging.log4j.Logger;
    
    79 79
     import org.jdesktop.swingx.JXTree;
    
    80 80
     
    
    81 81
     import javax.swing.SwingUtilities;
    
    ... ... @@ -104,15 +104,19 @@ public class NavigationTree extends JXTree {
    104 104
     
    
    105 105
         private static final Logger log = LogManager.getLogger(NavigationTree.class);
    
    106 106
         private final ImmutableList<SelectNodeStrategy> selectNodeStrategies;
    
    107
    +    private boolean skipContentCheck;
    
    107 108
     
    
    108 109
         public NavigationTree() {
    
    109 110
             super(new NavigationTreeModel());
    
    110 111
             setSelectionModel(new DefaultTreeSelectionModel() {
    
    111 112
                 @Override
    
    112 113
                 public void setSelectionPath(TreePath path) {
    
    113
    -                boolean canChange = !Objects.equals(path, getSelectionPath()) && ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI();
    
    114
    +                boolean skipContentCheck = NavigationTree.this.skipContentCheck;
    
    115
    +                NavigationTree.this.skipContentCheck = false;
    
    116
    +                boolean canChange = !Objects.equals(path, getSelectionPath()) && (skipContentCheck || ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI());
    
    114 117
                     if (!canChange) {
    
    115 118
                         // cancel the change of node
    
    119
    +                    log.warn(String.format("Do not change selection path: %s against: %s", path, getSelectionPath()));
    
    116 120
                         return;
    
    117 121
                     }
    
    118 122
                     super.setSelectionPath(path);
    
    ... ... @@ -207,7 +211,7 @@ public class NavigationTree extends JXTree {
    207 211
                 log.info("try to select node [" + node + "]");
    
    208 212
             }
    
    209 213
             TreePath path = new TreePath(getTreeModel().getPathToRoot(node));
    
    210
    -
    
    214
    +        skipContentCheck = true;
    
    211 215
             setSelectionPath(path);
    
    212 216
             SwingUtilities.invokeLater(() -> scrollPathToVisible(path));
    
    213 217
         }