All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sencha.gxt.data.shared.event.StoreDataChangeEvent Maven / Gradle / Ivy

/**
 * Ext GWT 3.0.0-beta2 - Ext for GWT
 * Copyright(c) 2007-2011, Sencha, Inc.
 * [email protected]
 *
 * http://sencha.com/license
 */
package com.sencha.gxt.data.shared.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
import com.sencha.gxt.data.shared.event.StoreDataChangeEvent.StoreDataChangeHandler;

/**
 * Indicates that the items in the store have been replaced.
 * 
 * @param  the model type
 */
public final class StoreDataChangeEvent extends StoreEvent> {

  /**
   * A class that implements this interface is a public source of
   * {@link StoreDataChangeEvent}.
   * 
   * @param  the type of data contained in the store
   */
  public interface HasStoreDataChangeHandlers extends HasHandlers {

    /**
     * Adds a {@link StoreDataChangeEvent} handler.
     * 
     * @param handler the handler
     * @return the registration for the event
     */
    HandlerRegistration addStoreDataChangeHandler(StoreDataChangeHandler handler);
  }

  /**
   * Handler interface for {@link StoreDataChangeEvent}.
   * 
   * @param  the type of data contained in the store
   */
  public interface StoreDataChangeHandler extends EventHandler {

    /**
     * Called when {@link StoreDataChangeEvent} is fired.
     * 
     * @param event the {@link StoreDataChangeEvent} that was fired
     */
    void onDataChange(StoreDataChangeEvent event);
  }

  private static GwtEvent.Type> TYPE;

  /**
   * Gets the type associated with this event.
   * 
   * @return returns the handler type
   */
  public static GwtEvent.Type> getType() {
    if (TYPE == null) {
      TYPE = new GwtEvent.Type>();
    }
    return TYPE;
  }

  private M parent;

  /**
   * Creates a new store data change event.
   */
  public StoreDataChangeEvent() {

  }

  /**
   * Creates a new store data change event.
   * 
   * @param parent the parent of the changed data
   */
  public StoreDataChangeEvent(M parent) {
    this.parent = parent;
  }

  @SuppressWarnings({"unchecked", "rawtypes"})
  @Override
  public GwtEvent.Type> getAssociatedType() {
    return (GwtEvent.Type) getType();
  }

  /**
   * Returns the parent model who's children were just loaded. Parent will
   * always be null with ListStore.
   * 
   * @return the parent or null if ListStore
   */
  public M getParent() {
    return parent;
  }

  @Override
  protected void dispatch(StoreDataChangeHandler handler) {
    handler.onDataChange(this);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy