001/* 002 * Copyright 2012 GWT-Bootstrap 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.github.gwtbootstrap.client.ui.event; 017 018import com.google.gwt.dom.client.NativeEvent; 019import com.google.gwt.event.shared.GwtEvent; 020 021/** 022 * Represents an event that is fired when a widget is completely hidden. 023 * 024 * @since 2.0.4.0 025 * 026 * @author Dominik Mayer 027 * 028 * @see HideEvent 029 * @see ShowEvent 030 * @see ShownEvent 031 * 032 */ 033public class HiddenEvent extends GwtEvent<HiddenHandler> { 034 035 private static final Type<HiddenHandler> TYPE = new Type<HiddenHandler>(); 036 private final NativeEvent nativeEvent; 037 038 public static Type<HiddenHandler> getType() { 039 return TYPE; 040 } 041 042 public HiddenEvent() { 043 this(null); 044 } 045 046 public HiddenEvent(NativeEvent nativeEvent) { 047 this.nativeEvent = nativeEvent; 048 } 049 050 @Override 051 public final Type<HiddenHandler> getAssociatedType() { 052 return TYPE; 053 } 054 055 @Override 056 protected void dispatch(HiddenHandler handler) { 057 handler.onHidden(this); 058 } 059 060 /** 061 * Prevents the browser from taking its default action for the given event. 062 */ 063 public final void preventDefault() { 064 065 if(nativeEvent == null) return; 066 067 nativeEvent.preventDefault(); 068 } 069 070 /** 071 * Stops the event from being propagated to parent elements. 072 */ 073 public final void stopPropagation() { 074 075 if(nativeEvent == null) return; 076 077 nativeEvent.stopPropagation(); 078 } 079 080}