Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Eclipse 4.0 RCP: Dynamic CSS Theme Switching

DZone's Guide to

Eclipse 4.0 RCP: Dynamic CSS Theme Switching

· Java Zone
Free Resource

Learn how our document data model can map directly to how you program your app, and native database features like secondary indexes, geospatial and text search give you full access to your data. Brought to you in partnership with MongoDB.

The css theming capabilities of the Eclipse 4.0 SDK are improving. Especially the mechanism to implement a dynamic theme switcher is much easier now. If you want to implement a css theme switcher, you just need to contribute to the extension point org.eclipse.e4.ui.css.swt.theme. Here is an example from my e4 contacts demo for declaring two themes:

<extension
point="org.eclipse.e4.ui.css.swt.theme">
<theme
basestylesheeturi="css/dark-gradient.css"
id="org.eclipse.e4.demo.contacts.themes.darkgradient"
label="Dark Gradient Theme">
</theme>
<theme
basestylesheeturi="css/bright-gradient.css"
id="org.eclipse.e4.demo.contacts.themes.brightgradient"
label="Bright Gradient Theme">
</theme>
</extension>

Then you need to specify a handler that does the actual theme switching. Here is the whole handler code for switching to the dark gradient theme:

public class DarkThemeHandler {

@Execute
public void execute(IThemeEngine engine) {
engine.setTheme("org.eclipse.e4.demo.contacts.themes.darkgradient");
}
}

Use the workbench model to bind this handler to a menu or tool bar item — that’s it. The two screenshots show the results when dynamically switching between the dark and the bright theme.

Kai

From http://www.toedter.com/blog/?p=113

Discover when your data grows or your application performance demands increase, MongoDB Atlas allows you to scale out your deployment with an automated sharding process that ensures zero application downtime. Brought to you in partnership with MongoDB.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}