Making @Service annotation even cleverer

As some of you might know e(fx)clipse provides a Eclipse DI extension supporting more powerful feature when we deal with OSGi-Services:

  • Support for dynamics (eg if a higher-ranked service comes along you get it injected, …)
  • Support for service list
  • ServiceFactory support because the request is made from the correct Bundle

Since tonights build the @Service annotation has support to define:

  • A static compile time defined LDAP-Filter expression
    public class MySQLDIComponent {
      @Inject
      public void setDataSource(
        @Service(filterExpression="(dbtype=mysql)") 
        DataSource ds) {
         // ...
      }
    }
    
    public class H2DIComponent {
      @Inject
      public void setDataSource(
        @Service(filterExpression="(dbtype=h2)") 
        DataSource ds) {
         // ...
      }
    }
    
  • A dynamic LDAP-Filter expression who is calculated at runtime and can change at any time
    public class CurrentDatasource extends BaseValueObservable<String> implements OString {
      @Inject
      public CurrentDatasource(
        @Preference(key="database",defaultValue="h2") String database) {
        super("(dbtype="+database+")");
      }
    
      @Inject
      public void setDatabase(
        @Preference(key="database",defaultValue="h2") String database) {
        setValue("(dbtype="+database+")");
      }
    }
    
    public class DIComponent {
      @Inject
      public void setDataSource(
        @Service(dynamicFilterExpression=CurrentDatasource.class)
        DataSource ds) {
        // ...
      }
    }
    

    You notice the dynamic provider itself if integration fully into the DI-Story 😉

Advertisements
Posted in e(fx)clipse | Leave a comment

Improving Min/Max performance in “e4-on-JavaFX” applications

When it comes to performance in JavaFX one of the biggest problems is that if you detach and reattach a big SceneGraph-Part you run:

  • CSS-Pass
  • Layout-Pass

So in general one should avoid those operations as much as possible but there are situations you can’t get something implemented without doing exactly this kind of thing.

In the current architecture of e(fx)clipse we need to use this reparenting in case of minimizing/maximizing certain areas of your e4-on-JavaFX application which might lead to a very poor user experience if you eg have a MPartStack with many complex substructures (like eg our code editor).

Today we took a closer look for one of our customers to find out if we – the e(fx)clipse – framework can do anything to fix that problem and after some experiments we managed to come up with a solution who allows us to reparent the content of an MPartStack in constant time:

In general I’d say that such optimization should not be required and JavaFX CSS and Layout performance HAS to be improved in general and JavaFX-Components have to get smarter in not running CSS-Passes on SG-Parts who are currently not showing.

Posted in e(fx)clipse, Uncategorized | 4 Comments

New SashLayout container has landed in e(fx)clipse

I just pushed a new layout-container who has a similar feature set than the JavaFX built-in SplitPane but ensures that proportions are not corrupted if you shrink the container (just watch the video below to get an idea what I mean).

The layout algorithm is not something I came up myself. I just reworked the one from SWT to be used in JavaFX.

Posted in e(fx)clipse | 8 Comments

Building e4 JavaFX applications with gitlab-ci and docker

We’ve decided internally sometime ago to use a self-hosted gitlab instance for our projects.

To get started quickly we first only used the ticket-system and keep our jenkins-instance to do our builds which works fine but it somehow bothered me that we’ve been unable to use the gitlab-ci system integrated directly into the gitlab-instance.

So yesterday we started to explore how we can do builds using the docker integration of gitlab-ci and after some troubles with FreeBSD & docker (where our gitlab instance is hosted on) we managed to get a build going.

If you want to do that as well. You can make use of a docker-image we prepared containing:

  • Maven 3.3.x
  • Oracle-JDK-8

(we unfortunately could not use the java-images provided by dockerhub because they ship OpenJDK8 who does not include JavaFX).

So if you run your e4 on JavaFX project as well on gitlab all you need to do is to add a gitlab-ci.yml to your git-repository holding the following content:

image: tomsontom/oracle-java8-mvn:latest

build:
  script: "cd my.project.app.releng; mvn clean package"
Posted in e(fx)clipse | 2 Comments

e(fx)clipse 2.4.0 & Eclipse Neon Builds available

For those who want to get an easy head start into JavaFX development with Eclipse as an IDE BestSolution provides a service many developers make use of (eg in June the IDE got downloaded 4000 times).

We provide All-in-One builds similar to the ones you can grab from Eclipse.org but we bundle even some external libraries for you with it.

We now managed to update the provided IDE to the latest and greatest:

  • Eclipse 4.6.0 SDK
  • e(fx)clipse 2.4.0
  • Xtext 2.10.0
  • EGit 4.4.0
  • WST-XML 3.8.0
  • Subclipse 1.8.20
  • m2e 1.7.0
  • bndtools 3.2.0
  • AnyEditTools 2.6.1
  • Findbugs 3.0.2
  • Eclemma 2.3.3

Finally if you like this an other services (eg. leaving no question at the newsgroup unanswered) BestSolution provides for free think about sponsoring our work.

If you rely on e(fx)clipse for your commercial product we suggest you sign a service and support contract with BestSolution.

Posted in Uncategorized | Leave a comment

Slides and Source from Munich DemoCamp on Java9

I’ve pushed the slides and source-code I used for my short introduction at the Munich Eclipse Democamp

Posted in Uncategorized | Leave a comment

e(fx)clipse 2.4.0 released

we are happy to announce that e(fx)clipse 2.4.0 has been released last week. The main working area in this release has once more been the code editor framework.

Code editor framework

Starting with this release we are have replacement for all features one is used from your Eclipse IDE Code-Editing framework, like keyboard navigation, hover-information, … .

We’ve as always taken extra care that we are not introduce JavaFX dependencies but kept a clean split between core-services providing the plain data and visualization services presenting those plain data points (eg in JavaFX).

  • Lexical-Code-Highlighting improvements:
    • Our custom rules have been adjusted to match the highlighting behavior known from the Eclipse Java-Editor.
      Old

      New
    • New rules to eg support lua multi-line string and comments. I confess I’ve not seen a language before who has a similar concept for multi-line constructs. If you are not familiar with lua let me try to explain it. A multi-line comment starts with --[ followed by an optional number of "="-chars followed by another "[" and then ends with "]" the same amount of "="-chars than you used in the start section followed by another "]"
      --[==[
      I'm a multi line
      comment
      ]==]
      
      lua-code
      
      --[====[
      I'm a multi line
      comment
      ]====]
      

      We have enhanced our highlighting format to support this kind of rules. For lua it looks like this:

      // ...
      rule {
        multi_line __lua_ml_comment   "--[" pattern '(=*)' '['   => "]{0}]"
        single_line __lua_sl_comment  "--"  => ''
        multi_line __lua_ml_string    "["  pattern '(=*)' '['   => "]{0}]"
        single_line __lua_string      "'"   => "'" escaped by "\\"
        single_line __lua_string      '"'   => '"' escaped by "\\"
      }
      // ...
      
    • While the ldef-language allows to specify rules very easy those rules have to be defined up-front which sometimes is not possible to the highlighting needs to adapt based on other conditions. We enhanced the system to contribute rules dynamically by registering a service of type DynamicScannerRuleCalculator
  • Autocomplete improvments: You can now configure the editor to invoke auto-complete system not only on CTRL+Space but as well eg at the moment you type "."-character
  • Code navigation support: This release introduces code navigation like you know it from your Eclipse IDE (including low-level APIs to jump to positions inside your editor control)
  • Support for block matching: We implemented exemplary code to show how one can implement block matching (eg matching braces)
  • Code rearrangement with DnD: We now have support to rearrange code parts using DnD
  • Support for undo/redo: We’ve now connected the editor to the undo/redo system available in eclipse.text

e4 on JavaFX

Prebuilt Perspective Switchers

The framework now provides:

  • A perspective switcher control one can embed into the TrimBar (PerspectiveSwitcherComponent)
  • A heavy and a lightweight perspective switcher dialog and a handler to trigger the dialog the appropriate one

New tag to center MWindow

You can now add the tag "efx-center-on-screen" to your Application.e4xmi and the window will be centered on screen.

Tab-Context-Menu

One can now register MPopupMenu on an MPart who is translated into a context-menu assigned to the Tab in a TabPane. Just taq the MPopupMenu with "tabmenu" and e4 on JavaFX will take care for you to render the context menu.

Other new runtime APIs

TextUtil#templateValuSubstitutor(String,Map)

This new helper allows you to evaluate simple template expressions and applying formats on it.

class Person {
   String name = "Tom";
   Date birthday = new Date(1,4,79);
}

Person p = new Person();
TextUtil.templateValuSubstitutor( 
  "The birthday from ${p.name} is on ${p.birthday,date,short}", Collections.singletonMap("p",p) );

ImageProvider support HiDPI images

JavaFX itself supports HiDPI images already since sometime but the internal abstraction who is used by e4 on JavaFX lacked such a support. This has been fixed with this release.

Delayed observables

To appropriately support undo/redo in form based UIs it is very important to collect changes in logical units. A good example is the that you probably would not require the user to undo each and every keystroke in a text-field. To address this use case Eclipse Databinding for SWT has the concept of so called delayed observables who wait for a certain amount of time before they inform others about their modification.

Eclipse Databinding for JavaFX controls now has the same concept.

TextField f = new TextField();
IObservableValue textObs = JavaFXUIProperties.text2().observeDelayed(400, f);

Error-Decoration

For form base UIs it is crucial to display validation information. We added new API to our control-library to who supports field decorations. The API is designed to work equally well in a basic scenario as well as when using MVVM (in the same vein we added new properties you can publish in your ViewModels)

static class VM {
  private final ValidatedStringProperty firstname;
  private final ValidatedStringProperty lastname;
  private final StatusAggregator aggregator;

  public VM(String firstname, String lastname) {
    this.firstname = new ValidatedSimpleStringProperty(new SimpleStringProperty(this, "firstname",firstname));
    this.firstname.registerValidator(s -> s.isEmpty() ? Status.status(State.ERROR, -1, "Vorname muß befüllt sein", null) : Status.ok());

    this.lastname = new ValidatedSimpleStringProperty(new SimpleStringProperty(this, "lastname", lastname));
    this.lastname.registerValidator(s -> s.isEmpty() ? Status.status(State.ERROR, -1, "Nachname muß befüllt sein", null) : Status.ok());

    this.aggregator = new StatusAggregator(this.firstname,this.lastname);
  }
}

VM vm = new VM("Tom", "Schindl");

{
  Label l = new Label("Vorname");
  p.getChildren().add(l);

  TextField field = new TextField();
  field.textProperty().bindBidirectional(vm.firstname.bindProperty());

  NodeDecorator.apply(field, vm.firstname);
  p.getChildren().add(field);
}
Posted in Uncategorized | 17 Comments