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

Bug 334524

Summary: [Commands] Loosing current selection of view after perspective switch
Product: [Eclipse Project] Platform Reporter: Heiko Techteam <techteam>
Component: UIAssignee: Prakash Rangaraj <prakash>
Status: VERIFIED FIXED QA Contact: Prakash Rangaraj <prakash>
Severity: normal    
Priority: P3 CC: pwebster, sanath.kv, tom.schindl
Version: 3.6.1   
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Project to test
none
Patch v01
none
Patch v02 none

Description Heiko Techteam CLA 2011-01-17 10:49:16 EST
I user an view with a TableViewer in some perspectives.
If I select something in the View on perspective A and use than a command  I get the current selection.
Afterwards I switch to perspective 2, where I see the view to and use than the same command  I get a null as current selection, although the view shows a selected object.

It is easy repoducable with: 

Generate a new project with the template: RCP application with a view
Inside the View.java -> set the TableViewer as SelectionProvider ( getViewSite().setSelectionProvider(viewer); )
Activate the PerspectiveBar inside the ApplicationWorkbenchWindowAdvisor ( configurer.setShowPerspectiveBar(true);)
Define a second perspective
Define a Command and a Handler and define it, to show the command inside the view toolbar
Read the current selection inside the Handler method .execute(ExecutionEvent event) with: 
HandlerUtil.getCurrentSelection(event);
Running the application 

I get:
nothing selected at the viewer ->  push command -> <empty selection>
select entry <One> -> push command -> <One>
switch to the other perspective: (<One> is inside the ui marked as selected) -> push command -> null
Comment 1 Thomas Schindl CLA 2011-01-17 10:51:07 EST
Are you sure that the view providing the selection is the one with the focus after you've switched the perspective?
Comment 2 Heiko Techteam CLA 2011-01-17 11:04:44 EST
Yes I do, I test it inside the Handler :
System.out.println(HandlerUtil.getVariable(event,  "activeWorkbenchWindow.activePerspective") + " / "+ HandlerUtil.getActivePartId(event) + " / " + HandlerUtil.getCurrentSelection(event));


I get 
zzz.test.selection.perspective / zzz.test.selection.view / [One]

-> switching perspective ->

zzz.test.selection.perspective2 / zzz.test.selection.view / null
Comment 3 Prakash Rangaraj CLA 2011-01-17 13:00:22 EST
Created attachment 186931 [details]
Project to test
Comment 4 Prakash Rangaraj CLA 2011-01-17 13:03:02 EST
Created attachment 186932 [details]
Patch v01
Comment 5 Prakash Rangaraj CLA 2011-01-18 01:23:40 EST
Created attachment 186970 [details]
Patch v02

Patch v01 + test
Comment 6 Prakash Rangaraj CLA 2011-01-18 01:25:56 EST
Patch v02 released to HEAD
Comment 7 Prakash Rangaraj CLA 2011-01-25 04:21:52 EST
Verified in I20110124-1800
Comment 8 Sanath Kumar Viswanath CLA 2012-04-02 05:06:29 EDT
Could anyone direct me to download the version of the build where this bug is fixed. I tried in eclipse 3.8M6, but this issue can be recreated.