Bug 17913 Fail to show source of selected element only in single-click mode
Build 20020521 1. Start new workspace 2. Open Java perspective 3. Create Java project Test 4. Create cu X.java in default package: public class X { public void foo() { } } 5. Select 'source of selected element only' 5. Close X.java 6. Change preferences to open perspective in new window and use single-click to open editor 7. Open Java Browsing perspective 8. Select Test, then default package, then X, then foo Observe: The whole cu source is still shown. It is only when you click in the editor that only the source of foo is shown.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.java
return (IJavaElement)editorInput.getAdapter(IJavaElement.class);
				}
			}
		}
		return null;	
	}
	
	/** 
	 * Gets the working copy of an compilation unit opened in an editor
	 * @param part the editor part
	 * @param cu the original compilation unit (or another working copy)
	 * @return the working copy of the compilation unit, or null if not found
	 */	
	public static ICompilationUnit getWorkingCopy(ICompilationUnit cu) {
		if (cu == null)
			return null;
		if (cu.isWorkingCopy())
			return cu;
			
		return (ICompilationUnit)cu.findSharedWorkingCopy(JavaUI.getBufferFactory());
	}
	
	/** 
	 * Gets the working copy of an member opened in an editor
	 *
	 * @param member the original member or a member in a working copy
	 * @return the corresponding member in the shared working copy or <code>null</code> if not found
	 */	
	public static IMember getWorkingCopy(IMember member) throws JavaModelException {
		ICompilationUnit cu= member.getCompilationUnit();