e(fx)clipse 0.0.6 released

UPDATE
Please download the latest version from efxclipse.org

I’ve justed pushed the 0.0.6 release of my JavaFX 2.0 Tooling and Runtime for Eclipse named e(fx)clipse to my git-repo and you can download the p2 repo to your local hard drive and install it using this link (DO NOT SIMPLY UNPACK THE ZIP TO YOUR ECLIPSE-INSTALL USE THE “Install New Software…”-Wizard!).

This release is the first one which does not only hold tooling stuff but also runtime components but I’ll go into detail after having introduced the new tooling features. Here’s a list of new and noteworthy stuff.

Tooling

css

Since b45 the CSS-Syntax for gradients changed to be valid CSS the CSS-Tooling of e(fx)clipse is now in sync with the one from the runtime. This release holds improved validation for radial-gradients

fxml

As outlined in my last blog I don’t think fxml is meant to be authored directly by developers. It is a good foundation for tools to produce JavaFX-Objects graphs instead of generating Java-Code. My approach to it is that I created a small DSL (or better markup language) which provides all the features FXML understands but remove the XML noise – I named the markup language fxgraph. To better view fxml-Files I’ve added an xml-viewer with markup support.

fxgraph

Is a simple DSL which allows one to define a JavaFX object graph but instead of producing executable code as its output it simply creates the an fxml-File which can be interpreted by the JavaFX runtime..

I know that there are a number of DSLs out there (GroovyFX, ScalaFX, Visage, …). The difference here is that fxgraph is not a programming language but a markup language which is used at design time but has no runtime concepts. The output of a fxgraph is fxml – so it is not a replacement for fxml but a different way to express the content of a fxml-File. The really cool thing about fxgraph is the excellent integration with Eclipse JDT/PDE because of Xtext+Xbase+JvmTypes which provides you content assistent like you get it in JDT.

Class-ContentAssist for Element Definition

Property-ContentAssist for Elements

PDE

OSGi is one of the keyconcepts in the up coming runtime components but to make the experience for users as good as possible integration into PDE is an absolute must. One of the most important things in this sense are project templates who allow a developers to:

  1. Create a runnable JavaFX Equinox OSGi-Application
  2. Create an OSGi-Bundle which uses JavaFX

The wizards are even more important for JavaFX based applications because there are some special settings and classpath adjustments needed to make your application compile, exported and run using Eclipse JDT/PDE.

Application Wizard
used to created an OSGi-Application bundle including a application and production definition in the plugin.xml

Bundle Wizard
used to create an OSGi-Bundle which uses JavaFX classes

Product Wizard
used to create a .product-File which is can be used to export an JavaFX application inside Eclipse or by using maven-tycho.

There’s no big difference to .product definition created by the default “Product Configuration” wizard but as always – the small things make the difference because to make JavaFX useable in OSGi (Equinox) one has to configure the Framework Adaptors appropriately and this is what the “JavaFX Product Configuration” wizard takes care of (See my other blog for some background info).

Runtime

As outlined in the first paragraph this release comes with a set of runtime components who are needed as a foundation for more sophisticated ones like the Eclipse 4 Application Platform. So what does this release come with:

Layout-Panes

I’ve ported some of the layouts one is used to from SWT:

  • FillLayoutPane: Is the FillLayout as you know it from SWT
  • GridLayoutPane: Is the GridLayout as you know it from SWT
  • RowLayoutPane: Is the RowLayout as you know it from SWT
  • SashLayoutPane: This one is probably not know to most of the people because it is not part of SWT nor Eclipse 3.x but has been developed for use in Eclipse 4.x which is not using Sashes for splitting up the Workbench-Window but a Layout

OSGi-Support

To make JavaFX useable in OSGi I’ve implemented 2 bundles and 1 fragment who make – together with the PDE-Integration – very easy to develop Equinox-OSGi-Applications. The following 2 bundles are available:

  • at.bestsolution.efxclipse.runtime.javafx
    Is a bundle which exports all public javafx-packages so that client bundles can define package-imports. The bundle doesn’t hold the javafx-classes but when equinox requests javafx-Classes from at.bestsolution.efxclipse.runtime.javafx a framework adaptor steps in and does the class look up in the location the oracle-installer placed the javafx.jar in (Warning: At the moment the location is hard coded to “C:/Program Files (x86)/Oracle/JavaFX Runtime 2.0/lib/jfxrt.jar” but this will change with the next release if I can figure out how to locate those files in a better way)
  • at.bestsolution.efxclipse.runtime.osgi
    This is a fragment for “org.eclipse.osgi” which contributes specialized classloader which used by “at.bestsolution.efxclipse.runtime.javafx”.
  • at.bestsolution.efxclipse.runtime.application
    This bundle provides a base class named AbstractJFXApplication which implements the IApplication-Interface for OSGi-Applications and can be subclassed like this:

    public class Application extends AbstractJFXApplication {
      @Override
      protected void jfxStart(Stage primaryStage) {
        Group root = new Group();
        Scene scene = new Scene(root, 800, 600, Color.BLACK);
        primaryStage.setScene(scene);
      }
    }
    

