You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StatusChangeEvent.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.data;
  17. import java.util.EventObject;
  18. import com.vaadin.data.Binder.Binding;
  19. import com.vaadin.data.Binder.BindingBuilder;
  20. import com.vaadin.server.Setter;
  21. /**
  22. * Binder status change event.
  23. * <p>
  24. * The {@link Binder} status is changed whenever any of the following happens:
  25. * <ul>
  26. * <li>if it's bound and any of its bound field or select has been changed
  27. * <li>{@link Binder#writeBean(Object)} or
  28. * {@link Binder#writeBeanIfValid(Object)} is called
  29. * <li>{@link Binder#readBean(Object)} is called
  30. * <li>{@link Binder#setBean(Object)} is called
  31. * <li>{@link Binder#removeBean()} is called
  32. * <li>{@link BindingBuilder#bind(ValueProvider, Setter)} is called
  33. * <li>{@link Binder#validate()} or {@link Binding#validate()} is called
  34. * </ul>
  35. *
  36. * @see StatusChangeListener#statusChange(StatusChangeEvent)
  37. * @see Binder#addStatusChangeListener(StatusChangeListener)
  38. *
  39. * @author Vaadin Ltd
  40. *
  41. */
  42. public class StatusChangeEvent extends EventObject {
  43. private final boolean hasValidationErrors;
  44. /**
  45. * Create a new status change event for given {@code binder} using its
  46. * current validation status.
  47. *
  48. * @param binder
  49. * the event source binder
  50. * @param hasValidationErrors
  51. * the binder validation status
  52. */
  53. public StatusChangeEvent(Binder<?> binder, boolean hasValidationErrors) {
  54. super(binder);
  55. this.hasValidationErrors = hasValidationErrors;
  56. }
  57. /**
  58. * Gets the binder validation status.
  59. *
  60. * @return {@code true} if the binder has validation errors, {@code false}
  61. * otherwise
  62. */
  63. public boolean hasValidationErrors() {
  64. return hasValidationErrors;
  65. }
  66. @Override
  67. public Binder<?> getSource() {
  68. return (Binder<?>) super.getSource();
  69. }
  70. /**
  71. * Gets the binder.
  72. *
  73. * @return the binder
  74. */
  75. public Binder<?> getBinder() {
  76. return getSource();
  77. }
  78. }