Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [Commands] locationURI and menubarPath
[Commands] locationURI and menubarPath [message #552503] Thu, 12 August 2010 12:04 Go to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
The new way of defining "actions" in Eclipse is by means
of commands instead of actions. This works usually quite
nicely, but I have not found a documentation that clearly
shows how the *relative* paths that can be provided via the
old mechanism either specifying menubarPath or toolbarPath
are mapped onto the locationURI's needed in org.eclipse.menus.

There exists a table in

http://wiki.eclipse.org/Menus_Extension_Mapping

that just says

"This is no longer necessary, it is part of a "menu:" or "popup:"
locationURI."

Now this does not really answer my question, because as of
my understanding, menubarPath specified a *relative* path
starting from the corresponding starting point (specified
by the view id or the popup menu id), while I have not found
a way to specify *relative* paths within a locationURI - at
least I could not deduce such a semantics from the specification
of this path as found e.g. in the description of the extension
point org.eclipse.ui.menus.

This question is especially relevant, if the menubarPath did
refer to a location that is part of a submenu of a popup menu.

Could anyone enlighten me, please?

[By trial and error it seemed as if the submenu id could be
used as absolute id - this disturbed me strongly, because
I expected that this submenu id was actually assumed to be
non-unique within different popups.]

Thanks and Greetings from Bremen,

Daniel Krügler
Re: [Commands] locationURI and menubarPath [message #553170 is a reply to message #552503] Mon, 16 August 2010 15:24 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Daniel Krügler wrote:
>
> [By trial and error it seemed as if the submenu id could be
> used as absolute id - this disturbed me strongly, because
> I expected that this submenu id was actually assumed to be
> non-unique within different popups.]

If it's non-unique, then it's not an id :-)

Your conclusion is correct. There are no paths, the id specified in the
locationURI is a parent ID that is used to determine when to include the
menuContribution or not. This was by design (if you enjoy a good horror
story I could spin you one about menubarPath and toolbarPath ... :-)

If they are different menus, they should have different IDs. If they're
the same menu included in multiple places, they should have the same ID
(think Team, Go To, Show In, etc)

It was known that because of the existing system, we could not enforce
the uniqueness of IDs for specific menus, but the advantages were
determined to outweigh that problem.

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: [Commands] locationURI and menubarPath [message #553380 is a reply to message #553170] Tue, 17 August 2010 11:05 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 16.08.2010 17:27, Paul Webster wrote:
> Daniel Krügler wrote:
>>
>> [By trial and error it seemed as if the submenu id could be
>> used as absolute id - this disturbed me strongly, because
>> I expected that this submenu id was actually assumed to be
>> non-unique within different popups.]
>
> If it's non-unique, then it's not an id :-)
>
> Your conclusion is correct. There are no paths, the id specified in the
> locationURI is a parent ID that is used to determine when to include the
> menuContribution or not. This was by design (if you enjoy a good horror
> story I could spin you one about menubarPath and toolbarPath ... :-)
>
> If they are different menus, they should have different IDs. If they're
> the same menu included in multiple places, they should have the same ID
> (think Team, Go To, Show In, etc)
>
> It was known that because of the existing system, we could not enforce
> the uniqueness of IDs for specific menus, but the advantages were
> determined to outweigh that problem.

Thanks Paul for your explanation - it makes sense. Nevertheless I need
to solve transition problems versus actions: We have several viewer
contributions that I need to transform into corresponding commands. A
viewer contribution already constrains the set of relevant
contributions, because it already fixes the view id and the menu id (via
targetID). To replace that properly, we need corresponding constraining
expressions, that is OK so far. AFAIK, for the view id, we can constrain
on the variable ISources.ACTIVE_PART_ID_NAME, in regard to the targetID,
is the correct test variable ISources.ACTIVE_MENU_NAME as
of http://wiki.eclipse.org/Command_Core_Expressions?

Thanks & Greetings from Bremen,

- Daniel Krügler
Re: [Commands] locationURI and menubarPath [message #553515 is a reply to message #553380] Tue, 17 August 2010 18:52 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Daniel Krügler wrote:
>
> Thanks Paul for your explanation - it makes sense. Nevertheless I need
> to solve transition problems versus actions: We have several viewer
> contributions that I need to transform into corresponding commands. A
> viewer contribution already constrains the set of relevant
> contributions, because it already fixes the view id and the menu id (via
> targetID). To replace that properly, we need corresponding constraining
> expressions, that is OK so far. AFAIK, for the view id, we can constrain
> on the variable ISources.ACTIVE_PART_ID_NAME, in regard to the targetID,
> is the correct test variable ISources.ACTIVE_MENU_NAME as
> of http://wiki.eclipse.org/Command_Core_Expressions?

right, org.eclipse.ui.ISources.ACTIVE_MENU_NAME is a Collection of the
activeMenu IDs that can be used with the popup: locationURI. ex:

#AbstractTextEditorContext
org.eclipse.jdt.ui.CompilationUnitEditor.EditorContext
#CompilationUnitEditorContext

these are equivalent to a targetId in a viewerContribution. The view ID
itself is used with a menu: locationURI and is the equivalent to a
targetId in a viewContribution.

The concern is a submenu in one of these that has the same ID? As part
of your conversion, can you not change one of the IDs to something
different?

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: [Commands] locationURI and menubarPath [message #553581 is a reply to message #553515] Wed, 18 August 2010 06:04 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 17.08.2010 20:52, Paul Webster wrote:
> Daniel Krügler wrote:
>>
>> Thanks Paul for your explanation - it makes sense. Nevertheless I need
>> to solve transition problems versus actions: We have several viewer
>> contributions that I need to transform into corresponding commands. A
>> viewer contribution already constrains the set of relevant
>> contributions, because it already fixes the view id and the menu id (via
>> targetID). To replace that properly, we need corresponding
>> constraining expressions, that is OK so far. AFAIK, for the view id,
>> we can constrain on the variable ISources.ACTIVE_PART_ID_NAME, in
>> regard to the targetID, is the correct test variable
>> ISources.ACTIVE_MENU_NAME as
>> of http://wiki.eclipse.org/Command_Core_Expressions?
>
> right, org.eclipse.ui.ISources.ACTIVE_MENU_NAME is a Collection of the
> activeMenu IDs that can be used with the popup: locationURI. ex:
>
> #AbstractTextEditorContext
> org.eclipse.jdt.ui.CompilationUnitEditor.EditorContext
> #CompilationUnitEditorContext
>
> these are equivalent to a targetId in a viewerContribution. The view ID
> itself is used with a menu: locationURI and is the equivalent to a
> targetId in a viewContribution.
>
> The concern is a submenu in one of these that has the same ID? As part
> of your conversion, can you not change one of the IDs to something
> different?

My situation is a bit different. Note that the command is not actually
targeting the *targetID* of the former viewer contribution: We have the
following scenario:

Several views have several tables, and each table has its own menu id
for the corresponding popup menu. The popup menu is constructed during
runtime to large extends programmatically and contains some repeating
blocks: Let*'s say the main popup ID is AA or BB or whatever, and each
such menu has always the same sub-menu with ID YY. Note that the ID of
the sub-menu YY is indeed intended to be the same in all cases. I
cannot change this ID for each popup, because I'm reusing this
component and must therefore use other means to constrain some
contribution addressing such a submenu ID.

Now this submenu with ID=YY again marks itself as extendable and thus
provides the canonical "additions" marker at the end of its own
contributions. Thus we have now several org.eclipse.ui.popupMenus
viewerContributions that contribute to a given view with a dedicated
menu ID (specified by the targetID element as XX which is either AA or
BB as mentioned above), and describe the specific position of the
contribution *relative* to this menu as

menubarPath="YY/additions"

(I assume we could omit the "/additions" part of the path, but that
detail is not the actual relevant part of the problem)

As a picture, the whole popup menu with ID=XX looks like this:

[bla-1]
[...]
[sub-menu {ID=YY}]-> [bla-2]
[...] [blub-2]
[...]
["additions"]

How can I realize a similar specific contribution via the new
org.eclipse.menus extension point provided that I must accept, that
the sub-menu ID is fixed?

It seems that I don't have a separate variable for the menu ID, correct?
Instead I have ISources.ACTIVE_MENU_NAME, that returns a
list of available menu ids. So, somehow, a contributor has to say that
he wants to address the locationURI

popup:YY?after=additions

given the constraints, that YY is within a menu that has the ID
XX. Does that mean that the contributor is supposed to iterate through
all items of the collection specified by ISources.ACTIVE_MENU_NAME and
to search for the ID=XX to realize the same thing as I did before?

Or does there exist a more intuitive/simpler way to realize that?

Thanks & Greetings from Bremen,

Daniel Krügler
Re: [Commands] locationURI and menubarPath [message #553698 is a reply to message #553581] Wed, 18 August 2010 13:54 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Daniel Krügler wrote:
> Now this submenu with ID=YY again marks itself as extendable and thus
> provides the canonical "additions" marker at the end of its own
> contributions. Thus we have now several org.eclipse.ui.popupMenus
> viewerContributions that contribute to a given view with a dedicated
> menu ID (specified by the targetID element as XX which is either AA or
> BB as mentioned above), and describe the specific position of the
> contribution *relative* to this menu as
>
> menubarPath="YY/additions"
>
> (I assume we could omit the "/additions" part of the path, but that
> detail is not the actual relevant part of the problem)
>
> As a picture, the whole popup menu with ID=XX looks like this:
>
> [bla-1]
> [...]
> [sub-menu {ID=YY}]-> [bla-2]
> [...] [blub-2]
> [...]
> ["additions"]
>
> How can I realize a similar specific contribution via the new
> org.eclipse.menus extension point provided that I must accept, that
> the sub-menu ID is fixed?
>
> It seems that I don't have a separate variable for the menu ID, correct?
> Instead I have ISources.ACTIVE_MENU_NAME, that returns a
> list of available menu ids. So, somehow, a contributor has to say that
> he wants to address the locationURI
>
> popup:YY?after=additions
>
> given the constraints, that YY is within a menu that has the ID
> XX. Does that mean that the contributor is supposed to iterate through
> all items of the collection specified by ISources.ACTIVE_MENU_NAME and
> to search for the ID=XX to realize the same thing as I did before?

It looks like you've set on the only way:
locationURI="popup:YY?after=additions" and then a visibleWhen that looks
similar to one that checks for activeContexts:

<with variable="activeMenu">
<iterate operator="or" ifEmpty="false">
<equals value="XX"/>
</iterate>
</with>

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: [Commands] locationURI and menubarPath [message #553845 is a reply to message #553698] Thu, 19 August 2010 07:30 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 18.08.2010 15:54, Paul Webster wrote:
> Daniel Krügler wrote:
[..]
>> It seems that I don't have a separate variable for the menu ID,
>> correct? Instead I have ISources.ACTIVE_MENU_NAME, that returns a
>> list of available menu ids. So, somehow, a contributor has to say that
>> he wants to address the locationURI
>>
>> popup:YY?after=additions
>>
>> given the constraints, that YY is within a menu that has the ID
>> XX. Does that mean that the contributor is supposed to iterate through
>> all items of the collection specified by ISources.ACTIVE_MENU_NAME and
>> to search for the ID=XX to realize the same thing as I did before?
>
> It looks like you've set on the only way:
> locationURI="popup:YY?after=additions" and then a visibleWhen that looks
> similar to one that checks for activeContexts:
>
> <with variable="activeMenu">
> <iterate operator="or" ifEmpty="false">
> <equals value="XX"/>
> </iterate>
> </with>

Thanks Paul, it was a pleasure to find out that your code
suggestion was exactly the thing I tried to to - and it
worked perfectly!

A lesson learned from this is, that one should tend to
reuse menu id's only, if any follow-up contributions
can contribute without additional need to evaluate the
context where the menu ID is embedded into. But in my
example, I couldn't follow this perfect-world guidance.

Greetings from Bremen,

Daniel Krügler
Previous Topic:DragAndDrop in AbstractDecoratedTextEditor
Next Topic:Project location relative to the workspace
Goto Forum:
  


Current Time: Thu Apr 25 10:50:33 GMT 2024

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

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

Back to the top