Directory

← Back

easylayout

Completely unorthodox but extremely productive API wrappers for Vaadin Layouts

Author

Rating

Popularity

<100

A completely unorthodox but extremely productive API wrappers for Vaadin Layouts

Currently, it only supports Horizontal and Vertical Layouts. Ideally, the unorthodoxy way of working may catch up in other layouts too :)

Using the addon for Vertial and Horizontal layouts

import net.hdavid.easylayout.L.*;
// ...
TextField name;
TextField lastName;
Button save;
Button cancel;
// ...
val vl = ve(name, lastName, ho(save, cancel)); 
// that is it!

A more complex full size view

Button newb = new Button("New");
Button modb = new Button("Modify");
Button delb = new Button("Delete");

Grid grid = new Grid(
   new BeanItemContainer(Arrays.asList(
      new PersonDTO("David Hofmann", 
                    new Date(1986, 07, 29), 
                    30),
      new PersonDTO("Vaadin Is Awesome!", 
                    new Date(), 
                    10))));

protected void init(VaadinRequest request) {

VerticalLayout vl = 
ve(_FULL_SIZE, _MARGIN,               // 1
   ho(_FULL_WIDTH,                    // 2
      _EXPANDER,                      // 3
      delb, ValoTheme.BUTTON_DANGER,  // 4
      modb,                           // 5
      newb, ValoTheme.BUTTON_PRIMARY),// 6
   grid, _FULL_SIZE, _EXPAND);        // 7

setContent(vl); // hard :D ?
}
  1. creating a vertical layout with full size and margin
  2. it's first component is a horizontal layout of full width
  3. the first horizontal layout component is an expander component
  4. the second one is the delete button and a css style is added to it
  5. third component is the modify button
  6. forth component is the new button with a css style added to it
  7. second component of the vertical layout is the grid with its full size and expand ratio to 1f

##FAQ

###Are you completely crazy and lost all your human traits and your oath to code hygiene?

Yeap! It will take me more time to explain you how much it helped me, though. But this "guide" will be updated if you don't get it yet :)

###This code is stupid! Are you aware of static evil and that your code is crappy and totally NOT OOP?

Yes! But for this particular case, it is safe, though, and you'll be okay using it "if" you like brevity in your H/V Layouts.

For rule explanations see the github page for more details.

Sample code

import static net.hdavid.easylayout.L.*;

@Theme("valo")
public class MYLayoutUI extends UI {

    static class MyLayout extends VerticalLayout {

        TextField search = new TextField("Search");
        Grid grid = new Grid(new BeanItemContainer<PersonDTO>(Arrays.asList(
                new PersonDTO("David Hofmann", new Date(1986, 07, 29), 30),
                new PersonDTO("Vaadin Is Awesome!", new Date(), 10)
        )));

        public MyLayout () {
            ve(this, _MARGIN, _FULL_SIZE,
                    search, Alignment.TOP_LEFT,
                    grid, _FULL_SIZE, _EXPAND);
        }
    }

    @Override
    protected void init(VaadinRequest request) {
        setContent(new MyLayout());
    }
}
import static net.hdavid.easylayout.L.*;

@Theme("valo")
public class SimpleLayoutTestUI extends UI {

    Button newb = new Button("New");
    Button modb = new Button("Modify");
    Button delb = new Button("Delete");

    Grid grid = new Grid(new BeanItemContainer<PersonDTO>(Arrays.asList(
            new PersonDTO("David Hofmann", new Date(1986, 07, 29), 30),
            new PersonDTO("Vaadin Is Awesome!", new Date(), 10)
    )));

    @Override
    protected void init(VaadinRequest request) {

        VerticalLayout vl = ve(_FULL_SIZE, _MARGIN,
                ho(_FULL_WIDTH, _EXPANDER,
                        delb, ValoTheme.BUTTON_DANGER,
                        modb,
                        newb, ValoTheme.BUTTON_PRIMARY),
                grid, _FULL_SIZE, _EXPAND);

        setContent(vl);
    }
}
class MyEditWindow extends Window {

