xworker.javafx.control.MenuActions Maven / Gradle / Ivy
package xworker.javafx.control;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import ognl.OgnlException;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;
import java.io.IOException;
public class MenuActions {
static{
PropertyFactory.regist(Menu.class, "onShownProperty", o -> {
Menu obj = (Menu) o;
return obj.onShownProperty();
});
PropertyFactory.regist(Menu.class, "onShowingProperty", o -> {
Menu obj = (Menu) o;
return obj.onShowingProperty();
});
PropertyFactory.regist(Menu.class, "onHiddenProperty", o -> {
Menu obj = (Menu) o;
return obj.onHiddenProperty();
});
PropertyFactory.regist(Menu.class, "onHidingProperty", o -> {
Menu obj = (Menu) o;
return obj.onHidingProperty();
});
}
public static void init(Menu menu, Thing thing, ActionContext actionContext) throws OgnlException, IOException {
MenuItemActions.init(menu, thing, actionContext);
}
public static Menu create(ActionContext actionContext) throws OgnlException, IOException {
Thing self = actionContext.getObject("self");
Menu menu = new Menu();
init(menu, self, actionContext);
actionContext.g().put(self.getMetadata().getName(), menu);
actionContext.peek().put("parent", menu);
for(Thing child : self.getChilds()) {
Object obj = child.doAction("create", actionContext);
if(obj instanceof MenuItem) {
menu.getItems().add((MenuItem) obj);
}
}
return menu;
}
}