YAML Declarative UI (Maven plugin)

Hi Guys,

I have developed a maven plugin which compiles YAML UI definition files to java classes at pre-compile time.

For example, the source file YAML file:


## Vaadin View
---
package: org.fdmtech.yamlcrunch.demo
name: TestGraph
imports:
  - &vl com.vaadin.ui.VerticalLayout
  - &button com.vaadin.ui.Button
  - &window com.vaadin.ui.Window
object:
  - !comp
    <class>: *window
    <name>: root
    caption: Test window
    <children>:
      - !comp
        <class>: *vl
        <name>: layout
        <children>:
          - !comp
            <class>: *button
            <name>: button
            caption: Click here

Generates the java source:


package org.fdmtech.yamlcrunch.demo;

import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Window;

public class TestGraph {

    public Window root;
    public VerticalLayout layout;
    public Button button;

    protected final void init() {
        // Create components
        root = new Window();
        layout = new VerticalLayout();
        button = new Button();
        // Setup
        root.setCaption("Test window");
        button.setCaption("Click here");
        // Hierarchy
        root.addComponent(layout);
        layout.addComponent(button);
    }

    public TestGraph() {
        init();
    }

}

Then you can use it as:


public class MyApplication extends Application {

    @Override
    public void init() {

        TestGraph view = new TestGraph();
        setMainWindow(view.root);

        view.button.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                event.getButton().setCaption("Clicked!!!");
            }
        });
    }
}

Pros:

  • No runtime dependencies
  • Generated classes can be extended
  • Definition errors are detected at runtime

What do you think about this approach?

I want to publish the plugin to the community, is anyone interested?