Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How do i get the styling engine for non e4 projects
How do i get the styling engine for non e4 projects [message #1860472] Tue, 08 August 2023 16:45 Go to next message
Chris Genly is currently offline Chris GenlyFriend
Messages: 6
Registered: May 2019
Junior Member
I'm attempting to take an existing plugin and have it honor the dark and light themes. The plugin is not an e4 plugin. I'm having trouble figuring out how to get the styling engine. In an e4 project it looks easy, you just use injection. Here is my lame attempt that didn't work

I'm using Eclipse 4.26

		IEclipseContext context = Workbench.getInstance().getContext();
		IStylingEngine iStylingEngine = null;
		if (context != null)
			iStylingEngine = context.get(IStylingEngine.class);
		System.out.println(iStylingEngine);


The styling engine comes back as null. This wouldn't be a great solution even if it worked, the Workbench.getInstance() is not public API.

How do I get the styling engine?
Re: How do i get the styling engine for non e4 projects [message #1860473 is a reply to message #1860472] Tue, 08 August 2023 17:18 Go to previous message
Chris Genly is currently offline Chris GenlyFriend
Messages: 6
Registered: May 2019
Junior Member
This seems to work.
		
		IStylingEngine iStylingEngine = null;
		Optional<MApplication> optApplication = PlatformUI.getApplication();
		if (optApplication.isPresent()) {
			MApplication application = optApplication.get();
			IEclipseContext context = application.getContext();
			if (context != null)
				iStylingEngine = context.get(IStylingEngine.class);
		}
		System.out.println(iStylingEngine);
Previous Topic:How to assign a issue from eclipse platform github to myself
Next Topic:IntelOne Mono font incorrectly rendered
Goto Forum:
  


Current Time: Thu May 30 16:30:42 GMT 2024

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

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

Back to the top