Project: Eclipse_Platform_UI
Bug 302132 [Tools] NPE when to create a UI Presentation
Reported: 2010-02-08 08:24:52 | Status: closed fixed

A NPE exception is notificed when we create a UI Presentation in case we select a folder: java.lang.NullPointerException at org.eclipse.e4.xwt.ui.wizards.NewPresentationWizardPage.setPackageFragment(NewPresentationWizardPage.java:251) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.initTypePage(NewTypeWizardPage.java:569) at org.eclipse.e4.xwt.ui.wizards.NewPresentationWizardPage.initTypePage(NewPresentationWizardPage.java:245) at org.eclipse.jdt.ui.wizards.NewClassWizardPage.init(NewClassWizardPage.java:91) at org.eclipse.e4.xwt.ui.wizards.NewPresentationWizard.addPages(NewPresentationWizard.java:42) at org.eclipse.jface.wizard.WizardSelectionPage.getNextPage(WizardSelectionPage.java:113) at org.eclipse.ui.internal.dialogs.WorkbenchWizardSelectionPage.getNextPage(WorkbenchWizardSelectionPage.java:100) at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:823) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:369) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473) at org.eclipse.jface.window.Window.runEventLoop(Window.java:825) at org.eclipse.jface.window.Window.open(Window.java:801) at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:253) at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:273) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294) at org.eclipse.ui.LegacyHandlerService$HandlerProxy.execute(LegacyHandlerService.java:78) 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.workbench.ui.internal.ReflectionContributionFactory.call(ReflectionContributionFactory.java:153) at org.eclipse.e4.ui.internal.services.ContextHandlerService.executeHandler(ContextHandlerService.java:58) at org.eclipse.ui.LegacyHandlerService.executeCommand(LegacyHandlerService.java:541) at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2818) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2782) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2634) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:562) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:555) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 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.equinox.launcher.Main.invokeFramework(Main.java:559) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514) at org.eclipse.equinox.launcher.Main.run(Main.java:1311) In fact, we expect the element selected is a Java class. When the selected elemnt is not Java class, the menu should be disabled or a message dialog is expected to notify the error.

Files changed in fix:
bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/NavigatorContentService.java tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/LabelProviderTest.java tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/SorterTest.java