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

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

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

import javafx.geometry.Side;
import javafx.scene.control.SingleSelectionModel;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;
import xworker.javafx.util.JavaFXUtils;

public class TabPaneActions {
    static{
        PropertyFactory.regist(TabPane.class, "rotateGraphicProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.rotateGraphicProperty();
        });
        PropertyFactory.regist(TabPane.class, "tabMinWidthProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.tabMinWidthProperty();
        });
        PropertyFactory.regist(TabPane.class, "tabClosingPolicyProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.tabClosingPolicyProperty();
        });
        PropertyFactory.regist(TabPane.class, "tabMaxWidthProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.tabMaxWidthProperty();
        });

        PropertyFactory.regist(TabPane.class, "tabMaxHeightProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.tabMaxHeightProperty();
        });
        PropertyFactory.regist(TabPane.class, "tabMinHeightProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.tabMinHeightProperty();
        });
        PropertyFactory.regist(TabPane.class, "sideProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.sideProperty();
        });
        PropertyFactory.regist(TabPane.class, "selectionModelProperty", o -> {
            TabPane obj = (TabPane) o;
            return obj.selectionModelProperty();
        });
    }

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

        if(thing.valueExists("rotateGraphic")){
            node.setRotateGraphic(thing.getBoolean("rotateGraphic"));
        }
        if(thing.valueExists("selectionModel")){
            SingleSelectionModel model = JavaFXUtils.getObject(thing, "selectionModel", actionContext);
            if(model != null) {
                node.setSelectionModel(model);
            }
        }
        if(thing.valueExists("side")){
            node.setSide(Side.valueOf(thing.getString("side")));
        }
        if(thing.valueExists("tabClosingPolicy")){
            node.setTabClosingPolicy(TabPane.TabClosingPolicy.valueOf(thing.getString("tabClosingPolicy")));
        }
        if(thing.valueExists("tabMaxHeight")){
            node.setTabMaxHeight(thing.getDouble("tabMaxHeight"));
        }
        if(thing.valueExists("tabMaxWidth")){
            node.setTabMaxWidth(thing.getDouble("tabMaxWidth"));
        }
        if(thing.valueExists("tabMinHeight")){
            node.setTabMinHeight(thing.getDouble("tabMinHeight"));
        }
        if(thing.valueExists("tabMinWidth")){
            node.setTabMinWidth(thing.getDouble("tabMinWidth"));
        }
    }

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

        TabPane node = new TabPane();
        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 Tab){
                node.getTabs().add((Tab) obj);
            }
        }

        return node;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy