Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Multiple Application.launch() from Plugin jobs(How to mimic application.launch more than once from menu command handlers)
icon3.gif  Multiple Application.launch() from Plugin jobs [message #1724871] Fri, 26 February 2016 16:48 Go to next message
Colin Donovan is currently offline Colin DonovanFriend
Messages: 3
Registered: February 2016
Junior Member
I am developing a plugin for Eclipse. I am using JavaFX for multiple features of this plugin. I have a menu built into the UI of Eclipse with handlers for each command i.e. each feature clicked. For example: user clicks "Start Symbol Table" then the SymbolTableHandler is called.

Each of these handlers starts a JavaFX application from an Eclipse job to make sure the UI does not become unresponsive. The JavaFX applications use application.launch() to begin.

My problem is that when a user starts two features, an error is thrown due to the limitation of only being allowed to call application.launch() once.

This would not be a problem if all features started together as I could create new stages manually and only call the launch() once etc.

So is there a way to mimic application.launch multiple times so multiple tables/features of this plugin can be run together ?
Re: Multiple Application.launch() from Plugin jobs [message #1725030 is a reply to message #1724871] Mon, 29 February 2016 08:14 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6313
Registered: July 2009
Senior Member
If I got right you are in an SWT-RCP/Eclipse-Plugin. The problem you
have is that you need bootstrap JavaFX where there's no public API hence
you launch an application. Are those assumptions right? If yes the you
have the following choices:
* Embed an FXCanvas somewhere in your UI which is instaniated before you
try to launch something
* Bootstrap through the none public API PlatformImpl.startup(Runnable)
=> there will be a public API in Java9!

Tom

On 26.02.16 21:48, Colin Donovan wrote:
> I am developing a plugin for Eclipse. I am using JavaFX for multiple
> features of this plugin. I have a menu built into the UI of Eclipse with
> handlers for each command i.e. each feature clicked. For example: user
> clicks "Start Symbol Table" then the SymbolTableHandler is called.
>
> Each of these handlers starts a JavaFX application from an Eclipse job
> to make sure the UI does not become unresponsive. The JavaFX
> applications use application.launch() to begin.
>
> My problem is that when a user starts two features, an error is thrown
> due to the limitation of only being allowed to call application.launch()
> once.
>
> This would not be a problem if all features started together as I could
> create new stages manually and only call the launch() once etc.
>
> So is there a way to mimic application.launch multiple times so multiple
> tables/features of this plugin can be run together ?
Re: Multiple Application.launch() from Plugin jobs [message #1727179 is a reply to message #1725030] Mon, 21 March 2016 03:19 Go to previous message
Colin Donovan is currently offline Colin DonovanFriend
Messages: 3
Registered: February 2016
Junior Member
I have made a solution to this problem. It involves creating a MultiLauncher class which has instances of each of the desired JavafX UI's with methods for creating new stages.

This MultiLauncher is created inside the activator and is started in a new thread, it's start method is empty.

In each handler, the packageName.Activator.getDefault().getLauncher(); is called to get the reference to the original JavaFX application i.e MultiLauncher.

In each handler a new job is created and has references to each UI inside MultiLauncher, each UI can then create a new stage. This must be surrounded with Platform.runLater to allow access to the JavaFX thread.

Finally, setImplicitExit is set to false to allow you to close and restart all UI's.

Let me know if anybody would like further information or the source code.

Note: The Multi-launcher and app.launch() does not have to be called in the activator, however, due to Tool-Kit's not setting up on time in handler jobs, it seems to be the best work-around.
Previous Topic:is it possible to use eclipse service in controller of fxml?
Next Topic:Nightly target builds unuseable because Platform introduced a dependency on SWT
Goto Forum:
  


Current Time: Sat May 27 00:26:44 GMT 2017

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

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