API Reference 0.3.24dart_web_toolkit_eventBeforeSelectionEvent<T>

BeforeSelectionEvent<T> class

Represents a before selection event.

@param <T> the type about to be selected

class BeforeSelectionEvent<T> extends DwtEvent {

 /**
  * Handler type.
  */
 static EventType<BeforeSelectionHandler> TYPE = new EventType<BeforeSelectionHandler>();

 /**
  * Fires a before selection event on all registered handlers in the handler
  * manager. If no such handlers exist, this method will do nothing.
  *
  * @param <T> the item type
  * @param source the source of the handlers
  * @param item the item
  * @return the event so that the caller can check if it was canceled, or null
  *         if no handlers of this event type have been registered
  */
 static BeforeSelectionEvent fire(HasBeforeSelectionHandlers source, item) {
   // If no handlers exist, then type can be null.
   if (TYPE != null) {
     BeforeSelectionEvent event = new BeforeSelectionEvent();
     event.setItem(item);
     source.fireEvent(event);
     return event;
   }
   return null;
 }

 /**
  * Gets the type associated with this event.
  *
  * @return returns the handler type
  */
 static EventType<BeforeSelectionHandler> getType() {
   return TYPE;
 }

 T _item;

 bool _canceled = false;

 /**
  * Creates a new before selection event.
  */
 BeforeSelectionEvent() { }

 /**
  * Cancel the before selection event.
  *
  * Classes overriding this method should still call super.cancel().
  */
 void cancel() {
   _canceled = true;
 }

 // The instance knows its BeforeSelectionHandler is of type I, but the TYPE
 // field itself does not, so we have to do an unsafe cast here.
 EventType<BeforeSelectionHandler> getAssociatedType() {
   return TYPE;
 }

 /**
  * Gets the item.
  *
  * @return the item
  */
 T getItem() {
   return _item;
 }

 /**
  * Has the selection event already been canceled?
  *
  * @return is canceled
  */
 bool isCanceled() {
   return _canceled;
 }

 void dispatch(BeforeSelectionHandler<T> handler) {
   handler.onBeforeSelection(this);
 }

 /**
  * Sets the item.
  *
  * @param item the item
  */
 void setItem(T item) {
   this._item = item;
 }
}

Extends

IEvent<H> > DwtEvent > BeforeSelectionEvent<T>

Static Properties

EventType<BeforeSelectionHandler> TYPE #

Handler type.

static EventType<BeforeSelectionHandler> TYPE = new EventType<BeforeSelectionHandler>()

Static Methods

BeforeSelectionEvent fire(HasBeforeSelectionHandlers source, item) #

Fires a before selection event on all registered handlers in the handler manager. If no such handlers exist, this method will do nothing.

@param <T> the item type @param source the source of the handlers @param item the item @return the event so that the caller can check if it was canceled, or null

    if no handlers of this event type have been registered
static BeforeSelectionEvent fire(HasBeforeSelectionHandlers source, item) {
 // If no handlers exist, then type can be null.
 if (TYPE != null) {
   BeforeSelectionEvent event = new BeforeSelectionEvent();
   event.setItem(item);
   source.fireEvent(event);
   return event;
 }
 return null;
}

EventType<BeforeSelectionHandler> getType() #

Gets the type associated with this event.

@return returns the handler type

static EventType<BeforeSelectionHandler> getType() {
 return TYPE;
}

Constructors

new BeforeSelectionEvent() #

Creates a new before selection event.

BeforeSelectionEvent() { }

Methods

void assertLive() #

inherited from DwtEvent

Asserts that the event still should be accessed. All events are considered to be "dead" after their original handler manager finishes firing them. An event can be revived by calling {@link GwtEvent#revive()}.

void assertLive() {
 assert (!_dead) ; //: "This event has already finished being processed by its original handler manager, so you can no longer access it";
}

void cancel() #

Cancel the before selection event.

Classes overriding this method should still call super.cancel().

void cancel() {
 _canceled = true;
}

void dispatch(BeforeSelectionHandler<T> handler) #

Implemented by subclasses to invoke their handlers in a type safe manner. Intended to be called by EventBus#fireEvent(Event) or EventBus#fireEventFromSource(Event, Object).

@param handler handler @see EventBus#dispatchEvent(Event, Object)

docs inherited from IEvent<H>
void dispatch(BeforeSelectionHandler<T> handler) {
 handler.onBeforeSelection(this);
}

EventType<BeforeSelectionHandler> getAssociatedType() #

Returns the EventType used to register this event, allowing an EventBus to find handlers of the appropriate class.

@return the type

docs inherited from IEvent<H>
EventType<BeforeSelectionHandler> getAssociatedType() {
 return TYPE;
}

T getItem() #

Gets the item.

@return the item

T getItem() {
 return _item;
}

Object getSource() #

inherited from DwtEvent

Returns the source for this event. The type and meaning of the source is arbitrary, and is most useful as a secondary key for handler registration. (See EventBus#addHandlerToSource, which allows a handler to register for events of a particular type, tied to a particular source.)

Note that the source is actually set at dispatch time, e.g. via EventBus#fireEventFromSource(Event, Object).

@return object representing the source of this event

docs inherited from IEvent<H>
Object getSource() {
 assertLive();
 return super.getSource();
}

bool isCanceled() #

Has the selection event already been canceled?

@return is canceled

bool isCanceled() {
 return _canceled;
}

bool isLive() #

inherited from DwtEvent

Is the event current live?

@return whether the event is live

bool isLive() {
 return !_dead;
}

void kill() #

inherited from DwtEvent

Kill the event. After the event has been killed, users cannot really on its values or functions being available.

void kill() {
 _dead = true;
 setSource(null);
}

void overrideSource(Object source) #

inherited from DwtEvent
void overrideSource(Object source) {
 super.setSource(source);
}

void revive() #

inherited from DwtEvent

Revives the event. Used when recycling event instances.

void revive() {
 _dead = false;
 setSource(null);
}

void setItem(T item) #

Sets the item.

@param item the item

void setItem(T item) {
 this._item = item;
}

void setSource(source) #

inherited from IEvent

Set the source that triggered this event. Intended to be called by the EventBus during dispatch.

@param source the source of this event. @see EventBus#fireEventFromSource(Event, Object) @see EventBus#setSourceOfEvent(Event, Object)

void setSource(dynamic source) {
 this._source = source;
}

String toString() #

inherited from IEvent

The toString() for abstract event is overridden to avoid accidently including class literals in the the compiled output. Use Event

toDebugString to get more information about the event.

String toString() {
 return "An event type";
}