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

Commits:

1 changed file:

Changes:

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationTree.java
    ... ... @@ -31,6 +31,8 @@ import org.apache.logging.log4j.LogManager;
    31 31
     import org.apache.logging.log4j.Logger;
    
    32 32
     import org.jdesktop.swingx.JXTree;
    
    33 33
     
    
    34
    +import javax.swing.JScrollBar;
    
    35
    +import javax.swing.JScrollPane;
    
    34 36
     import javax.swing.SwingUtilities;
    
    35 37
     import javax.swing.text.Position;
    
    36 38
     import javax.swing.tree.TreeNode;
    
    ... ... @@ -139,6 +141,8 @@ public class NavigationTree extends JXTree implements WithClientUIContextApi {
    139 141
             if (then != null) {
    
    140 142
                 then.run();
    
    141 143
             }
    
    144
    +        // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2749
    
    145
    +        resetHorizontalScrollBar();
    
    142 146
         }
    
    143 147
     
    
    144 148
         public void reSelectSafeNode(TreeNode node) {
    
    ... ... @@ -167,6 +171,7 @@ public class NavigationTree extends JXTree implements WithClientUIContextApi {
    167 171
             TreePath path = new TreePath(getModel().getPathToRoot(node));
    
    168 172
             setSelectionPath(path);
    
    169 173
             SwingUtilities.invokeLater(() -> scrollPathToVisible(path));
    
    174
    +        resetHorizontalScrollBar();
    
    170 175
         }
    
    171 176
     
    
    172 177
         /**
    
    ... ... @@ -233,4 +238,10 @@ public class NavigationTree extends JXTree implements WithClientUIContextApi {
    233 238
             addTreeSelectionListener(selectionListener);
    
    234 239
             addMouseListener(selectionListener);
    
    235 240
         }
    
    241
    +
    
    242
    +    public void resetHorizontalScrollBar() {
    
    243
    +        JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this);
    
    244
    +        JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar();
    
    245
    +        SwingUtilities.invokeLater(() -> horizontalScrollBar.setValue(0));
    
    246
    +    }
    
    236 247
     }