Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Menu.getItems return null in Eclipse 3.4 and working fine in Eclipse 3.3.2
Menu.getItems return null in Eclipse 3.4 and working fine in Eclipse 3.3.2 [message #481237] Thu, 20 August 2009 08:27 Go to next message
vikas  is currently offline vikas Friend
Messages: 10
Registered: July 2009
Junior Member
Hi All
I have 2 actions added to main menubar and toolbar using plugin.xml of
Plugin1
Depending upon some internal state i want to enable/disable these actions
from other plugin2. To enable/ disable action i use the following code
(http://www.eclipsezone.com/eclipse/forums/t90781.rhtml) with some
modification.
Display.getDefault().syncExec(new Runnable() {
public void run() {
IWorkbench workbench = PlatformUI.getWorkbench();
Menu menubar =
workbench.getActiveWorkbenchWindow().getShell().getMenuBar() ;
if(menubar == null ){
return;
}
MenuItem[] mItems = menubar.getItems();
if(mItems == null){
return;
}
for(int i = 0 ;i if(mItems .getText().equals("Tools")){
Menu menu = mItems .getMenu();
for(MenuItem item : menu.getItems()){ /////it returns null but i can see
actions entry in main menu and toolbar

SubContributionItem cItem = null;
Object menuItemData = item.getData();
if(menuItemData == null){
continue;
}
if(menuItemData instanceof SubContributionItem){
cItem = (SubContributionItem)menuItemData;
IContributionItem conItems = cItem.getInnerItem();
if(conItems instanceof ActionContributionItem){
ActionContributionItem items = (ActionContributionItem) conItems;
String id = cItem.getId();
if((id != null) && (toolsID.contains(id))){
items.getAction().setEnabled(state);
}
}
}
}
}
}
}
});

This code is working perfectly fine in eclise 3.3.2.
Same code gives problem in Eclipse 3.4. It is not able to enable / disable
required actions. During debugging i found that menu.getItems() returns
'null' (menu.itemCount() returns 0) and its cause is in from Menu.class in
org.eclipse.swt plugin.
Is their any change in eclipse 3.4 due to which it is not working in
Eclipse 3.4?
Or is there any other solution/approach to enable/disable
programmatically.
Any help in this regard will be great help.
Thanks in advance.
Regards
Vikas
Re: Menu.getItems return null in Eclipse 3.4 and working fine in Eclipse 3.3.2 [message #482850 is a reply to message #481237] Fri, 28 August 2009 10:38 Go to previous message
vikas  is currently offline vikas Friend
Messages: 10
Registered: July 2009
Junior Member
Hi
I want to update my actionset in update method (Observer interface), as
enable/disable of actionset is possible in selectionchange event of
IAction but how to enable/disable Actionset from update method.
Any pointers in this regard will be great help.
Regards
Vikas
Previous Topic:Application startup problem in 3.5 with login dialog befor workbench start
Next Topic:Selection provider that is not a workbench part
Goto Forum:
  


Current Time: Fri Apr 19 08:13:29 GMT 2024

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

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

Back to the top