PageRenderTime 35ms CodeModel.GetById 30ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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