Search in sources :

Example 6 with Function

use of elemental2.core.Function in project kie-wb-common by kiegroup.

the class DataTypeSelectView method makeOption.

HTMLOptionElement makeOption(final DataType dataType, final Function<DataType, String> dataTypeConsumer) {
    final String optionValue = dataTypeConsumer.apply(dataType);
    final HTMLOptionElement option = makeHTMLOptionElement();
    option.text = optionValue;
    option.value = optionValue;
    return option;
}
Also used : HTMLOptionElement(elemental2.dom.HTMLOptionElement)

Example 7 with Function

use of elemental2.core.Function in project kie-wb-common by kiegroup.

the class DataTypeSelectView method makeOptionGroup.

HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) {
    final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement();
    optionGroup.label = groupTitle;
    dataTypes.stream().forEach(dataType -> {
        final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer);
        optionGroup.appendChild(option);
    });
    return optionGroup;
}
Also used : HTMLOptGroupElement(elemental2.dom.HTMLOptGroupElement) HTMLOptionElement(elemental2.dom.HTMLOptionElement)

Example 8 with Function

use of elemental2.core.Function in project vue-gwt by Axellience.

the class VueComponentOptions method initTemplateExpressions.

/**
 * Add template expressions to this {@link VueComponentOptions}.
 */
@JsOverlay
private void initTemplateExpressions() {
    int i = 0;
    Function templateMethod;
    while ((templateMethod = getJavaComponentMethod("exp$" + i)) != null) {
        addMethod("exp$" + i, templateMethod);
        i++;
    }
}
Also used : Function(elemental2.core.Function) JsOverlay(jsinterop.annotations.JsOverlay)

Example 9 with Function

use of elemental2.core.Function in project vue-gwt by Axellience.

the class VueDirectiveOptions method copyHook.

/**
 * Copy the given hook function from the Java instance to the options we pass to Vue
 * @param hookFunctionName The name of the hook function to copy
 */
private void copyHook(String hookFunctionName) {
    Function hookFunction = (Function) ((JsPropertyMap) vuegwt$javaDirectiveInstance).get(hookFunctionName);
    if (hookFunction == null)
        return;
    // Filter empty function inherited from VueDirective
    String body = getFunctionBody(hookFunction);
    if ("".equals(body))
        return;
    set(hookFunctionName, hookFunction);
}
Also used : Function(elemental2.core.Function) JsString(elemental2.core.JsString)

Example 10 with Function

use of elemental2.core.Function in project vue-gwt by Axellience.

the class VueDirectiveOptions method getFunctionBody.

private String getFunctionBody(Function jsFunction) {
    JsString jsString = cast(jsFunction.toString());
    // Get content between first { and last }
    JsString m = cast(jsString.match(new JsRegExp("\\{([\\s\\S]*)\\}", "m"))[1]);
    // Strip comments
    return m.replace(new JsRegExp("^\\s*\\/\\/.*$", "mg"), "").trim();
}
Also used : JsRegExp(elemental2.core.JsRegExp) JsString(elemental2.core.JsString)

Aggregations

Function (elemental2.core.Function)3 JsObject (elemental2.core.JsObject)2 JsString (elemental2.core.JsString)2 HTMLOptionElement (elemental2.dom.HTMLOptionElement)2 JsPropertyMap (jsinterop.base.JsPropertyMap)2 ComponentJavaPrototype (com.axellience.vuegwt.core.client.component.ComponentJavaPrototype)1 VueComponent (com.axellience.vuegwt.core.client.component.VueComponent)1 VueJsConstructor (com.axellience.vuegwt.core.client.vue.VueJsConstructor)1 JsRegExp (elemental2.core.JsRegExp)1 HTMLElement (elemental2.dom.HTMLElement)1 HTMLOptGroupElement (elemental2.dom.HTMLOptGroupElement)1 HTMLScriptElement (elemental2.dom.HTMLScriptElement)1 Promise (elemental2.promise.Promise)1 Function (java.util.function.Function)1 JsFunction (jsinterop.annotations.JsFunction)1 JsOverlay (jsinterop.annotations.JsOverlay)1 Caller (org.jboss.errai.common.client.api.Caller)1