protected MenuImpl CreateMenuImmutableAsSubMenu(string subMenuName, string id) { var subMenu = new MenuImpl(Metamodel, subMenuName) { Id = id }; AddAsSubMenu(subMenu); return(subMenu); }
public IMenu GetSubMenu(string menuName) { MenuImpl menu = GetSubMenuIfExists(menuName); if (menu == null) { throw new Exception(Log.LogAndReturn($"No sub-menu named {menuName}")); } return(menu); }
public IMenuImmutable GetSubMenu(string menuName) { MenuImpl menu = GetSubMenuIfExists(menuName); if (menu == null) { throw new Exception("No sub-menu named " + menuName); } return(menu); }
private MenuImpl CreateMenuImmutableAsSubMenu(string subMenuName, string id = null) { var subMenu = new MenuImpl(Metamodel, Type, false, subMenuName); if (id == null) { subMenu.Id += $"-{subMenuName}:"; } else { subMenu.Id = id; } subMenu.SuperMenu = this; AddMenuItem(subMenu); return(subMenu); }
private void AddContributedAction(IActionSpecImmutable ca, IObjectSpecImmutable spec) { var facet = ca.GetFacet <IContributedActionFacet>(); string subMenuName = facet.SubMenuWhenContributedTo(spec); if (subMenuName != null) { string id = facet.IdWhenContributedTo(spec); MenuImpl subMenu = GetSubMenuIfExists(subMenuName) ?? CreateMenuImmutableAsSubMenu(subMenuName, id); subMenu.AddOrderableElementsToMenu(new List <IActionSpecImmutable> { ca }, subMenu); } else { //i.e. no sub-menu AddMenuItem(new MenuAction(ca)); } }
public ITypedMenu <TObject> AddContributedActions() { IObjectSpecImmutable spec = GetObjectSpec <TObject>(); foreach (IActionSpecImmutable ca in spec.ContributedActions) { var facet = ca.GetFacet <IContributedActionFacet>(); string subMenuName = facet.SubMenuWhenContributedTo(spec); if (subMenuName != null) { string id = facet.IdWhenContributedTo(spec); MenuImpl subMenu = GetSubMenuIfExists(subMenuName) ?? CreateMenuImmutableAsSubMenu(subMenuName, id); subMenu.AddOrderableElementsToMenu(new List <IActionSpecImmutable> { ca }, subMenu); } else { //i.e. no sub-menu AddMenuItem(new MenuAction(ca)); } } return(this); }
public void CreateDefaultMenu(IMetamodelBuilder metamodel, Type type, string menuName, string id) { var menu = new MenuImpl(metamodel, type, false, menuName) {Id = id}; menu.AddRemainingNativeActions(); menu.AddContributedActions(); Menu = menu; }
private void AddOrderableElementsToMenu(IList <IActionSpecImmutable> ordeableElements, MenuImpl toMenu) { foreach (IActionSpecImmutable action in ordeableElements) { if (action != null) { if (!toMenu.HasActionOrSuperMenuHasAction(action)) { toMenu.AddMenuItem(new MenuAction(action)); } } } }
public MenuImpl AddAsSubMenu(MenuImpl subMenu) { AddMenuItem(subMenu); subMenu.SuperMenu = this; return(this); }
private MenuImpl CreateMenuImmutableAsSubMenu(string subMenuName, string id = null) { var subMenu = new MenuImpl(Metamodel, Type, false, subMenuName); if (id == null) { subMenu.Id += $"-{subMenuName}:"; } else { subMenu.Id = id; } subMenu.SuperMenu = this; AddMenuItem(subMenu); return subMenu; }
private void AddOrderableElementsToMenu(IList<IActionSpecImmutable> ordeableElements, MenuImpl toMenu) { foreach (IActionSpecImmutable action in ordeableElements) { if (action != null) { if (!toMenu.HasActionOrSuperMenuHasAction(action)) { toMenu.AddMenuItem(new MenuAction(action)); } } } }
//Creates a menu based on the definition in the object's Menu method public override void CreateMenu(IMetamodelBuilder metamodel) { var menu = new MenuImpl( metamodel, method.DeclaringType, false, GetMenuName(Spec)); InvokeUtils.InvokeStatic(method, new object[] {menu}); Menu = menu; }