summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/event/MouseEvents.java
blob: 19fdff8cc4932de372e02f421775c43dc25499d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.vaadin.event;

import java.lang.reflect.Method;

import com.vaadin.tools.ReflectTools;
import com.vaadin.ui.Component;

public interface MouseEvents {

    /**
     * defines the clicked mouse button for a ComponentClickEvents
     */
    public enum MouseButton {
        LEFT, RIGHT, MIDDLE
    }

    public class ClickEvent extends Component.Event {

        private MouseButton mouseButton;

        private static final long serialVersionUID = -7644184999481404162L;

        public ClickEvent(Component source, String mouseButton) {
            super(source);
            if (mouseButton.equals("left")) {
                this.mouseButton = MouseButton.LEFT;
            } else if (mouseButton.equals("right")) {
                this.mouseButton = MouseButton.RIGHT;
            } else {
                this.mouseButton = MouseButton.MIDDLE;
            }
        }

        public MouseButton getMouseButton() {
            return mouseButton;
        }

    }

    public interface ClickListener extends ComponentEventListener {

        public static final Method clickMethod = ReflectTools.findMethod(
                ClickListener.class, "click", ClickEvent.class);

        /**
         * Component has been clicked
         * 
         * @param event
         *            Component click event.
         */
        public void click(ClickEvent event);
    }

    /*
     * component double click event
     */

    public class DoubleClickEvent extends Component.Event {

        private static final long serialVersionUID = -7644184999481404162L;

        public DoubleClickEvent(Component source) {
            super(source);
        }
    }

    public interface DoubleClickListener extends ComponentEventListener {

        public static final Method doubleClickMethod = ReflectTools.findMethod(
                DoubleClickListener.class, "doubleClick",
                DoubleClickEvent.class);

        /**
         * Component value was changed
         * 
         * @param event
         *            Component change event.
         */
        public void doubleClick(DoubleClickEvent event);
    }

}