Exemplo n.º 1
0
        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);
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 6
0
        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));
             }
         }
     }
 }
Exemplo n.º 9
0
 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;
 }