Menu.getItems return null in Eclipse 3.4 and working fine in Eclipse 3.3.2 [message #481237] |
Thu, 20 August 2009 04:27  |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.06606 seconds