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

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

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

import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.ToolBar;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class ToolBarActions {
    static{
        PropertyFactory.regist(ToolBar.class, "orientationProperty", o -> {
            ToolBar obj = (ToolBar) o;
            return obj.orientationProperty();
        });
    }

    public static void init(ToolBar node, Thing thing, ActionContext actionContext) {
        ControlActions.init(node, thing, actionContext);

        if(thing.valueExists("orientation")){
            node.setOrientation(Orientation.valueOf(thing.getString("orientation")));
        }
    }

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

        ToolBar node = new ToolBar();
        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 Node){
                node.getItems().add((Node) obj);
            }
        }

        return node;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy