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

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

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

import javafx.scene.control.CheckBox;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class CheckBoxActions {
	static{
		PropertyFactory.regist(CheckBox.class, "allowIndeterminateProperty", o -> {
			CheckBox obj = (CheckBox) o;
			return obj.allowIndeterminateProperty();
		});
		PropertyFactory.regist(CheckBox.class, "indeterminateProperty", o -> {
			CheckBox obj = (CheckBox) o;
			return obj.indeterminateProperty();
		});
		PropertyFactory.regist(CheckBox.class, "selectedProperty", o -> {
			CheckBox obj = (CheckBox) o;
			return obj.selectedProperty();
		});
	}

	public static void init(CheckBox box, Thing thing, ActionContext actionContext) {
		ButtonBaseActions.init(box, thing, actionContext);
		 
		 if(thing.valueExists("allowIndeterminate")) {
			 box.setAllowIndeterminate(thing.getBoolean("allowIndeterminate"));
		 }
		 
		 if(thing.valueExists("indeterminate")) {
			 box.setIndeterminate(thing.getBoolean("indeterminate"));
		 }
		 
		 if(thing.valueExists("selected")) {
			 box.setSelected(thing.getBoolean("selected"));
		 }
	}
	
	public static CheckBox create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		
		CheckBox box = new CheckBox();
		init(box, self, actionContext);
		actionContext.g().put(self.getMetadata().getName(), box);
		
		actionContext.peek().put("parent", box);
		for(Thing child : self.getChilds()) {
			child.doAction("create", actionContext);
		}
		
		return box;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy