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 is opened.
030 *
031 * @author Ben Dol
032 */
033public class GalleryOpenEvent extends GwtEvent<GalleryOpenHandler> {
034
035    public static  void fire(final Gallery source, final Event nativeEvent) {
036        GalleryOpenEvent event = new GalleryOpenEvent(source, nativeEvent);
037        source.fireEvent(event);
038    }
039
040    private static final Type<GalleryOpenHandler> TYPE = new Type<GalleryOpenHandler>();
041
042    private final Gallery gallery;
043    private final Event nativeEvent;
044
045    public static Type<GalleryOpenHandler> getType() {
046        return TYPE;
047    }
048
049    private GalleryOpenEvent(final Gallery gallery, final Event nativeEvent) {
050        this.gallery = gallery;
051        this.nativeEvent = nativeEvent;
052    }
053
054    public Gallery getGallery() {
055        return gallery;
056    }
057
058    public Event getNativeEvent() {
059        return nativeEvent;
060    }
061
062    @Override
063    public Type<GalleryOpenHandler> getAssociatedType() {
064        return TYPE;
065    }
066
067    @Override
068    protected void dispatch(final GalleryOpenHandler handler) {
069        handler.onOpen(this);
070    }
071}