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