Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » I don't know how to control the availability of the menu(I don't know how to control the availability of the menu)
I don't know how to control the availability of the menu [message #760043] Thu, 01 December 2011 05:17 Go to next message
Taichi Yamamura is currently offline Taichi YamamuraFriend
Messages: 3
Registered: November 2011
Junior Member
Eclipse plugin, which we are developing now, adds menu to Eclipse without using perspective.
The added menu executes the embedded process by selecting it. It is simple as that.
However, use of the added menu is controlled; therefore it is not that the menu is always available.
Availability of the menu switches depends on the conditions.

I needed to increase the number of Eclipse versions that Eclipse plugin can correspond to.
I then modified the program to have Eclipse 4.x corresponsive, but the following two problems are found:

1. I don't know how to control the availability of the menu, which is added by extending org.eclipse.ui.menus.
2. I don't know when the menu action class is loaded.

The details are as follows:


1. I don't know how to control the availability of the menu, which is added by extending org.eclipse.ui.menus.

Up to Eclipse 3.2, in order to add menu to the Eclipse existing menu using plugin, I used the extension of org.eclipse.ui.actionSets.

org.eclipse.ui.actionSets
**└ actionSet
****├ menu
****└ action

Above Eclipse 3.3, it says in the manual that, use the extension of org.eclipse.ui.menus and not the extension of org.eclipse.ui.actionSets.
So I replaced org.eclipse.ui.actionSets with org.eclipse.ui.menus and then I modified the source.

org.eclipse.ui.menus
**└ menuContribution
****└ command
*******└ visibleWhen

After extending org.eclipse.ui.menus and added menu, I understood how to implement the process after the menu selected and controlling method of menu enable/disable.
However, I cannot find out how to control menu availability, which is what we mostly want to do.
Could you please tell me how to control availability of the menu that is added by extending org.eclipse.ui.menus? Or is controlling the availability impossible at all?


2. I don't know when the menu action class is loaded.

In Eclipse 3.x, the menu added by extending org.eclipse.ui.actionSets creates class in which IWorkbenchWindowActionDelegate is embedded, and implements the process (run method) when the menu is selected, and the control (selectionChanged method) of menu availability.

The class created is loaded at the start of Eclipse. When the Eclipse started, I was able to use all functions of plugin.
When I used the Eclipse plugin, which we developed, in Eclipse 4.x, the action of the menu seems to be correctly executed, but controlling of the menu availability is not.
I tried to find out why the controlling of the menu availability is not correctly executed, the class in which IWorkbenchWindowActionDelegate was embedded was loaded at the start of Eclipse in Eclipse 3.x, but in Eclipse 4.x, it was not loaded at the start.
In Eclipse 4.x, it seems that the class is loaded when the action occurs and that is why controlling of the menu availability was impossible.
Is it possible to load the class at the start of Eclipse like it was done for Eclipse 3.x? Or is there any other solution even though the class is not loaded at the start of Eclipse?


Please give me information or hint(s) that would lead to solve the problems.
Re: I don't know how to control the availability of the menu [message #761455 is a reply to message #760043] Tue, 06 December 2011 13:54 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

When you are using visibleWhen, you're using the core expressions to determine your menu visibility. See some of the examples at:

http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions


w.r.t. IActionDelegate loading. This was a bug in 3.2 that was fixed in later releases. After 3.3 or 3.4, the delegate was only loaded after a user action (like the user clicked on the menu item from the same plugin).

In an RCP app, you can use the WorkbenchAdvisor#postStartup() to eagerly activate your plugin.

But in the IDE the best practice is to wait for a user action to activate your plugin.

PW


Previous Topic:how to correct this entry
Next Topic:Runtime defined "Pluglet" functionality
Goto Forum:
  


Current Time: Fri Apr 26 15:56:50 GMT 2024

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

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

Back to the top