views:

192

answers:

1

Hi,

how do I configure an Eclipse RCP command style menu to match the different menu structures on Windows and on Mac OS?

Mac OS X menu example http://images.apple.com/macosx/refinements/images/services_menu_20090902.jpg

Windows menu example http://www.flamingpear.com/images/psp8menu.gif

In the example you see, the differences in the menu structures. For example has the Mac in its application menu the preference command, the about command and the exit command. These are under Windows usally in the file menu and the about command is found in the help menu. Is there a "standard" way of doing it with RCP programs? It should somehow be possible because Eclipse itself does it. But I can not figure out how.

+1  A: 

Although I have not done it myself yet, it should be possible to use OS dependent plugin fragments for that task. I've seen those used for OS dependent SWT code in the Eclipse Delta Pack.

1) For each OS you want to support, define a plugin fragment, named by that OS.

2) The MANIFEST.MF files can contain a filter for the platform, as explained in an answer to another question. Set the Eclipse-PlatformFilter by adding the one of the following lines to the fragment's MANIFEST.MF:

  • Eclipse-PlatformFilter: (osgi.os=win32)
  • Eclipse-PlatformFilter: (osgi.os=macosx)

Or use an OSGi filter for org.osgi.framework.os.name (recommended in the answer mentioned above), but I could not find in the 288 pages of spec how that filter would be declared.

3) Each fragment contains in its fragment.xml the menu structure for that OS. The plugin.xml of the original plugin only contains the common configuration, like the commands and handlers.

You can add own menu contributions to predefined menus, if you know the menu ID. See the Eclipse Wiki on Menu Contributions and the Eclipse Help for org.eclipse.ui.menus.

Christian Semrau
Ok, thanks. But this leaves me with 2 further questions:1) How and where do i deciede to load which fragment?2) How do I get menu items in the application menu in MAC OS?(question still remaining)
Raven
Edited my answer.
Christian Semrau