Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334524 - [Commands] Loosing current selection of view after perspective switch
Summary: [Commands] Loosing current selection of view after perspective switch
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Prakash Rangaraj CLA
QA Contact: Prakash Rangaraj CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-17 10:49 EST by Heiko Techteam CLA
Modified: 2012-04-02 05:06 EDT (History)
3 users (show)

See Also:


Attachments
Project to test (7.88 KB, application/zip)
2011-01-17 13:00 EST, Prakash Rangaraj CLA
no flags Details
Patch v01 (1.03 KB, patch)
2011-01-17 13:03 EST, Prakash Rangaraj CLA
no flags Details | Diff
Patch v02 (3.76 KB, patch)
2011-01-18 01:23 EST, Prakash Rangaraj CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.