Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Setting a menu item's name dynamically
Setting a menu item's name dynamically [message #329180] Mon, 16 June 2008 14:47 Go to next message
Michael Barkhouse is currently offline Michael BarkhouseFriend
Messages: 8
Registered: July 2009
Junior Member
This is similar to what was discussed in
http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg23489.html

I am adding a menu item to a file using an object contribution via the
org.eclipse.ui.popupMenus extension point. I want to dynamicaly set the
name of the menu item based on some information stored in the file. If my
plug-in is already loaded I can do so using the selectionChanged
mechanism. If it's not loaded, it currently always uses the name that is
statically defined in plugin.xml.

I might be able to make the solution proposed in the above mentioned
thread work in my scenario, but it doesn't seem to be the ideal way to go.
It uses a property tester which can have the side effect of causing
plug-in activation. Loading the plug-in is actually what I want, but is
there another way to do that?
Re: Setting a menu item's name dynamically [message #329244 is a reply to message #329180] Tue, 17 June 2008 12:33 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Michael Barkhouse wrote:
> I might be able to make the solution proposed in the above mentioned
> thread work in my scenario, but it doesn't seem to be the ideal way to
> go. It uses a property tester which can have the side effect of causing
> plug-in activation. Loading the plug-in is actually what I want, but is
> there another way to do that?

In RCP you can do what you want, including forcing your plugin to load.
If you are using a property tester (objectContribution/enablement)
then forcing the plugin to load from the property tester is probably
acceptable since it will be called when the menu is invoked (and if the
menu is not invoked, no problem). In RCP you can also add the bundle to
osgi.bundles property to be started, or use
org.osgi.framework.Bundle.start(int) with the START_TRANSIENT flag from
your WorkbenchAdvisor, or use org.eclipse.ui.startup to force the bundle
to start (after the workbench windows appear).

In eclipse, you should follow the lazy loading policy. That means
providing the generic menu item name until such times as your plugin is
loaded.


--
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


Re: Error retrieving "feature.xml" [error opening zip file] [message #329273 is a reply to message #329180] Tue, 17 June 2008 20:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stephang.bluewin.ch

Hello !

I found this link very useful to fix the problem:
http://www.holvn.org/article/showentry.html?e=2

Regards,
Stephan Gloor
Switzerland
Re: Setting a menu item's name dynamically [message #329343 is a reply to message #329244] Fri, 20 June 2008 02:07 Go to previous messageGo to next message
Michael Barkhouse is currently offline Michael BarkhouseFriend
Messages: 8
Registered: July 2009
Junior Member
Paul Webster wrote:

> In eclipse, you should follow the lazy loading policy. That means
> providing the generic menu item name until such times as your plugin is
> loaded.

Thanks for the reply Paul. I still don't think using the generic menu item
name is ideal. The user right clicks on my file, sees the menu item with
the generic name and clicks on it (that causes my plug-in to load). Then
the user right clicks on that same file and this time sees a different
name for the same menu item. That doesn't seem right. What I think should
happen is the plug-in should be loaded when the menu item is about to be
displayed. That way the plug-in is not loaded at startup, but it will be
loaded a little bit earlier than what you're suggesting. For menu items
with static names, I agree with you 100%. Plug-ins should not be loaded
until the user clicks on the menu item.

Have I changed your mind? If so, is there a way (perhaps the property
tester that you mentioned for RCP) for me to cause the plug-in to load
when the menu is shown?
Re: Setting a menu item's name dynamically [message #329354 is a reply to message #329343] Fri, 20 June 2008 16:13 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Michael Barkhouse wrote:
> Paul Webster wrote:
>
>> In eclipse, you should follow the lazy loading policy. That means
>> providing the generic menu item name until such times as your plugin
>> is loaded.
>
> Thanks for the reply Paul. I still don't think using the generic menu
> item name is ideal. The user right clicks on my file, sees the menu item
> with the generic name and clicks on it (that causes my plug-in to load).
> Then the user right clicks on that same file and this time sees a
> different name for the same menu item. That doesn't seem right.

It is slightly odd behaviour ... but it is the eclipse policy (all lazy
loading plugins behave the same way). That policy is there because
(especially as the eclipse environment or RCP app grows) it is a minor
price to pay compared to the memory footprint and speed costs of not
doing it.

> Have I changed your mind? If so, is there a way (perhaps the property
> tester that you mentioned for RCP) for me to cause the plug-in to load
> when the menu is shown?

Yes, the property tester in your plugin can force plugin loading. There
are a couple of ways to force plugin loading in RCP apps.

Later,
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:[3.4RC4] Disable a plugin installed via dropins
Next Topic:Problem with jar included twice
Goto Forum:
  


Current Time: Tue Jul 16 14:06:45 GMT 2024

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

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

Back to the top