| Summary: | ComboViewer#setSelection does not work always when input changes | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Christian <christian.hoesel> |
| Component: | RWT | Assignee: | 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 | ||
Does it happen with plain Combo widget (not ComboViewer)? OK... I can reproduce it and I know what is going on. Pending change: https://git.eclipse.org/r/33421 Fixed in master with change https://git.eclipse.org/r/33421. +1 for backporting to 2.3.2 Backported to 2.3-maintenance branch with change https://git.eclipse.org/r/40521 |
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.