Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 82048

Summary: RCP App template should use IWorkbenchActionConstants
Product: [Eclipse Project] PDE Reporter: Pascal Rapicault <pascal>
Component: UIAssignee: Cherie Wong <cherie.wong>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: wassim.melhem
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Pascal Rapicault CLA 2004-12-31 08:39:37 EST
The code creating menus should make use of IWorkbenchActionConstants.
Comment 1 Wassim Melhem CLA 2005-01-06 02:42:28 EST
can you provide a concrete example?
Comment 2 Pascal Rapicault CLA 2005-01-06 22:33:38 EST
In the RCP Tutorial 3, you can find the following:
        private MenuManager createFileMenu(IWorkbenchWindow window) {
            MenuManager menu = new MenuManager(Messages.getString("File"), //$NON-NLS-1$
                IWorkbenchActionConstants.M_FILE);
            menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
            menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
            menu.add(ActionFactory.QUIT.create(window));
            menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
            return menu;
        }
Comment 3 Wassim Melhem CLA 2005-01-18 12:46:54 EST
Cherie, we may not be using IWorkbenchActionConstants for 'File'.  please fix 
it if necessary.
Comment 4 Cherie Wong CLA 2005-01-25 03:46:36 EST
RCP Mail Template code for menu generation was changed from:
MenuManager fileMenu = new MenuManager("&File", "file");
MenuManager aboutMenu = new MenuManager("&About", "about");

to:
MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
MenuManager aboutMenu = new MenuManager("&About", "about");

Additionally, the "about" can use...
1. IWorkbenchActionConstants.ABOUT (deprecated)  
2. IDEActionFactory.ABOUT.getId() (the recommended replacement for deprecated #1)
However, since #1 is deprecated and IDEActionFactory does not have an ABOUT
ActionFactory, I have not made any changes to the About menu here.  I can
definitely make that change if desired -- just let me know :)

Changes are currently in head.  Marking as fixed :)
Comment 5 Cherie Wong CLA 2005-01-25 03:52:30 EST
In my previous comment, I mentioned the possibility of making the change to the
About menu id, "about".  

Just to clarify, I only mean for #1 (deprecated IWorkbenchActionConstants.ABOUT)
to be an option in this case as I doubt you all would want to add a dependency
on o.e.ui.ide for an RCP app. :)

Comment 6 Pascal Rapicault CLA 2005-01-25 08:47:07 EST
ARGh ! I copied the wrong snippet.
The comment for IWorkbenchActionConstants.ABOUT is incomplete. It should have
the following line: org.eclipse.ui.ActionFactory.ABOUT.create(IWorkbenchWindow)
which does not require new dependencies.
Comment 7 Cherie Wong CLA 2005-01-25 10:02:30 EST
Hi Pascal!

Just to recap our conversation just now, the "about" text could be changed to 
use ActionFactory.ABOUT.getId(); however, this would likely cause confusion as 
the action id and menu id are two different things.  Thus, the code will stay 
as is :)

The code snippet currently appears in ActionBuilder as:
public void populateMenuBar(IActionBarConfigurer configurer) {
	IMenuManager mgr = configurer.getMenuManager();
	
	MenuManager fileMenu = new MenuManager("&File", 
IWorkbenchActionConstants.M_FILE);
	MenuManager aboutMenu = new MenuManager("&About", "about");
	
	// Allow contributions to the top-level menu
	mgr.add(fileMenu);
	mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
	mgr.add(aboutMenu);
	
	// File
	fileMenu.add(newWindow);
	fileMenu.add(new Separator());
	fileMenu.add(messagePopup);
	fileMenu.add(openViewAction);
	fileMenu.add(new Separator());
	fileMenu.add(exitAction);
	
	// About
	aboutMenu.add(aboutAction);
}


Thanks!