Project: Eclipse_Platform_UI
Bug 334524 [Commands] Loosing current selection of view after perspective switch
Reported: 2011-01-17 10:49:16 | Status: verified fixed

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

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/WorkbenchSourceProvider.java tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/EvaluationServiceTest.java