All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xworker.javafx.util.ThingCallback Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package xworker.javafx.util;

import javafx.util.Callback;
import org.xmeta.ActionContext;
import org.xmeta.Thing;

public class ThingCallback implements Callback {
    Thing thing;
    ActionContext actionContext;
    Object object;

    public ThingCallback(Thing thing, ActionContext actionContext){
        this.thing = thing;
        this.actionContext = actionContext;
        object = FXThingLoader.getObject();
    }

    @Override
    public R call(P param) {
        if(object != null){
            FXThingLoader.push(object);
            try{
                return thing.doAction("call", actionContext, "param", param);
            }finally {
                FXThingLoader.pop();
            }
        }else{
            return thing.doAction("call", actionContext, "param", param);
        }

    }

    public static ThingCallback create(ActionContext actionContext){
        Thing self = actionContext.getObject("self");
        ThingCallback callback = new ThingCallback(self, actionContext);
        actionContext.g().put(self.getMetadata().getName(), callback);

        return callback;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy