User Tools

Site Tools


This is an old revision of the document!

Eclipse e4 RCP Theming

Giving an Eclipse e4 application a new theme is rather easy with the e4 css theme support. There are many tutorials and articles about it.

And you can give your e4 RCP application a distinct theme. No problem there. But when you want to give your user the ability to switch themes that is a completely other story. Switching themes includes accessing the IThemeManager which is in the package org.eclipse.ui.themes. Still sounds easy enough. Importing the package as a dependency and add the bundle org.eclipse.ui.themes to the application build and we are all done.


There is a bundle with the symbolic name org.eclipse.ui.themes but it doesn't export the java package org.eclipse.ui.themes. The bundles contains the CSS and image files but no java package.

I found the package in the bundle org.eclipse.ui.workbench. What the f…!!! That is an Eclipse 3.x bundle.

So no IThemeManager for switching themes.

But if we can't switch themes dynamically perhaps we can load the correct theme on application start … and yes, that is possible. Long live the PartRenderingEngine.

import org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;

public class LifeCycleManager {

	void postContextCreate(IEclipseContext context) {
		String cssURI = "platform:/plugin/miworkplace.ui.themes/css/dark.css";
		this.context.set(E4Workbench.CSS_URI_ARG, cssURI);
		PartRenderingEngine.initializeStyling(Display.getCurrent(), this.context);

e4_rcp_theming.1513005460.txt.gz · Last modified: 2017/12/11 15:17 by mihael