| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ModelChangeEvent | 
 | 
 | 1.0;1 | ||||
| ModelChangeEvent$Action | 
 | 
 | 1.0;1 | 
| 1 |  /** | |
| 2 |   * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 |   * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 |   * not use this file except in compliance with the License. You may | |
| 5 |   * obtain a copy of the License at | |
| 6 |   * | |
| 7 |   * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 |   * | |
| 9 |   * Unless required by applicable law or agreed to in writing, | |
| 10 |   * software distributed under the License is distributed on an "AS IS" | |
| 11 |   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 |   * or implied. See the License for the specific language governing | |
| 13 |   * permissions and limitations under the License. | |
| 14 |   */ | |
| 15 | ||
| 16 |  package org.kuali.student.common.ui.client.mvc; | |
| 17 | ||
| 18 |  import com.google.gwt.event.shared.GwtEvent; | |
| 19 | ||
| 20 |  /** | |
| 21 |   * Event that is fired when the model is changed. | |
| 22 |   *  | |
| 23 |   * @author Kuali Student Team | |
| 24 |   * @param <T> | |
| 25 |   */ | |
| 26 | 13 | public class ModelChangeEvent extends GwtEvent<ModelChangeHandler> { | 
| 27 | 1 | public static final Type<ModelChangeHandler> TYPE = new Type<ModelChangeHandler>(); | 
| 28 | ||
| 29 |      /** | |
| 30 |       * The actions that can be performed on a model. | |
| 31 |       *  | |
| 32 |       * @author Kuali Student Team | |
| 33 |       */ | |
| 34 | 5 |      public enum Action { | 
| 35 | 1 | ADD, REMOVE, UPDATE, RELOAD | 
| 36 | } | |
| 37 | ||
| 38 | private final Action action; | |
| 39 | private final Model source; | |
| 40 | ||
| 41 |      /** | |
| 42 |       * Constructs a new ModelChangeEvent with an action and a value | |
| 43 |       *  | |
| 44 |       * @param action | |
| 45 |       * @param value | |
| 46 |       */ | |
| 47 | 13 |      public ModelChangeEvent(Action action, Model source) { | 
| 48 | 13 |          this.action = action; | 
| 49 | 13 |          this.source = source; | 
| 50 | 13 | } | 
| 51 | ||
| 52 | @Override | |
| 53 | protected void dispatch(ModelChangeHandler handler) { | |
| 54 | 0 |          handler.onModelChange(this); | 
| 55 | 0 |      } | 
| 56 | ||
| 57 | @Override | |
| 58 |      @SuppressWarnings("unchecked") | |
| 59 |      public Type<ModelChangeHandler> getAssociatedType() { | |
| 60 | 13 |          return (Type) TYPE; | 
| 61 | } | |
| 62 | ||
| 63 |      /** | |
| 64 |       * Returns the action (ADD/UPDATE/REMOVE) associated with the event | |
| 65 |       *  | |
| 66 |       * @return | |
| 67 |       */ | |
| 68 |      public Action getAction() { | |
| 69 | 0 |          return this.action; | 
| 70 | } | |
| 71 | ||
| 72 |      /** | |
| 73 |       * Returns the model from which this event originated | |
| 74 |       *  | |
| 75 |       * @return the model from which this event originated | |
| 76 |       */ | |
| 77 |      public Model getSource() { | |
| 78 | 13 | return this.source; | 
| 79 | } | |
| 80 | } |