Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 10476 - Selection not shown in SWT Table
Summary: Selection not shown in SWT Table
Status: RESOLVED DUPLICATE of bug 22983
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Stef van Dijk CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 11975
  Show dependency tree
 
Reported: 2002-02-28 10:09 EST by Stef van Dijk CLA
Modified: 2002-09-10 11:22 EDT (History)
0 users

See Also:


Attachments
plugin testcase to demonstrate problem (zip file) (7.44 KB, application/octet-stream)
2002-02-28 10:10 EST, Stef van Dijk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stef van Dijk CLA 2002-02-28 10:09:16 EST
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.
Comment 1 Stef van Dijk CLA 2002-02-28 10:10:39 EST
Created attachment 408 [details]
plugin testcase to demonstrate problem (zip file)
Comment 2 Stef van Dijk CLA 2002-02-28 10:11:31 EST
Forgot to mention that I'm running WSDD 3.99.85 which includes Eclipse Rollup 2.
Comment 3 Veronika Irvine CLA 2002-03-06 17:13:52 EST
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();
}
Comment 4 Veronika Irvine CLA 2002-03-07 09:04:55 EST
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?
Comment 5 Stef van Dijk CLA 2002-03-07 11:40:01 EST
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.
Comment 6 Veronika Irvine CLA 2002-05-15 16:34:50 EDT
Stef,
Is this still a problem?
Comment 7 Stef van Dijk CLA 2002-05-15 22:18:54 EDT
No. I was able to fix this by showing the selection after the table was sized.
Comment 8 Tod Creasey CLA 2002-07-25 09:13:10 EDT
Can this be marked as closed? If so we should check Bug 11975 again.
Comment 9 Veronika Irvine CLA 2002-09-10 11:22:11 EDT

*** This bug has been marked as a duplicate of 22983 ***