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

xworker.javafx.control.TextFieldActions Maven / Gradle / Ivy

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

import javafx.geometry.Pos;
import javafx.scene.control.TextField;
import javafx.scene.text.Font;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class TextFieldActions {
    static{
        PropertyFactory.regist(TextField.class, "alignmentProperty", o -> {
            TextField obj = (TextField) o;
            return obj.alignmentProperty();
        });
        PropertyFactory.regist(TextField.class, "prefColumnCountProperty", o -> {
            TextField obj = (TextField) o;
            return obj.prefColumnCountProperty();
        });
        PropertyFactory.regist(TextField.class, "onActionProperty", o -> {
            TextField obj = (TextField) o;
            return obj.onActionProperty();
        });
    }

    public static void init(TextField node, Thing thing, ActionContext actionContext){
        TextInputControlActions.init(node, thing, actionContext);

        if(thing.valueExists("prefColumnCount")){
            node.setPrefColumnCount(thing.getInt("prefColumnCount"));
        }
        if(thing.valueExists("alignment")){
            node.setAlignment(Pos.valueOf(thing.getString("alignment")));
        }
    }

    public static TextField create(ActionContext actionContext){
        Thing self = actionContext.getObject("self");

        TextField node = new TextField();
        init(node, self, actionContext);
        actionContext.g().put(self.getMetadata().getName(), node);

        actionContext.peek().put("parent", node);
        for(Thing child : self.getChilds()){
            Object obj = child.doAction("create", actionContext);
            if(obj instanceof Font){
                node.setFont((Font) obj);
            }
        }

        return node;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy