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

xworker.javafx.control.MenuButtonActions 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.MenuButton;
import javafx.scene.control.MenuItem;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class MenuButtonActions {
	static{
		PropertyFactory.regist(MenuButton.class, "popupSideProperty", o -> {
			MenuButton obj = (MenuButton) o;
			return obj.popupSideProperty();
		});
	}

	public static void init(MenuButton button, Thing thing, ActionContext actionContext) {
		ButtonBaseActions.init(button, thing, actionContext);
		 
		 if(thing.valueExists("popupSide")) {
			 button.setPopupSide(Side.valueOf(thing.getString("popupSide")));
		 }
		 
	}
	
	public static MenuButton create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		
		MenuButton button = new MenuButton();
		init(button, self, actionContext);
		actionContext.g().put(self.getMetadata().getName(), button);
		
		actionContext.peek().put("parent", button);
		for(Thing child : self.getChilds()) {
			Object obj = child.doAction("create", actionContext);
			if(obj instanceof MenuItem) {
				button.getItems().add((MenuItem) obj);
			}
		}
		
		return button;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy