in my Eclipse Plugin I have this workflow:
1 (and 3) are realized like that:
ISelectionService selectionService = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getSelectionService();
ISelection selection = selectionService.getSelection();
[...]
Now, the problem is that before 1, the Package Explorer is selected, because that's the only way to trigger the workflow. But step 2 changes the active part because it refreshes a TreeView which makes it the active part. When I now try to run 3, which is the same method as 1, I have a problem: The Package Explorer is no longer the activePart
of the selectionService
and therefore selection
is null.
My questions are: Is there any way to get the ISelectionService
for a particular View which is not the active one? If not, is there a way to programmatically set the active part before executing step 3?
Btw that's an Eclipse 3.x plugin.
If you find the IViewPart
for the package explorer you can access its ISelectionProvider
directly using:
IViewPart part = .. find package explorer view part
IViewSite viewSite = part.getViewSite();
ISelectionProvider provider = viewSite.getSelectionProvider();
ISelection selection = provider.getSelection();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With