Time for action – switching between themes
The themes can be switched at runtime by interacting with the IThemeEngine
, which can be acquired from the Eclipse 4 runtime service through injection. This provides a list of all installed themes, which can be used to populate the list viewer, and to allow the style to be changed.
- Create a class called
ThemePart
in thecom.packtpub.e4.application.parts
package. Add an injected fieldIThemeEngine
, and acreate
method annotated with@PostConstruct
that takes aComposite
parameter:public class ThemePart { @Inject private IThemeEngine themeEngine; @PostConstruct public void create(Composite parent) { } }
- In the
create
method, add aListViewer
that is associated with anArrayContentProvider
:ListViewer lv = ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.