开发者

Eclispe RCP SWT menus for Windows and Mac OS

开发者 https://www.devze.com 2022-12-23 18:41 出处:网络
how do I configure an Eclipse RCP command style menu to match the different menu structures on Windows and on Mac OS?

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/psp开发者_开发百科8menu.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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消