Bug 7823 - [Workbench] Null is converted in an empty StructuredSelection
Summary: [Workbench] Null is converted in an empty StructuredSelection
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate, needinfo
Depends on:
Blocks: 7383
  Show dependency tree
 
Reported: 2002-01-17 05:45 EST by Dirk Baeumer CLA
Modified: 2009-08-30 02:11 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2002-01-17 05:45:19 EST
I found a strange behaviour when using ActionDelegates and listening to 
selection changes. Below is my scenario

- I have a compilation unit editor open with an active text selection.
- now I click on the packages view which has selected elements.

As a result the method ActionDelegate#selectionChanged is called two times.

first call: you get an empty structured selection also the reset method on 
SelectionService fires with the selection null, indicating that you are losing 
the selection. This null selection is magically converted into an empty 
structured selection in PluginAction.selectionChanged. I think this is not ok 
when the platform handles any kind of selection. It should propagate the null 
selection to my action delegate. Another strange behaviour of this conversion is
that in ActionDelegate#selectionChanged the received selection is unequal the 
selection I retrieve from the 
IWorkbenchWindow.getSelectionService.getSelection. This one is still the old 
text selection.

second call: now I get the structured selection from the packages view.
Comment 1 Dirk Baeumer CLA 2002-01-23 11:18:01 EST
We have a workaround for this but which will fail if a someone emits an empty 
structured selection on purpose. Opt to raise to P2
Comment 2 Nick Edgar CLA 2002-01-23 15:04:10 EST
Randy, could you investigate this one?
selectionChanged should only be called once.
We need to ensure that propogating null is allowed by the existing contracts 
and won't break existing clients.
Comment 3 Randy Giffen CLA 2002-01-29 11:34:13 EST
The spec for IActionDelegate.selectionChanged indicates that null is a valid 
selection. However the following two classes in my workbench do not check for 
null:
org.eclipse.jdt.internal.debug.ui.actions.WatchpointAction
org.eclipse.debug.internal.ui.actions.CopyVariablesToClipboardActionDelegate
Comment 4 Randy Giffen CLA 2002-05-28 11:17:03 EDT
Agree that we should not be magically turning null into an empty selection. 

The null selection is fired because the selection service listens for part 
deactivation/activation and does not know that one will be followed by the 
other. This would require a change in the way we notify of part activation 
changes.

I think it is now too late in the cycle for 2.0 to make such a changes. 
Suggest defer.
Comment 5 Randy Giffen CLA 2002-05-28 15:16:09 EDT
Defer
Comment 6 Randy Giffen CLA 2002-08-09 11:38:09 EDT
Reopen to investigate
Comment 7 Nick Edgar CLA 2006-04-12 13:49:29 EDT
History lesson: although we spec'ed that null could be passed, we originally did not pass null in the case of no selection (i.e. when the active part does not implement ISelectionProvider), but instead converted it to the empty selection.
When we added the support to distinguish between no selection and empty selection, we did that using the mix-in interface INullSelectionListener.
If the listener implements INullSelectionListener, we do pass null rather than converting to the empty selection (as per the spec for ISelectionListener.selectionChanged).

Comment 8 Tod Creasey CLA 2006-04-13 15:11:12 EDT
There is no plan to work on this currently
Comment 9 Denis Roy CLA 2009-08-30 02:11:21 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.