Exemplo n.º 1
0
        /// <summary>
        ///   Reset Pulldown menu.
        /// </summary>
        /// <param name = "context task"></param>
        public bool MenuReset(TaskBase mainProg, TaskBase task)
        {
            MgFormBase formOrg = task.getTopMostForm();
            MgFormBase form    = (formOrg != null)
                              ? formOrg.getTopMostFrameForm()
                              : null;

            form = (form ?? formOrg);

            if (form != null)
            {
                int pulldownMenuIdx = form.getPulldownMenuNumber();

                if (pulldownMenuIdx > 0)
                {
                    String menusFileUrl = mainProg.getMenusFileURL();

                    //Suspend drawing of frame form till pulldown menu is destroy and rebuilt.
                    Commands.addAsync(CommandType.SUSPEND_PAINT, form);

                    //destroy and rebuild all application menus.
                    destroyAndRebuild(menusFileUrl);

                    Commands.addAsync(CommandType.RESUME_PAINT, form);

                    MgMenu pulldownMenu = form.getPulldownMenu();

                    //recreate the pulldown menu, only if it is not instantiated.This happens only in case, if MenuRemove()
                    //is called to remove the pulldown menu.
                    if (!pulldownMenu.menuIsInstantiated(form, MenuStyle.MENU_STYLE_PULLDOWN))
                    {
                        form.setPulldownMenuNumber(pulldownMenuIdx, true);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  This method returns a specific menu object, which matches the passed menu index. It checks if the wanted
        ///  menu already exists. If it does not, it calls the CreateMenu method for this entry. The matching MgMenu
        ///  object is returned. This method will be called from the Property::RefreshDisplay. It will provide the
        ///  Property mechanism with a matching MenuEntry to the specified menu identification.
        /// </summary>
        /// <param name="mainProg"></param>
        /// <param name="menuIndex"></param>
        /// <param name="menuStyle">type of the menu: MENU_TYPE_PULLDOWN, MENU_TYPE_CONTEXT</param>
        /// <param name="form"></param>
        /// <param name="createIfNotExist">This will decide if menu is to be created or not.</param>
        /// <returns></returns>
        public MgMenu getMenu(TaskBase mainProg, int menuIndex, MenuStyle menuStyle, MgFormBase form, bool createIfNotExist)
        {
            MgMenu retMenu = null;

            if (mainProg.menusAttached())
            {
                ApplicationMenus appMenus = getApplicationMenus(mainProg);

                if (appMenus != null)
                {
                    retMenu = appMenus.getMgMenu(menuIndex);
                    if (createIfNotExist && retMenu != null && !retMenu.menuIsInstantiated(form, menuStyle))
                    {
                        // this menu does not have a matching java object for this shell – we need to create it
                        // Context menus are created & destroyed on the fly. For context menu, if no visible menu entry
                        // is found at 1st level, then don't create it. Because, if no visible menu entry is found ,
                        // no popup is displayed, So menu gets instantiated but it is not destroyed as we don't get CLOSING message.
                        if (menuStyle == MenuStyle.MENU_STYLE_CONTEXT)
                        {
                            if (retMenu.isAnyMenuEntryVisible())
                            {
                                retMenu.createMenu(form, menuStyle);
                            }
                            else
                            {
                                retMenu = null;
                            }
                        }
                        else
                        {
                            retMenu.createMenu(form, menuStyle);
                        }
                    }
                }
            }

            return(retMenu);
        }