A whole lot of new features which means a lot of polishing has to go on as the 0.0.6 version number indicates. The most impressive feature I’ve implemented in the tooling is the support for fxgraph but the support for JavaFX in Equinox is also an extremely import feature.

How to author fxml

JavaFX allows one to define an UI not only using the JVM-Language of your choice but also by describing the UI in an XML-Format which is turned into an object graph at runtime.

The JavaFX samples are coming with an example like this:

<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Copyright (c) 2008, 2011 Oracle and/or its affiliates.
 * All rights reserved. Use is subject to license terms.
 *
 * This file is available and licensed under the following license:
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  - Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  - Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the distribution.
 *  - Neither the name of Oracle Corporation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>

<AnchorPane fx:controller="demo.LoginController" id="Login" prefHeight="280.0" prefWidth="480.0"
  xmlns:fx="http://javafx.com/fxml">
  <children>
    <TextField layoutX="68.0" layoutY="58.0" prefWidth="126.0" fx:id="userId" onAction="#processLogin"/>
    <PasswordField layoutX="323.0" layoutY="58.0" prefWidth="126.0" fx:id="password" onAction="#processLogin"/>
    <Label layoutX="229.0" layoutY="61.0" text="Password:" />
    <Label layoutX="16.0" layoutY="61.0" text="User:" />
    <Button layoutX="200.0" layoutY="125.0" text="login" defaultButton="true" fx:id="login" onAction="#processLogin"/>
    <Label layoutX="80.0" layoutY="200.0" textFill="RED" fx:id="errorMessage" />
  </children>
  <styleClass>
    <String fx:value="login" />
  </styleClass>
  <properties>
    <backgroundColor>
      <Color blue="1.0" green="1.0" red="1.0" />
    </backgroundColor>
    <elementLockSel>
      <Boolean fx:value="true" />
    </elementLockSel>
  </properties>
</AnchorPane>

The important thing here is that there’s no DTD or Schema available (which is similar to XAML) but there’s a set of rules how the XML-Elements are mapped to Java-Objects. I’m not going into the details of the mapping the interested reader can consult the PDF which describes the XML-Format in detail – the important fact for me is:

  • XML is very verbose – so a more condense syntax would be favored to author such files and generate the fxml-File from it
  • One needs integration in to Java Development Tools to look up Classes, Attributes, …

Price Question: Which framework in Eclipse world can be used to meet those requirements? Correct Xtext + Xbase + Xtend2 is the perfect match for those requirements. One of the strengths of Xtext is that you get a useable editor out of the box so I defined my own DSL. The translated XML-File from above looks like this:

import java.lang.*
import java.util.*
import javafx.collections.*
import javafx.scene.control.*
import javafx.scene.layout.*
import javafx.scene.paint.*
import javafx.scene.text.*

AnchorPane {
	children: [
		TextField id userId {
			layoutX:68.0,
			layoutY:58.0, 
			prefWidth: 126,
			prefHeight: 280
		},
		PasswordField id password {
			layoutX:323,
			layoutY:58,
			prefWidth:126
		},
		Label {
			layoutX: 229,
			layoutY: 61,
			text: "Password:"
		},
		Label {
			layoutX: 16,
			layoutY: 61,
			text: "User:"
		},
		Button id login { 
			layoutX: 200,
			layoutY: 125,
			text: "login",
			defaultButton: true
		},
		Label id errorMessage {
			layoutX: 80,
			layoutY: 200,
			textFill: "RED",
			call GridPane#rowIndex: 0
		} 
	],
	styleClass: String("login"),
	properties: {
		backgroundColor: Color {
			blue: 1.0,
			green: 1.0,
			red: 1.0
		},
		elementLockSel: Boolean("true")     
	}
}

Which automatically generates the following xml-file in the background while you are editing:

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
	Do not edit this file it is generated by e(fx)clipse from /demo/login.fxgraph
-->
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>

<AnchorPane xmlns:fx="http://javafx.com/fxml"> 
	<children>
		<TextField fx:id="userId" layoutX="68.0" layoutY="58.0" prefWidth="126" prefHeight="280"/> 
		<PasswordField fx:id="password" layoutX="323" layoutY="58" prefWidth="126"/> 
		<Label layoutX="229" layoutY="61"> 
			<text>Password:</text>
		</Label>
		<Label layoutX="16" layoutY="61"> 
			<text>User:</text>
		</Label>
		<Button fx:id="login" layoutX="200" layoutY="125" defaultButton="true"> 
			<text>login</text>
		</Button>
		<Label fx:id="errorMessage" layoutX="80" layoutY="200"> 
			<textFill>RED</textFill>
			<GridPane.rowIndex>0</GridPane.rowIndex>
		</Label>
	</children>
	<styleClass>
		<String fx:value="login"/> 
	</styleClass>
	<properties>
		<backgroundColor>
			<Color blue="1.0" green="1.0" red="1.0"/> 
		</backgroundColor>
		<elementLockSel>
			<Boolean fx:value="true"/> 
		</elementLockSel>
	</properties>
