Bug 572874

Summary: Simplify event service registration in ModelServiceImpl
Product: [Eclipse Project] Platform Reporter: Lars Vogel <Lars.Vogel>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: Lars.Vogel, rolf.theunissen
Version: 4.17   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Lars Vogel CLA 2021-04-15 07:28:52 EDT
ModelServiceImpl uses two methods to register its handler.

@Inject
	public ModelServiceImpl(IEclipseContext appContext) {
		Objects.requireNonNull(appContext, "No application context given!"); //$NON-NLS-1$
		this.appContext = appContext;

	Bundle bundle = FrameworkUtil.getBundle(getClass());
		if (bundle != null) {
		 // handle OSGi case
			}
		} else {
		// handle non OSGi case
		}

I suggest to remove the special handling for the OSGi case, the second approach using the IEventBroker directly also works in OSGi.
Comment 1 Lars Vogel CLA 2021-04-15 07:29:15 EDT
Rolf, do you have an opinion here?
Comment 2 Rolf Theunissen CLA 2021-04-16 14:07:19 EDT
It seems to me that this whole registration could be moved to an @Inject on the UIElement.TOPIC_WIDGET topic, so that no explicit registration to a IEventBroker is needed.

Furthermore, I really wonder if this code (and the call to renderer#createGui) should be in the EModelService, the functionality seems less related to other methods in this class. It might have deserved its own service or addon. Also, IPresentationEngine.CUSTOM_RENDERER_KEY could be used to assign a custom renderer to the hosted elements. Such that there is no rendering code in the ModelService.