I followed this post Get TreeViewer in RCP from another Plugin . When I add this code to a handler, I got the exception " java.lang.IllegalStateException: Workbench has not been created yet.
":
@Execute
public void execute() {
IWorkbench wb = PlatformUI.getWorkbench();
}
If I execute this code in a part, there are no exception:
@PostConstruct
public void createComposite(Composite parent) {
IWorkbench wb = PlatformUI.getWorkbench();
}
I don't know why. Can you help me? Thanks!
In a pure e4 application PlatformUI
(and IWorkbench
, IWorkbenchWindow
, IWorkbenchPage
) are not available at all. Many techniques described in various places for Eclipse only work for 3.x compatibility mode RCPs.
The call in your part is most likely also throwing an exception but it is only being logged (or discarded altogether).
In an e4 application you use the findPart
method of EPartService
to find another part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.