Summary: | [Navigator] Tree scroll bar out of sync with top item (1GEJYGD) | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Knut Radloff <knut_radloff> |
Component: | UI | Assignee: | Knut Radloff <knut_radloff> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.0 | ||
Target Milestone: | 2.1 M2 | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: |
Description
Knut Radloff
2001-10-11 14:21:05 EDT
PRODUCT VERSION: 114 Not sure when I saw the manual setting the vertical scroll bar selection work. It should always fail on Linux, i.e., the scroll bar will be set but the Tree won't be notified since it was a programmatic change. I experimented with using Tree.showItem with mixed results. On Linux this always scrolls the given item to the top. However, this is spec'd to return without doing anything if the item is already visible. On Windows, since the viewer/widget is not yet visible when the viewer state is restored in JDT, it works as long as the given item is above the selected item. If it is below the selected item the actual top item appears to be off by one. Bottom line: JDT should not try to restore the scroll bar position. It leads to a confusing UI state on Linux. Test case to reproduce what can be seen in Eclipse below: import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; /** * This type was created in VisualAge. */ public class Bug_4676 { public static void main(String arguments[]) { Shell shell = new Shell(); Tree tree = new Tree(shell, 0); TreeItem item1 = new TreeItem(tree, 0); TreeItem item1_1 = new TreeItem(item1, 0); TreeItem item1_2 = new TreeItem(item1, 0); TreeItem item1_3 = new TreeItem(item1, 0); TreeItem item; TreeItem item2 = new TreeItem(tree, 0); item1.setText("item1"); item2.setText("item2"); item1_3.setText("item1.3"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item2, 0)).setText("2.1"); (new TreeItem(item1, 0)).setText("1.1"); (new TreeItem(item1, 0)).setText("1.1"); item1.setExpanded(true); tree.setSelection(new TreeItem[]{item1_2}); tree.getVerticalBar().setSelection(0); // tree.showItem(item1); tree.setSize(400, 300); shell.open(); Display display = shell.getDisplay (); while (!shell.isDisposed ()) if (!display.readAndDispatch ()) display.sleep (); } } Moved to JDT UI for consideration Claude, can you have a look at this on yr linux box? yup, it comes up with the second child item at the top, although the vertical scroll bar is at the top. changed package explorer to no longer save/restore scroll state. Moving to Platform UI - the ResourceNavigate is also saving/restoring the scroll state. Knut, since you're most familiar with this, could you fix the Navigator up? We should request SWT API to save/restore the top item of a tree. Like the top index in a table. Removed the code that saves and restores the position of the horizontal and vertical scrollbars. Trying to restore the horizontal position seems like overkill anyway. Restoring the top index would indeed be nice. We currently set the item selection which moves the selected item to the top. This is sufficient but could be better. Opened SWT bug 24333 asking for getTopIndex/setTopIndex API. |