001/* 002 * Copyright 2008 Google Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 005 * use this file except in compliance with the License. You may obtain a copy of 006 * the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations under 014 * the License. 015 */ 016package gwt.material.design.addins.client.swipeable.events; 017 018/* 019 * #%L 020 * GwtMaterial 021 * %% 022 * Copyright (C) 2015 - 2016 GwtMaterialDesign 023 * %% 024 * Licensed under the Apache License, Version 2.0 (the "License"); 025 * you may not use this file except in compliance with the License. 026 * You may obtain a copy of the License at 027 * 028 * http://www.apache.org/licenses/LICENSE-2.0 029 * 030 * Unless required by applicable law or agreed to in writing, software 031 * distributed under the License is distributed on an "AS IS" BASIS, 032 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 033 * See the License for the specific language governing permissions and 034 * limitations under the License. 035 * #L% 036 */ 037 038 039import com.google.gwt.event.shared.EventHandler; 040import com.google.gwt.event.shared.GwtEvent; 041import gwt.material.design.addins.client.swipeable.base.HasSwipeable; 042 043/** 044 * Represents a swipe right event. 045 * @author kevzlou7979 046 * @param <T> the type being swiped to right 047 */ 048public class SwipeRightEvent<T> extends GwtEvent<SwipeRightEvent.SwipeRightHandler<T>> { 049 050 private static Type<SwipeRightHandler<?>> TYPE; 051 052 public interface SwipeRightHandler<T> extends EventHandler { 053 void onSwipeRight(SwipeRightEvent<T> event); 054 } 055 056 public static <T> void fire(HasSwipeable<T> source, T target) { 057 if (TYPE != null) { 058 SwipeRightEvent<T> event = new SwipeRightEvent<T>(target); 059 source.fireEvent(event); 060 } 061 } 062 063 public static Type<SwipeRightHandler<?>> getType() { 064 return TYPE != null ? TYPE : (TYPE = new Type<SwipeRightHandler<?>>()); 065 } 066 067 private final T target; 068 069 protected SwipeRightEvent(T target) { 070 this.target = target; 071 } 072 073 @Override 074 public final Type<SwipeRightHandler<T>> getAssociatedType() { 075 return (Type) TYPE; 076 } 077 078 public T getTarget() { 079 return target; 080 } 081 082 @Override 083 protected void dispatch(SwipeRightHandler<T> handler) { 084 handler.onSwipeRight(this); 085 } 086}