I'm trying to get the instance of a view part in an Eclipse e4 application but I can't find the PlatformUI class. Has the name changed since Eclipse 3 or is it located in a different package?
When looking at Eclipse e4 Parts:

bugs like 371405 can be instructive:
This API no longer works in 4.2, and we never intend to make it work.
It is incompatible with the pluggable rendering story in 4.2. Decisions that could once be made by the presentation extensions are now up to the renderer.Affected API that needs deprecation:
- Entire API package:
org.eclipse.ui.presentations- Extension point:
org.eclipse.ui.presentationFactories
org.eclipse.ui.IWorkbenchPreferenceConstants#PRESENTATION_FACTORY_ID
org.eclipse.ui.IWorkbenchWindowConfigurer#getPresentationFactory
org.eclipse.ui.IWorkbenchWindowConfigurer#setPresentationFactory
The rest of the Tutorial explains how to declare "parts" (editors or views)
The OP August Karlstrom mentions:
This used to work:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("some view");
Using a singleton like PlatformUI is a bad practice and one of the reason of the introduction, in e4, of Context. See this presentation on Context.
Paul Webster (IBM Eclipse Platform team member) comments:
In Eclipse4 you would use
org.eclipse.e4.ui.workbench.modeling.EPartService.findPart(String)to find anMPartby ID.
TheMPartcontains the injected part in its object property.
As the page Workbench_Services details:
In e4, the notion of a workbench page will not be present.
The part service API will essentially be a merge of the existing 3.xIPartServiceandWorkbenchPageinterfaces.
Note that this isn't ideal, as bug 372488 illustrates (following this thread):
An
MPartfor anMPartDescriptoris created withEPartService.createPart(descriptor_id), where descriptor_id is the identifier of theMPartDescriptor.
This part can be found again withEPartService.findPart(descriptor_id)-- if there is only one.The problem is, that one may need do create more than one
MPartfor oneMPartDescriptor.
An editor may be one example: one may want to edit different instances of one and the same kind.The creation of more than one
MPartfor a givenMPartDescriptoris possible, but there is no convenient method to find these parts.EPartService.findPart(descriptor_id)will return the firstMPartcreated for a particularMPartDescriptor, even if there is more than one.
So there are three problems, for a given MPartDescriptor:
EPartService.findPart(id)does not tell that there is more than oneMPart.- There is no convenient way to get all
MPartsfor this descriptor.- There is no API-way to get the particular
MPartfor given descriptor and "content" or "reference".Currently the way to go is using
EPartService.getParts()which unfortunately returns allMParts, not only those corresponding to one particularMPartDescriptor.
Then one would need to check, whether there is oneMPartfor the particularMPartDescriptorhaving a particular "content".So something is missing that will find an
MPartfor a givenMPartDescriptorwith particular "content" or "reference".
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