View Javadoc

    1   package net.sourceforge.pmd.util.viewer.model;
    2
    3   /**
    4    * The event which will be sent every time  the model changes
    5    * <p/>
    6    * <p/>
    7    * <p/>
    8    * <p/>
    9    * <p/>
    10   * Note: the instances will be immutable
    11   * <p/>
    12   * </p>
    13   *
    14   * @author Boris Gruschko ( boris at gruschko.org )
    15   * @version $Id$
    16   */
    17  public class ViewerModelEvent {
    18      /**
    19       * reason in the case of code recompilation
    20       */
    21      public static final int CODE_RECOMPILED = 1;
    22      /**
    23       * reason in the case of node selection
    24       */
    25      public static final int NODE_SELECTED = 2;
    26      /**
    27       * reason in the case of path extension
    28       */
    29      public static final int PATH_EXPRESSION_APPENDED = 3;
    30      /**
    31       * reason in the case of path expression evaluation
    32       */
    33      public static final int PATH_EXPRESSION_EVALUATED = 4;
    34      private Object source;
    35      private int reason;
    36      private Object parameter;
    37
    38      /**
    39       * Creates an event
    40       *
    41       * @param source event's source
    42       * @param reason event's reason
    43       */
    44      public ViewerModelEvent(Object source, int reason) {
    45          this(source, reason, null);
    46      }
    47
    48      /**
    49       * Creates an event
    50       *
    51       * @param source    event's source
    52       * @param reason    event's reason
    53       * @param parameter parameter object
    54       */
    55      public ViewerModelEvent(Object source, int reason, Object parameter) {
    56          this.source = source;
    57          this.reason = reason;
    58          this.parameter = parameter;
    59      }
    60
    61      public int getReason() {
    62          return reason;
    63      }
    64
    65      public Object getSource() {
    66          return source;
    67      }
    68
    69      public Object getParameter() {
    70          return parameter;
    71      }
    72  }