Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to listen theme change event ??
How to listen theme change event ?? [message #1062190] Thu, 06 June 2013 13:09 Go to next message
SD Khan is currently offline SD KhanFriend
Messages: 63
Registered: May 2013
Member
Hi all,

I want's to listen the theme change event in my eclipse rcp application , i have done the following steps.

1. Created a rcp application (3.x)

2. created extension point "org.eclipse.e4.ui.css.swt.theme" and added two themes in it and set the respective css files for each theme.

3. Added a ViewerPreferencePage, which given the option to change theme.


Now, when i change theme , it work's fine and applied on all the swt controls which i have specified in css file, Actually i want's to listen the event when theme is changed ??,

I have done the following steps.

Register theme.
PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(new ThemeChangeHandler());

"ThemeChangeHandler" is the class which implements the "org.eclipse.jface.util.IPropertyChangeListener".

But nothing happens when theme is changed and my listener doesn't fire,


Any help/clue/idea/hint will be appreciated Razz .

Thanks,
SDK


Re: How to listen theme change event ?? [message #1860519 is a reply to message #1062190] Fri, 11 August 2023 20:08 Go to previous messageGo to next message
Chris Genly is currently offline Chris GenlyFriend
Messages: 6
Registered: May 2019
Junior Member
I ran into a similar need. It seems to me what you did is very reasonable. I don't know why google points to this unanswered question as a first result. So ten years later, here is my approach.

I don't know if this is supported AI. I just listen for a preference store change.

	IPreferenceStore runtimeStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.e4.ui.css.swt.theme");
	runtimeStore.addPropertyChangeListener(ev -> {
			if (ev.getProperty().equals("themeid")) {
Re: How to listen theme change event ?? [message #1860737 is a reply to message #1860519] Wed, 30 August 2023 17:17 Go to previous message
Chris Genly is currently offline Chris GenlyFriend
Messages: 6
Registered: May 2019
Junior Member
This seems to be a more official way:

		import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;

		IEventBroker eb = PlatformUI.getWorkbench().getService(IEventBroker.class);
		eb.subscribe(IThemeEngine.Events.THEME_CHANGED, event -> {
			
		});

[Updated on: Wed, 30 August 2023 17:18]

Report message to a moderator

Previous Topic:Occasional Exit hang/crash
Next Topic:ClassNotFoundException emf.ecore cannot find emf.common
Goto Forum:
  


Current Time: Mon Oct 07 05:32:22 GMT 2024

Powered by FUDForum. Page generated in 0.03680 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top