Bug 54900 [rulers] Java Editor does not show ruler on external Java files
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java
if (!(element instanceof IStorageEditorInput))
			return null;
		
		final IStorageEditorInput sei= (IStorageEditorInput)element;
		
		try {
			final IStorage storage= sei.getStorage();
			IJavaModel jm= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
			IJavaProject jp;
			
			jp= jm.getJavaProject("__projectWorkingcopy__"); 
			IPackageFragmentRoot root= jp.getPackageFragmentRoot(jp.getProject());
			IPackageFragment pkg= root.getPackageFragment(""); 
			ICompilationUnit cu= pkg.getCompilationUnit(storage.getName());
			
			WorkingCopyOwner woc= new WorkingCopyOwner() {
				/*
				 * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.core.ICompilationUnit)
				 * @since 3.2
				 */
				public IBuffer createBuffer(ICompilationUnit workingCopy) {
					return new DocumentAdapter(workingCopy, storage.getFullPath());
				}
			};
			cu= cu.getWorkingCopy(woc, null, getProgressMonitor());
			
			if (setContents) {
				int READER_CHUNK_SIZE= 2048;
				int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
				Reader in= new BufferedReader(new InputStreamReader(storage.getContents()));