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

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

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

import javafx.scene.control.ContextMenu;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.scene.control.Tooltip;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;
import xworker.javafx.layout.RegionActions;
import xworker.javafx.util.JavaFXUtils;

public class ControlActions {
	static{
		PropertyFactory.regist(Control.class, "skinProperty", o -> {
			Control obj = (Control) o;
			return obj.skinProperty();
		});
		PropertyFactory.regist(Control.class, "tooltipProperty", o -> {
			Control obj = (Control) o;
			return obj.tooltipProperty();
		});
		PropertyFactory.regist(Control.class, "contextMenuProperty", o -> {
			Control obj = (Control) o;
			return obj.contextMenuProperty();
		});
	}

	public static void init(Control node, Thing thing, ActionContext actionContext) {
		RegionActions.init(node, thing, actionContext);

		if(thing.valueExists("contextMenu")){
			ContextMenu contextMenu = JavaFXUtils.getObject(thing, "contextMenu", actionContext);
			if(contextMenu != null) {
				node.setContextMenu(contextMenu);
			}
		}
		if(thing.valueExists("skin")){
			Skin skin = JavaFXUtils.getObject(thing, "skin", actionContext);
			if(skin != null) {
				node.setSkin(skin);
			}
		}
		if(thing.valueExists("tooltip")){
			Tooltip tooltip = JavaFXUtils.getObject(thing, "tooltip", actionContext);
			if(tooltip != null) {
				node.setTooltip(tooltip);
			}
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy