Bug 18412 Type hierarchy should support JavaModel as input
To support opening a Java perspective from the Welcome page it should handle the case when it is opened with a JavaModel. This is the call to open the perspective in OpenJavaPerspectiveAction window.openPage(JavaUI.ID_PERSPECTIVE, JavaCore.create (ResourcesPlugin.getWorkspace().getRoot())); This is the NPE java.lang.NullPointerException at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle.doHierarchyRefr esh(TypeHierarchyLifeCycle.java:173) at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle.access$0 (TypeHierarchyLifeCycle.java:133) at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle$1.run (TypeHierarchyLifeCycle.java:109) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inter nalRun(BusyIndicatorRunnableContext.java:107) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:74) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:64) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:120) at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle.ensureRefreshed TypeHierarchy(TypeHierarchyLifeCycle.java:117) at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyViewPart.updateInput (TypeHierarchyViewPart.java:402) at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyViewPart.setInputElement (TypeHierarchyViewPart.java:388) at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyViewPart.createPartContro l(TypeHierarchyViewPart.java:679) at org.eclipse.ui.internal.PartPane$4.run(PartPane.java:136) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:802) at org.eclipse.core.runtime.Platform.run(Platform.java:416) at org.eclipse.ui.internal.PartPane.createChildControl (PartPane.java:134) at org.eclipse.ui.internal.PartPane.createControl(PartPane.java:178) at org.eclipse.ui.internal.ViewPane.createControl(ViewPane.java:181) at org.eclipse.ui.internal.PartTabFolder.createPartTab (PartTabFolder.java:252) at org.eclipse.ui.internal.PartTabFolder.createControl (PartTabFolder.java:224) at org.eclipse.ui.internal.PartSashContainer.createControl (PartSashContainer.java:177) at org.eclipse.ui.internal.PerspectivePresentation.activate (PerspectivePresentation.java:94) at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:657) at org.eclipse.ui.internal.WorkbenchPage.onActivate (WorkbenchPage.java:1513) at org.eclipse.ui.internal.WorkbenchWindow$7.run (WorkbenchWindow.java:1165) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:64) at org.eclipse.ui.internal.WorkbenchWindow.setActivePage (WorkbenchWindow.java:1152) at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage (WorkbenchWindow.java:344) at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow (Workbench.java:227) at org.eclipse.ui.internal.Workbench.access$8(Workbench.java:220) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:892) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:64) at org.eclipse.ui.internal.Workbench.openWorkbenchWindow (Workbench.java:889) at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage (WorkbenchWindow.java:346) at org.eclipse.ui.internal.WorkbenchWindow$6.run (WorkbenchWindow.java:905) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:64) at org.eclipse.ui.internal.WorkbenchWindow.openPage (WorkbenchWindow.java:902) at org.eclipse.jdt.ui.actions.OpenJavaPerspectiveAction.run (OpenJavaPerspectiveAction.java:42) at org.eclipse.ui.internal.dialogs.WelcomeItem.runAction (WelcomeItem.java:137) at org.eclipse.ui.internal.dialogs.WelcomeItem.triggerLinkAt (WelcomeItem.java:156) at org.eclipse.ui.internal.dialogs.WelcomeEditor$2.mouseUp (WelcomeEditor.java:210) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:128) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1527) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1289) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1145) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1128) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) 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.basicRun(Main.java:200) at org.eclipse.core.launcher.Main.run(Main.java:643) at org.eclipse.core.launcher.Main.main(Main.java:476)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java
int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
		memento.putInteger(TAG_RATIO, ratio);
		
		ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
		int position= bar != null ? bar.getSelection() : 0;
		memento.putInteger(TAG_VERTICAL_SCROLL, position);
		IJavaElement selection= (IJavaElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement();
		if (selection != null) {
			memento.putString(TAG_SELECTION, selection.getHandleIdentifier());
		}
			
		fMethodsViewer.saveState(memento);
	}
	
	/**
	 * Restores the type hierarchy settings from a memento.
	 */
	private void restoreState(IMemento memento, IJavaElement defaultInput) {
		IJavaElement input= defaultInput;
		String elementId= memento.getString(TAG_INPUT);
		if (elementId != null) {
			input= JavaCore.create(elementId);
			if (input != null && !input.exists()) {
				input= null;
			}
		}
		setInputElement(input);
		Integer viewerIndex= memento.getInteger(TAG_VIEW);
		if (viewerIndex != null) {
			setView(viewerIndex.intValue());