Community
Participate
Working Groups
Created attachment 187273 [details] Fix HEAD PageBook#showPage(Control) should set all other pages to invisible. Currently, only pages that have been explicitly shown before are set to invisible, but controls that have just been created as children of a PageBook have getVisible()==true (but their bounds are not set by the layout). This is a problem when a focus should be set to the PageBook. In the snippet below, the focus ends up in the Text, because the hidden page is not set to invisible. This was a real problem in bug 334966, and I will remove the workaround there as soon as this bug has been fixed. import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.part.PageBook; public class PageBookSnippet { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setSize(320, 200); shell.setLayout(new GridLayout()); final StyledText editor = new StyledText(shell, SWT.BORDER); editor.setText("editor"); editor.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final PageBook pageBook = new PageBook(shell, SWT.NONE); pageBook.setLayoutData(new GridData(GridData.FILL_BOTH)); display.timerExec(1000, new Runnable() { public void run() { Text text = new Text(pageBook, SWT.BORDER); text.setText("Text"); Table table = new Table(pageBook, SWT.BORDER); for (int i = 0; i < 10; i++) { new TableItem(table, SWT.NONE).setText("Item " + i); } table.select(0); pageBook.showPage(table); pageBook.setFocus(); editor.setText(display.getFocusControl().toString()); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
I think the fix is correct, but to get more internal testing, I think it's better to wait with releasing it for after M5.
Fixed in HEAD (and reverted bug 334966).
Verified in I20110307-2110.
This didn't make it into the 4.x stream. Cherry-picked now: Commit eab9e01d0609234b09f6b52ef55ed1b67e4f75d9