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

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

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

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

public class MenuBarAction {
	static{
		PropertyFactory.regist(MenuBar.class, "useSystemMenuBarProperty", o -> {
			MenuBar obj = (MenuBar) o;
			return obj.useSystemMenuBarProperty();
		});
	}

	public static void init(MenuBar list, Thing thing, ActionContext actionContext) {
		ControlActions.init(list, thing, actionContext);
        if(thing.valueExists("useSystemMenuBar")){
            list.setUseSystemMenuBar(thing.getBoolean("useSystemMenuBar"));
        }
	}
	
	public static MenuBar create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		
		MenuBar item = new MenuBar();
		init(item, self, actionContext);
		actionContext.g().put(self.getMetadata().getName(), item);
		
		actionContext.peek().put("parent", item);
		for(Thing child : self.getChilds()) {
			Object obj = child.doAction("create", actionContext);
			if(obj instanceof Menu) {
				item.getMenus().add((Menu) obj);
			}
		}
		
		return item;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy