Community
Participate
Working Groups
Follow up on bug 471782 comment 56. We have different ways and different API's to open legacy/e4 parts. Everyone who wants to open view via id is forced to write the block code below to open a part: String viewId = viewDescriptor.getElementId(); if (CompatibilityPart.COMPATIBILITY_VIEW_URI.equals(viewDescriptor.getContributionURI())) { IWorkbenchPage page = window.getActivePage(); if (page != null) { try { page.showView(viewId); } catch (PartInitException e) { handleViewError(viewId, e); } } } else { MPart part = partService.findPart(viewId); if (part == null) { MPlaceholder placeholder = partService.createSharedPart(viewId); part = (MPart) placeholder.getRef(); } partService.showPart(part, PartState.ACTIVATE); } This code is duplicated now at least 2 times (see ShowViewHandler and ViewElement). The problems I see for the new API implementation: 1) e4 does not differentiate between views/editors, e3 uses different types for them. If we want return the reference to the opened part, we need some tricks because e3 and e4 return types are different. 2) The code naturally belongs to the EPartService but it seem still require the access to the legacy code in WorkbenchPage. Ideally it will be something like: MPart EPartService.openPart(String id, PartState partState). For e3 we must provide some utility method to get IWorkbenchPartReference from MPart, may be just adapter to it. May be I'm just missing something obvious and all the code is lying already somewhere and just need to be properly organized. The code in WorkbenchPage.shiwView(...) and EPartService.showPart(...) should be either deprecated or fixed to properly work via the new API independently if the given id is from e3 or e4, the duplicated code in ShowViewHandler and ViewElement should also be changed to use that new API.
The restriction we have is that e4 code is not allowed to have a dependency to e3 plug-ins.
New Gerrit change created: https://git.eclipse.org/r/63757
Gerrit change https://git.eclipse.org/r/63757 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=afaba1ebc1615d034fcddf6220d3269b8b341550
New Gerrit change created: https://git.eclipse.org/r/63761