Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright 2000-2014 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.event;
  17. import java.io.Serializable;
  18. import java.lang.reflect.Method;
  19. import com.vaadin.ui.Component;
  20. import com.vaadin.ui.UI;
  21. import com.vaadin.util.ReflectTools;
  22. /**
  23. * A class that contains events, listeners and handlers specific to the
  24. * {@link UI} class.
  25. *
  26. * @since 7.2
  27. * @author Vaadin Ltd
  28. */
  29. public interface UIEvents {
  30. /**
  31. * A {@link PollListener} receives and handles {@link PollEvent PollEvents}
  32. * fired by {@link PollNotifier PollNotifiers}.
  33. *
  34. * @since 7.2
  35. * @author Vaadin Ltd
  36. */
  37. public interface PollListener extends Serializable {
  38. public static final Method POLL_METHOD = ReflectTools.findMethod(
  39. PollListener.class, "poll", PollEvent.class);
  40. /**
  41. * A poll request has been received by the server.
  42. *
  43. * @param event
  44. * poll event
  45. */
  46. public void poll(PollEvent event);
  47. }
  48. /**
  49. * An event that is fired whenever a client polls the server for
  50. * asynchronous UI updates.
  51. *
  52. * @since 7.2
  53. * @author Vaadin Ltd
  54. */
  55. public static class PollEvent extends Component.Event {
  56. public PollEvent(UI ui) {
  57. super(ui);
  58. }
  59. /**
  60. * Get the {@link UI} instance that received the poll request.
  61. *
  62. * @return the {@link UI} that received the poll request. Never
  63. * <code>null</code>.
  64. */
  65. public UI getUI() {
  66. /*
  67. * This cast is safe to make, since this class' constructor
  68. * constrains the source to be a UI instance.
  69. */
  70. return (UI) getComponent();
  71. }
  72. }
  73. /**
  74. * The interface for adding and removing {@link PollEvent} listeners.
  75. * <p>
  76. * By implementing this interface, a class publicly announces that it is
  77. * able to send {@link PollEvent PollEvents} whenever the client sends a
  78. * periodic poll message to the client, to check for asynchronous
  79. * server-side modifications.
  80. *
  81. * @since 7.2
  82. * @see UI#setPollInterval(int)
  83. */
  84. public interface PollNotifier extends Serializable {
  85. /**
  86. * Add a poll listener.
  87. * <p>
  88. * The listener is called whenever the client polls the server for
  89. * asynchronous UI updates.
  90. *
  91. * @see UI#setPollInterval(int)
  92. * @see #removePollListener(PollListener)
  93. * @param listener
  94. * the {@link PollListener} to add
  95. */
  96. public void addPollListener(PollListener listener);
  97. /**
  98. * Remove a poll listener.
  99. *
  100. * @see #addPollListener(PollListener)
  101. * @param listener
  102. * the listener to be removed
  103. */
  104. public void removePollListener(PollListener listener);
  105. }
  106. }