javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/OnController.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 26 Jan 2013 08:47:05 +0100
changeset 592 5e13b1ac2886
child 813 2fa85847ccf7
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
/** Controller created via {@link OnEvent#of(org.apidesign.bck2brwsr.htmlpage.api.Element[])}.
jaroslav@435
    21
 *
jaroslav@435
    22
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@435
    23
 */
jaroslav@435
    24
public final class OnController {
jaroslav@435
    25
    private final Element[] arr;
jaroslav@435
    26
    private final OnEvent event;
jaroslav@435
    27
    
jaroslav@435
    28
    OnController(OnEvent event, Element[] arr) {
jaroslav@435
    29
        this.event = event;
jaroslav@435
    30
        this.arr = arr;
jaroslav@435
    31
    }
jaroslav@435
    32
    
jaroslav@435
    33
    /** Registers a runnable to be performed on associated {@link OnEvent} 
jaroslav@435
    34
     * and {@link Element}.
jaroslav@435
    35
     * 
jaroslav@435
    36
     * @see OnEvent#of
jaroslav@435
    37
     */
jaroslav@435
    38
    public void perform(Runnable r) {
jaroslav@435
    39
        for (Element e : arr) {
jaroslav@435
    40
            e.on(event, r);
jaroslav@435
    41
        }
jaroslav@435
    42
    }
jaroslav@435
    43
}