Bug 3975 New Class Wizard does not detect package if a resource is selected (1GFCU9G)
1. JUnit setup 2. Select ok.gif in junit.swingui 3. Open New Class wizard ==> package is default instead of junit.swingui (as if a class would have been selected) NOTES:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewContainerWizardPage.java
}
			}
		}	
		setPackageFragmentRoot(initRoot, true);
	}
	
	/**
	 * Utility method to inspect a selection to find a Java element as initial element.
	 * @return Returns a Java element to use as initial selection, or <code>null</code>,
	 * if none is found.
	 */
	protected IJavaElement getInitialJavaElement(IStructuredSelection selection) {
		IJavaElement jelem= null;
		if (selection != null && !selection.isEmpty()) {
			Object selectedElement= selection.getFirstElement();
			if (selectedElement instanceof IAdaptable) {
				IAdaptable adaptable= (IAdaptable) selectedElement;			
				
				jelem= (IJavaElement) adaptable.getAdapter(IJavaElement.class);
				if (jelem == null) {
					IResource resource= (IResource) adaptable.getAdapter(IResource.class);
					if (resource != null) {
						IProject proj= resource.getProject();
						if (proj != null) {
							jelem= JavaCore.create(proj);
						}
					}
				}
			}
		}