Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public class MyClass extends VerticalLayout {
  2.  
  3. LocalDate[] date = {LocalDate.now(), LocalDate.now(), LocalDate.now()};
  4. Boolean[] isPresent = {true, false, false, true, true, false, false, true, true};
  5. Map<LocalDate, Boolean[]> trainingsMap = new HashMap<>();
  6. Grid<Map<LocalDate, Boolean[]>> grid = new Grid();
  7. Icon icon;
  8.  
  9. public MyClass() {
  10.  
  11. for (int i = 0; i < date.length; i++) {
  12. trainingsMap.put(date[i], isPresent);
  13. }
  14.  
  15. for (Map.Entry<LocalDate, Boolean[]> entry : trainingsMap.entrySet()) {
  16.  
  17. grid.addColumn(new ComponentRenderer<>(createIsPresent(entry.getValue()))
  18. .setHeader(new LocalDateTimeRenderer<>(entry.getKey(), "dd/MM")));
  19.  
  20. add(grid);
  21. }
  22. }
  23.  
  24. private Component createIsPresent(Boolean[] isPresent) {
  25. for (Boolean b : isPresent) {
  26. if (b) {
  27. icon = UIUtils.createPrimaryIcon(VaadinIcon.CHECK);
  28. } else {
  29. icon = UIUtils.createDisabledIcon(VaadinIcon.CLOSE);
  30. }
  31. }
  32. return icon;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement