Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 88eb3ac5 by Tony Chemit at 2023-07-15T12:14:02+02:00 Sur enregistrement d'une nouvelle donnée, déplacement non souhaité de l'arbre vers la droite - Close #2749 - - - - - 1 changed file: - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/navigation/NavigationTree.java 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; import org.apache.logging.log4j.Logger; import org.jdesktop.swingx.JXTree; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import javax.swing.text.Position; import javax.swing.tree.TreeNode; @@ -139,6 +141,8 @@ public class NavigationTree extends JXTree implements WithClientUIContextApi { if (then != null) { then.run(); } + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2749 + resetHorizontalScrollBar(); } public void reSelectSafeNode(TreeNode node) { @@ -167,6 +171,7 @@ public class NavigationTree extends JXTree implements WithClientUIContextApi { TreePath path = new TreePath(getModel().getPathToRoot(node)); setSelectionPath(path); SwingUtilities.invokeLater(() -> scrollPathToVisible(path)); + resetHorizontalScrollBar(); } /** @@ -233,4 +238,10 @@ public class NavigationTree extends JXTree implements WithClientUIContextApi { addTreeSelectionListener(selectionListener); addMouseListener(selectionListener); } + + public void resetHorizontalScrollBar() { + JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this); + JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar(); + SwingUtilities.invokeLater(() -> horizontalScrollBar.setValue(0)); + } } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/88eb3ac50e725474941569f4f1... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/88eb3ac50e725474941569f4f1... You're receiving this email because of your account on gitlab.com.