Bug 302132 [Tools] NPE when to create a UI Presentation
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.
bundles/org.eclipse.ui.navigator/src/org/eclipse/ui/internal/navigator/NavigatorContentService.java
rootExtensions.add(extension);
					}
				}
			}
		}
		if (rootExtensions.isEmpty()) {
			return findContentExtensionsByTriggerPoint(anElement);
		}
		return rootExtensions;
	}
	/**
	 * Search for extensions that declare the given element in their
	 * <b>possibleChildren</b> expression.
	 * 
	 * @param anElement
	 *            The element to use in the query
	 * @return The set of {@link INavigatorContentExtension}s that are
	 *         <i>visible</i> and <i>active</i> for this content service and
	 *         have a <b>possibleChildren</b> expression that is <i>enabled</i>
	 *         for the given element.
	 */
	public Set findOverrideableContentExtensionsForPossibleChild(
			Object anElement) {
		Set overrideableExtensions = new TreeSet(
				ExtensionSequenceNumberComparator.INSTANCE);
		Set descriptors = findDescriptorsWithPossibleChild(anElement, false);
		for (Iterator iter = descriptors.iterator(); iter.hasNext();) {
			INavigatorContentDescriptor descriptor = (INavigatorContentDescriptor) iter
					.next();
			if (descriptor.hasOverridingExtensions()) {