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");
}
Aggregations