| Summary: | [Viewers] Table.setSelection doesn't fire selection event anymore | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Giovanni Quarella <giovanni> |
| Component: | UI | Assignee: | Platform-UI-Inbox <Platform-UI-Inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | bokowski |
| Version: | 3.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Giovanni Quarella
(In reply to comment #0) > I'm just using eclipse-SDK-N20060812-0010-win32.zip, but my code: > viewer.getTable().setSelection(nextSelectedIndex); > doesn't fire selection event as before. In which release was a selection event fired? (In reply to comment #1) > (In reply to comment #0) > > I'm just using eclipse-SDK-N20060812-0010-win32.zip, but my code: > > viewer.getTable().setSelection(nextSelectedIndex); > > doesn't fire selection event as before. > In which release was a selection event fired? When I used eclipse-SDK-N20060709-0010-win32 all worked correctly. In one view I put getSite().setSelectionProvider(viewer); In the other OtherView extends ViewPart implements ISelectionListener ... public void selectionChanged(IWorkbenchPart part, ISelection selection) { System.out.println("selectionChanged"); } In N20060812 viewer.getTable().setSelection(nextSelectedIndex); doesn't fire anymore like before the call to selectionChanged. I have the same problem when I call viewer.getTable().setTopIndex(0) In N20060709 version the first table item 0 is selected, in N20060812 the table item 0 becomes visible, but it's not selected. I'm using a ILazyContentProvider and in the tableviewer doc of setSelection you read Use Table#setSelection(int[] indices) and Table#showSelection() if you wish to set selection more effeciently when using a ILazyContentProvider. Moving to SWT for comment - did Table.setSelection(int) ever cause selection events to be fired? (In reply to comment #3) > Moving to SWT for comment - did Table.setSelection(int) ever cause selection > events to be fired? Maybe I believed that the setSelection caused selection events to be fired, instead what I observed was a side effect of another bug I entered about removing items from a virtual table. Anyway the doc is misleading because Table#setSelection(int[] indices) seems equivalent to TableViewer.setSelection. So with a ILazyContentProvider if I want to fire a selection event on item 0, what should I use? A TableViewer.setSelection(0) would be helpful... Nope. Table.setSelection() never should have. It's possible a bug was fixed but I don't remember it. (In reply to comment #4) > So with a ILazyContentProvider if I want to fire a selection event on item 0, > what should I use? > A TableViewer.setSelection(0) would be helpful... This is not going to be more efficient than tableViewer.setSelection(tableViewer.getSelection()) since when we fire a selection event, it has to be in terms of elements, not items, so we would have to map from that index back to an element. This is exactly what getSelection() does. Closing as wontfix. As a workaround, you can implement your own selection provider that forwards native selection events coming from the viewer, and inserts its own selection events for when you set the selection programmatically. |