Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » ActionSet enablement ?
ActionSet enablement ? [message #406799] Wed, 26 January 2005 21:29 Go to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi,

I would like to add Menus and MenuItems intoPerspective in using
actionSet rather than using WorkbenchAdvisor way with contributions ...

But to enable or disable the MenuItems, I need to perform a method
(boolean computeEnablement() ) to check user rigths and so on...

I do not want this method called on selectionChanged but called when
the menu is opened.

I have only read some criteria for actionSet to deal with enablement :
enableFor + enablement objectClass ....
I am a bit confused because it seems not to suit my needs.

Does anyone know how to do that ?

Stephane
Re: ActionSet enablement ? [message #435431 is a reply to message #406799] Thu, 18 August 2005 08:37 Go to previous message
WojT is currently offline WojTFriend
Messages: 11
Registered: July 2009
Junior Member
> I would like to add Menus and MenuItems intoPerspective in using
> actionSet rather than using WorkbenchAdvisor way with contributions ...
>
> But to enable or disable the MenuItems, I need to perform a method
> (boolean computeEnablement() ) to check user rigths and so on...
>
> I do not want this method called on selectionChanged but called when the
> menu is opened.
>
> I have only read some criteria for actionSet to deal with enablement :
> enableFor + enablement objectClass ....
> I am a bit confused because it seems not to suit my needs.
>
> Does anyone know how to do that ?
>


I have done it like this:

WorkbenchWindow workbenchWindow = get Workbench Window in Your way....

String mainMenuText = "menu label You set in actionSet in plugin.xml"
String subMenuText = "action label You set for subMenu"

MenuManager manager = workbenchWindow.getMenuManager();
MenuItem[] items = manager.getMenu().getItems();
for (int i = 0; i < items.length; i++){
MenuItem item = items[i];
if (item.getText().equals(mainMenuText)){
MenuItem[] subItems = item.getMenu().getItems();
for (int j = 0; j < subItems.length; j++){
MenuItem subItem = subItems[j];
if (subItem.getText().equals(subMenuText)){
subItem.setEnabled('THERE YOU SHOULD PUT METHOD WHICH
COMPUTE MENU ENABLING');
}
}
}
}


Maybe it is not the best way but it works for me :)

...::WojT::..
Previous Topic:remove/kill/destroy view and reinitialize it
Next Topic:How to load a class of swt
Goto Forum:
  


Current Time: Fri Dec 06 14:59:55 GMT 2024

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

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

Back to the top