Search in sources :

Example 1 with Size

use of com.dala.data.building.size.Size in project DoodleVerse by davidemarcoli.

the class BuildHouseView method setupPage.

public void setupPage() {
    Button createButton = new Button();
    HorizontalLayout createButtonLayout = new HorizontalLayout();
    createButton.setIcon(new Icon(VaadinIcon.HAMMER));
    createButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_LARGE);
    createButtonLayout.setAlignItems(Alignment.END);
    createButtonLayout.add(createButton);
    add(createButtonLayout);
    houseImage.setAlt("The Selected House!");
    add(houseImage);
    HorizontalLayout dropdownLayout = new HorizontalLayout();
    sizeSelect.setLabel("Size");
    Size[] sizes = sizeRepository.findAll().toArray(new Size[0]);
    ArrayList<String> sizeNames = new ArrayList<>();
    Arrays.stream(sizes).forEach(size -> sizeNames.add(size.getType()));
    sizeSelect.setItems(sizeNames);
    sizeSelect.setValue(sizeNames.get(0));
    dropdownLayout.add(sizeSelect);
    wallSelect.setLabel("Wall");
    Wall[] walls = wallRepository.findAll().toArray(new Wall[0]);
    ArrayList<String> wallNames = new ArrayList<>();
    Arrays.stream(walls).forEach(wall -> wallNames.add(wall.getType()));
    wallSelect.setItems(wallNames);
    wallSelect.setValue(wallNames.get(0));
    dropdownLayout.add(wallSelect);
    colorField.setLabel("Ceiling Color");
    colorField.setRequired(true);
    String colorHelperText = "Example: blue<br>or 0000ff or 00f<br>or 0, 0, 255";
    Div colorHelperDiv = new Div();
    colorHelperDiv.getElement().setProperty("innerHTML", colorHelperText);
    colorHelperDiv.getStyle().set("text-align", "left");
    colorField.setHelperComponent(colorHelperDiv);
    dropdownLayout.add(colorField);
    add(dropdownLayout);
    createButton.addClickListener(buttonClickEvent -> {
        saveHouse();
    });
    colorField.addValueChangeListener(event -> {
        updateInfos();
        setImageSource();
    });
    sizeSelect.addValueChangeListener(selectStringComponentValueChangeEvent -> {
        updateInfos();
        setImageSource();
    });
    wallSelect.addValueChangeListener(selectStringComponentValueChangeEvent -> {
        updateInfos();
        setImageSource();
    });
    updateInfos();
    setImageSource();
    setSizeFull();
    setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
    setDefaultHorizontalComponentAlignment(FlexComponent.Alignment.CENTER);
    getStyle().set("text-align", "center");
}
Also used : Div(com.vaadin.flow.component.html.Div) Wall(com.dala.data.building.wall.Wall) Button(com.vaadin.flow.component.button.Button) Size(com.dala.data.building.size.Size) ArrayList(java.util.ArrayList) Icon(com.vaadin.flow.component.icon.Icon) VaadinIcon(com.vaadin.flow.component.icon.VaadinIcon) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

Size (com.dala.data.building.size.Size)1 Wall (com.dala.data.building.wall.Wall)1 Button (com.vaadin.flow.component.button.Button)1 Div (com.vaadin.flow.component.html.Div)1 Icon (com.vaadin.flow.component.icon.Icon)1 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)1 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)1 ArrayList (java.util.ArrayList)1