        Button checkout = new Button("Checkout");
        Button viewContacts = new Button("View Contacts");
        Button download = new Button("Download");
        Button viewRecords = new Button("View Records");
        Button interested = new Button("Interested");
        Button delete = new Button("Delete");
        Button save = new Button("Save");
        TextArea textArea1 = new TextArea();
        TextArea textArea2 = new TextArea();
        OptionGroup type = new OptionGroup("", Arrays.asList("D2D", "Business", "Phone", "Letter"));
        TextField number = new TextField("");
        TextField description = new TextField("");

        MyEditWindow() {
            setModal(true);
            center();
            setCaption("Edit Territory");
            setWidth("70%");
            setHeight("80%");
//            setSizeFull();


            setContent(
                    ve(_NOOP, _FULL_SIZE, _MARGIN,
                        ho(_FULL_WIDTH, number, _FULL_WIDTH, 2f, description, _FULL_WIDTH, 8f),

                        type, ValoTheme.OPTIONGROUP_HORIZONTAL,

                        ho(_NOOP, _FULL_SIZE,
                                ve(_FULL_SIZE,
                                        textArea1,_FULL_SIZE, _EXPAND,
                                        textArea2, _FULL_SIZE, _EXPAND), 8f,
                                ve(_FULL_SIZE, //Alignment.MIDDLE_CENTER,
                                        checkout, _FULL_WIDTH, ValoTheme.BUTTON_FRIENDLY,
                                        viewContacts, _FULL_WIDTH,
                                        download, _FULL_WIDTH,
                                        viewRecords, _FULL_WIDTH,
                                        interested, _FULL_WIDTH), 2f
                        ), _EXPAND,
                        ho(_FULL_WIDTH,
                                save, _FULL_WIDTH, 8f, ValoTheme.BUTTON_PRIMARY,
                                delete, _FULL_WIDTH, 2f, ValoTheme.BUTTON_DANGER))
            );
        }
    }

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Initial release to gather feedback

Released
2016-10-20
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.0+
Vaadin 8.0+
Browser
Browser Independent

easylayout - Vaadin Add-on Directory

Completely unorthodox but extremely productive API wrappers for Vaadin Layouts easylayout - Vaadin Add-on Directory
**A completely unorthodox but extremely productive API wrappers for Vaadin Layouts** Currently, it only supports Horizontal and Vertical Layouts. Ideally, the unorthodoxy way of working may catch up in other layouts too :) **Using the addon for Vertial and Horizontal layouts** ``` import net.hdavid.easylayout.L.*; // ... TextField name; TextField lastName; Button save; Button cancel; // ... val vl = ve(name, lastName, ho(save, cancel)); // that is it! ``` **A more complex full size view** ``` Button newb = new Button("New"); Button modb = new Button("Modify"); Button delb = new Button("Delete"); Grid grid = new Grid( new BeanItemContainer(Arrays.asList( new PersonDTO("David Hofmann", new Date(1986, 07, 29), 30), new PersonDTO("Vaadin Is Awesome!", new Date(), 10)))); protected void init(VaadinRequest request) { VerticalLayout vl = ve(_FULL_SIZE, _MARGIN, // 1 ho(_FULL_WIDTH, // 2 _EXPANDER, // 3 delb, ValoTheme.BUTTON_DANGER, // 4 modb, // 5 newb, ValoTheme.BUTTON_PRIMARY),// 6 grid, _FULL_SIZE, _EXPAND); // 7 setContent(vl); // hard :D ? } ``` 1. creating a vertical layout with full size and margin 2. it's first component is a horizontal layout of full width 3. the first horizontal layout component is an expander component 4. the second one is the delete button and a css style is added to it 5. third component is the modify button 6. forth component is the new button with a css style added to it 7. second component of the vertical layout is the grid with its full size and expand ratio to 1f ##FAQ ###Are you completely crazy and lost all your human traits and your oath to code hygiene? Yeap! It will take me more time to explain you how much it helped me, though. But this "guide" will be updated if you don't get it yet :) ###This code is stupid! Are you aware of static evil and that your code is crappy and totally NOT OOP? Yes! But for this particular case, it is safe, though, and you'll be okay using it "if" you like brevity in your H/V Layouts. For rule explanations see [the github page](https://github.com/hofmanndavid/easylayout) for more details.
Issue Tracker
Source Code

easylayout version 1.0
Initial release to gather feedback

Online