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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.SerializableBiConsumer;
  21. import com.vaadin.server.SerializableFunction;
  22. /**
  23. * Binder status change event.
  24. * <p>
  25. * The {@link Binder} status is changed whenever any of the following happens:
  26. * <ul>
  27. * <li>if it's bound and any of its bound field or select has been changed
  28. * <li>{@link Binder#writeBean(Object)} or
  29. * {@link Binder#writeBeanIfValid(Object)} is called
  30. * <li>{@link Binder#readBean(Object)} is called
  31. * <li>{@link Binder#setBean(Object)} is called
  32. * <li>{@link Binder#removeBean()} is called
  33. * <li>{@link BindingBuilder#bind(SerializableFunction, SerializableBiConsumer)}
  34. * is called
  35. * <li>{@link Binder#validate()} or {@link Binding#validate()} is called
  36. * </ul>
  37. *
  38. * @see StatusChangeListener#statusChange(StatusChangeEvent)
  39. * @see Binder#addStatusChangeListener(StatusChangeListener)
  40. *
  41. * @author Vaadin Ltd
  42. *
  43. */
  44. public class StatusChangeEvent extends EventObject {
  45. private final boolean hasValidationErrors;
  46. /**
  47. * Create a new status change event for given {@code binder} using its
  48. * current validation status.
  49. *
  50. * @param binder
  51. * the event source binder
  52. * @param hasValidationErrors
  53. * the binder validation status
  54. */
  55. public StatusChangeEvent(Binder<?> binder, boolean hasValidationErrors) {
  56. super(binder);
  57. this.hasValidationErrors = hasValidationErrors;
  58. }
  59. /**
  60. * Gets the binder validation status.
  61. *
  62. * @return {@code true} if the binder has validation errors, {@code false}
  63. * otherwise
  64. */
  65. public boolean hasValidationErrors() {
  66. return hasValidationErrors;
  67. }
  68. @Override
  69. public Binder<?> getSource() {
  70. return (Binder<?>) super.getSource();
  71. }
  72. /**
  73. * Gets the binder.
  74. *
  75. * @return the binder
  76. */
  77. public Binder<?> getBinder() {
  78. return getSource();
  79. }
  80. }