Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Requirements to use FXCanvas in Eclipse plugins?
Requirements to use FXCanvas in Eclipse plugins? [message #1766631] Fri, 23 June 2017 15:51 Go to next message
Theodore Murdock is currently offline Theodore MurdockFriend
Messages: 5
Registered: January 2015
Junior Member
I'm wondering what bundle I'm supposed to depend on currently in order to have access to javafx.embed.swt.FXCanvas...

I'm currently in the process of switching a plugin from depending on a customized version of SWT_AWT + Albireo (removing the deadlock-prone assumption that one of the two UI threads can safely lock on the other) to instead using FXCanvas + SwingNode to display Swing components in Eclipse.

I gather, from what I've seen, that classloading FXCanvas is a bit complicated in osgi, but I was happy to see that you had put out an orbit bundle (org.eclipse.fx.javafx) that we could depend on to make sure it was available...but now it seems you've deprecated that bundle, as I'm seeing a warning to that effect when I debug my plugin.

I'm seeing suggestions that the plugin dependency should be replaced with the VM argument -Dorg.osgi.framework.bundle.parent=ext

...is that command-line argument sufficient for all Eclipse installations, regardless of whether e(fx)clipse is installed, or is there a p2 orbit bundle that we must also depend on?

Is it necessary to require our customers to modify their Eclipse.ini by hand if we switch to using FXCanvas?
Re: Requirements to use FXCanvas in Eclipse plugins? [message #1766938 is a reply to message #1766631] Wed, 28 June 2017 21:12 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
First of all using SwingNode in FXCanvas sounds a bit scary and won't save you from deadlocks because Swing would still run on its own event dispatcher thread so you gained nothing from this exercise! You can force Swing on the SWT event thread without the use SwingNode but stay with SWT_AWT - see https://tomsondev.bestsolution.at/2014/02/10/embedding-swing-into-swt-on-java8/

Back to your question: If you want to embed JavaFX in SWT "-Dorg.osgi.framework.bundle.parent=ext" does not help you but you still need our Equinox-Adapter-Hook (org.eclipse.fx.osgi) who is available from our Update-Site (http://download.eclipse.org/efxclipse/runtime-shared-released/3.0.0/site) and if you bundle the "org.eclipse.fx.osgi"-fragment the p2 installer makes the necessary entries in your Eclipse.ini. In case you use the adapter-hook you can remove the import package declarations. This way usage of OSGi works the same in plain Equinox-OSGi (-Dorg.osgi.framework.bundle.parent=ext) and Eclipse-SWT-OSGi (org.eclipse.fx.osgi)
Re: Requirements to use FXCanvas in Eclipse plugins? [message #1768698 is a reply to message #1766938] Fri, 21 July 2017 18:30 Go to previous message
Theodore Murdock is currently offline Theodore MurdockFriend
Messages: 5
Registered: January 2015
Junior Member
We do gain something from the exercise, because SWT/AWT is responsible for the deadlocks, it blocks one UI thread on another, which is not safe because they lock the same native resources.

Our version that removes those deadlocks and integrates the abandoned Albireo improvements has its own issues. Java's own SwingNode class is a big improvement over SWT/AWT: it has the right level of access to Swings internals to be able to get things right without (as?) weird hacks, and they made the right assumption, that all communication between the two UI threads must be asynchronous, unlike SWT/AWT.

Of course, one still has to keep in mind that it's a multi-threaded UI, and be sure to never block from one UI thread on the other (which even requires odd things like never checking whether you're on the AWT thread from the SWT thread), but with the right thread-switching tools it's possible to embed Swing in SWT via FX.

So the change was that org.eclipse.fx.javafx is replaced by org.eclipse.fx.osgi? Thanks!

[Updated on: Fri, 21 July 2017 18:44]

Report message to a moderator

Previous Topic:@PostConsturct not always called
Next Topic:CI with Jenkins and suggested project structure
Goto Forum:
  


Current Time: Tue Mar 19 04:13:38 GMT 2024

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

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

Back to the top