1 | // Module : $RCSfile: MessageType.java,v $
|
---|
2 | // Version : $Revision: 0.0 $ $Author: Patrick $ $Date: 26.11.2011 14:36:45 $
|
---|
3 | // Project : TaskTreePerformanceTest
|
---|
4 | // Creation : 2011 by Patrick
|
---|
5 | // Copyright : Patrick Harms, 2011
|
---|
6 |
|
---|
7 | package de.ugoe.cs.quest.plugin.jfc.eventcore;
|
---|
8 |
|
---|
9 | import java.awt.event.FocusEvent;
|
---|
10 | import java.awt.event.KeyEvent;
|
---|
11 | import java.awt.event.MouseEvent;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * TODO comment
|
---|
15 | *
|
---|
16 | * @version $Revision: $ $Date: $
|
---|
17 | * @author 2011, last modified by $Author: $
|
---|
18 | */
|
---|
19 | public enum JFCEventId {
|
---|
20 |
|
---|
21 | MOUSE_CLICKED(MouseEvent.MOUSE_CLICKED),
|
---|
22 | MOUSE_PRESSED(MouseEvent.MOUSE_PRESSED),
|
---|
23 | MOUSE_RELEASED(MouseEvent.MOUSE_RELEASED),
|
---|
24 | MOUSE_MOVED(MouseEvent.MOUSE_MOVED),
|
---|
25 | MOUSE_ENTERED(MouseEvent.MOUSE_ENTERED),
|
---|
26 | MOUSE_EXITED(MouseEvent.MOUSE_EXITED),
|
---|
27 | MOUSE_DRAGGED(MouseEvent.MOUSE_DRAGGED),
|
---|
28 | MOUSE_WHEEL(MouseEvent.MOUSE_WHEEL),
|
---|
29 | FOCUS_GAINED(FocusEvent.FOCUS_GAINED),
|
---|
30 | FOCUS_LOST(FocusEvent.FOCUS_LOST),
|
---|
31 | KEY_TYPED(KeyEvent.KEY_TYPED),
|
---|
32 | KEY_PRESSED(KeyEvent.KEY_PRESSED),
|
---|
33 | KEY_RELEASED(KeyEvent.KEY_RELEASED);
|
---|
34 |
|
---|
35 | /** the numerical representation of the event type */
|
---|
36 | private int mNumber;
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * @param number
|
---|
40 | */
|
---|
41 | JFCEventId(int number) {
|
---|
42 | mNumber = number;
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * @return Returns the number.
|
---|
47 | */
|
---|
48 | public int getNumber() {
|
---|
49 | return mNumber;
|
---|
50 | }
|
---|
51 |
|
---|
52 | /**
|
---|
53 | *
|
---|
54 | */
|
---|
55 | public static JFCEventId parseEventId(String numberString) {
|
---|
56 | try {
|
---|
57 | int number = Integer.parseInt(numberString);
|
---|
58 | return valueOf(number);
|
---|
59 | }
|
---|
60 | catch (NumberFormatException e) {
|
---|
61 | return JFCEventId.valueOf(JFCEventId.class, numberString);
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | /**
|
---|
66 | *
|
---|
67 | */
|
---|
68 | public static JFCEventId valueOf(int number) {
|
---|
69 | for (JFCEventId type : JFCEventId.values()) {
|
---|
70 | if (type.mNumber == number) {
|
---|
71 | return type;
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | throw new IllegalArgumentException("there is no event type with number " + number);
|
---|
76 | }
|
---|
77 |
|
---|
78 | }
|
---|