Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 73729 - [Workbench] [Mac] Dual preferences menu items
Summary: [Workbench] [Mac] Dual preferences menu items
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.3 M2   Edit
Assignee: Kim Horne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 73728 102235 123900 153313 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-11 19:12 EDT by Elliotte Rusty Harold CLA
Modified: 2006-09-19 10:20 EDT (History)
6 users (show)

See Also:


Attachments
Patch against org.eclipse.ui.ide (3.16 KB, patch)
2005-06-30 14:42 EDT, Kim Horne CLA
no flags Details | Diff
Patch against org.eclipse.ui.carbon (3.65 KB, patch)
2005-06-30 14:42 EDT, Kim Horne CLA
no flags Details | Diff
Patch against the workspace root (6.08 KB, patch)
2006-08-09 14:07 EDT, Kim Horne CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elliotte Rusty Harold CLA 2004-09-11 19:12:42 EDT
On Mac OS X, the preferences menu item appears in the Eclipse menu. This is
correct. However, the same menu item that does the same thing also appears in
the Window menu, which is correct on other platforms but not the Mac. It should
be removed from the Window menu.
Comment 1 Andre Weinand CLA 2004-09-15 08:55:40 EDT
Billy, just for your information: I'm the owner of the org.eclipse.ui.carbon fragment (hack) that fills the 
standard Mac application menu with the expected menu items and hooks them to the corresponding 
workbench actions. My take on this problem is that SWT needs to provide abstractions and API for these 
issues.
Comment 2 Billy Biggs CLA 2004-09-15 13:08:16 EDT
*** Bug 73728 has been marked as a duplicate of this bug. ***
Comment 3 Billy Biggs CLA 2005-06-29 20:32:04 EDT
*** Bug 102235 has been marked as a duplicate of this bug. ***
Comment 4 Bob Foster CLA 2005-06-29 21:55:23 EDT
This seems to be going nowhere. The problem is not confined to preferences.
File>Exit, Window>Preferences and Help>About all duplicate standard Carbon
menus. I truly don't understand the response. Exactly what SWT abstraction do
you envision that would keep Eclipse from duplicating MacOS X standard menu
items? What if Eclipse adds a Services menu item in the Edit menu?

The actual fix for this, albeit not restricted to a fragment, is about six lines
of code.
Comment 5 Andre Weinand CLA 2005-06-30 03:23:49 EDT
We have no public API in SWT for accessing the Mac's application menu.
The org.eclipse.ui.carbon fragment uses internal SWT API that only exists on the Mac.
In order to avoid duplicate menu entries, org.eclipse.platform.ui would have to find out what standard Mac 
menus the ui.carbon fragment is hooking up, and remove the corresponding items from the other menus.
This sounds like a hack.
I envision the following solution:
SWT makes the Mac's application menu API so that other Eclipse plug-ins could find out about it, and 
install actions like Preferences, About, and Exit in the correct place depending on platform.

Bob, could you please attach your six line fix as a patch? Thanks.
Comment 6 Bob Foster CLA 2005-06-30 11:47:05 EDT
I'm not in a good position to make a CVS/rdiff patch file. Below is the simple
patch file I actually use. It's pretty obvious what it does and where.

patch:
../org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkbenchActionBuilder.java
change:
        menu.add(openPreferencesAction);
to:
        if (!"carbon".equals(SWT.getPlatform()))
            menu.add(openPreferencesAction);
change:
        menu.add(new Separator());
        menu.add(quitAction);
to:
        if (!"carbon".equals(SWT.getPlatform())) {
            menu.add(new Separator());
            menu.add(quitAction);
        }
change:
		menu.add(aboutAction);
to:
		if (!"carbon".equals(SWT.getPlatform()))
			menu.add(aboutAction);
Comment 7 Michael Van Meekeren CLA 2005-06-30 12:15:43 EDT
assigning to Kim
Comment 8 Kim Horne CLA 2005-06-30 12:51:37 EDT
Bob: that patch can't work.  The Carbon fragment relies on the existence of the actions in the menu.  When 
it receives the various signals from the OS, the carbon fragment attempts to crawl the menu structure and 
find the appropriate action to run.  Without them present, you can't activate About or Preferences from the 
Eclipse menu. 

We can either alter the Carbon fragment to run the commands in another fashion or just try to hide the 
visibility of the items in the menu.
Comment 9 Kim Horne CLA 2005-06-30 14:20:12 EDT
I have a patch that will fix this problem by making certain items invisible in the menus.  They're still there 
so the carbon fragment can find them (with a bit of modification).  

I agree with Andre that new API is needed to fix this properly.  I'm not sure it needs to live in SWT 
necessarily - it could probably live in UI.  As it stands all RCP developers that target the Mac will need to 
do the same kind of trickery if we go with the hiding solution.

Perhaps the UI should create a registry for actions that have standard positions within various platform 
UIs.  Instead of adding them manually to certain menus in the advisor you'd simply declare that you want 
them present and the UI would put them in the appropriate spot (depending on platform).
Comment 10 Bob Foster CLA 2005-06-30 14:35:18 EDT
Could you attach your patch, please, and suggest what certain changes are needed
to the fragment? Thanks.
Comment 11 Kim Horne CLA 2005-06-30 14:42:15 EDT
Created attachment 24231 [details]
Patch against org.eclipse.ui.ide
Comment 12 Kim Horne CLA 2005-06-30 14:42:37 EDT
Created attachment 24232 [details]
Patch against org.eclipse.ui.carbon
Comment 13 Bob Foster CLA 2005-06-30 15:10:39 EDT
Thanks. What about the separators, e.g., before the quitAction?
Comment 14 Kim Horne CLA 2005-06-30 15:15:36 EDT
Yah, they bug me too.  :)  If this is the path we end up taking I'll add some polish to the patch to clean 
those up.
Comment 15 Kim Horne CLA 2006-01-16 15:25:18 EST
*** Bug 123900 has been marked as a duplicate of this bug. ***
Comment 16 Tod Creasey CLA 2006-05-01 11:20:33 EDT
Deferring
Comment 17 Kim Horne CLA 2006-08-09 14:03:04 EDT
*** Bug 153313 has been marked as a duplicate of this bug. ***
Comment 18 Kim Horne CLA 2006-08-09 14:05:03 EDT
A bug has languished sufficiently when it's owner forgets that it exists and not only enters a dupe but fixes the dupe in a manner similar to the patch that is already attached to the original bug.  I will proceed with the quick solution I mentioned before as soon as M1 is out the door.  Sigh.  
Comment 19 Kim Horne CLA 2006-08-09 14:07:13 EDT
Created attachment 47632 [details]
Patch against the workspace root
Comment 20 Kim Horne CLA 2006-08-14 10:01:30 EDT
Fix committed.  I've entered bug 153761 to investigate adding API to the platform that would allow easier addition to the application menu.
Comment 21 Kim Horne CLA 2006-09-19 10:20:25 EDT
Verified in I20060918-2000