/ftr-gwt-library-date/src/main/java/eu/future/earth/gwt/client/date/week/WeekScrollEvent.java

http://ftr-gwt-library.googlecode.com/ · Java · 92 lines · 41 code · 14 blank · 37 comment · 4 complexity · e14bf0dc3de4ed3850e3a0cb5385cebd MD5 · raw file

  1. /*
  2. * Copyright 2007 Future Earth, info@future-earth.eu
  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 eu.future.earth.gwt.client.date.week;
  17. import com.google.gwt.event.shared.GwtEvent;
  18. public class WeekScrollEvent extends GwtEvent<WeekScrollEventHandler> {
  19. private static final long serialVersionUID = -3798647759325157673L;
  20. private int pos = -1;
  21. public WeekScrollEvent() {
  22. super();
  23. }
  24. /**
  25. * Handler type.
  26. */
  27. private static Type<WeekScrollEventHandler> TYPE;
  28. /**
  29. * Fires a before selection event on all registered handlers in the handler manager. If no such handlers exist, this
  30. * method will do nothing.
  31. *
  32. * @param source
  33. * the source of the handlers
  34. * @param navigator
  35. * the navigator associated with this event
  36. * @param token
  37. * the navigation token associated with this event
  38. * @return the event so that the caller can check if it was canceled, or null if no handlers of this event type have
  39. * been registered
  40. */
  41. public static WeekScrollEvent fire(HasWeekScrollEventHandlers source, int navigator) {
  42. // If no handlers exist, then type can be null.
  43. if (TYPE != null) {
  44. final WeekScrollEvent event = new WeekScrollEvent(navigator);
  45. source.fireEvent(event);
  46. return event;
  47. }
  48. return null;
  49. }
  50. public int getPos() {
  51. return pos;
  52. }
  53. /**
  54. * Gets the type associated with this event.
  55. *
  56. * @return returns the handler type
  57. */
  58. public static Type<WeekScrollEventHandler> getType() {
  59. if (TYPE == null) {
  60. TYPE = new Type<WeekScrollEventHandler>();
  61. }
  62. return TYPE;
  63. }
  64. protected WeekScrollEvent(int newPos) {
  65. super();
  66. pos = newPos;
  67. }
  68. @SuppressWarnings({
  69. "unchecked", "rawtypes"
  70. })
  71. @Override
  72. public final Type<WeekScrollEventHandler> getAssociatedType() {
  73. return (Type) TYPE;
  74. }
  75. protected void dispatch(WeekScrollEventHandler handler) {
  76. handler.handleScrollEvent(this);
  77. }
  78. }