001package org.gwtbootstrap3.extras.gallery.client.events;
002
003/*
004 * #%L
005 * GwtBootstrap3
006 * %%
007 * Copyright (C) 2013 - 2014 GwtBootstrap3
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023
024import com.google.gwt.event.shared.GwtEvent;
025import com.google.gwt.user.client.Event;
026import org.gwtbootstrap3.extras.gallery.client.ui.Gallery;
027
028/**
029 * Triggered when the gallery item slides.
030 *
031 * @author Ben Dol
032 */
033public class GallerySlideEvent extends GwtEvent<GallerySlideHandler> {
034
035    public static  void fire(final Gallery source, final Event nativeEvent, int index) {
036        GallerySlideEvent event = new GallerySlideEvent(source, nativeEvent, index);
037        source.fireEvent(event);
038    }
039
040    private static final Type<GallerySlideHandler> TYPE = new Type<GallerySlideHandler>();
041
042    private final Gallery gallery;
043    private final Event nativeEvent;
044    private final int index;
045
046    public static Type<GallerySlideHandler> getType() {
047        return TYPE;
048    }
049
050    private GallerySlideEvent(final Gallery gallery, final Event nativeEvent, int index) {
051        this.gallery = gallery;
052        this.nativeEvent = nativeEvent;
053        this.index = index;
054    }
055
056    public Gallery getGallery() {
057        return gallery;
058    }
059
060    public Event getNativeEvent() {
061        return nativeEvent;
062    }
063
064    public int getIndex() {
065        return index;
066    }
067
068    @Override
069    public Type<GallerySlideHandler> getAssociatedType() {
070        return TYPE;
071    }
072
073    @Override
074    protected void dispatch(final GallerySlideHandler handler) {
075        handler.onSlide(this);
076    }
077}