Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. package com.deepsearch.fe.util;
  2.  
  3. import com.vaadin.flow.component.customfield.CustomField;
  4. import com.vaadin.flow.component.html.Label;
  5. import com.vaadin.flow.component.orderedlayout.FlexComponent;
  6. import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
  7. import com.vaadin.flow.component.textfield.TextField;
  8.  
  9. public class TextRangeFieldInt extends CustomField<StartToEndRangeInt> {
  10. private final TextField start = new TextField();
  11. private final Label lblTo = new Label("to");
  12. private final TextField end = new TextField();
  13.  
  14. public TextRangeFieldInt(final StartToEndRangeInt startToEndRangeInt, final String startEndWidths) {
  15. this.setHeight("10px");
  16. this.setMinHeight("10px");
  17. this.setMaxHeight("10px");
  18. this.getElement().getStyle().set("background-color", "red");
  19. //this.getStyle().set("background-color", "red");
  20. setPresentationValue(startToEndRangeInt);
  21. final HorizontalLayout hl = new HorizontalLayout();
  22. hl.setWidth("100%");
  23. hl.getStyle().set("background-color", "yellow");
  24. hl.setMargin(false);
  25. hl.setPadding(false);
  26. hl.setAlignItems(FlexComponent.Alignment.CENTER);
  27.  
  28. lblTo.setWidth("1.5rem");
  29. start.setWidth(startEndWidths);
  30. end.setWidth(startEndWidths);
  31. hl.add(start);
  32. hl.add(lblTo);
  33. hl.add(end);
  34. add(hl);
  35. }
  36.  
  37. @Override
  38. protected StartToEndRangeInt generateModelValue() {
  39. return new StartToEndRangeInt(Integer.parseInt(start.getValue()), Integer.parseInt(end.getValue()));
  40. }
  41.  
  42. @Override
  43. protected void setPresentationValue(StartToEndRangeInt newPresentationValue) {
  44. start.setValue(newPresentationValue.getStartStr());
  45. end.setValue(newPresentationValue.getEndStr());
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement