Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Sorting contributed commands in a Menu
Sorting contributed commands in a Menu [message #329858] Tue, 08 July 2008 12:35 Go to next message
Eclipse UserFriend
All,

Using the Commands and MenuContributions extension points is it possible to
define a Menu so that other plugins may contribute to a given "group", but
have those contributions show up say in alphabetical order?

I know you can contribute commands or other menus before or after a given
ID, "additions" for example.

This would be similar to the sorting behavior of Views in the Window->Show
View menu or perspectives in the Window->Open Perspective. Now, I know
those two examples have not been converted over to commands and
menuContributions is that because you can't do that with those extension
points?

-Stu Pond
Re: Sorting contributed commands in a Menu [message #329926 is a reply to message #329858] Thu, 10 July 2008 12:50 Go to previous message
Eclipse UserFriend
Stuart Pond wrote:
> This would be similar to the sorting behavior of Views in the Window->Show
> View menu or perspectives in the Window->Open Perspective. Now, I know
> those two examples have not been converted over to commands and
> menuContributions is that because you can't do that with those extension
> points?

In general menu contributions are sorted by insertion point (which has
to do with ID), and the order from there on is simply "document" order
(it matches the XML).

For multiple contributions to a group (like after=additions) you are
correct, the order is non-deterministic. You could write something that
uses API and would allow you to get at least part way there, but the
extension points themselves do not.

If you look at something like the Show View menu, it's done in
org.eclipse.ui.internal.ShowViewMenu ... which is itself an
ContributionItem and had to do the pre-work to sort the
CommandContributionItems. It can be added using the dynamic element in
a menu contribution.

There was the notion of a pluggable sorter introduced in 3.4 ...
currently only applied to properties, I believe.


PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Previous Topic:Contributing Actions to an action set
Next Topic:How to programatically customize perspective
Goto Forum:
  


Current Time: Tue May 06 18:21:53 EDT 2025

Powered by FUDForum. Page generated in 0.03506 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top