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.

StateChangeEvent.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright 2011 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.client.communication;
  17. import java.io.Serializable;
  18. import java.util.Collections;
  19. import java.util.Set;
  20. import com.google.gwt.event.shared.EventHandler;
  21. import com.vaadin.client.ServerConnector;
  22. import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
  23. public class StateChangeEvent extends
  24. AbstractServerConnectorEvent<StateChangeHandler> {
  25. /**
  26. * Type of this event, used by the event bus.
  27. */
  28. public static final Type<StateChangeHandler> TYPE = new Type<StateChangeHandler>();
  29. private Set<String> changedProperties;
  30. @Override
  31. public Type<StateChangeHandler> getAssociatedType() {
  32. return TYPE;
  33. }
  34. /**
  35. * Creates a new state change event.
  36. *
  37. * @param connector
  38. * the event whose state has changed
  39. * @param changedProperties
  40. * a set of names of the changed properties
  41. */
  42. public StateChangeEvent(ServerConnector connector,
  43. Set<String> changedProperties) {
  44. setConnector(connector);
  45. this.changedProperties = changedProperties;
  46. }
  47. @Override
  48. public void dispatch(StateChangeHandler listener) {
  49. listener.onStateChanged(this);
  50. }
  51. /**
  52. * Event handler that gets notified whenever any part of the state has been
  53. * updated by the server.
  54. *
  55. * @author Vaadin Ltd
  56. * @version @VERSION@
  57. * @since 7.0.0
  58. */
  59. public interface StateChangeHandler extends Serializable, EventHandler {
  60. /**
  61. * Notifies the event handler that the state has changed.
  62. *
  63. * @param stateChangeEvent
  64. * the state change event with details about the change
  65. */
  66. public void onStateChanged(StateChangeEvent stateChangeEvent);
  67. }
  68. /**
  69. * Gets the properties that have changed.
  70. *
  71. * @return a set of names of the changed properties
  72. */
  73. public Set<String> getChangedProperties() {
  74. return Collections.unmodifiableSet(changedProperties);
  75. }
  76. }