Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344117 - NPE during context menu generation prevents 'Progress' view from coming up
Summary: NPE during context menu generation prevents 'Progress' view from coming up
Status: CLOSED FIXED
Alias: None
Product: MoDisco
Classification: Modeling
Component: Infrastructure (show other bugs)
Version: 0.9.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 0.9.0 M7   Edit
Assignee: Nicolas Bros CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 333742
  Show dependency tree
 
Reported: 2011-04-28 08:34 EDT by Remy Suen CLA
Modified: 2011-08-18 08:19 EDT (History)
3 users (show)

See Also:
nicolas.bros: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2011-04-28 08:34:22 EDT
I installed a lot of Indigo plug-ins and was unable to open the 'Progress' view. From the trace I guess it is dying in MoDisco's code though that's not to necessarily say they are at fault here.

java.lang.NullPointerException
	at org.eclipse.gmt.modisco.infra.discoverymanager.ui.actions.ContributionItemForMoDiscoMenu.fill(ContributionItemForMoDiscoMenu.java:56)
	at org.eclipse.ui.internal.menus.DynamicMenuContributionItem.fill(DynamicMenuContributionItem.java:125)
	at org.eclipse.jface.action.MenuManager.doItemFill(MenuManager.java:737)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:818)
	at org.eclipse.jface.action.MenuManager.update(MenuManager.java:678)
	at org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer.processContents(MenuManagerRenderer.java:505)
	at org.eclipse.e4.ui.workbench.swt.modeling.MenuService.registerMenu(MenuService.java:74)
	at org.eclipse.ui.internal.PopupMenuExtender.registerE4Support(PopupMenuExtender.java:179)
	at org.eclipse.ui.internal.PopupMenuExtender.createModelFor(PopupMenuExtender.java:174)
	at org.eclipse.ui.internal.PopupMenuExtender.<init>(PopupMenuExtender.java:145)
	at org.eclipse.ui.internal.PartSite.registerContextMenu(PartSite.java:127)
	at org.eclipse.ui.internal.PartSite.registerContextMenu(PartSite.java:475)
	at org.eclipse.ui.internal.PartSite.registerContextMenu(PartSite.java:484)
	at org.eclipse.ui.internal.progress.ProgressView.initContextMenu(ProgressView.java:109)
	at org.eclipse.ui.internal.progress.ProgressView.createPartControl(ProgressView.java:67)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:114)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.createPartControl(CompatibilityView.java:76)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:244)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:828)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:808)
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:108)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:310)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:237)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:153)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:90)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:64)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:141)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:762)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:541)
	at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.createWidget(ElementReferenceRenderer.java:69)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:762)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:541)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:618)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$1.handleEvent(PartRenderingEngine.java:123)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4681)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:182)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:81)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setToBeRendered(UIElementImpl.java:292)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:353)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:310)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:502)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:477)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:466)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:894)
	at org.eclipse.ui.internal.WorkbenchPage.showPart(WorkbenchPage.java:952)
Comment 1 Remy Suen CLA 2011-04-28 08:56:03 EDT
MoDisco's ContributionItemForMoDiscoMenu's fill(Menu, int) implementation arbitrarily retrieves the menu's shell, calls getData() on it, and then downcasts the result to IWorkbenchWindow. This is not documented API. Based on your code, it seems you just want a selection listener, you can retrieve this from a service locator.

What you should do instead is the following:

public class ContributionItemForMoDiscoMenu extends ContributionItem
    implements IWorkbenchContribution {

  private ISelectionService selectionService;

  public void initialize(IServiceLocator serviceLocator) {
    selectionService = (ISelectionService)
        serviceLocator.getService(ISelectionService.class);
  }
}
Comment 2 Nicolas Bros CLA 2011-04-28 09:26:19 EDT
Thank you Remy.

Fixed in revision 4364 by using the IServiceLocator, both in org.eclipse.modisco.infra.discovery.ui and the deprecated org.eclipse.gmt.modisco.infra.discoverymanager.
Comment 3 Hugo Bruneliere CLA 2011-08-18 08:19:01 EDT
Bug solved.