</AnchorPane>

As you see in the end my DSL looks very similar to FX-Script (I’ve never used it myself so I’m doing guess work here).

Anyways the really cool thing is that you get integration into JDT (current only for the element-definition not for the attributes):

  • Content assist integration
  • JavaDoc integration

What I have currently is the default generated editor (took around 8 hours) and I’ll include this initial version into the up-coming e(fx)clipse release.

JavaFX 2.0 and OSGi (Equinox)

If you follow my blog you’ve noticed that I’m currently investing some of my OSS time into JavaFX. The project I’m working on is named e(fx)clipse and until now I’ve been working most of the time on the tooling front but like I promised I don’t only want to provide tooling but also a runtime framework.

So when it comes to runtimes the most important thing for me is that I’m able to use an OSGi-Container (for me equinox is the one with the highest priority) and because JavaFX is NOT shiped with the appropriate OSGi-Metadata it is not as easy to use JavaFX 2.0 in an OSGi-Application.

So I explored multiple different options:

The important things for me are:

  • I don’t want to modify the plain javafx-jar shiped by Oracle – not even sure I would be allowed to do that
  • I’d like to have seemless integration into PDE, so developing an JavaFX-OSGi application should be not different to SWT/Swing
  • I’d like to use the standard export and build tools (Product-Export from IDE, maven-tycho)
  • I’d like to follow OSGi best practices as much possible (e.g. you do a package-import in the client-bundles, let OSGi-wire up stuff at runtime appropriately, …)

In the end I came to the conclusion that using Adapter Hooks is the way to go. So I went ahead and implemented support for this which will make it extremly simple for you to implement JavaFX 2.0 application with Eclipse, Equinox and e(fx)clipse – There are still some glitches in Eclipse to make the PDE-export and JDT happy but I’m going to look into this later on because once you know them they are not really a problem to solve.

I’ll describe in more detail on how to create an (Equinox)OSGi-enabled JavaFX-Application when I release e(fx)clipse 0.0.6 but here are some screenshots to see that this isn’t a pipedream.

Inside Eclipse it looks like standard OSGi-Project:

And here the exported application:

As always when having problems questions about some OSGi stuff Tom Watson from Equinox helped me to get into the right direction.

For those interested in how I managed to teached Equinox the location of the default JavaFX 2.0 classes can look at my github-repo where I already pushed the code and examples to.

e(fx)clipse 0.0.5 released

UPDATE
Please download the latest version from efxclipse.org

So its been less than 1 day after I released 0.0.4 why yet another release within one day?

  1. I got feedback and tracked down some bugs makeing the packaging feature not useable
  2. It looks like the API of the packager changed with b42 and so the build-File didn’t work

Anyways thanks for the feedback I received. Here’s release 0.0.5 that hopefully fixes those problems. It looks like though there’s a bug when using fxml-Files and using the packager which leads to an Exception.

e(fx)clipse 0.0.4 released

Update 2011-09-05:

It was reported that the download link does not work it looks like the old upload failed. I’ve reuploaded the file. Sorry for not having tested the upload.

Update 2011-09-05:

The 0.0.4 release is broken because of b42 changes and an internal bug I introduced please use 0.0.5 and provide feedback if you encounter problems

UPDATE
Please download the latest version from efxclipse.org

Original Post:

Release early and often is something I learned opensource projects should do. So I’m trying to follow this scheme and release new version quite frequently.

This release comes with:

  • CSS improvements

    Once more I improved the CSS compability. The feature that took most of my time was support for the new CSS-compatible gradient syntax (the new syntax will get part of one of the next JavaFX-Builds). Currently validation of linear-gradients is supported, radial support will follow in the next release.

  • Support for JavaFX-Packager

    The JavaFX-SDK comes with an ant-extensions that allows developers to easily package and deploy their JavaFX application.

    The 0.0.4 release adds the possibility to define File with the extension fxbuild which can be opened using an formbased editor

    The fxbuild-File is an ordinary .properties-File

    The Packageing and Build Support integrates itself in the External Tool Launch because internally an ant-Build file is created and launched using the IDE-Support for this

    The build support takes care of classpath dependencies like referenced projects, referenced jars, … and includes them in the generated aretfacts

    One can run directly from the Jar (this is supported)

    Or deploy on the web and launch inside the browser

I read somewhere that e(fx)clipse runs only on Eclipse 4.x which is not correct. e(fx)clipse’s tooling part runs on 3.7 and 4.1. Only the runtime part which is going to part of the project leverages the Eclipse 4 Application Platform.

To prove this here is the tooling running in 3.7.0:

You can download the 0.0.4 update-site archive from my git-repository