Guest User

Untitled

a guest
Nov 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. public class Tasks{
  2. private int id;
  3. private Double duration;
  4.  
  5. public StakeholderTasks(int i, String string) {
  6. this.id = id;
  7. this.taskName=taskName;
  8. // TODO Auto-generated constructor stub
  9. }
  10. public int getId() {
  11. return id;
  12. }
  13. public void setId(int id) {
  14. this.id = id;
  15. }
  16. public Double getDuration() {
  17. return duration;
  18. }
  19.  
  20. public void setDuration(Double duration) {
  21. this.duration = duration;
  22. }
  23. }
  24.  
  25. public class stakeholderImpl extends CustomComponent {
  26. private Grid<Tasks> grid1;
  27. private Binder<Tasks> binder = new Binder<>(Tasks.class);
  28. cmpy = datastoreinstance.updateTaskList();
  29. provider1 = new ListDataProvider<>(cmpy );
  30. grid1 = new Grid<>();
  31. grid1.addColumn(Tasks::getDuration);
  32. grid1.asSingleSelect().addValueChangeListener(event -> {
  33.  
  34. form.setVisible(false);
  35.  
  36. window = createWindow(window,
  37. ((MainUI) (UI.getCurrent())).getLanguageMessage("general.addnewtask"),
  38. event.getValue(), "EDIT",form);
  39. } catch (ClassNotFoundException e1) {
  40. // TODO Auto-generated catch block
  41. e1.printStackTrace();
  42. } catch (SQLException e1) {
  43. // TODO Auto-generated catch block
  44. e1.printStackTrace();
  45. }
  46.  
  47. }
  48.  
  49. });
  50. binder.forField(duration).asRequired(((MainUI) (UI.getCurrent())).getLanguageMessage("general.required"))
  51. .withValidator(new RegexpValidator(((MainUI) (UI.getCurrent())).getLanguageMessage("general.numerror"), DBConstants.regex))
  52. .bind(taskdetails -> nf_out.format(stakeholders.getDuration()),
  53. (taskdetails, formValue) -> {
  54. NumberFormat nf_in = NumberFormat.getNumberInstance(Locale.GERMANY);
  55. double val = 0d;
  56. try {
  57. val = nf_in.parse(formValue).doubleValue();
  58. taskdetails.setDuration(val);
  59. } catch (ParseException e) {
  60. // TODO Auto-generated catch block
  61. e.printStackTrace();
  62. }
  63. });
  64. }
Add Comment
Please, Sign In to add comment