RCP II: Expand Universal Workbench (3)

xiaoxiao2021-03-06  61

3, integrated menu to perspective

l To add new menu items to the menu bar, you need to override the FillActionbars method in the WorkbenChadvisor class.

Public Void FillActionbars (iWorkbenchWindow Window,

IActionBarconfigurer Configurer, int flags) {

IMenumanager menubar = configurer.getMenumanager ();

Menumanager filemenu = new menuManager ("file",

IWorkBenChatConstants.m_file);

FileMenu.add (New GroupMarker (iWorkBenChctionConstants.file_start);

FileMenu.add (New GroupMarker (iWorkbenChatconstants.mb_additions);

FileMenu.add (actionFactory.quit.create (Window);

FileMenu.add (New GroupMarker (iWorkBenChctionConstants.file_end);

MenuBar.Add (FileMenu);

}

l First GetMenumanager () get the menu bar object

l create a standard File menu: GroupMarker create special menus packet marking, IWorkbenchActionConstants.FILE_START and IWorkbenchActionConstants.FILE_END packet indicating the start and end of the File menu, IWorkbenchActionConstants.MB_ADDITIONS expressed File menu to the top level menu; ActionFactory.QUIT.create (window) to create Standard exit workbench action, ie EXIT menu item

l The File menu is added to the menu bar.

转载请注明原文地址:https://www.9cbs.com/read-119601.html

New Post(0)