Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 93279

Summary: [Contributions] MenuManager, allowItem and NullPointerException
Product: [Eclipse Project] Platform Reporter: Thomas SZADEL <thomas.szadel>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P5 CC: felix.mayer, pwebster
Version: 3.1Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard: stalebug

Description Thomas SZADEL CLA 2005-04-29 11:44:48 EDT
Hello,

In my RCP app, I use my own MenuManager in order to use the method "allowItem"
(inherited from ContributionManager).

I just want to avoid external contribution. Thus, I only accept GroupMarker,
Separator and actions with specific id.

But I got a NullPointerException when I do that : 

!ENTRY org.eclipse.ui 4 4 2005-04-29 17:13:06.476
!MESSAGE Could not find new menu: converstLineDelimitersTo
Could not find new menu: converstLineDelimitersTo

!ENTRY org.eclipse.ui 4 4 2005-04-29 17:13:06.476
!MESSAGE Unhandled event loop exception
Reason:
Unhandled event loop exception

!ENTRY org.eclipse.ui 4 0 2005-04-29 17:13:06.476
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.ui.internal.PluginActionBuilder$BasicContribution.contributeSeparator(PluginActionBuilder.java:378)
	at
org.eclipse.ui.internal.PluginActionBuilder$BasicContribution.contributeMenu(PluginActionBuilder.java:317)
	at
org.eclipse.ui.internal.PluginActionSetBuilder$ActionSetContribution.contribute(PluginActionSetBuilder.java:301)
	at
org.eclipse.ui.internal.PluginActionSetBuilder.readActionExtensions(PluginActionSetBuilder.java:244)
	at
org.eclipse.ui.internal.PluginActionSetBuilder.processActionSets(PluginActionSetBuilder.java:195)
	at
org.eclipse.ui.internal.ActionPresentation.setActionSets(ActionPresentation.java:167)
	at
org.eclipse.ui.internal.WorkbenchWindow.updateActionSets(WorkbenchWindow.java:2426)
	at org.eclipse.ui.internal.WorkbenchWindow$4.run(WorkbenchWindow.java:2248)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2221)
	at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:572)
	at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:587)
	at org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1209)
	at
org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:178)
	at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:717)
	at org.eclipse.ui.internal.Workbench.init(Workbench.java:918)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1554)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:293)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
	at
com.atos.vigile.vigistudio.rcp.VigistudioApplication.run(VigistudioApplication.java:43)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:228)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:333)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:150)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:268)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:260)
	at org.eclipse.core.launcher.Main.run(Main.java:887)
	at org.eclipse.core.launcher.Main.main(Main.java:871)


I think there is a bug in the org.eclipse.ui.internal.PluginActionBuilder :

// Get the menu again as it may be wrapped, otherwise adding
            // the separators and group markers below will not be wrapped
            // properly if the menu was just created.
            newMenu = parent.findMenuUsingPath(id);
            if (newMenu == null)
                WorkbenchPlugin.log("Could not find new menu: " + id); //$NON-NLS-1$

>>>>>>>>>>>>>>> HERE, if newMenu is NULL, then we pass null parameter to
contributeSeparator which doesn't assert argument is not null...
>>>>>>>>>>>>>>> Maybe we can ignore the following section if newMenu is null ???

            // Create separators.
            IConfigurationElement[] children = menuElement.getChildren();
            for (int i = 0; i < children.length; i++) {
                String childName = children[i].getName();
                if (childName.equals(IWorkbenchRegistryConstants.TAG_SEPARATOR)) {
                    contributeSeparator(newMenu, children[i]);
                } else if
(childName.equals(IWorkbenchRegistryConstants.TAG_GROUP_MARKER)) {
                    contributeGroupMarker(newMenu, children[i]);
                }
            }


Thanks


Tom
Comment 1 Michael Van Meekeren CLA 2006-04-21 13:56:28 EDT
Moving Dougs bugs
Comment 2 Paul Webster CLA 2007-04-05 19:04:18 EDT
Assigning to component owner
PW
Comment 3 Felix L J Mayer CLA 2012-03-01 08:58:23 EST
Can you please fix this? It is the reason that my Eclipse plug-in sometimes doesn't have context menus because of contributions from some other, completely unrelated plug-in. This should be a really simple fix fix, and the bug has been sitting around for 7 years already.
Comment 4 Paul Webster CLA 2012-03-01 09:02:28 EST
I'm working on something different ATM, but would accept a contribution.
See http://wiki.eclipse.org/Platform_UI/How_to_Contribute

PW
Comment 5 Lars Vogel CLA 2019-11-14 03:20:40 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.