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.events; 021 022import com.google.gwt.dom.client.Element; 023import com.google.gwt.event.shared.EventHandler; 024import com.google.gwt.event.shared.GwtEvent; 025import com.google.gwt.event.shared.HasHandlers; 026 027public class SideNavPushEvent extends GwtEvent<SideNavPushEvent.SideNavPushHandler> { 028 029 public interface SideNavPushHandler extends EventHandler { 030 void onPush(SideNavPushEvent event); 031 } 032 033 public static final Type<SideNavPushHandler> TYPE = new Type<>(); 034 035 private final int width; 036 private final Element element, activator; 037 private final boolean toggle; 038 039 public SideNavPushEvent(Element element, Element activator, boolean toggle, int width) { 040 this.element = element; 041 this.activator = activator; 042 this.toggle = toggle; 043 this.width = width; 044 } 045 046 public static void fire(HasHandlers source, Element element, Element activator, 047 boolean toggle, int width) { 048 source.fireEvent(new SideNavPushEvent(element, activator, toggle, width)); 049 } 050 051 public int getWidth() { 052 return width; 053 } 054 055 public boolean isToggle() { 056 return toggle; 057 } 058 059 public Element getElement() { 060 return element; 061 } 062 063 public Element getActivator() { 064 return activator; 065 } 066 067 @Override 068 public Type<SideNavPushHandler> getAssociatedType() { 069 return TYPE; 070 } 071 072 @Override 073 protected void dispatch(SideNavPushHandler handler) { 074 handler.onPush(this); 075 } 076}