Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 444128

Summary: ComboViewer#setSelection does not work always when input changes
Product: [RT] RAP Reporter: Christian <christian.hoesel>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: falko.schumann, rsternberg
Version: 2.3   
Target Milestone: 3.0 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard: sr232

Description Christian CLA 2014-09-15 10:43:48 EDT
Use the sample code and do the following steps:
1. Select a number 1 in the combo
2. Push the "Next" button
3. The selection is not visible any more

public class BasicEntryPoint extends AbstractEntryPoint {
	private List<String> segmente = Arrays.asList("1", "2", "3", "4", "5");
	@Override
	protected void createContents(Composite parent) {
		parent.setLayout(new GridLayout(2, false));
		ComboViewer fromCombo = new ComboViewer(parent);
		fromCombo.setContentProvider(new ArrayContentProvider());
		fromCombo.setInput(segmente);
		Button button = new Button(parent, SWT.PUSH);
		button.setText("Next");
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Object currentSelection = ((IStructuredSelection) fromCombo
						.getSelection()).getFirstElement();
				segmente = segmente.subList(0, segmente.size()-1);
				fromCombo.setInput(segmente);
				fromCombo
						.setSelection(new StructuredSelection(currentSelection));
			}
		});
	}
}

Everytime we push the "Next" button we reduce the new input by one element from the end and we set the selection again. In this case the old selection is not visible again. If we change the example and reduce the new input by one element from the beginning the selection will be visible. Using SWT both ways are working.
Comment 1 Ivan Furnadjiev CLA 2014-09-16 02:33:30 EDT
Does it happen with plain Combo widget (not ComboViewer)?
Comment 2 Ivan Furnadjiev CLA 2014-09-16 03:05:26 EDT
OK... I can reproduce it and I know what is going on.
Comment 3 Ivan Furnadjiev CLA 2014-09-16 04:26:21 EDT
Pending change: https://git.eclipse.org/r/33421
Comment 4 Ivan Furnadjiev CLA 2014-09-16 08:12:55 EDT
Fixed in master with change https://git.eclipse.org/r/33421.
Comment 5 Ralf Sternberg CLA 2015-01-27 05:18:36 EST
+1 for backporting to 2.3.2
Comment 6 Ivan Furnadjiev CLA 2015-01-28 05:23:19 EST
Backported to 2.3-maintenance branch with change https://git.eclipse.org/r/40521