UPDATE
Please download the latest version from efxclipse.org
So the next release 0.0.7 with a huge amount of new features is available so let’s directly dive into it them.
Tooling
New Wizards
- A JavaFX category to group all JavaFX-Wizards has been added
- A Wizards to create FXGraph-Files has been added who takes care that the src-gen directory is created if it does not exist so that the fxml-File can be generated for you in the background
FXGraph
Speaking of my FXGraph-DSL the syntax has change so that the live preview e.g. knows where to locate CSS-Files and Resource-Properties take a look the git-repo to see how FXGraph-Files now look like beside that the following things have been changed/improved:
- Autocompletion for controller methods
- Autocompletion for static properties (used mainly to set layout informations)
- JavaDoc displayed for fairly Java elements you reference (controller, properties, …)
Live Preview
Although this is a feature of the FXGraph-Tooling I think this feature deserves its own entry because it is a really cool feature when writing UIs using FXGraph because you directly see which effect a change is going to have in the final UI. I’ve recorded a small videa showing the FXGraph-Tooling in action:
CSS
I once more fixed some CSS-Problems like the fact that e.g. Alpha-Hex-Colors have been marked as errors
Documentation
I’ve added an install documentation to the Wiki because to get the “Live Preview” working you’ll have to add an extra attribute to your eclipse.ini
Runtime
Detection of Installed JavaFX-Binaries
I’m now reading the installation directory from the Windows registry.
Eclipse Databinding for JavaFX’s properties
A component is included which allows one to use observe properties of JavaFX-Objects using Eclipse Databinding which then allows one to bind them e.g. to JavaBeans, EObjects, … .
Support for DI in FXML-Controllers
Google Guice
For standard java users I’ve added a small library which allows one to use Google Guice for the controllers so that one doesn’t have to think a lot one self on how to inject informations into your controller.
Eclipse DI user
For those of you who want to use Eclipse DI which was developed for Eclipse 4.x and is used by the Eclipse 4.x Application Platform an OSGi bundle is available that takes care of making FXML to work inside Equinox. There are some special things needed as I outlined in this blog post but you don’t need to care about this and simple let you inject a appropriately configured FXML-Loader.
import java.io.IOException; import javafx.scene.Node; import javafx.scene.layout.BorderPane; import javax.annotation.PostConstruct; import at.bestsolution.efxclipse.runtime.di.FXMLBuilder; import at.bestsolution.efxclipse.runtime.di.FXMLLoader; import at.bestsolution.efxclipse.runtime.di.FXMLLoaderFactory; public class MyClass { @Inject @FXMLLoader private FXMLLoaderFactory factory; @PostConstruct void init(BorderPane parent) { try { FXMLBuilder<Node> builder = factory.loadRequestorRelative("personform.fxml"); parent.setCenter(builder.load()); } catch (IOException e) { e.printStackTrace(); } } }
Eclipse 4.x Application Platform for JavaFX
I saw that there was a talk at JavaOne 2011 about providing a JavaFX-RCP-Framework ontop the Netbeans-Core-Runtime – I only looked at their slides and not at their code yet. Well my efforts are the same and this release now holds a first version of an implementation of such a platform.
Here’s the model of the application:
What I think is very nice is how the EAP, FXGraph (FXML), Eclipse Databinding and DI can work together to create an UI. Take a look at the following code:
The Part-Definition:
package at.bestsolution.efxclipse.runtime.examples.e4.parts; import java.io.IOException; import javafx.scene.Node; import javafx.scene.layout.BorderPane; import javax.annotation.PostConstruct; import at.bestsolution.efxclipse.runtime.di.FXMLBuilder; import at.bestsolution.efxclipse.runtime.di.FXMLLoader; import at.bestsolution.efxclipse.runtime.di.FXMLLoaderFactory; public class PersonDetailPart { @PostConstruct void init(BorderPane parent, @FXMLLoader FXMLLoaderFactory factory) { try { FXMLBuilder<Node> builder = factory.loadRequestorRelative("personform.fxml"); parent.setCenter(builder.load()); } catch (IOException e) { e.printStackTrace(); } } }
The controller:
package at.bestsolution.efxclipse.runtime.examples.e4.parts.controllers; import javafx.animation.FadeTransition; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; import javafx.util.Duration; import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.core.databinding.DataBindingContext; import org.eclipse.core.databinding.beans.BeanProperties; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.core.databinding.observable.value.WritableValue; import org.eclipse.e4.core.di.annotations.Optional; import at.bestsolution.efxclipse.runtime.databinding.IJFXBeanValueProperty; import at.bestsolution.efxclipse.runtime.databinding.JFXBeanProperties; import at.bestsolution.efxclipse.runtime.di.FXMLLoaderFactory; import at.bestsolution.efxclipse.runtime.examples.e4.model.Person; @SuppressWarnings("restriction") public class PersonDetailPartController { private IObservableValue master = new WritableValue(); @FXML TextField firstname; @FXML TextField lastname; @FXML TextField street; @FXML TextField zip; @FXML TextField city; private FadeTransition fadeOutTransition; private FadeTransition fadeInTransition; @PostConstruct void init(@Named(FXMLLoaderFactory.CONTEXT_KEY) GridPane rootPane) { IJFXBeanValueProperty uiProp = JFXBeanProperties.value("text"); DataBindingContext ctx = new DataBindingContext(); ctx.bindValue(uiProp.observe(firstname), BeanProperties.value("firstname").observeDetail(master)); ctx.bindValue(uiProp.observe(lastname), BeanProperties.value("lastname").observeDetail(master)); ctx.bindValue(uiProp.observe(street), BeanProperties.value("street").observeDetail(master)); ctx.bindValue(uiProp.observe(zip), BeanProperties.value("zip").observeDetail(master)); ctx.bindValue(uiProp.observe(city), BeanProperties.value("city").observeDetail(master)); fadeOutTransition = new FadeTransition(Duration.millis(500), rootPane); fadeOutTransition.setFromValue(1.0f); fadeOutTransition.setToValue(0.0f); fadeOutTransition.setAutoReverse(true); fadeInTransition = new FadeTransition(Duration.millis(500), rootPane); fadeInTransition.setFromValue(0.0f); fadeInTransition.setToValue(1.0f); fadeInTransition.setAutoReverse(true); } @Inject public void setPerson(@Optional final Person person) { if( fadeOutTransition != null ) { fadeOutTransition.setOnFinished(new EventHandler<ActionEvent>() { public void handle(ActionEvent arg0) { master.setValue(person); fadeOutTransition.setOnFinished(null); fadeInTransition.playFromStart(); } }); fadeOutTransition.playFromStart(); } } }
What does the framework provide:
- Modularity through OSGi
- All features it inherits from the Eclipse Application Platform like a Command Framework, Event Bus, Dependency Injection, …
- Themeability through CSS-Contribution (similar to how Eclipse 4.x provides such a feature)
Please note that JavaFX-Renderers are in a very early stage and most of the things are not yet implemented. Improvements will be made in the next releases. If you are interested in example codes, … simply clone my github-repository.
Please provide feedback on problems you encounter with the tooling as well of the runtime components (an important note in this respect is that to make @PostConstruct work you have to set the Bundle-RequiredExecutionEnvironment: J2SE-1.5 and not 1.6!).
Hi Tom,
nice work but I have a question.
Have you ever tried the modularity of your plugins? I mean have you ever uninstalled your plug-in at runtime replaced it with a new version started it up again an rerun a test if the new plug-in is really loaded and the old one really gets unloaded? Because modularity in eclipse is not always what it seams to be (https://bugs.eclipse.org/bugs/show_bug.cgi?id=325965).
Regards
René
You are mixing 2 different things here:
While I agree that dynamic loading/unloading is a cool feature of OSGi I don’t think this is what modularity is. The Eclipse 4.x Application Platform (EAP) currently does NOT support Dynamic Bundle unloading/loading and so the JavaFX versions doesn’t provide it either but once EAP has it my JavaFX version inherits it from upstream. EAP already tracks the information need support such a feature but we haven’t implemented it yet (the same is true for the Eclipse DI stuff).
Pingback: JavaFX links of the week, October 24 // JavaFX News, Demos and Insight // FX Experience
Pingback: Java desktop links of the week, October 24 | Jonathan Giles
Pingback: Kai's Blog » Java FX 2.0 CSS Styling
Hi, I had installed 0.0.6 and figured the Eclipse Updater available under the Help menu should be able to keep me updated as I follow the upgrade to 0.0.7 and onwards but I get the following error:
Some sites could not be found. See the error log for more detail.
No repository found at https://github.com/tomsontom/e-fx-clipse.git.
Unable to read repository at jar:file:/Users/Zoomclub/Desktop/at.bestsolution.efxclipse.tooling.updatesite-0.0.6.zip!/content.xml.
error in opening zip file
No repository found at https://github.com/tomsontom/e-fx-clipse.
No repository found at file:/Users/SuperstringMedia/Desktop/tomsontom-e-fx-clipse-c02f1c8/.
Do I need to go through the manual download and re-install process continually? Sorry for my inexperience and over expectations of Eclipse if that is the case :-]
There’s currently no other option than to download the ZIP and follow the instructions I’ve put on the wiki. To install the 0.0.7 release you also have to add another update-site you probably don’t have yet. So make sure you follow the instructions given on https://github.com/tomsontom/e-fx-clipse/wiki/Installation
And just to state it: This is not a problem of Eclipse but of how i publish the update site because github doesn’t give me another option than to publish a zip-File. I know that’s not an ideal situation but I’m unable to to change that for now. So just download the new zip file and point the update-wizard to the 0.0.7-zip. If you don’t want to see the Unable to read repository at jar:….. you should remove this entry from your install list.
Pingback: Kai's Blog » Eclipse 4.x RCP + JavaFX Renderer
Pingback: Eclipse 4.x RCP + JavaFX Renderer
Pingback: » Java FX + Eclipse + Ubuntu Linux Sagas
I want to create a development framework which will be installed as a plugin in eclipse and leverage eclipse features to create unique development project. In order to do so I want to
use javaFx and eclipse PDE to develop this plugin. I would like to know if there is some documentation or tutorial available which discuss how to create wizards, context menu etc on eclipse environment using javaFx instead of swt/jface.
The real problem when using JavaFX inside the IDE is that you need to use FXCanvas, if you contribute a wizard the outerpart is made by SWT (e.g. the header, buttons, …) you only control the content are and of course there’s going to be an L&F break because JavaFX components look completely different. Same goes for editors where the menus, … are still rendered through SWT and all you can control is the inner part of the editor. Context-Menus are done through IDE-extension points so their are rendered in SWT.
To sum up, yes you can write your stuff in JavaFX but it has its draw backs.
Hi Tom,
Creating an Eclipse ViewPart using JavaFX is not rendering the view as expected.
https://www.eclipse.org/forums/index.php/m/1847614/#msg_1847614
Could you please help me with this?
Thanks,