source: trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/eventcore/JFCEventId.java @ 655

Last change on this file since 655 was 655, checked in by pharms, 12 years ago
  • removed old copyright file header
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1package de.ugoe.cs.quest.plugin.jfc.eventcore;
2
3import java.awt.event.FocusEvent;
4import java.awt.event.KeyEvent;
5import java.awt.event.MouseEvent;
6
7/**
8 * TODO comment
9 *
10 * @version $Revision: $ $Date: $
11 * @author 2011, last modified by $Author: $
12 */
13public enum JFCEventId {
14   
15    MOUSE_CLICKED(MouseEvent.MOUSE_CLICKED),
16    MOUSE_PRESSED(MouseEvent.MOUSE_PRESSED),
17    MOUSE_RELEASED(MouseEvent.MOUSE_RELEASED),
18    MOUSE_MOVED(MouseEvent.MOUSE_MOVED),
19    MOUSE_ENTERED(MouseEvent.MOUSE_ENTERED),
20    MOUSE_EXITED(MouseEvent.MOUSE_EXITED),
21    MOUSE_DRAGGED(MouseEvent.MOUSE_DRAGGED),
22    MOUSE_WHEEL(MouseEvent.MOUSE_WHEEL),
23    FOCUS_GAINED(FocusEvent.FOCUS_GAINED),
24    FOCUS_LOST(FocusEvent.FOCUS_LOST),
25    KEY_TYPED(KeyEvent.KEY_TYPED),
26    KEY_PRESSED(KeyEvent.KEY_PRESSED),
27    KEY_RELEASED(KeyEvent.KEY_RELEASED);
28
29    /** the numerical representation of the event type */
30    private int mNumber;
31
32    /**
33     * @param number
34     */
35    JFCEventId(int number) {
36        mNumber = number;
37    }
38
39    /**
40     * @return Returns the number.
41     */
42    public int getNumber() {
43        return mNumber;
44    }
45
46    /**
47     *
48     */
49    public static JFCEventId parseEventId(String numberString) {
50        try {
51            int number = Integer.parseInt(numberString);
52            return valueOf(number);
53        }
54        catch (NumberFormatException e) {
55            return JFCEventId.valueOf(JFCEventId.class, numberString);
56        }
57    }
58
59    /**
60     *
61     */
62    public static JFCEventId valueOf(int number) {
63        for (JFCEventId type : JFCEventId.values()) {
64            if (type.mNumber == number) {
65                return type;
66            }
67        }
68
69        throw new IllegalArgumentException("there is no event type with number " + number);
70    }
71
72}
Note: See TracBrowser for help on using the repository browser.