Community
Participate
Working Groups
I have a New Wizard in which I display a list. In addition, I preselect one of the items in the list using setSelection() followed by showSelection(). However, the selected item is not made visible. The list does scroll, but the selected item is typically two rows higher up in the list than the top visible item. For example, I have a list with 26 entries, set the selection to 14 (zero- based) and ask the selection to show. When the window appears, the top item is the 16th entry (zero-based). I have created a simple testcase as a plugin which I will attach. The zip contains a plugin.xml and code. Create a PDE project and import the files from the zip. Then launch a Run-time Workbench using the PDE. From the target Eclipse, just go to File --> New --> Other..., select Table Testcase on the left, select Testcase on the right and press Next. The item "ooooo" is selected and should be visible. I am currently running on Windows 2000 with Internet Explorer version 5.50.4522.1800.
Created attachment 408 [details] plugin testcase to demonstrate problem (zip file)
Forgot to mention that I'm running WSDD 3.99.85 which includes Eclipse Rollup 2.
I can not get the attached plugin to work in either 1.0 or 2.0. I have to make many modifications to get it to compile and then when I run it I get an error. I have run the following simple SWT standalone example on 1.0 and 2.0 and in both cases it works correctly. Can you modify this example to make it fail or test if this example fails in your workspace? public static void main(String[] args) { Display display = new Display(); Image image = new Image(display, _Scrapbook.class.getResourceAsStream ("image3.bmp")); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); int style= SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER; final Table fProjectTable= new Table(shell, style); fProjectTable.setHeaderVisible(false); fProjectTable.setLinesVisible(false); String[] s= {"aaaaa", "bbbbb", "ccccc", "ddddd", "eeeee", "fffff", "ggggg", "hhhhh", "iiiii", "jjjjj", "kkkkk", "lllll", "mmmmm", "nnnnn", "ooooo", "ppppp", "qqqqq", "rrrrr", "sssss", "ttttt", "uuuuu", "vvvvv", "wwwww", "xxxxx", "yyyyy", "zzzzz"}; for (int i=0; i<s.length; i++) { TableItem tableItem= new TableItem(fProjectTable, SWT.DEFAULT); tableItem.setText(s[i]); tableItem.setImage(image); } Button b = new Button(shell, SWT.PUSH); b.setText(" show item "); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fProjectTable.setSelection(14); fProjectTable.showSelection(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
If you call showSelection when the table size is less than the size required to show one row (typically (0,0) but it could be less), then showSelection is not going to do anything. This can happen if you call showSelection before the wizard ever opens. If you call showSelection and then the window is resized, the table will not scroll again to show the selection. Could either of these cases be what is happening?
I think the latter case is quite possibly the problem. Since this is part of the Eclipse wizard framework, I'll have to investigate whether there's some way to know when the wizard page has been sized properly. Even though the wizards are not resizable (at least on windows), I'm not comfortable just adding a sizing listener to my table for the purpose of showing the selection. And I'll check to see what others do as I'm sure I'm not the only person attempting to show selection in a table on a wizard page. Thanks for the clue.
Stef, Is this still a problem?
No. I was able to fix this by showing the selection after the table was sized.
Can this be marked as closed? If so we should check Bug 11975 again.
*** This bug has been marked as a duplicate of 22983 ***