Search in sources :

Example 1 with EventListener

use of org.jboss.errai.common.client.dom.EventListener in project kie-wb-common by kiegroup.

the class CustomGroupItem method createAnchor.

@JsOverlay
public static CustomGroupItem createAnchor(final String text, final IconType iconType, final Command command) {
    final CustomGroupItem anchor = (CustomGroupItem) Window.getDocument().createElement("a");
    anchor.setClassName(Styles.LIST_GROUP_ITEM);
    if (iconType != null) {
        final HTMLElement icon = Window.getDocument().createElement("i");
        icon.getClassList().add("fa");
        icon.getClassList().add(iconType.getCssName());
        anchor.setInnerHTML(icon.getOuterHTML() + " " + text);
    } else {
        anchor.setTextContent(checkNotEmpty("text", text));
    }
    anchor.setHref("#");
    // can't use lambda here; GWT limitation (bug!)!
    anchor.setOnclick(new EventListener() {

        @Override
        public void call(final Event event) {
            command.execute();
        }
    });
    return anchor;
}
Also used : HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) Event(org.jboss.errai.common.client.dom.Event) EventListener(org.jboss.errai.common.client.dom.EventListener) JsOverlay(jsinterop.annotations.JsOverlay)

Aggregations

JsOverlay (jsinterop.annotations.JsOverlay)1 Event (org.jboss.errai.common.client.dom.Event)1 EventListener (org.jboss.errai.common.client.dom.EventListener)1 HTMLElement (org.jboss.errai.common.client.dom.HTMLElement)1