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

Commits:

2 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java
    ... ... @@ -1196,7 +1196,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U
    1196 1196
             return getModel().getBean();
    
    1197 1197
         }
    
    1198 1198
     
    
    1199
    -    void openedUI() {
    
    1199
    +    protected void openedUI() {
    
    1200 1200
             SwingUtilities.invokeLater(this::forceGrabFocusOnForm);
    
    1201 1201
         }
    
    1202 1202
     
    

  • client/src/main/java/fr/ird/observe/client/ui/content/data/seine/FloatingObjectUIHandler.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU General Public License as
    
    9 9
      * published by the Free Software Foundation, either version 3 of the
    
    10 10
      * License, or (at your option) any later version.
    
    11
    - * 
    
    11
    + *
    
    12 12
      * This program is distributed in the hope that it will be useful,
    
    13 13
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14 14
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15 15
      * GNU General Public License for more details.
    
    16
    - * 
    
    16
    + *
    
    17 17
      * You should have received a copy of the GNU General Public
    
    18 18
      * License along with this program.  If not, see
    
    19 19
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -27,6 +27,7 @@ import fr.ird.observe.client.db.ClientDataContext;
    27 27
     import fr.ird.observe.client.db.ObserveSwingDataSource;
    
    28 28
     import fr.ird.observe.client.db.constants.DataContextType;
    
    29 29
     import fr.ird.observe.client.ui.content.ContentMode;
    
    30
    +import fr.ird.observe.client.ui.content.ContentUI;
    
    30 31
     import fr.ird.observe.client.ui.content.ContentUIHandler;
    
    31 32
     import fr.ird.observe.client.ui.content.ContentUIModel;
    
    32 33
     import fr.ird.observe.client.ui.content.ObserveLayoutFocusTraversalPolicy;
    
    ... ... @@ -193,8 +194,12 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    193 194
             if (mode != ContentMode.READ) {
    
    194 195
                 getUi().startEdit(null);
    
    195 196
             }
    
    197
    +    }
    
    196 198
     
    
    199
    +    @Override
    
    200
    +    protected void openedUI() {
    
    197 201
             SwingUtilities.invokeLater(() -> ui.getMainTabbedPane().setSelectedIndex(0));
    
    202
    +        super.openedUI();
    
    198 203
         }
    
    199 204
     
    
    200 205
         @Override
    
    ... ... @@ -213,14 +218,14 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    213 218
             getUi().getValidator().setContext(contextName);
    
    214 219
             if (create) {
    
    215 220
                 addMessage(getUi(),
    
    216
    -                    NuitonValidatorScope.INFO,
    
    217
    -                    getTypeI18nKey(FloatingObjectDto.class),
    
    218
    -                    t("observe.common.FloatingObjectDto.message.creating"));
    
    221
    +                       NuitonValidatorScope.INFO,
    
    222
    +                       getTypeI18nKey(FloatingObjectDto.class),
    
    223
    +                       t("observe.common.FloatingObjectDto.message.creating"));
    
    219 224
             } else {
    
    220 225
                 addMessage(getUi(),
    
    221
    -                    NuitonValidatorScope.INFO,
    
    222
    -                    getTypeI18nKey(FloatingObjectDto.class),
    
    223
    -                    t("observe.common.FloatingObjectDto.message.updating"));
    
    226
    +                       NuitonValidatorScope.INFO,
    
    227
    +                       getTypeI18nKey(FloatingObjectDto.class),
    
    228
    +                       t("observe.common.FloatingObjectDto.message.updating"));
    
    224 229
             }
    
    225 230
             super.startEditUI(FloatingObjectUI.BINDING_COMMENT_MODEL);
    
    226 231
             contentUIModel.setModified(create);
    
    ... ... @@ -263,11 +268,19 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    263 268
                 FloatingObjectReference reference = DtoModelHelper.fromDataDto(FloatingObjectDto.class).toReference(getDecoratorService().getReferentialLocale(), bean);
    
    264 269
                 node = treeHelper.addFloatingObject(parentNode, reference);
    
    265 270
                 stopEditUI();
    
    271
    +            int selectedIndex = ui.getMainTabbedPane().getSelectedIndex();
    
    266 272
                 if (refresh) {
    
    267
    -                treeHelper.selectSafeNode(node);
    
    273
    +                try {
    
    274
    +                    treeHelper.selectSafeNode(node);
    
    275
    +                } finally {
    
    276
    +                    if (selectedIndex > 0) {
    
    277
    +                        // use new ui!
    
    278
    +                        FloatingObjectUI content = ObserveSwingApplicationContext.get().getContentUIManager().getContent();
    
    279
    +                        SwingUtilities.invokeLater(() -> content.getMainTabbedPane().setSelectedIndex(selectedIndex));
    
    280
    +                    }
    
    281
    +                }
    
    268 282
                 }
    
    269 283
             } else {
    
    270
    -
    
    271 284
                 treeHelper.refreshSelectedNode();
    
    272 285
             }
    
    273 286
         }