Bug 483699 - [View Mgmt] Unified API to open parts
Summary: [View Mgmt] Unified API to open parts
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-04 16:56 EST by Andrey Loskutov CLA
Modified: 2016-09-16 04:50 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2015-12-04 16:56:51 EST
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.
Comment 1 Lars Vogel CLA 2015-12-08 05:47:59 EST
The restriction we have is that e4 code is not allowed to have a dependency to e3 plug-ins.
Comment 2 Eclipse Genie CLA 2016-01-07 12:01:01 EST
New Gerrit change created: https://git.eclipse.org/r/63757
Comment 4 Eclipse Genie CLA 2016-01-07 12:54:51 EST
New Gerrit change created: https://git.eclipse.org/r/63761