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

Commits:

15 changed files:

Changes:

  • client/core/src/main/java/fr/ird/observe/client/util/init/UIInitHelper.java
    ... ... @@ -24,18 +24,21 @@ package fr.ird.observe.client.util.init;
    24 24
     
    
    25 25
     import org.jdesktop.swingx.painter.Painter;
    
    26 26
     
    
    27
    +import javax.swing.ActionMap;
    
    27 28
     import javax.swing.InputMap;
    
    28 29
     import javax.swing.JComponent;
    
    29 30
     import javax.swing.JScrollBar;
    
    30 31
     import javax.swing.JScrollPane;
    
    31 32
     import javax.swing.JSplitPane;
    
    32 33
     import javax.swing.JTabbedPane;
    
    34
    +import javax.swing.JTable;
    
    33 35
     import javax.swing.JToolBar;
    
    34 36
     import javax.swing.JTree;
    
    35 37
     import javax.swing.KeyStroke;
    
    36 38
     import javax.swing.UIDefaults;
    
    37 39
     import java.awt.Color;
    
    38 40
     import java.awt.event.KeyEvent;
    
    41
    +import java.util.Arrays;
    
    39 42
     
    
    40 43
     /**
    
    41 44
      * To manage init of our ui.
    
    ... ... @@ -62,7 +65,7 @@ public class UIInitHelper {
    62 65
                 "fr.ird.observe.client.ui.admin.actions.CopyToClipBoard"
    
    63 66
         };
    
    64 67
         public static final Class<?>[] ACCEPTABLE_COMPONENTS_TYPE = {
    
    65
    -            JScrollBar.class, JTabbedPane.class
    
    68
    +            JScrollBar.class, JTabbedPane.class, JTable.class
    
    66 69
         };
    
    67 70
     
    
    68 71
         public static void init(JScrollPane selectedTreePane, JTree tree) {
    
    ... ... @@ -97,4 +100,14 @@ public class UIInitHelper {
    97 100
             editor.setOpaque(false);
    
    98 101
         }
    
    99 102
     
    
    103
    +    public static void cleanInputMapAndSet(JComponent editor, KeyStroke[] keyStrokes, InputMap newInputMap, ActionMap newActionMap) {
    
    104
    +        cleanInputMap(editor, keyStrokes);
    
    105
    +        editor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(newInputMap);
    
    106
    +        editor.getActionMap().setParent(newActionMap);
    
    107
    +    }
    
    108
    +
    
    109
    +    public static void cleanInputMap(JComponent editor, KeyStroke[] keyStrokes) {
    
    110
    +        InputMap map = editor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    
    111
    +        Arrays.stream(keyStrokes).forEach(uiActionKeyStroke -> map.put(uiActionKeyStroke, "none"));
    
    112
    +    }
    
    100 113
     }

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIHandler.java
    ... ... @@ -134,8 +134,6 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe
    134 134
             log.info(String.format("%sInit ui", prefix));
    
    135 135
             DefaultUIInitializerResult initializerResult = contentOpen.init(initializer);
    
    136 136
     
    
    137
    -        onInit(ui);
    
    138
    -
    
    139 137
             installFocusTraversalPolicy();
    
    140 138
             model.getStates().addPropertyChangeListener(ContentUIModelStates.PROPERTY_FORM_FOCUS_OWNER, evt -> onFormFocusOwnerChanged((JComponent) evt.getNewValue()));
    
    141 139
             installPermanentFocusOwnerListener();
    
    ... ... @@ -181,14 +179,11 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe
    181 179
             action.doAction();
    
    182 180
         }
    
    183 181
     
    
    182
    +    @SuppressWarnings("unchecked")
    
    184 183
         public final void resetFromPreviousUi(ContentUI ui) {
    
    185 184
             contentOpen.resetFromPreviousUi((U) ui);
    
    186 185
         }
    
    187 186
     
    
    188
    -    public final void restartEditUI() {
    
    189
    -        contentOpen.restartEditUI();
    
    190
    -    }
    
    191
    -
    
    192 187
         public final void destroyUI() {
    
    193 188
             if (ui == null) {
    
    194 189
                 return;
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIInitializer.java
    ... ... @@ -78,12 +78,12 @@ import javax.swing.JList;
    78 78
     import javax.swing.JScrollBar;
    
    79 79
     import javax.swing.JSplitPane;
    
    80 80
     import javax.swing.JTabbedPane;
    
    81
    +import javax.swing.JTable;
    
    81 82
     import javax.swing.JToolBar;
    
    82 83
     import javax.swing.KeyStroke;
    
    83 84
     import javax.swing.ListCellRenderer;
    
    84 85
     import java.awt.Component;
    
    85 86
     import java.awt.Dimension;
    
    86
    -import java.awt.event.KeyEvent;
    
    87 87
     import java.util.ArrayList;
    
    88 88
     import java.util.Collection;
    
    89 89
     import java.util.Collections;
    
    ... ... @@ -125,11 +125,12 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup
    125 125
                 NormalTextEditor.class,
    
    126 126
                 ContentUI.class,
    
    127 127
                 Table.class,
    
    128
    +            JTable.class,
    
    128 129
                 JTabbedPane.class
    
    129 130
         };
    
    130 131
         protected final UI ui;
    
    131 132
         protected final DecoratorService decoratorService;
    
    132
    -    private final Class<?>[] acceptedClassesInBlockingLayer = new Class[]{TripMapUI.class, ObserveMapPane.class, JScrollBar.class, JTabbedPane.class};
    
    133
    +    protected final Class<?>[] acceptedClassesInBlockingLayer = new Class[]{TripMapUI.class, JTable.class, /*NotStandaloneContentUI.class,*/ ObserveMapPane.class, JScrollBar.class, JTabbedPane.class};
    
    133 134
         private final boolean isParentUI;
    
    134 135
     
    
    135 136
         public ContentUIInitializer(UI ui) {
    
    ... ... @@ -202,6 +203,7 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup
    202 203
                     .onComponents(NormalTextEditor.class, this::init)
    
    203 204
                     .onSubComponents(ContentUI.class, this::init)
    
    204 205
                     .onComponents(Table.class, this::init)
    
    206
    +                .onComponents(JTable.class, true, this::init)
    
    205 207
                     .startSecondPass()
    
    206 208
                     .onSubComponents(JTabbedPane.class, this::init)
    
    207 209
                     .onSubComponents(BlockingLayerUI.class, this::init);
    
    ... ... @@ -278,10 +280,13 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup
    278 280
     
    
    279 281
         private void init(JLabel editor) {
    
    280 282
             initializerContext.checkFirstPass();
    
    281
    -        String editorName = StringUtils.removeEnd(editor.getName(), "Label");
    
    282
    -        Object objectById = ui.getObjectById(editorName);
    
    283
    -        if (objectById instanceof JComponent) {
    
    284
    -            editor.setLabelFor((Component) objectById);
    
    283
    +        String editorName = editor.getName();
    
    284
    +        if (editorName.endsWith("Label")) {
    
    285
    +            editorName = StringUtils.removeEnd(editorName, "Label");
    
    286
    +            Object objectById = ui.getObjectById(editorName);
    
    287
    +            if (objectById instanceof JComponent) {
    
    288
    +                editor.setLabelFor((Component) objectById);
    
    289
    +            }
    
    285 290
             }
    
    286 291
         }
    
    287 292
     
    
    ... ... @@ -309,13 +314,13 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup
    309 314
             JTextComponents.addAutoSelect(editor.getTextField());
    
    310 315
         }
    
    311 316
     
    
    317
    +    public JComponent getActionContainer() {
    
    318
    +        return ui;
    
    319
    +    }
    
    320
    +
    
    312 321
         @SuppressWarnings({"unchecked", "rawtypes"})
    
    313 322
         protected void init(JaxxComboBox editor) {
    
    314 323
             initializerContext.checkFirstPass();
    
    315
    -        InputMap inputMap = editor.getCombobox().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    
    316
    -        inputMap.setParent(ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
    
    317
    -        editor.getCombobox().getActionMap().setParent(ui.getActionMap());
    
    318
    -        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none");
    
    319 324
             @SuppressWarnings({"RawTypeCanBeGeneric", "rawtypes"}) Class referenceType = editor.getBeanType();
    
    320 325
             editor.setI18nPrefix("observe.common.");
    
    321 326
             editor.setAutoSelectContent(true);
    
    ... ... @@ -471,6 +476,11 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup
    471 476
             initializerContext.checkFirstPass();
    
    472 477
         }
    
    473 478
     
    
    479
    +    private void init(JTable editor) {
    
    480
    +        initializerContext.checkFirstPass();
    
    481
    +//        UIInitHelper.init(editor);
    
    482
    +    }
    
    483
    +
    
    474 484
         @SuppressWarnings({"unchecked", "rawtypes"})
    
    475 485
         private <R extends DataDtoReference> void prepareDataFilterableDoubleList(Class<R> dtoClass, FilterableDoubleList<R> editor) {
    
    476 486
             DataReferenceDecorator<R> decorator = decoratorService.getDataReferenceDecorator(dtoClass);
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/open/ContentOpen.java
    ... ... @@ -40,13 +40,16 @@ import fr.ird.observe.client.datasource.validation.ClientValidationContext;
    40 40
     import fr.ird.observe.client.util.UIHelper;
    
    41 41
     import fr.ird.observe.client.util.init.DefaultUIInitializer;
    
    42 42
     import fr.ird.observe.client.util.init.DefaultUIInitializerResult;
    
    43
    +import fr.ird.observe.client.util.init.UIInitHelper;
    
    43 44
     import fr.ird.observe.dto.IdDto;
    
    44 45
     import fr.ird.observe.dto.form.Form;
    
    45 46
     import fr.ird.observe.spi.module.ObserveBusinessProject;
    
    46 47
     import io.ultreia.java4all.bean.JavaBean;
    
    48
    +import io.ultreia.java4all.jaxx.widgets.combobox.JaxxComboBox;
    
    47 49
     import org.apache.logging.log4j.LogManager;
    
    48 50
     import org.apache.logging.log4j.Logger;
    
    49 51
     import org.nuiton.jaxx.runtime.swing.JVetoableTabbedPane;
    
    52
    +import org.nuiton.jaxx.runtime.swing.action.MenuAction;
    
    50 53
     import org.nuiton.jaxx.validator.swing.SwingValidatorUtil;
    
    51 54
     import org.nuiton.jaxx.validator.swing.tab.JTabbedPaneValidator;
    
    52 55
     import org.nuiton.jaxx.widgets.datetime.DateTimeEditor;
    
    ... ... @@ -57,14 +60,21 @@ import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditorModel;
    57 60
     import org.nuiton.jaxx.widgets.hidor.HidorButton;
    
    58 61
     import org.nuiton.jaxx.widgets.temperature.TemperatureEditor;
    
    59 62
     
    
    63
    +import javax.swing.Action;
    
    64
    +import javax.swing.ActionMap;
    
    65
    +import javax.swing.InputMap;
    
    60 66
     import javax.swing.JComponent;
    
    61 67
     import javax.swing.JOptionPane;
    
    62 68
     import javax.swing.JPanel;
    
    63 69
     import javax.swing.JTabbedPane;
    
    70
    +import javax.swing.JTable;
    
    71
    +import javax.swing.KeyStroke;
    
    64 72
     import javax.swing.MenuElement;
    
    65 73
     import javax.swing.SwingUtilities;
    
    66 74
     import javax.swing.event.ChangeEvent;
    
    67 75
     import javax.swing.event.ChangeListener;
    
    76
    +import javax.swing.plaf.ActionMapUIResource;
    
    77
    +import javax.swing.plaf.InputMapUIResource;
    
    68 78
     import java.beans.PropertyChangeListener;
    
    69 79
     import java.util.LinkedHashMap;
    
    70 80
     import java.util.List;
    
    ... ... @@ -101,6 +111,9 @@ public class ContentOpen<U extends ContentUI> {
    101 111
         private JTabbedPaneValidator tabbedPaneValidator;
    
    102 112
         private JTabbedPaneValidator subTabbedPaneValidator;
    
    103 113
         private ArrayListMultimap<String, JComponent> focusComponents;
    
    114
    +    private List<JTable> tables;
    
    115
    +    private ActionMap newActionMap;
    
    116
    +    private InputMap newInputMap;
    
    104 117
     
    
    105 118
         public ContentOpen(U ui, ContentOpenExecutor<U> contentOpenExecutor) {
    
    106 119
             this(ui, contentOpenExecutor, null);
    
    ... ... @@ -126,6 +139,7 @@ public class ContentOpen<U extends ContentUI> {
    126 139
     
    
    127 140
         public DefaultUIInitializerResult init(ContentUIInitializer<U> initializer) {
    
    128 141
             DefaultUIInitializerResult initializerResult = initializer.initUI();
    
    142
    +        tables = initializerResult.getComponentsList(JTable.class);
    
    129 143
             tabbedPaneValidator = initializerResult.getTabbedPaneValidator();
    
    130 144
             subTabbedPaneValidator = initializerResult.getSubTabbedPaneValidator();
    
    131 145
             coordinateEditors = initializerResult.getCoordinateEditors();
    
    ... ... @@ -136,9 +150,18 @@ public class ContentOpen<U extends ContentUI> {
    136 150
             dateTimeEditors.forEach(e -> e.getSliderHidor().addPropertyChangeListener(HidorButton.PROPERTY_TARGET_VISIBLE, onToggleDateTimeEditorSliderChangedListener));
    
    137 151
             timeEditors.forEach(e -> e.getSliderHidor().addPropertyChangeListener(HidorButton.PROPERTY_TARGET_VISIBLE, onToggleTimeEditorSliderChangedListener));
    
    138 152
             coordinateEditors.forEach(e -> e.getModel().addPropertyChangeListener(CoordinatesEditorModel.PROPERTY_FORMAT, onCoordinateFormatChangedListener));
    
    139
    -        initActions();
    
    153
    +        ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(null);
    
    154
    +        ui.getActionMap().setParent(null);
    
    155
    +        JComponent actionContainer = initializer.getActionContainer();
    
    156
    +        initActions(actionContainer, initializerResult);
    
    140 157
             ContentUIModel model = ui.getModel();
    
    158
    +
    
    159
    +        @SuppressWarnings("unchecked") ContentUIHandler<U> handler = (ContentUIHandler<U>) ui.getHandler();
    
    141 160
             model.init(ui, initializerResult);
    
    161
    +        handler.onInit(ui);
    
    162
    +
    
    163
    +        postInstallActions(actionContainer, newInputMap, newActionMap, initializerResult);
    
    164
    +
    
    142 165
             model.getStates().addPropertyChangeListener(ContentUIModelStates.PROPERTY_MODE, evt -> {
    
    143 166
                 ContentMode newValue = (ContentMode) evt.getNewValue();
    
    144 167
                 ui.getHandler().onModeChanged(newValue);
    
    ... ... @@ -179,8 +202,6 @@ public class ContentOpen<U extends ContentUI> {
    179 202
             if (contentEditExecutor != null) {
    
    180 203
                 contentEditExecutor.doEditOnOpen(ui);
    
    181 204
             }
    
    182
    -        //FIXME:Action We got ComboBox actions here... Side effecrt JaxxComboBox :(
    
    183
    -        ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(null);
    
    184 205
         }
    
    185 206
     
    
    186 207
         public boolean doClose() {
    
    ... ... @@ -458,6 +479,8 @@ public class ContentOpen<U extends ContentUI> {
    458 479
             ContentTableUIModel<?, ?> model = subUi.getModel();
    
    459 480
             if (!model.getStates().isStandalone()) {
    
    460 481
                 log.info(String.format("%sInit not standalone table ui: %s", ui.getModel().getPrefix(), subUi.getClass().getSimpleName()));
    
    482
    +            InputMap inputMap = ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    
    483
    +            ActionMap actionMap = ui.getActionMap();
    
    461 484
                 ui.getTitleRightToolBar().add(subUi.getSelectToolbar(), 0);
    
    462 485
                 subUi.getSelectToolbar().setVisible(false);
    
    463 486
                 MenuElement[] subElements = subUi.getInsertPopup().getSubElements();
    
    ... ... @@ -518,10 +541,29 @@ public class ContentOpen<U extends ContentUI> {
    518 541
             return ui;
    
    519 542
         }
    
    520 543
     
    
    521
    -    private void initActions() {
    
    544
    +    public void initActions(JComponent actionContainer, DefaultUIInitializerResult initializerResult) {
    
    522 545
             ContentUIHandler<?> handler = ui.getHandler();
    
    523 546
             handler.initActions();
    
    524 547
             handler.installChangeModeAction();
    
    548
    +
    
    549
    +        InputMap inputMap = actionContainer.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    
    550
    +        KeyStroke[] uiActionKeyStrokes = inputMap.allKeys();
    
    551
    +        log.info(String.format("%sFound %d actions to share", ui.getModel().getPrefix(), uiActionKeyStrokes.length));
    
    552
    +        ActionMap actionMap = actionContainer.getActionMap();
    
    553
    +        newActionMap = new ActionMapUIResource();
    
    554
    +        newInputMap = new InputMapUIResource();
    
    555
    +        for (KeyStroke actionKeyStroke : uiActionKeyStrokes) {
    
    556
    +            Object actionMapKey = inputMap.get(actionKeyStroke);
    
    557
    +            newInputMap.put(actionKeyStroke, actionMapKey);
    
    558
    +            Action action = actionMap.get(actionMapKey);
    
    559
    +            if (action instanceof MenuAction) {
    
    560
    +                log.info(String.format("Skip menu action %s → %s", actionKeyStroke, actionMapKey));
    
    561
    +                continue;
    
    562
    +            }
    
    563
    +            newActionMap.put(actionMapKey, action);
    
    564
    +            log.info(String.format("Register action %s → %s", actionKeyStroke, actionMapKey));
    
    565
    +        }
    
    566
    +
    
    525 567
             ContentUIModel model = ui.getModel();
    
    526 568
             NodeCapability<?> capability = model.getSource().getCapability();
    
    527 569
             if (capability instanceof ContainerCapability) {
    
    ... ... @@ -540,6 +582,17 @@ public class ContentOpen<U extends ContentUI> {
    540 582
             handler.updateToggleInsertVisibility();
    
    541 583
         }
    
    542 584
     
    
    585
    +    protected void postInstallActions(JComponent actionContainer, InputMap newInputMap, ActionMap newActionMap, DefaultUIInitializerResult initializerResult) {
    
    586
    +        KeyStroke[] keyStrokes = newInputMap.allKeys();
    
    587
    +        initializerResult.getComponents(JaxxComboBox.class).forEach(editor -> UIInitHelper.cleanInputMapAndSet(editor, keyStrokes, newInputMap, newActionMap));
    
    588
    +        initializerResult.getComponents(JTable.class).forEach(editor -> UIInitHelper.cleanInputMap(editor, keyStrokes));
    
    589
    +        for (Map.Entry<ContentTableUI<?, ?, ?>, JPanel> entry : subUiMap.entrySet()) {
    
    590
    +            ContentTableUI<?, ?, ?> subUi = entry.getKey();
    
    591
    +            subUi.getHandler().getContentOpen().getTables().forEach(editor -> UIInitHelper.cleanInputMap(editor, keyStrokes));
    
    592
    +            //FIXME:Actions We should define some scope only for subUi ?
    
    593
    +        }
    
    594
    +    }
    
    595
    +
    
    543 596
         private void onToggleDateTimeEditorSliderChanged(boolean newValue) {
    
    544 597
             if (!toggleDateTimeEditorSliderIsChanging) {
    
    545 598
                 toggleDateTimeEditorSliderIsChanging = true;
    
    ... ... @@ -555,6 +608,10 @@ public class ContentOpen<U extends ContentUI> {
    555 608
             }
    
    556 609
         }
    
    557 610
     
    
    611
    +    public List<JTable> getTables() {
    
    612
    +        return tables;
    
    613
    +    }
    
    614
    +
    
    558 615
         private void onToggleTimeEditorSliderChanged(boolean newValue) {
    
    559 616
             if (!toggleTimeEditorSliderIsChanging) {
    
    560 617
                 toggleTimeEditorSliderIsChanging = true;
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/edit/ContentEditUIOpenExecutor.java
    ... ... @@ -51,18 +51,13 @@ public class ContentEditUIOpenExecutor<D extends DataDto, U extends ContentEditU
    51 51
             // chaque arrive sur un écran invalide le cache de validation
    
    52 52
             getClientValidationContext().reset();
    
    53 53
     
    
    54
    -        openModel(ui);
    
    55
    -
    
    56
    -        handler.fixFormSize();
    
    57
    -        handler.onEndOpenUI();
    
    58
    -    }
    
    59
    -
    
    60
    -    public void openModel(U ui) {
    
    61 54
             ContentEditUIModel<D> model = ui.getModel();
    
    62 55
             Form<D> form = model.openForm(model.getStates().getSelectedId());
    
    63
    -        ContentEditUIHandler<D, U> handler = ui.getHandler();
    
    64 56
             handler.getContentOpen().onOpenForm(form);
    
    65 57
             handler.onOpenAfterOpenModel();
    
    58
    +
    
    59
    +        handler.fixFormSize();
    
    60
    +        handler.onEndOpenUI();
    
    66 61
         }
    
    67 62
     
    
    68 63
         @Override
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableEditorLayerUI.java
    ... ... @@ -69,7 +69,7 @@ public class ContentTableEditorLayerUI extends ObserveBlockingLayerUI implements
    69 69
             try {
    
    70 70
                 log.trace("Set focus on table editor");
    
    71 71
                 Component focusComponent = editor.getModel().getStates().getFormFocusOwner();
    
    72
    -            log.debug(String.format("Set focus on table editor - initial form focus owner: %s", focusComponent));
    
    72
    +            log.debug(String.format("Set focus on table editor - initial form focus owner: %s", focusComponent == null ? null : focusComponent.getName()));
    
    73 73
                 boolean readingMode = editor.getModel().getStates().isReadingMode();
    
    74 74
                 if (focusComponent != null) {
    
    75 75
                     // if not reading, then we can try to have a more accurate focus owner
    
    ... ... @@ -88,17 +88,17 @@ public class ContentTableEditorLayerUI extends ObserveBlockingLayerUI implements
    88 88
                     // compute focus owner
    
    89 89
                     FocusTraversalPolicy focusTraversalPolicy = editor.getFocusTraversalPolicy();
    
    90 90
                     focusComponent = Objects.requireNonNull(focusTraversalPolicy).getFirstComponent(editor);
    
    91
    -                log.debug(String.format("compute new form focus owner: %s", focusComponent));
    
    91
    +                log.debug(String.format("compute new form focus owner: %s", focusComponent==null?null:focusComponent.getName()));
    
    92 92
                 }
    
    93 93
                 if (focusComponent == null) {
    
    94 94
                     focusComponent = editor.getMode();
    
    95
    -            } else if (focusComponent.hasFocus()) {
    
    95
    +            }
    
    96
    +            if (Objects.requireNonNull(focusComponent).hasFocus()) {
    
    96 97
                     return;
    
    97 98
                 }
    
    98
    -            log.debug(String.format("Set focus on table editor: %s", focusComponent));
    
    99
    +            log.debug(String.format("Set focus on table editor: %s", focusComponent.getName()));
    
    99 100
                 // this will change the focus
    
    100 101
                 editor.getModel().getStates().setFormFocusOwner(focusComponent);
    
    101
    -//            editor.getHandler().setFormFocusOwner(focusComponent);
    
    102 102
             } finally {
    
    103 103
                 focusAdjusting = false;
    
    104 104
             }
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUIHandler.java
    ... ... @@ -40,6 +40,12 @@ import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.en
    40 40
     import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.ResetEntry;
    
    41 41
     import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.SaveAndNewEntry;
    
    42 42
     import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.SaveTableEntry;
    
    43
    +import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectFirst;
    
    44
    +import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectLast;
    
    45
    +import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectNext;
    
    46
    +import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectPrevious;
    
    47
    +import fr.ird.observe.client.datasource.editor.api.content.data.table.sortable.AutoSelectWithMoveUpAndDownShowPopupAction;
    
    48
    +import fr.ird.observe.client.datasource.editor.api.content.data.table.sortable.SortableTableUI;
    
    43 49
     import fr.ird.observe.client.datasource.editor.api.content.ui.ObserveLayoutFocusTraversalPolicy;
    
    44 50
     import fr.ird.observe.client.datasource.editor.api.navigation.tree.NavigationNode;
    
    45 51
     import fr.ird.observe.dto.data.DataDto;
    
    ... ... @@ -138,6 +144,16 @@ public abstract class ContentTableUIHandler<D extends DataDto, C extends DataDto
    138 144
             getComponent(JButton.class, "importData").ifPresent(e -> ImportDataFile.installAction(ui, e));
    
    139 145
             getComponent(JButton.class, "deleteData").ifPresent(e -> DeleteDataFile.installAction(ui, e));
    
    140 146
             getComponent(JButton.class, "exportData").ifPresent(e -> ExportDataFile.installAction(ui, e));
    
    147
    +
    
    148
    +        SelectFirst.init(ui, ui.getSelectFirstTableEntry(), SelectFirst.class);
    
    149
    +        SelectPrevious.init(ui, ui.getSelectPreviousTableEntry(), SelectPrevious.class);
    
    150
    +        SelectNext.init(ui, ui.getSelectNextTableEntry(), SelectNext.class);
    
    151
    +        SelectLast.init(ui, ui.getSelectLastTableEntry(), SelectLast.class);
    
    152
    +
    
    153
    +        if (ui instanceof SortableTableUI) {
    
    154
    +            log.info(String.format("%sInstall sortable popup actions", ui.getModel().getPrefix()));
    
    155
    +            new AutoSelectWithMoveUpAndDownShowPopupAction(ui);
    
    156
    +        }
    
    141 157
         }
    
    142 158
     
    
    143 159
         @Override
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUIInitializer.java
    ... ... @@ -23,12 +23,7 @@ package fr.ird.observe.client.datasource.editor.api.content.data.table;
    23 23
      */
    
    24 24
     
    
    25 25
     import fr.ird.observe.client.datasource.editor.api.content.ContentUIInitializer;
    
    26
    -import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectFirst;
    
    27
    -import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectLast;
    
    28
    -import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectNext;
    
    29
    -import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.entry.select.SelectPrevious;
    
    30
    -import fr.ird.observe.client.datasource.editor.api.content.data.table.sortable.AutoSelectWithMoveUpAndDownShowPopupAction;
    
    31
    -import fr.ird.observe.client.datasource.editor.api.content.data.table.sortable.SortableTableUI;
    
    26
    +import fr.ird.observe.client.datasource.editor.api.content.NotStandaloneContentUI;
    
    32 27
     import fr.ird.observe.client.util.UIHelper;
    
    33 28
     import fr.ird.observe.client.util.init.DefaultUIInitializerResult;
    
    34 29
     import fr.ird.observe.dto.data.DataDto;
    
    ... ... @@ -36,7 +31,6 @@ import io.ultreia.java4all.i18n.I18n;
    36 31
     import org.apache.logging.log4j.LogManager;
    
    37 32
     import org.apache.logging.log4j.Logger;
    
    38 33
     
    
    39
    -import javax.swing.ActionMap;
    
    40 34
     import javax.swing.InputMap;
    
    41 35
     import javax.swing.JComponent;
    
    42 36
     import javax.swing.KeyStroke;
    
    ... ... @@ -100,32 +94,11 @@ public class ContentTableUIInitializer<D extends DataDto, C extends DataDto, U e
    100 94
             ui.getSelectNextTableEntry().setEnabled(false);
    
    101 95
             ui.getSelectLastTableEntry().setEnabled(false);
    
    102 96
             InputMap inputMap = ui.getTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    
    103
    -
    
    104 97
             inputMap.put(KeyStroke.getKeyStroke("pressed UP"), "none");
    
    105 98
             inputMap.put(KeyStroke.getKeyStroke("pressed DOWN"), "none");
    
    106 99
             inputMap.put(KeyStroke.getKeyStroke("pressed LEFT"), "none");
    
    107 100
             inputMap.put(KeyStroke.getKeyStroke("pressed RIGHT"), "none");
    
    108 101
     
    
    109
    -        ActionMap actionMap = ui.getTable().getActionMap();
    
    110
    -
    
    111
    -//        inputMap = ui.getTable().getInputMap(JComponent.WHEN_FOCUSED);
    
    112
    -        SelectFirst selectFirst = SelectFirst.init(ui, ui.getSelectFirstTableEntry(), SelectFirst.class);
    
    113
    -        inputMap.put(selectFirst.getKeyStroke(), "selectFirstRow");
    
    114
    -        actionMap.put("selectFirstRow", selectFirst);
    
    115
    -        SelectPrevious selectPrevious = SelectPrevious.init(ui, ui.getSelectPreviousTableEntry(), SelectPrevious.class);
    
    116
    -        inputMap.put(selectPrevious.getKeyStroke(), "selectPreviousRow");
    
    117
    -        actionMap.put("selectPreviousRow", selectPrevious);
    
    118
    -        SelectNext selectNext = SelectNext.init(ui, ui.getSelectNextTableEntry(), SelectNext.class);
    
    119
    -        inputMap.put(selectNext.getKeyStroke(), "selectNextRow");
    
    120
    -        actionMap.put("selectNextRow", selectNext);
    
    121
    -        SelectLast selectLast = SelectLast.init(ui, ui.getSelectLastTableEntry(), SelectLast.class);
    
    122
    -        inputMap.put(selectLast.getKeyStroke(), "selectLastRow");
    
    123
    -        actionMap.put("selectLastRow", selectLast);
    
    124
    -
    
    125
    -        if (ui instanceof SortableTableUI) {
    
    126
    -            log.info(String.format("%sInstall sortable popup actions", ui.getModel().getPrefix()));
    
    127
    -            new AutoSelectWithMoveUpAndDownShowPopupAction(ui);
    
    128
    -        }
    
    129 102
             ui.getTitleRightToolBar().add(ui.getSelectToolbar(), 0);
    
    130 103
     
    
    131 104
             String message = I18n.t("observe.data.Data.list.message.none", ContentTableUII18nHelper.getType(getModel().getScope().getMainType()));
    
    ... ... @@ -146,7 +119,7 @@ public class ContentTableUIInitializer<D extends DataDto, C extends DataDto, U e
    146 119
                     log.debug("<<<<<<<<<< has clear selection...");
    
    147 120
                 } else {
    
    148 121
                     // on met a jour le modele de selection
    
    149
    -                log.info(String.format(">>>>>>>>>> will set selection to %d", selectedRow));
    
    122
    +                log.debug(String.format(">>>>>>>>>> will set selection to %d", selectedRow));
    
    150 123
                     ui.getSelectionModel().setSelectionInterval(selectedRow, selectedRow);
    
    151 124
                 }
    
    152 125
                 FocusTraversalPolicy focusTraversalPolicy = ui.getFocusTraversalPolicy();
    
    ... ... @@ -157,7 +130,6 @@ public class ContentTableUIInitializer<D extends DataDto, C extends DataDto, U e
    157 130
                     if (focusComponent != null) {
    
    158 131
                         log.info(String.format("New form focus owner: %s", focusComponent));
    
    159 132
                         ui.getModel().getStates().setFormFocusOwner(focusComponent);
    
    160
    -//                    ui.getHandler().setFormFocusOwner(focusComponent);
    
    161 133
                     }
    
    162 134
                 }
    
    163 135
     
    
    ... ... @@ -173,4 +145,11 @@ public class ContentTableUIInitializer<D extends DataDto, C extends DataDto, U e
    173 145
             ui.getEditorBlockLayerUI().setAcceptedComponentNames(doNotBlockComponentIds);
    
    174 146
         }
    
    175 147
     
    
    148
    +    @Override
    
    149
    +    public JComponent getActionContainer() {
    
    150
    +        if (!ui.getModel().getStates().isStandalone()) {
    
    151
    +            return (JComponent) ((NotStandaloneContentUI<?>) ui).getParentUI();
    
    152
    +        }
    
    153
    +        return super.getActionContainer();
    
    154
    +    }
    
    176 155
     }

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/NotStandaloneContentTableUIHandler.java
    ... ... @@ -37,6 +37,7 @@ public abstract class NotStandaloneContentTableUIHandler<D extends DataDto, C ex
    37 37
     
    
    38 38
         private EditableContentUI<D> parent;
    
    39 39
     
    
    40
    +    @Override
    
    40 41
         public EditableContentUI<D> getParentUI() {
    
    41 42
             if (parent == null) {
    
    42 43
                 parent = NotStandaloneContentUIHandler.getParentUI(ui);
    
    ... ... @@ -50,23 +51,8 @@ public abstract class NotStandaloneContentTableUIHandler<D extends DataDto, C ex
    50 51
             return new ContentOpen<>(ui, executor, executor);
    
    51 52
         }
    
    52 53
     
    
    53
    -//    @Override
    
    54
    -//    public void startEditUI() {
    
    55
    -//        ui.getValidatorTable().setParentValidator(ui.getValidator());
    
    56
    -//        super.startEditUI();
    
    57
    -//    }
    
    58
    -
    
    59
    -//    @Override
    
    60
    -//    public void stopEditUI() {
    
    61
    -//        ui.getValidatorTable().setParentValidator(null);
    
    62
    -//        super.stopEditUI();
    
    63
    -//    }
    
    64
    -
    
    65
    -//    @Override
    
    66
    -//    public void onEndOpenUI() {
    
    67
    -//        super.onEndOpenUI();
    
    68
    -//        if (!getModel().getStates().isUpdatingMode()) {
    
    69
    -//            reselectRow();
    
    70
    -//        }
    
    71
    -//    }
    
    54
    +    @Override
    
    55
    +    public void installChangeModeAction() {
    
    56
    +        // not for this one
    
    57
    +    }
    
    72 58
     }

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ContentTableUIEntryActionSupport.java
    ... ... @@ -23,16 +23,17 @@ package fr.ird.observe.client.datasource.editor.api.content.data.table.actions.e
    23 23
      */
    
    24 24
     
    
    25 25
     import fr.ird.observe.client.WithClientUIContext;
    
    26
    +import fr.ird.observe.client.datasource.editor.api.content.NotStandaloneContentUI;
    
    26 27
     import fr.ird.observe.client.datasource.editor.api.content.data.table.ContentTableUI;
    
    27 28
     import fr.ird.observe.client.datasource.editor.api.content.data.table.ContentTableUITableModel;
    
    28 29
     import fr.ird.observe.client.datasource.editor.api.content.data.table.actions.ContentTableUIActionSupport;
    
    29
    -import fr.ird.observe.client.main.MainUIModel;
    
    30 30
     import org.apache.logging.log4j.LogManager;
    
    31 31
     import org.apache.logging.log4j.Logger;
    
    32 32
     import org.nuiton.jaxx.runtime.JAXXObject;
    
    33 33
     import org.nuiton.jaxx.runtime.swing.action.JAXXObjectActionSupport;
    
    34 34
     
    
    35 35
     import javax.swing.AbstractButton;
    
    36
    +import javax.swing.JComponent;
    
    36 37
     import javax.swing.KeyStroke;
    
    37 38
     import java.awt.event.ActionEvent;
    
    38 39
     import java.beans.PropertyChangeListener;
    
    ... ... @@ -49,7 +50,6 @@ public abstract class ContentTableUIEntryActionSupport extends ContentTableUIAct
    49 50
         private boolean canExecuteFromRead;
    
    50 51
     
    
    51 52
         public static <U extends JAXXObject, A extends JAXXObjectActionSupport<U>> A init(U ui, AbstractButton editor, Class<A> actionType) {
    
    52
    -
    
    53 53
             A action = JAXXObjectActionSupport.init(ui, editor, actionType);
    
    54 54
             editor.putClientProperty(ACTIVATE_FROM_POPUP, true);
    
    55 55
             return action;
    
    ... ... @@ -61,11 +61,19 @@ public abstract class ContentTableUIEntryActionSupport extends ContentTableUIAct
    61 61
                 boolean b = computeEnabled(this.ui.getTableModel().getSelectedRow(), this.ui.getTableModel().getRowCount());
    
    62 62
                 log.debug("Set enabled? " + b + " on " + getActionCommandKey());
    
    63 63
                 setEnabled(b);
    
    64
    -//            editor.setEnabled(b);
    
    65 64
             };
    
    66 65
             setEnabled(false);
    
    67 66
         }
    
    68 67
     
    
    68
    +    @Override
    
    69
    +    protected JComponent getContainer(ContentTableUI<?, ?, ?> ui) {
    
    70
    +        if (ui.getModel().getStates().isStandalone()) {
    
    71
    +            return super.getContainer(ui);
    
    72
    +        }
    
    73
    +        // if not standalone, attach to body since this is the only part which will be displayed and action aware
    
    74
    +        return (JComponent) ((NotStandaloneContentUI<?>) ui).getParentUI();
    
    75
    +    }
    
    76
    +
    
    69 77
         public abstract boolean computeEnabled(int selectedRow, int rowCount);
    
    70 78
     
    
    71 79
         protected abstract void actionPerformed(ContentTableUITableModel<?, ?, ?> tableModel, int selectedRow);
    
    ... ... @@ -79,34 +87,15 @@ public abstract class ContentTableUIEntryActionSupport extends ContentTableUIAct
    79 87
         }
    
    80 88
     
    
    81 89
         @Override
    
    82
    -    protected void doActionPerformed(ActionEvent e, ContentTableUI<?,?,?> contentTableUI) {
    
    90
    +    protected void doActionPerformed(ActionEvent e, ContentTableUI<?, ?, ?> contentTableUI) {
    
    83 91
             if (!isEnabled()) {
    
    84 92
                 //FIXME should not have to check this here...
    
    85 93
                 log.info(String.format("Reject action: %s :: %s", getActionCommandKey(), this));
    
    86 94
                 return;
    
    87 95
             }
    
    88 96
             log.info(String.format("Accept action: %s :: %s", getActionCommandKey(), this));
    
    89
    -//        boolean focusOwner = ui.getTable().isFocusOwner();
    
    90
    -//        log.debug("table has focus? " + focusOwner);
    
    91
    -//        MainUIModel mainUIModel = getClientUIContext().getMainUIModel();
    
    92
    -//        boolean blockFocus = mainUIModel.isBlockFocus();
    
    93
    -//        if (focusOwner) {
    
    94
    -//            mainUIModel.blockFocus();
    
    95
    -//        }
    
    96
    -        try {
    
    97
    -            int selectedRow = ui.getTable().getSelectedRow();
    
    98
    -            actionPerformed(ui.getTableModel(), selectedRow);
    
    99
    -        } finally {
    
    100
    -//            //FIXME:Focus
    
    101
    -//            if (focusOwner) {
    
    102
    -//                if (!blockFocus) {
    
    103
    -//                    mainUIModel.unblockFocus();
    
    104
    -//                }
    
    105
    -//                log.debug("Add focus back to table");
    
    106
    -//                //ui.getTable().requestFocusInWindow();
    
    107
    -//                ui.getHandler().setFormFocusOwner(ui.getTable());
    
    108
    -//            }
    
    109
    -        }
    
    97
    +        int selectedRow = ui.getTable().getSelectedRow();
    
    98
    +        actionPerformed(ui.getTableModel(), selectedRow);
    
    110 99
         }
    
    111 100
     
    
    112 101
         @Override
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/select/SelectFirst.java
    ... ... @@ -45,6 +45,9 @@ public final class SelectFirst extends ContentTableUIEntryActionSupport {
    45 45
     
    
    46 46
         @Override
    
    47 47
         protected void actionPerformed(ContentTableUITableModel<?, ?, ?> tableModel, int selectedRow) {
    
    48
    +        if (selectedRow == -1) {
    
    49
    +            return;
    
    50
    +        }
    
    48 51
             tableModel.selectFirst();
    
    49 52
         }
    
    50 53
     }

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/select/SelectLast.java
    ... ... @@ -45,6 +45,9 @@ public final class SelectLast extends ContentTableUIEntryActionSupport {
    45 45
     
    
    46 46
         @Override
    
    47 47
         protected void actionPerformed(ContentTableUITableModel<?, ?, ?> tableModel, int selectedRow) {
    
    48
    +        if (selectedRow==-1) {
    
    49
    +            return;
    
    50
    +        }
    
    48 51
             tableModel.selectLast();
    
    49 52
         }
    
    50 53
     }

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/select/SelectNext.java
    ... ... @@ -46,6 +46,9 @@ public final class SelectNext extends ContentTableUIEntryActionSupport {
    46 46
     
    
    47 47
         @Override
    
    48 48
         protected void actionPerformed(ContentTableUITableModel<?, ?, ?> tableModel, int selectedRow) {
    
    49
    +        if (selectedRow==-1) {
    
    50
    +            return;
    
    51
    +        }
    
    49 52
             tableModel.selectNext(selectedRow);
    
    50 53
         }
    
    51 54
     }

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/select/SelectPrevious.java
    ... ... @@ -45,6 +45,9 @@ public final class SelectPrevious extends ContentTableUIEntryActionSupport {
    45 45
     
    
    46 46
         @Override
    
    47 47
         protected void actionPerformed(ContentTableUITableModel<?, ?, ?> tableModel, int selectedRow) {
    
    48
    +        if (selectedRow==-1) {
    
    49
    +            return;
    
    50
    +        }
    
    48 51
             tableModel.selectPrevious(selectedRow);
    
    49 52
         }
    
    50 53
     }

  • client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/BranchlineUIHandler.java
    ... ... @@ -89,6 +89,11 @@ public class BranchlineUIHandler extends GeneratedBranchlineUIHandler {
    89 89
             };
    
    90 90
         }
    
    91 91
     
    
    92
    +    @Override
    
    93
    +    public void installChangeModeAction() {
    
    94
    +        // not for this one (not standalone)
    
    95
    +    }
    
    96
    +
    
    92 97
         @Override
    
    93 98
         protected void installResetAction() {
    
    94 99
             ResetAction<BranchlineUI> action = ResetAction.prepareAction(new DefaultResetAdapter<BranchlineUI>() {