Bug 9066 ClassCastException opening a editor.
Got the following error opening a editor. Not sure how to reproduce it. 4 org.eclipse.ui 0 org.eclipse.ui.texteditor.AbstractDocumentProvider$ElementInfo java.lang.ClassCastException: org.eclipse.ui.texteditor.AbstractDocumentProvider$ElementInfo at org.eclipse.ui.editors.text.StorageDocumentProvider.isReadOnly (StorageDocumentProvider.java:185) at org.eclipse.ui.texteditor.AbstractTextEditor.isEditorInputReadOnly (AbstractTextEditor.java:2259) at org.eclipse.ui.texteditor.AbstractTextEditor.updateStatusField (AbstractTextEditor.java:2210) at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput (AbstractTextEditor.java:1164) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.doSetInput (JavaEditor.java:338) at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput (ClassFileEditor.java:181) at org.eclipse.ui.texteditor.AbstractTextEditor.setInput (AbstractTextEditor.java:1175) at org.eclipse.ui.internal.EditorManager.openEditor (EditorManager.java:363) at org.eclipse.ui.internal.EditorManager.openEditor (EditorManager.java:269) at org.eclipse.ui.internal.WorkbenchPage.openEditor (WorkbenchPage.java:1206) at org.eclipse.ui.internal.WorkbenchPage.openEditor (WorkbenchPage.java:1102) at org.eclipse.ui.actions.OpenFileAction.openFile (OpenFileAction.java:89) at org.eclipse.ui.actions.OpenSystemEditorAction.run (OpenSystemEditorAction.java:91) at org.eclipse.ui.actions.OpenFileAction.handleDoubleClick (OpenFileAction.java:111) at org.eclipse.ui.views.navigator.OpenActionFactory.handleDoubleClick (OpenActionFactory.java:124) at org.eclipse.ui.views.navigator.ResourceNavigatorActionFactory.handleDoubleClick (ResourceNavigatorActionFactory.java:118) at org.eclipse.ui.views.navigator.ResourceNavigator.handleDoubleClick (ResourceNavigator.java:389) at org.eclipse.ui.views.navigator.ResourceNavigator$4.doubleClick (ResourceNavigator.java:186) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick (StructuredViewer.java:272) at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect (StructuredViewer.java:416) at org.eclipse.jface.viewers.AbstractTreeViewer$1.widgetDefaultSelected (AbstractTreeViewer.java:627) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:92) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:74) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1413) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1205) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:827) at org.eclipse.ui.internal.Workbench.run(Workbench.java:810) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:895) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:321) at SlimLauncher.main(SlimLauncher.java:14)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java
/**
	 * Replaces createAnnotionModel of the super class
	 */
	protected IAnnotationModel createCompilationUnitAnnotationModel(Object element) throws CoreException {
		if ( !(element instanceof IFileEditorInput))
			throw new CoreException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE_TYPE));
		
		IFileEditorInput input= (IFileEditorInput) element;
		return new CompilationUnitMarkerAnnotationModel(input.getFile());
	}
	
	/**
	 * Replaces createDocument of the super class.
	 */
	protected IDocument createCompilationUnitDocument(ICompilationUnit unit) throws CoreException {
		
		String contents= ""; 
		
		try {
			contents= unit.getSource();
		} catch (JavaModelException x) {
			throw new CoreException(x.getStatus());
		}
		
		Document document= new Document(contents);		
		
		JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
		IDocumentPartitioner partitioner= tools.createDocumentPartitioner();
		partitioner.connect(document);
		document.setDocumentPartitioner(partitioner);