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

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

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

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

public class TextAreaActions {
    static{
        PropertyFactory.regist(TextArea.class, "prefRowCountProperty", o -> {
            TextArea obj = (TextArea) o;
            return obj.prefRowCountProperty();
        });
        PropertyFactory.regist(TextArea.class, "prefColumnCountProperty", o -> {
            TextArea obj = (TextArea) o;
            return obj.prefColumnCountProperty();
        });
        PropertyFactory.regist(TextArea.class, "scrollTopProperty", o -> {
            TextArea obj = (TextArea) o;
            return obj.scrollTopProperty();
        });
        PropertyFactory.regist(TextArea.class, "scrollLeftProperty", o -> {
            TextArea obj = (TextArea) o;
            return obj.scrollLeftProperty();
        });
        PropertyFactory.regist(TextArea.class, "wrapTextProperty", o -> {
            TextArea obj = (TextArea) o;
            return obj.wrapTextProperty();
        });
    }

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

        if(thing.valueExists("prefColumnCount")){
            node.setPrefColumnCount(thing.getInt("prefColumnCount"));
        }
        if(thing.valueExists("prefRowCount")){
            node.setPrefRowCount(thing.getInt("prefRowCount"));
        }
        if(thing.valueExists("scrollLeft")){
            node.setScrollLeft(thing.getDouble("scrollLeft"));
        }
        if(thing.valueExists("scrollTop")){
            node.setScrollTop(thing.getDouble("scrollTop"));
        }
        if(thing.valueExists("wrapText")){
            node.setWrapText(thing.getBoolean("wrapText"));
        }
    }

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

        TextArea node = new TextArea();
        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