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