1 package fr.ove.openmath.jome.ctrlview.bidim.selection.events;
2
3 import java.util.EventObject;
4
5 /***
6 * The event to send to all objects that implements the interface SlectionEventListener
7 * and which want to maintain a list of selected elements.
8 *
9 * @author © 1998 DIRAT Laurent
10 * @version 1.0 30/06/98
11 */
12 public class SelectionEvent extends EventObject {
13 /***
14 * The action to execute by sending the event.
15 */
16 private int action;
17
18 /***
19 * The object which has been selected.
20 */
21 private Object argument;
22
23 /***
24 * The constructor.
25 * @param src the object which produces this event.
26 */
27 public SelectionEvent(Object src) {
28 super(src);
29 }
30
31 /***
32 * Sets the action to execute and its argument.
33 * @param action the action.
34 * @param argument the argument.<BR>
35 * In the case of the actions GET_SELECTION and GET_SELECTION_SIZE,
36 * arguments will serve as well as the return value
37 */
38 public void setAction(int action, Object argument) {
39 this.action = action;
40 this.argument = argument;
41 }
42
43 /***
44 * Returns the action associated with the event.
45 */
46 public int getAction() {
47 return action;
48 }
49
50 /***
51 * Returns the action argument.
52 */
53 public Object getArgument() {
54 return argument;
55 }
56
57 /***
58 * Sets the action argument.
59 * @param argument the action argument.
60 */
61 public void setArgument(Object argument) {
62 this.argument = argument;
63 }
64
65 /***
66 * The different actions associated with the event.<BR>
67 */
68
69 /***
70 * This action tells the selections manager to remove all the elements it has.
71 */
72 public static final int PURGE = 0;
73
74 /***
75 * This action tells the selections manager to remove an element. (which will be
76 * given to him)
77 */
78 public static final int REMOVE = 1;
79
80 /***
81 * This action tells the selections manager to add an element. (which will be
82 * given to him)
83 */
84 public static final int ADD = 2;
85
86 /***
87 * This action tells the selections manager to give the number of selected
88 * elements
89 */
90 public static final int GET_SELECTION_SIZE = 3;
91
92 /***
93 * This action tells the selections manager to give all the selected elements
94 */
95 public static final int GET_SELECTION = 4;
96
97 /***
98 * For debugg only. To list all the selected elements.
99 */
100 public static final int LIST = 10;
101 }