javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnEvent.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 26 Jan 2013 08:47:05 +0100
changeset 592 5e13b1ac2886
parent 435 fb4ed6cc0d4b
child 1787 ea12a3bb4b33
permissions -rw-r--r--
In order to support fields of the same name in subclasses we are now prefixing them with name of the class that defines them. To provide convenient way to access them from generated bytecode and also directly from JavaScript, there is a getter/setter function for each field. It starts with _ followed by the field name. If called with a parameter, it sets the field, with a parameter it just returns it.
jaroslav@435
     1
/**
jaroslav@435
     2
 * Back 2 Browser Bytecode Translator
jaroslav@435
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@435
     4
 *
jaroslav@435
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@435
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@435
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@435
     8
 *
jaroslav@435
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@435
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@435
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@435
    12
 * GNU General Public License for more details.
jaroslav@435
    13
 *
jaroslav@435
    14
 * You should have received a copy of the GNU General Public License
jaroslav@435
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@435
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@435
    17
 */
jaroslav@435
    18
package org.apidesign.bck2brwsr.htmlpage.api;
jaroslav@435
    19
jaroslav@435
    20
/** Type of events to use in connection with {@link On} annotation.
jaroslav@435
    21
 *
jaroslav@435
    22
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@435
    23
 */
jaroslav@435
    24
public enum OnEvent {
jaroslav@435
    25
    ABORT("onabort"),
jaroslav@435
    26
    BLUR("onblur"),
jaroslav@435
    27
    CAN_PLAY("oncanplay"),
jaroslav@435
    28
    CAN_PLAY_THROUGH("oncanplaythrough"),
jaroslav@530
    29
    CHANGE("onchange"),
jaroslav@435
    30
    CLICK("onclick"),
jaroslav@435
    31
    CONTEXT_MENU("oncontextmenu"),
jaroslav@435
    32
    DBL_CLICK("ondblclick"),
jaroslav@435
    33
    DRAG("ondrag"),
jaroslav@435
    34
    DRAG_END("ondragend"),
jaroslav@435
    35
    DRAG_ENTER("ondragenter"),
jaroslav@435
    36
    DRAG_LEAVE("ondragleave"),
jaroslav@435
    37
    DRAG_OVER("ondragover"),
jaroslav@435
    38
    DRAG_START("ondragstart"),
jaroslav@435
    39
    DROP("ondrop"),
jaroslav@435
    40
    DURATION_CHANGE("ondurationchange"),
jaroslav@435
    41
    EMPTIED("onemptied"),
jaroslav@435
    42
    ENDED("onended"),
jaroslav@435
    43
    ERROR("onerror"),
jaroslav@435
    44
    FOCUS("onfocus"),
jaroslav@435
    45
    FORM_CHANGE("onformchange"),
jaroslav@435
    46
    FORM_INPUT("onforminput"),
jaroslav@435
    47
    INPUT("oninput"),
jaroslav@435
    48
    INVALID("oninvalid"),
jaroslav@435
    49
    KEY_DOWN("onkeydown"),
jaroslav@435
    50
    KEY_PRESS("onkeypress"),
jaroslav@435
    51
    KEY_UP("onkeyup"),
jaroslav@435
    52
    LOAD("onload"),
jaroslav@435
    53
    LOADED_DATA("onloadeddata"),
jaroslav@435
    54
    LOADED_META_DATA("onloadedmetadata"),
jaroslav@435
    55
    LOAD_START("onloadstart"),
jaroslav@435
    56
    MOUSE_DOWN("onmousedown"),
jaroslav@435
    57
    MOUSE_MOVE("onmousemove"),
jaroslav@435
    58
    MOUSE_OUT("onmouseout"),
jaroslav@435
    59
    MOUSE_OVER("onmouseover"),
jaroslav@435
    60
    MOUSE_UP("onmouseup"),
jaroslav@435
    61
    MOUSE_WHEEL("onmousewheel"),
jaroslav@435
    62
    PAUSE("onpause"),
jaroslav@435
    63
    PLAY("onplay"),
jaroslav@435
    64
    PLAYING("onplaying"),
jaroslav@435
    65
    PROGRESS("onprogress"),
jaroslav@435
    66
    RATE_CHANGE("onratechange"),
jaroslav@435
    67
    READY_STATE_CHANGE("onreadystatechange"),
jaroslav@435
    68
    SCROLL("onscroll"),
jaroslav@435
    69
    SEEKED("onseeked"),
jaroslav@435
    70
    SEEKING("onseeking"),
jaroslav@435
    71
    SELECT("onselect"),
jaroslav@435
    72
    SHOW("onshow"),
jaroslav@435
    73
    STALLED("onstalled"),
jaroslav@435
    74
    SUBMIT("onsubmit"),
jaroslav@435
    75
    SUSPEND("onsuspend"),
jaroslav@435
    76
    TIME_UPDATE("ontimeupdate"),
jaroslav@435
    77
    VOLUME_CHANGE("onvolumechange"),
jaroslav@435
    78
    WAITING("onwaiting");
jaroslav@435
    79
    
jaroslav@435
    80
    final String id;
jaroslav@435
    81
    
jaroslav@435
    82
    private OnEvent(String id) {
jaroslav@435
    83
        this.id = id;
jaroslav@435
    84
    }
jaroslav@435
    85
    
jaroslav@530
    86
    /** The name of property this event is referenced by from an {@link Element}.
jaroslav@530
    87
     * For {@link OnEvent#CHANGE}, it is <code>onchange</code>.
jaroslav@530
    88
     */
jaroslav@530
    89
    public String getElementPropertyName() {
jaroslav@530
    90
        return id;
jaroslav@530
    91
    }
jaroslav@530
    92
    
jaroslav@435
    93
    /** What should happen when this even happen on one
jaroslav@435
    94
     * of associated elements. Continue by calling {@link OnController#perform(java.lang.Runnable)}
jaroslav@435
    95
     * method.
jaroslav@435
    96
     * 
jaroslav@435
    97
     * @param elmnts one or more elements
jaroslav@435
    98
     * @return controller with <code>perform</code> method.
jaroslav@435
    99
     */
jaroslav@435
   100
    public OnController of(Element... elmnts) {
jaroslav@435
   101
        return new OnController(this, elmnts);
jaroslav@435
   102
    }
jaroslav@435
   103
}