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

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

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

import javafx.scene.control.ToggleButton;
import javafx.scene.control.ToggleGroup;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.util.UtilData;
import xworker.javafx.beans.property.PropertyFactory;

public class ToggleButtonActions {
	static{
		PropertyFactory.regist(ToggleButton.class, "toggleGroupProperty", o -> {
			ToggleButton obj = (ToggleButton) o;
			return obj.toggleGroupProperty();
		});
		PropertyFactory.regist(ToggleButton.class, "selectedProperty", o -> {
			ToggleButton obj = (ToggleButton) o;
			return obj.selectedProperty();
		});
	}

	public static void init(ToggleButton item, Thing thing, ActionContext actionContext) {
		ButtonBaseActions.init(item, thing, actionContext);
		
		if(thing.valueExists("selected")) {
			item.setSelected(thing.getBoolean("selected"));
		}
		
		if(thing.valueExists("toggleGroup")) {
			ToggleGroup toggleGroup = (ToggleGroup) UtilData.getData(thing.getString("toggleGroup"), actionContext);
			if(toggleGroup != null) {
				item.setToggleGroup(toggleGroup);
			}
		}
	}
	
	public static ToggleButton create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		
		ToggleButton item = new ToggleButton();
		init(item, self, actionContext);
		actionContext.g().put(self.getMetadata().getName(), item);
		
		actionContext.peek().put("parent", item);
		for(Thing child : self.getChilds()) {
			child.doAction("create", actionContext);
		}
		
		return item;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy