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 */
020package gwt.material.design.client.data.events;
021
022import com.google.gwt.dom.client.Element;
023import com.google.gwt.event.shared.EventHandler;
024import com.google.gwt.event.shared.GwtEvent;
025import gwt.material.design.jquery.client.api.Event;
026import gwt.material.design.jquery.client.api.MouseEvent;
027
028public abstract class RowEvent<T, H extends EventHandler> extends GwtEvent<H> {
029
030    private final Event event;
031    private final T model;
032    private final Element row;
033
034    public RowEvent(Event event, T model, Element row) {
035        this.event = event;
036        this.model = model;
037        this.row = row;
038    }
039
040    /**
041     * Get the event source. This can be null if no source event triggered the {@link RowEvent}.
042     */
043    public Event getEvent() {
044        return event;
045    }
046
047    /**
048     * Attempt to cast the event as a {@link MouseEvent}.
049     */
050    public MouseEvent getMouseEvent() {
051        return (MouseEvent) getEvent();
052    }
053
054    /**
055     * Model of the row.
056     */
057    public T getModel() {
058        return model;
059    }
060
061    /**
062     * The rows element.
063     */
064    public Element getRow() {
065        return row;
066    }
067}