Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass extends VerticalLayout {
- LocalDate[] date = {LocalDate.now(), LocalDate.now(), LocalDate.now()};
- Boolean[] isPresent = {true, false, false, true, true, false, false, true, true};
- Map<LocalDate, Boolean[]> trainingsMap = new HashMap<>();
- Grid<Map<LocalDate, Boolean[]>> grid = new Grid();
- Icon icon;
- public MyClass() {
- for (int i = 0; i < date.length; i++) {
- trainingsMap.put(date[i], isPresent);
- }
- for (Map.Entry<LocalDate, Boolean[]> entry : trainingsMap.entrySet()) {
- grid.addColumn(new ComponentRenderer<>(createIsPresent(entry.getValue()))
- .setHeader(new LocalDateTimeRenderer<>(entry.getKey(), "dd/MM")));
- add(grid);
- }
- }
- private Component createIsPresent(Boolean[] isPresent) {
- for (Boolean b : isPresent) {
- if (b) {
- icon = UIUtils.createPrimaryIcon(VaadinIcon.CHECK);
- } else {
- icon = UIUtils.createDisabledIcon(VaadinIcon.CLOSE);
- }
- }
- return icon;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement